VideoCommon: remove VertexShaderManager functions instead preferring the direct freelook camera methods

This commit is contained in:
iwubcode
2020-04-26 16:40:25 -05:00
parent 5bd7cc8bac
commit e125c61d47
4 changed files with 21 additions and 43 deletions

View File

@ -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);

View File

@ -29,10 +29,6 @@ public:
static void SetProjectionChanged();
static void SetMaterialColorChanged(int index);
static void TranslateView(float x, float y, float z = 0.0f);
static void RotateView(float x, float y, float z);
static void ResetView();
static void SetVertexFormat(u32 components);
static void SetTexMatrixInfoChanged(int index);
static void SetLightingConfigChanged();