diff options
author | 3gg <3gg@shellblade.net> | 2023-02-10 08:28:33 -0800 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2023-02-10 08:28:33 -0800 |
commit | a8ba7e5e9c98890a13c0eb6868acf97f6fffaac3 (patch) | |
tree | d78ceb97fc368ac560b99a3f9a15a5640f3f3835 | |
parent | c5aecf2d5a8b29c8b960380255d3a74982ad1f67 (diff) |
Fix traversal of root children during animation.
-rw-r--r-- | gfx/src/scene/animation.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gfx/src/scene/animation.c b/gfx/src/scene/animation.c index 91d3e08..8d8178e 100644 --- a/gfx/src/scene/animation.c +++ b/gfx/src/scene/animation.c | |||
@@ -328,7 +328,8 @@ static void compute_joint_matrices_rec( | |||
328 | while (child.val != 0) { | 328 | while (child.val != 0) { |
329 | compute_joint_matrices_rec( | 329 | compute_joint_matrices_rec( |
330 | child, global_joint_transform, root_inv_global_transform); | 330 | child, global_joint_transform, root_inv_global_transform); |
331 | node = mem_get_node(child); | 331 | node = mem_get_node(child); |
332 | assert(node); | ||
332 | child = node->next; // Next sibling. | 333 | child = node->next; // Next sibling. |
333 | } | 334 | } |
334 | } | 335 | } |
@@ -384,8 +385,15 @@ void gfx_update_animation(Anima* anima, R t) { | |||
384 | // LOGD("Root: %u, child: %u", root_index.val, root->child.val); | 385 | // LOGD("Root: %u, child: %u", root_index.val, root->child.val); |
385 | const mat4 root_global_transform = gfx_get_node_global_transform(root); | 386 | const mat4 root_global_transform = gfx_get_node_global_transform(root); |
386 | const mat4 root_inv_global_transform = mat4_inverse(root_global_transform); | 387 | const mat4 root_inv_global_transform = mat4_inverse(root_global_transform); |
387 | compute_joint_matrices_rec( | 388 | // Step over root's children (siblings of the first child). |
388 | root->child, root_global_transform, &root_inv_global_transform); | 389 | node_idx child = root->child; |
390 | while (child.val != 0) { | ||
391 | compute_joint_matrices_rec( | ||
392 | child, root_global_transform, &root_inv_global_transform); | ||
393 | SceneNode* node = mem_get_node(child); | ||
394 | assert(node); | ||
395 | child = node->next; // Next sibling. | ||
396 | } | ||
389 | } | 397 | } |
390 | 398 | ||
391 | const Skeleton* gfx_get_anima_skeleton(const Anima* anima, size_t i) { | 399 | const Skeleton* gfx_get_anima_skeleton(const Anima* anima, size_t i) { |