mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-01 14:37:25 +00:00
fix: not correctly applying translation of children of rotated nodes from gltf
This commit is contained in:
@@ -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();
|
||||
|
@@ -533,6 +533,8 @@ namespace
|
||||
|
||||
vertexIndex++;
|
||||
surface.vertInfo.vertCount[0]++;
|
||||
|
||||
AddBoneToXSurfacePartBits(surface, weight0.boneIndex);
|
||||
}
|
||||
|
||||
vertsBlendData.reserve(vertsBlendData.size() + (vertexCount - vertexIndex) * 3u);
|
||||
@@ -551,6 +553,9 @@ namespace
|
||||
|
||||
vertexIndex++;
|
||||
surface.vertInfo.vertCount[1]++;
|
||||
|
||||
AddBoneToXSurfacePartBits(surface, weight0.boneIndex);
|
||||
AddBoneToXSurfacePartBits(surface, weight1.boneIndex);
|
||||
}
|
||||
|
||||
vertsBlendData.reserve(vertsBlendData.size() + (vertexCount - vertexIndex) * 5u);
|
||||
@@ -572,6 +577,10 @@ namespace
|
||||
|
||||
vertexIndex++;
|
||||
surface.vertInfo.vertCount[2]++;
|
||||
|
||||
AddBoneToXSurfacePartBits(surface, weight0.boneIndex);
|
||||
AddBoneToXSurfacePartBits(surface, weight1.boneIndex);
|
||||
AddBoneToXSurfacePartBits(surface, weight2.boneIndex);
|
||||
}
|
||||
|
||||
vertsBlendData.reserve(vertsBlendData.size() + (vertexCount - vertexIndex) * 7u);
|
||||
@@ -594,6 +603,11 @@ namespace
|
||||
|
||||
vertexIndex++;
|
||||
surface.vertInfo.vertCount[3]++;
|
||||
|
||||
AddBoneToXSurfacePartBits(surface, weight0.boneIndex);
|
||||
AddBoneToXSurfacePartBits(surface, weight1.boneIndex);
|
||||
AddBoneToXSurfacePartBits(surface, weight2.boneIndex);
|
||||
AddBoneToXSurfacePartBits(surface, weight3.boneIndex);
|
||||
}
|
||||
|
||||
surface.vertInfo.vertsBlend = m_memory.Alloc<uint16_t>(vertsBlendData.size());
|
||||
|
Reference in New Issue
Block a user