From 3b7d593f4e1d59cc53b701734bbdf68e4165fa78 Mon Sep 17 00:00:00 2001 From: Sven Balzer <4653051+Kyuusokuna@users.noreply.github.com> Date: Wed, 1 Apr 2026 18:01:39 +0200 Subject: [PATCH] switch to reverse z and get rid of tilt sign flip --- src/math_graphics.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/math_graphics.cpp b/src/math_graphics.cpp index 810943e..0ba2573 100644 --- a/src/math_graphics.cpp +++ b/src/math_graphics.cpp @@ -874,27 +874,27 @@ namespace M { } M4x4 view(V3 player_pos, float tilt, float camera_distance) { - float s = sinf(-tilt); - float c = cosf(-tilt); + float s = sinf(tilt); + float c = cosf(tilt); - return M4x4_( + return { 1, 0, 0, -player_pos.x, 0, c, s, c * -player_pos.y, - 0, -s, c, s * player_pos.y + camera_distance, - 0, 0, 0, 1 - ); + 0, -s, c, s * player_pos.y - camera_distance, + 0, 0, 0, 1, + }; } M4x4 inverse_view(V3 player_pos, float tilt, float camera_distance) { - float s = sinf(-tilt); - float c = cosf(-tilt); + float s = sinf(tilt); + float c = cosf(tilt); - return M4x4_( - 1, 0, 0, player_pos.x, - 0, c, -s, s * camera_distance + player_pos.y, - 0, s, c, c * -camera_distance, - 0, 0, 0, 1 - ); + return { + 1, 0, 0, player_pos.x, + 0, c, -s, -s * camera_distance + player_pos.y, + 0, s, c, c * camera_distance, + 0, 0, 0, 1, + }; } M4x4 projection(float fovy, float aspect, float near) { @@ -904,7 +904,7 @@ namespace M { g / aspect, 0, 0, 0, 0, g, 0, 0, 0, 0, 0, near, - 0, 0, 1, 0, + 0, 0, -1, 0, }; } @@ -912,10 +912,10 @@ namespace M { float g = 1.0 / tanf(fovy * 0.5); return { - aspect / g, 0, 0, 0, - 0, 1 / g, 0, 0, - 0, 0, 0, 1, - 0, 0, 1 / near, 0, + aspect / g, 0, 0, 0, + 0, 1 / g, 0, 0, + 0, 0, 0, -1, + 0, 0, 1 / near, 0, }; } }