summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexShaderManager.cpp
diff options
context:
space:
mode:
authoriwubcode <iwubcode@users.noreply.github.com>2020-04-26 16:40:25 -0500
committeriwubcode <iwubcode@users.noreply.github.com>2020-05-03 13:34:13 -0500
commite125c61d474bf459883590bd89f02b2a6cd21115 (patch)
tree111fbfba8f439fea0744aa660de6fe1fdeef983d /Source/Core/VideoCommon/VertexShaderManager.cpp
parent5bd7cc8bac67797a3a72b34fbeaf82546ffbe568 (diff)
VideoCommon: remove VertexShaderManager functions instead preferring the direct freelook camera methods
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexShaderManager.cpp40
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);