Name object manipulation magic numbers
authorLukas Jiriste <ljiriste@student.42prague.com>
Wed, 8 Jan 2025 11:54:34 +0000 (12:54 +0100)
committerLukas Jiriste <ljiriste@student.42prague.com>
Wed, 8 Jan 2025 11:54:34 +0000 (12:54 +0100)
src/main.c

index 5e6266b54e7f0e8342de64a5cca6c9ca416c2ddd..14433179a34311d4257262110ce7dbc9e28df7f7 100644 (file)
@@ -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)