summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authoriwubcode <iwubcode@users.noreply.github.com>2020-06-18 23:49:07 -0500
committeriwubcode <iwubcode@users.noreply.github.com>2020-12-24 13:49:25 -0600
commitbcf63c463b5b90c03c5d48b29ac1b2eb3ee9588f (patch)
tree71b75b28642fc07868787893d2a7d5ab6d505855 /Source/Core/VideoCommon
parenta37fd8c5d9f51d1a5280469336652a30e292bd74 (diff)
VideoCommon: Add 'Active' state to FreelookCamera to future proof if we ever add multiple cameras
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/FreeLookCamera.cpp5
-rw-r--r--Source/Core/VideoCommon/FreeLookCamera.h3
-rw-r--r--Source/Core/VideoCommon/VertexShaderManager.cpp4
3 files changed, 10 insertions, 2 deletions
diff --git a/Source/Core/VideoCommon/FreeLookCamera.cpp b/Source/Core/VideoCommon/FreeLookCamera.cpp
index 2f7eabebad..f3123e5cb6 100644
--- a/Source/Core/VideoCommon/FreeLookCamera.cpp
+++ b/Source/Core/VideoCommon/FreeLookCamera.cpp
@@ -319,3 +319,8 @@ void FreeLookCamera::SetClean()
{
m_dirty = false;
}
+
+bool FreeLookCamera::IsActive() const
+{
+ return FreeLook::GetActiveConfig().enabled;
+}
diff --git a/Source/Core/VideoCommon/FreeLookCamera.h b/Source/Core/VideoCommon/FreeLookCamera.h
index 2c91967c3e..4db1ad68c1 100644
--- a/Source/Core/VideoCommon/FreeLookCamera.h
+++ b/Source/Core/VideoCommon/FreeLookCamera.h
@@ -66,6 +66,8 @@ public:
void ResetSpeed();
float GetSpeed() const;
+ bool IsActive() const;
+
private:
bool m_dirty = false;
float m_fov_x = 1.0f;
@@ -75,6 +77,7 @@ private:
float m_fov_step_size = 0.025f;
float m_speed = 1.0f;
+ bool m_enabled = true;
};
extern FreeLookCamera g_freelook_camera;
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp
index 174ab70316..9c82d9b431 100644
--- a/Source/Core/VideoCommon/VertexShaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexShaderManager.cpp
@@ -356,7 +356,7 @@ void VertexShaderManager::SetConstants()
case GX_PERSPECTIVE:
{
const Common::Vec2 fov =
- g_ActiveConfig.bFreeLook ? g_freelook_camera.GetFieldOfView() : Common::Vec2{1, 1};
+ g_freelook_camera.IsActive() ? g_freelook_camera.GetFieldOfView() : Common::Vec2{1, 1};
g_fProjectionMatrix[0] = rawProjection[0] * g_ActiveConfig.fAspectRatioHackW * fov.x;
g_fProjectionMatrix[1] = 0.0f;
g_fProjectionMatrix[2] = rawProjection[1] * g_ActiveConfig.fAspectRatioHackW * fov.x;
@@ -419,7 +419,7 @@ void VertexShaderManager::SetConstants()
auto corrected_matrix = s_viewportCorrection * Common::Matrix44::FromArray(g_fProjectionMatrix);
- if (xfmem.projection.type == GX_PERSPECTIVE)
+ if (g_freelook_camera.IsActive() && xfmem.projection.type == GX_PERSPECTIVE)
corrected_matrix *= g_freelook_camera.GetView();
memcpy(constants.projection.data(), corrected_matrix.data.data(), 4 * sizeof(float4));