From d727afadbb1cec1b04e8d3c3ffb8502d8a975cee Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Wed, 8 Jan 2025 12:54:34 +0100 Subject: [PATCH] Name object manipulation magic numbers --- src/main.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main.c b/src/main.c index 5e6266b..1443317 100644 --- a/src/main.c +++ b/src/main.c @@ -135,6 +135,9 @@ int close_win(t_session *s) return (0); } +static const double TRANSLATION_STEP = 0.1; +static const double ROTATION_STEP = 0.1; + int handle_key_press(int keycode, t_session *s) { t_element *element; @@ -153,29 +156,29 @@ int handle_key_press(int keycode, t_session *s) close_win(s); } else if (keycode == XK_Up) - translate(element, camera->orientation, 0.1); + translate(element, camera->orientation, TRANSLATION_STEP); else if (keycode == XK_Down) - translate(element, camera->orientation, -0.1); + translate(element, camera->orientation, -TRANSLATION_STEP); else if (keycode == XK_Left) - translate(element, vec_vec_mul(camera->orientation, camera->up_direction), 0.1); + translate(element, vec_vec_mul(camera->orientation, camera->up_direction), TRANSLATION_STEP); else if (keycode == XK_Right) - translate(element, vec_vec_mul(camera->orientation, camera->up_direction), -0.1); + translate(element, vec_vec_mul(camera->orientation, camera->up_direction), -TRANSLATION_STEP); else if (keycode == XK_space) - translate(element, camera->up_direction, 0.1); + translate(element, camera->up_direction, TRANSLATION_STEP); else if (keycode == XK_Shift_L) - translate(element, camera->up_direction, -0.1); + translate(element, camera->up_direction, -TRANSLATION_STEP); else if (keycode == XK_w) - rotate(element, vec_vec_mul(camera->orientation, camera->up_direction), -0.1); + rotate(element, vec_vec_mul(camera->orientation, camera->up_direction), -ROTATION_STEP); else if (keycode == XK_s) - rotate(element, vec_vec_mul(camera->orientation, camera->up_direction), 0.1); + rotate(element, vec_vec_mul(camera->orientation, camera->up_direction), ROTATION_STEP); else if (keycode == XK_a) - rotate(element, camera->up_direction, -0.1); + rotate(element, camera->up_direction, -ROTATION_STEP); else if (keycode == XK_d) - rotate(element, camera->up_direction, 0.1); + rotate(element, camera->up_direction, ROTATION_STEP); else if (keycode == XK_e) - rotate(element, camera->orientation, -0.1); + rotate(element, camera->orientation, -ROTATION_STEP); else if (keycode == XK_q) - rotate(element, camera->orientation, 0.1); + rotate(element, camera->orientation, ROTATION_STEP); /* else if (keycode == XK_KP_Add) else if (keycode == XK_KP_Subtract) -- 2.30.2