From fc5553a8c718603efca2a1dafdbf7e56c934befc Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 2 Jan 2025 20:52:29 +1000 Subject: [PATCH] GTE: Improve reverse transform freecam Transform the move direction, that way it behaves more FPS-camera like. --- src/core/gte.cpp | 21 +++++++++++++++------ src/core/imgui_overlays.cpp | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/core/gte.cpp b/src/core/gte.cpp index cc9594225..eb9e9ab86 100644 --- a/src/core/gte.cpp +++ b/src/core/gte.cpp @@ -56,9 +56,9 @@ namespace { struct ALIGN_TO_CACHE_LINE Config { DisplayAspectRatio aspect_ratio = DisplayAspectRatio::R4_3; - u32 custom_aspect_ratio_numerator; - u32 custom_aspect_ratio_denominator; - float custom_aspect_ratio_f; + u32 custom_aspect_ratio_numerator = 0; + u32 custom_aspect_ratio_denominator = 0; + float custom_aspect_ratio_f = 1.0f; #ifdef ENABLE_FREECAM @@ -77,13 +77,13 @@ struct ALIGN_TO_CACHE_LINE Config GSVector4 freecam_translation = GSVector4::cxpr(0.0f); ALIGN_TO_CACHE_LINE GSMatrix4x4 freecam_matrix = GSMatrix4x4::Identity(); - + GSMatrix4x4 freecam_inverted_rotation_matrix = GSMatrix4x4::Identity(); #endif }; } // namespace -static Config s_config; +static constinit Config s_config; #define REGS CPU::g_state.gte_regs @@ -1483,7 +1483,11 @@ void GTE::UpdateFreecam(u64 current_time) if (!(s_config.freecam_move == GSVector4::zero()).alltrue()) { - s_config.freecam_translation += s_config.freecam_move * GSVector4(s_config.freecam_move_speed * dt); + GSVector4 disp = s_config.freecam_move * GSVector4(s_config.freecam_move_speed * dt); + if (s_config.freecam_reverse_transform_order) + disp = s_config.freecam_inverted_rotation_matrix * disp; + + s_config.freecam_translation += disp; changed = true; } @@ -1560,6 +1564,11 @@ void GTE::UpdateFreecam(u64 current_time) any_xform = true; } + if (any_xform) + s_config.freecam_inverted_rotation_matrix = s_config.freecam_matrix.invert(); + else + s_config.freecam_inverted_rotation_matrix = GSMatrix4x4::Identity(); + if (s_config.freecam_translation.x != 0.0f || s_config.freecam_translation.y != 0.0f || s_config.freecam_translation.z != 0.0f) { diff --git a/src/core/imgui_overlays.cpp b/src/core/imgui_overlays.cpp index 7b3677be4..9b045797f 100644 --- a/src/core/imgui_overlays.cpp +++ b/src/core/imgui_overlays.cpp @@ -85,7 +85,7 @@ static void DrawInputsOverlay(); static constexpr size_t NUM_DEBUG_WINDOWS = 7; static constexpr const char* DEBUG_WINDOW_CONFIG_SECTION = "DebugWindows"; static constexpr const std::array s_debug_window_info = {{ - {"Freecam", "Free Camera", ":icons/applications-system.png", >E::DrawFreecamWindow, 500, 400}, + {"Freecam", "Free Camera", ":icons/applications-system.png", >E::DrawFreecamWindow, 500, 425}, {"SPU", "SPU State", ":icons/applications-system.png", &SPU::DrawDebugStateWindow, 800, 915}, {"CDROM", "CD-ROM State", ":icons/applications-system.png", &CDROM::DrawDebugWindow, 800, 540}, {"GPU", "GPU State", ":icons/applications-system.png", [](float sc) { g_gpu.DrawDebugStateWindow(sc); }, 450, 550},