From 6799f7bd263202d8697c5e27bf12f4e66e4c0ed1 Mon Sep 17 00:00:00 2001
From: 3gg <3gg@shellblade.net>
Date: Sat, 17 Feb 2024 14:35:11 -0800
Subject: Introduce gfx_update().

---
 game/src/plugins/viewer.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

(limited to 'game')

diff --git a/game/src/plugins/viewer.c b/game/src/plugins/viewer.c
index 945a422..88821af 100644
--- a/game/src/plugins/viewer.c
+++ b/game/src/plugins/viewer.c
@@ -155,21 +155,15 @@ void update(Game* game, State* state, double t, double dt) {
   assert(state->scene);
   assert(state->camera);
 
-  // TODO: Move this to some sort of update_scene(). Note that models do not
-  //  need to be animated if they are not visible to the camera. The camera
-  //  update also should happen first.
-  Anima* anima = gfx_get_model_anima(state->model);
-  if (anima) {
-    gfx_update_animation(anima, (R)t);
-  }
-
   const vec3 orbit_point = vec3_make(0, 2, 0);
   Camera*    camera      = gfx_get_camera_camera(state->camera);
   spatial3_orbit(
       &camera->spatial, orbit_point,
       /*radius=*/5,
-      /*azimuth=*/t * 0.5, /*zenith=*/0);
+      /*azimuth=*/(R)(t * 0.5), /*zenith=*/0);
   spatial3_lookat(&camera->spatial, orbit_point);
+
+  gfx_update(state->scene, state->camera, (R)t);
 }
 
 /// Render the bounding boxes of all scene objects.
@@ -207,9 +201,10 @@ static void render_bounding_boxes_rec(ImmRenderer* imm, const SceneNode* node) {
   }
 
   // Render children's boxes.
-  for (NodeIter it = gfx_get_node_child(node); it;
-       it          = gfx_get_next_child(it)) {
-    render_bounding_boxes_rec(imm, gfx_get_iter_node(it));
+  const SceneNode* child = gfx_get_node_child(node);
+  while (child) {
+    render_bounding_boxes_rec(imm, child);
+    child = gfx_get_node_sibling(child);
   }
 }
 
-- 
cgit v1.2.3