diff options
| author | 3gg <3gg@shellblade.net> | 2024-02-17 14:35:11 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2024-02-17 14:35:11 -0800 |
| commit | 6799f7bd263202d8697c5e27bf12f4e66e4c0ed1 (patch) | |
| tree | d89482cddb145cec3c4badac69889be126f27dfc /game/src | |
| parent | 6d5e336c5f1b249404d29bc4349b9cf95f058dbf (diff) | |
Introduce gfx_update().
Diffstat (limited to 'game/src')
| -rw-r--r-- | game/src/plugins/viewer.c | 19 |
1 files changed, 7 insertions, 12 deletions
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) { | |||
| 155 | assert(state->scene); | 155 | assert(state->scene); |
| 156 | assert(state->camera); | 156 | assert(state->camera); |
| 157 | 157 | ||
| 158 | // TODO: Move this to some sort of update_scene(). Note that models do not | ||
| 159 | // need to be animated if they are not visible to the camera. The camera | ||
| 160 | // update also should happen first. | ||
| 161 | Anima* anima = gfx_get_model_anima(state->model); | ||
| 162 | if (anima) { | ||
| 163 | gfx_update_animation(anima, (R)t); | ||
| 164 | } | ||
| 165 | |||
| 166 | const vec3 orbit_point = vec3_make(0, 2, 0); | 158 | const vec3 orbit_point = vec3_make(0, 2, 0); |
| 167 | Camera* camera = gfx_get_camera_camera(state->camera); | 159 | Camera* camera = gfx_get_camera_camera(state->camera); |
| 168 | spatial3_orbit( | 160 | spatial3_orbit( |
| 169 | &camera->spatial, orbit_point, | 161 | &camera->spatial, orbit_point, |
| 170 | /*radius=*/5, | 162 | /*radius=*/5, |
| 171 | /*azimuth=*/t * 0.5, /*zenith=*/0); | 163 | /*azimuth=*/(R)(t * 0.5), /*zenith=*/0); |
| 172 | spatial3_lookat(&camera->spatial, orbit_point); | 164 | spatial3_lookat(&camera->spatial, orbit_point); |
| 165 | |||
| 166 | gfx_update(state->scene, state->camera, (R)t); | ||
| 173 | } | 167 | } |
| 174 | 168 | ||
| 175 | /// Render the bounding boxes of all scene objects. | 169 | /// Render the bounding boxes of all scene objects. |
| @@ -207,9 +201,10 @@ static void render_bounding_boxes_rec(ImmRenderer* imm, const SceneNode* node) { | |||
| 207 | } | 201 | } |
| 208 | 202 | ||
| 209 | // Render children's boxes. | 203 | // Render children's boxes. |
| 210 | for (NodeIter it = gfx_get_node_child(node); it; | 204 | const SceneNode* child = gfx_get_node_child(node); |
| 211 | it = gfx_get_next_child(it)) { | 205 | while (child) { |
| 212 | render_bounding_boxes_rec(imm, gfx_get_iter_node(it)); | 206 | render_bounding_boxes_rec(imm, child); |
| 207 | child = gfx_get_node_sibling(child); | ||
| 213 | } | 208 | } |
| 214 | } | 209 | } |
| 215 | 210 | ||
