Skip to content

Commit

Permalink
Fix aliasing with multiple animation clips per skin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans-Kristian Arntzen committed Aug 13, 2017
1 parent a5b8a66 commit 0915778
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
21 changes: 11 additions & 10 deletions importers/gltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,20 +1090,21 @@ void Parser::parse(const string &original_path, const string &json)
if (doc.HasMember("animations"))
{
auto &animations = doc["animations"];
if (animations.IsArray())
unsigned counter = 0;
for (auto itr = animations.Begin(); itr != animations.End(); ++itr)
{
unsigned counter = 0;
for (auto itr = animations.Begin(); itr != animations.End(); ++itr)
string name;

if (itr->HasMember("name"))
name = (*itr)["name"].GetString();
else
{
string name = "animation_";
name = "animation_";
name += to_string(counter);
json_animation_names.push_back(move(name));
}
}
else
{
for (auto itr = animations.MemberBegin(); itr != animations.MemberEnd(); ++itr)
json_animation_names.push_back(itr->name.GetString());

json_animation_names.push_back(move(name));
counter++;
}
iterate_elements(animations, add_animation);
}
Expand Down
23 changes: 23 additions & 0 deletions renderer/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,27 @@ void Scene::gather_visible_shadow_renderables(const Frustum &frustum, Visibility
list.push_back({ get<1>(object)->renderable.get(), nullptr });
}

#if 0
static void log_node_transforms(const Scene::Node &node)
{
for (unsigned i = 0; i < node.cached_skin_transform.bone_world_transforms.size(); i++)
{
LOGI("Joint #%u:\n", i);

const auto &ibp = node.cached_skin_transform.bone_world_transforms[i];
LOGI(" Transform:\n"
" [%f, %f, %f, %f]\n"
" [%f, %f, %f, %f]\n"
" [%f, %f, %f, %f]\n"
" [%f, %f, %f, %f]\n",
ibp[0][0], ibp[1][0], ibp[2][0], ibp[3][0],
ibp[0][1], ibp[1][1], ibp[2][1], ibp[3][1],
ibp[0][2], ibp[1][2], ibp[2][2], ibp[3][2],
ibp[0][3], ibp[1][3], ibp[2][3], ibp[3][3]);
}
}
#endif

void Scene::update_skinning(Node &node)
{
if (!node.cached_skin_transform.bone_world_transforms.empty())
Expand All @@ -182,6 +203,8 @@ void Scene::update_skinning(Node &node)
node.cached_skin_transform.bone_world_transforms[i] = node.get_skin().cached_skin[i]->world_transform;
node.cached_skin_transform.bone_normal_transforms[i] = node.get_skin().cached_skin[i]->normal_transform;
}

//log_node_transforms(node);
}
}

Expand Down
1 change: 0 additions & 1 deletion renderer/scene_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ Scene::NodeHandle SceneLoader::build_tree_for_subscene(const SubsceneData &subsc
{
animation_system->register_animation(animation.name, animation);
animation_system->start_animation(*nodeptr, animation.name, 0.0, true);
//break;
}
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int application_main(int, char **)
Filesystem::get().register_protocol("assets", std::unique_ptr<FilesystemBackend>(new OSFilesystem(asset_dir)));
#endif

SceneViewerApplication app("assets://scene.gltf", 1280, 720);
SceneViewerApplication app("assets://RiggedFigure/glTF/RiggedFigure.gltf", 1280, 720);
app.rescale_scene(5.0f);
app.loop_animations();
return app.run();
Expand Down

0 comments on commit 0915778

Please sign in to comment.