summaryrefslogtreecommitdiff
path: root/src/plugins/viewer.c
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-11-01 21:08:41 -0700
committer3gg <3gg@shellblade.net>2025-11-01 21:08:41 -0700
commit13218f8cfab6bc02fc57a2eef582ab93056fb59c (patch)
tree17bac951fc039d5cffd4e926f3f2c2b3499e4e4b /src/plugins/viewer.c
parent840755ea4559a71f78360701dd046f7944d76aaf (diff)
Slow down camera movement when pressing shift
Diffstat (limited to 'src/plugins/viewer.c')
-rw-r--r--src/plugins/viewer.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/viewer.c b/src/plugins/viewer.c
index ba699cc..08e4d57 100644
--- a/src/plugins/viewer.c
+++ b/src/plugins/viewer.c
@@ -57,6 +57,7 @@ typedef struct CameraCommand {
57 bool CameraMoveRight : 1; 57 bool CameraMoveRight : 1;
58 bool CameraMoveForward : 1; 58 bool CameraMoveForward : 1;
59 bool CameraMoveBackward : 1; 59 bool CameraMoveBackward : 1;
60 bool CameraSlow : 1; // When true, move more slowly.
60 bool CameraIsRotating : 1; // When true, subsequent mouse movements cause the 61 bool CameraIsRotating : 1; // When true, subsequent mouse movements cause the
61 // camera to rotate. 62 // camera to rotate.
62} CameraCommand; 63} CameraCommand;
@@ -203,6 +204,7 @@ static CameraCommand make_camera_command_from_input(GfxApp* app) {
203 .CameraMoveRight = gfx_app_is_key_pressed(app, KeyD), 204 .CameraMoveRight = gfx_app_is_key_pressed(app, KeyD),
204 .CameraMoveForward = gfx_app_is_key_pressed(app, KeyW), 205 .CameraMoveForward = gfx_app_is_key_pressed(app, KeyW),
205 .CameraMoveBackward = gfx_app_is_key_pressed(app, KeyS), 206 .CameraMoveBackward = gfx_app_is_key_pressed(app, KeyS),
207 .CameraSlow = gfx_app_is_key_pressed(app, KeyLShift),
206 .CameraIsRotating = gfx_app_is_mouse_button_pressed(app, LMB), 208 .CameraIsRotating = gfx_app_is_mouse_button_pressed(app, LMB),
207 }; 209 };
208} 210}
@@ -218,8 +220,10 @@ static void update_camera(
218 (R)(command.CameraMoveRight ? 1 : 0); 220 (R)(command.CameraMoveRight ? 1 : 0);
219 const R move_y = (R)(command.CameraMoveForward ? 1 : 0) + 221 const R move_y = (R)(command.CameraMoveForward ? 1 : 0) +
220 (R)(command.CameraMoveBackward ? -1 : 0); 222 (R)(command.CameraMoveBackward ? -1 : 0);
221 const vec2 translation = vec2_scale( 223 const R speed_factor = command.CameraSlow ? 0.3 : 1.0;
222 vec2_normalize(vec2_make(move_x, move_y)), controller->camera_speed * dt); 224 const vec2 translation = vec2_scale(
225 vec2_normalize(vec2_make(move_x, move_y)),
226 controller->camera_speed * speed_factor * dt);
223 spatial3_move_right(camera, translation.x); 227 spatial3_move_right(camera, translation.x);
224 spatial3_move_forwards(camera, translation.y); 228 spatial3_move_forwards(camera, translation.y);
225 229