diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2020-05-17 17:33:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-17 17:33:04 +0200 |
| commit | cea779cc844ffe1a470b174bba7198b27d1e5d6a (patch) | |
| tree | c6202c092148a8d4f3ab0787cc6b2023b1634057 /Source/Core/VideoCommon/VertexShaderManager.cpp | |
| parent | 30b166e3b1614a0a383ae4374960790bf077a6fc (diff) | |
| parent | aed7319ef8449cb84f8ce3bd103c0c65a503e071 (diff) | |
Merge pull request #8767 from iwubcode/freelook-camera-type
Expand freelook camera with control options
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexShaderManager.cpp | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 59a89be52d..2044de1aff 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -12,13 +12,16 @@ #include "Common/BitSet.h" #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/Config/Config.h" #include "Common/Logging/Log.h" #include "Common/Matrix.h" +#include "Core/Config/GraphicsSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "VideoCommon/BPFunctions.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/CPMemory.h" +#include "VideoCommon/FreeLookCamera.h" #include "VideoCommon/RenderBase.h" #include "VideoCommon/Statistics.h" #include "VideoCommon/VertexManagerBase.h" @@ -42,7 +45,6 @@ static std::array<int, 2> nPostTransformMatricesChanged; // min,max static std::array<int, 2> nLightsChanged; // min,max static Common::Matrix44 s_viewportCorrection; -static Common::Matrix44 s_freelook_matrix; VertexShaderConstants VertexShaderManager::constants; bool VertexShaderManager::dirty; @@ -110,10 +112,10 @@ void VertexShaderManager::Init() bViewportChanged = false; bTexMtxInfoChanged = false; bLightingConfigChanged = false; + g_freelook_camera.SetControlType(Config::Get(Config::GFX_FREE_LOOK_CONTROL_TYPE)); std::memset(static_cast<void*>(&xfmem), 0, sizeof(xfmem)); constants = {}; - ResetView(); // TODO: should these go inside ResetView()? s_viewportCorrection = Common::Matrix44::Identity(); @@ -344,7 +346,7 @@ void VertexShaderManager::SetConstants() } } - if (bProjectionChanged) + if (bProjectionChanged || g_freelook_camera.IsDirty()) { bProjectionChanged = false; @@ -413,7 +415,7 @@ void VertexShaderManager::SetConstants() auto corrected_matrix = s_viewportCorrection * Common::Matrix44::FromArray(g_fProjectionMatrix); if (g_ActiveConfig.bFreeLook && xfmem.projection.type == GX_PERSPECTIVE) - corrected_matrix *= s_freelook_matrix; + corrected_matrix *= g_freelook_camera.GetView(); memcpy(constants.projection.data(), corrected_matrix.data.data(), 4 * sizeof(float4)); @@ -445,6 +447,9 @@ void VertexShaderManager::SetConstants() dirty = true; } + + // Handle a potential config change + g_freelook_camera.SetControlType(Config::Get(Config::GFX_FREE_LOOK_CONTROL_TYPE)); } void VertexShaderManager::InvalidateXFRange(int start, int end) @@ -600,31 +605,6 @@ void VertexShaderManager::SetMaterialColorChanged(int index) nMaterialsChanged[index] = true; } -void VertexShaderManager::TranslateView(float x, float y, float z) -{ - s_freelook_matrix = Common::Matrix44::Translate({x, z, y}) * s_freelook_matrix; - - bProjectionChanged = true; -} - -void VertexShaderManager::RotateView(float x, float y, float z) -{ - using Common::Matrix33; - - s_freelook_matrix = Common::Matrix44::FromMatrix33(Matrix33::RotateX(x) * Matrix33::RotateY(y) * - Matrix33::RotateZ(z)) * - s_freelook_matrix; - - bProjectionChanged = true; -} - -void VertexShaderManager::ResetView() -{ - s_freelook_matrix = Common::Matrix44::Identity(); - - bProjectionChanged = true; -} - void VertexShaderManager::SetVertexFormat(u32 components) { if (components != constants.components) @@ -673,7 +653,7 @@ void VertexShaderManager::DoState(PointerWrap& p) { p.DoArray(g_fProjectionMatrix); p.Do(s_viewportCorrection); - p.Do(s_freelook_matrix); + g_freelook_camera.DoState(p); p.DoArray(nTransformMatricesChanged); p.DoArray(nNormalMatricesChanged); |
