From a8ba7e5e9c98890a13c0eb6868acf97f6fffaac3 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Fri, 10 Feb 2023 08:28:33 -0800 Subject: Fix traversal of root children during animation. --- gfx/src/scene/animation.c | 14 +++++++++++--- 1 file 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( while (child.val != 0) { compute_joint_matrices_rec( child, global_joint_transform, root_inv_global_transform); - node = mem_get_node(child); + node = mem_get_node(child); + assert(node); child = node->next; // Next sibling. } } @@ -384,8 +385,15 @@ void gfx_update_animation(Anima* anima, R t) { // LOGD("Root: %u, child: %u", root_index.val, root->child.val); const mat4 root_global_transform = gfx_get_node_global_transform(root); const mat4 root_inv_global_transform = mat4_inverse(root_global_transform); - compute_joint_matrices_rec( - root->child, root_global_transform, &root_inv_global_transform); + // Step over root's children (siblings of the first child). + node_idx child = root->child; + while (child.val != 0) { + compute_joint_matrices_rec( + child, root_global_transform, &root_inv_global_transform); + SceneNode* node = mem_get_node(child); + assert(node); + child = node->next; // Next sibling. + } } const Skeleton* gfx_get_anima_skeleton(const Anima* anima, size_t i) { -- cgit v1.2.3