From a958c1f50a131a8864b37ffb83012f49015e6148 Mon Sep 17 00:00:00 2001 From: sergeypdev Date: Sat, 2 Aug 2025 20:58:01 +0400 Subject: [PATCH] Fix wrong sign when converting from dir to yaw pitch --- game/game.odin | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/game/game.odin b/game/game.odin index bbf8e5e..d42ddd1 100644 --- a/game/game.odin +++ b/game/game.odin @@ -898,24 +898,20 @@ collect_camera_input :: proc() -> (delta: rl.Vector2, sense: f32, is_mouse: bool } should_capture_mouse := rl.IsMouseButtonDown(.RIGHT) + @(static) last_mouse_pos: rl.Vector2 if g_mem.mouse_captured != should_capture_mouse { if should_capture_mouse { rl.DisableCursor() + last_mouse_pos = rl.GetMousePosition() } else { rl.EnableCursor() } g_mem.mouse_captured = should_capture_mouse } - mouse_delta := g_mem.mouse_captured ? rl.GetMouseDelta() : 0 - - @(static) first_delta := true - if mouse_delta != 0 && first_delta { - first_delta = false - mouse_delta = 0 - } else if mouse_delta == 0 { - first_delta = true - } + mouse_pos := rl.GetMousePosition() + mouse_delta := g_mem.mouse_captured ? mouse_pos - last_mouse_pos : 0 + last_mouse_pos = mouse_pos MOUSE_SENSE :: 0.005 GAMEPAD_SENSE :: 1 @@ -967,7 +963,7 @@ orbit_camera_to_rl :: proc(camera: Orbit_Camera) -> rl.Camera3D { } dir_to_yaw_pitch :: proc "contextless" (dir: rl.Vector3) -> (yaw: f32, pitch: f32) { - pitch = math.asin(dir.y) + pitch = -math.asin(dir.y) yaw = -math.atan2(dir.x, dir.z) + math.PI return } @@ -1189,9 +1185,6 @@ update :: proc() { car_follow_cam := &game_cam.(Car_Follow_Camera) car_follow_cam.body = world.car_handle - if world.physics_dt == 0 { - log.debugf("phys dt == 0") - } game_camera_update(world, &get_runtime_world().game_camera, dt) get_runtime_world().camera = game_camera_to_rl(get_runtime_world().game_camera) }