Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed joints conversion from gltf to ozz #186

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading