2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-05-17 07:21:43 +00:00

fix: properly dump gltf with root node in models with more than one root bone

This commit is contained in:
Jan Laupetin
2026-04-20 19:32:15 +01:00
parent 080e8261bb
commit ff7b940e86
2 changed files with 13 additions and 7 deletions
+10 -3
View File
@@ -187,10 +187,10 @@ namespace
const auto meshCount = xmodel.m_objects.size();
for (auto meshIndex = 0u; meshIndex < meshCount; meshIndex++)
rootNode.children->push_back(m_first_mesh_node + meshIndex);
rootNode.children->emplace_back(m_first_mesh_node + meshIndex);
if (!xmodel.m_bones.empty())
rootNode.children->push_back(m_first_bone_node);
for (auto rootBoneIndex = 0u; rootBoneIndex < m_root_bone_count; rootBoneIndex++)
rootNode.children->emplace_back(m_first_bone_node + rootBoneIndex);
m_root_node = static_cast<unsigned>(gltf.nodes->size());
gltf.nodes->emplace_back(std::move(rootNode));
@@ -303,6 +303,7 @@ namespace
const auto boneCount = common.m_bones.size();
m_first_bone_node = static_cast<unsigned>(gltf.nodes->size());
m_root_bone_count = 0;
for (auto boneIndex = 0u; boneIndex < boneCount; boneIndex++)
{
JsonNode boneNode;
@@ -335,6 +336,11 @@ namespace
translation = inverseParentRotation * translation;
rotation = inverseParentRotation * rotation;
}
else
{
assert(m_root_bone_count == boneIndex);
m_root_bone_count++;
}
rotation.normalize();
boneNode.name = bone.name;
@@ -745,6 +751,7 @@ namespace
unsigned m_first_mesh_node = 0u;
unsigned m_root_node = 0u;
unsigned m_first_bone_node = 0u;
unsigned m_root_bone_count = 0u;
unsigned m_position_accessor = 0u;
unsigned m_normal_accessor = 0u;
unsigned m_color_accessor = 0u;