fix projection of mouse into view space

This commit is contained in:
Sven Balzer 2025-03-09 06:01:19 +01:00
parent 88da989ad7
commit 5016f906ea

View File

@ -1111,7 +1111,7 @@ int main(int argc, char **argv) {
float mouse_y = event.button.y;
V2 mouse = remap(V2{ 0, 0 }, V2{ (float)window_width, (float)window_height }, V2{ -1, -1 }, V2{ 1, 1 }, V2{ mouse_x, mouse_y });
V4 mouse_world = inverse_projection_matrix * V4{ mouse.x, mouse.y, 10 * 0.001, 1 };
V4 mouse_world = inverse_projection_matrix * V4{ mouse.x, mouse.y, -per_frame.camera_z * 0.001f, 1 };
mouse_world.xy *= mouse_world.w;
Sint32 tile_x = roundf(mouse_world.x) + player.pos_x;