Skip to content

Commit

Permalink
fixed joints conversion from gltf to ozz: removed Armature nodes that…
Browse files Browse the repository at this point in the history
… not indexed in joints and vertex bone indices
  • Loading branch information
NoirMorilec committed Nov 18, 2024
1 parent c40a726 commit 25ab612
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/animation/offline/gltf/gltf2ozz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,17 @@ class GltfImporter : public ozz::animation::offline::OzzImporter {
return success;
}

static bool IsSkinJoint(const tinygltf::Skin& skin, int node) {
static constexpr int invalid_node = -1;
static constexpr int visited = -2;
if (node == invalid_node || node == visited) return false;

return std::any_of(
skin.joints.begin(), skin.joints.end(),
[&node](const int& joint) { return joint == node; }
);
}

// Find all unique root joints of skeletons used by given skins and add them
// to `roots`
void FindSkinRootJointIndices(const ozz::vector<tinygltf::Skin>& skins,
Expand All @@ -546,7 +557,7 @@ class GltfImporter : public ozz::animation::offline::OzzImporter {
}

int root = skin.joints[0];
while (root != visited && parents[root] != no_parent) {
while (IsSkinJoint(skin, parents[root])) {
root = parents[root];
}
if (root != visited) {
Expand Down

0 comments on commit 25ab612

Please sign in to comment.