diff --git a/apps/testgame/scenes/ingame.c b/apps/testgame/scenes/ingame.c index 472a54f..7039875 100644 --- a/apps/testgame/scenes/ingame.c +++ b/apps/testgame/scenes/ingame.c @@ -14,19 +14,21 @@ static void ingame_tick(struct state *state) { static t_camera cam = { .pos = { 32, 0, 1 }, .up = { 0, 1, 0 }, .fov = (float)M_PI_2 }; - const float sensitivity = 0.6f; /* TODO: put this in a better place */ - scn->yaw += (float)ctx.input.mouse_relative_position.x * sensitivity; - scn->pitch -= (float)ctx.input.mouse_relative_position.y * sensitivity; - scn->pitch = clampf(scn->pitch, -89.0f, 89.0f); + if (input_is_mouse_captured(&ctx.input)) { + const float sensitivity = 0.6f; /* TODO: put this in a better place */ + scn->yaw += (float)ctx.input.mouse_relative_position.x * sensitivity; + scn->pitch -= (float)ctx.input.mouse_relative_position.y * sensitivity; + scn->pitch = clampf(scn->pitch, -89.0f, 89.0f); - const float yaw_rad = scn->yaw * (float)DEG2RAD; - const float pitch_rad = scn->pitch * (float)DEG2RAD; + const float yaw_rad = scn->yaw * (float)DEG2RAD; + const float pitch_rad = scn->pitch * (float)DEG2RAD; - cam.target = m_vec_norm(((t_fvec3){ - cosf(yaw_rad) * cosf(pitch_rad), - sinf(pitch_rad), - sinf(yaw_rad) * cosf(pitch_rad) - })); + cam.target = m_vec_norm(((t_fvec3){ + cosf(yaw_rad) * cosf(pitch_rad), + sinf(pitch_rad), + sinf(yaw_rad) * cosf(pitch_rad) + })); + } const t_fvec3 right = m_vec_norm(m_vec_cross(cam.target, cam.up)); const float speed = 0.04f; /* TODO: put this in a better place */ diff --git a/src/camera.h b/src/camera.h index 0d2f0f9..dc1fa38 100644 --- a/src/camera.h +++ b/src/camera.h @@ -11,7 +11,7 @@ typedef struct camera { t_fvec3 pos; /* eye position */ t_fvec3 target; /* normalized target vector */ t_fvec3 up; /* normalized up vector */ - float fov; /* field of view, in radians */ + float fov; /* field of view, in radians */ } t_camera; t_matrix4 camera_look_at(const t_camera *camera); diff --git a/src/rendering/triangles.h b/src/rendering/triangles.h index e26c1b2..d3ebefc 100644 --- a/src/rendering/triangles.h +++ b/src/rendering/triangles.h @@ -64,8 +64,8 @@ static void draw_uncolored_space_traingle_batch(struct mesh_batch *batch, struct uncolored_space_triangle_payload *payload = &((union uncolored_space_triangle *)batch->primitives)[i].payload; - t_frect srcrect = textures_get_srcrect(&ctx.texture_cache, texture_key); - t_frect dims = textures_get_dims(&ctx.texture_cache, texture_key); + const t_frect srcrect = textures_get_srcrect(&ctx.texture_cache, texture_key); + const t_frect dims = textures_get_dims(&ctx.texture_cache, texture_key); /* TODO: fast path for uvs mapped directly on srcrect corners? */