2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-12 19:47:27 +00:00

fix: not correctly applying translation of children of rotated nodes from gltf

This commit is contained in:
Jan Laupetin
2025-07-13 17:43:00 +01:00
parent d240655160
commit 2dc4dac785
2 changed files with 22 additions and 5 deletions

View File

@@ -516,13 +516,16 @@ namespace
bone.scale[1] *= parentScale[1];
bone.scale[2] *= parentScale[2];
bone.globalOffset[0] = bone.localOffset[0] + parentOffset[0];
bone.globalOffset[1] = bone.localOffset[1] + parentOffset[1];
bone.globalOffset[2] = bone.localOffset[2] + parentOffset[2];
const auto localRotationEigen = Eigen::Quaternionf(bone.localRotation.w, bone.localRotation.x, bone.localRotation.y, bone.localRotation.z);
const auto parentRotationEigen = Eigen::Quaternionf(parentRotation.w, parentRotation.x, parentRotation.y, parentRotation.z);
const auto globalRotationEigen = localRotationEigen * parentRotationEigen;
const auto globalRotationEigen = (parentRotationEigen * localRotationEigen).normalized();
const Eigen::Vector3f localTranslationEigen(bone.localOffset[0], bone.localOffset[1], bone.localOffset[2]);
const Eigen::Vector3f parentTranslationEigen(parentOffset[0], parentOffset[1], parentOffset[2]);
const auto globalTranslationEigen = (parentRotationEigen * localTranslationEigen) + parentTranslationEigen;
bone.globalOffset[0] = globalTranslationEigen.x();
bone.globalOffset[1] = globalTranslationEigen.y();
bone.globalOffset[2] = globalTranslationEigen.z();
bone.globalRotation.x = globalRotationEigen.x();
bone.globalRotation.y = globalRotationEigen.y();