mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
VideoCommon: remove VertexShaderManager functions instead preferring the direct freelook camera methods
This commit is contained in:
parent
5bd7cc8bac
commit
e125c61d47
@ -30,6 +30,7 @@
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
||||
#include "VideoCommon/FreeLookCamera.h"
|
||||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
#include "VideoCommon/RenderBase.h"
|
||||
#include "VideoCommon/VertexShaderManager.h"
|
||||
@ -545,25 +546,25 @@ void HotkeyScheduler::Run()
|
||||
fl_speed = 1.0;
|
||||
|
||||
if (IsHotkey(HK_FREELOOK_UP, true))
|
||||
VertexShaderManager::TranslateView(0.0, 0.0, -fl_speed);
|
||||
g_freelook_camera.MoveVertical(-fl_speed);
|
||||
|
||||
if (IsHotkey(HK_FREELOOK_DOWN, true))
|
||||
VertexShaderManager::TranslateView(0.0, 0.0, fl_speed);
|
||||
g_freelook_camera.MoveVertical(fl_speed);
|
||||
|
||||
if (IsHotkey(HK_FREELOOK_LEFT, true))
|
||||
VertexShaderManager::TranslateView(fl_speed, 0.0);
|
||||
g_freelook_camera.MoveHorizontal(fl_speed);
|
||||
|
||||
if (IsHotkey(HK_FREELOOK_RIGHT, true))
|
||||
VertexShaderManager::TranslateView(-fl_speed, 0.0);
|
||||
g_freelook_camera.MoveHorizontal(-fl_speed);
|
||||
|
||||
if (IsHotkey(HK_FREELOOK_ZOOM_IN, true))
|
||||
VertexShaderManager::TranslateView(0.0, fl_speed);
|
||||
g_freelook_camera.Zoom(fl_speed);
|
||||
|
||||
if (IsHotkey(HK_FREELOOK_ZOOM_OUT, true))
|
||||
VertexShaderManager::TranslateView(0.0, -fl_speed);
|
||||
g_freelook_camera.Zoom(-fl_speed);
|
||||
|
||||
if (IsHotkey(HK_FREELOOK_RESET, true))
|
||||
VertexShaderManager::ResetView();
|
||||
g_freelook_camera.Reset();
|
||||
|
||||
// Savestates
|
||||
for (u32 i = 0; i < State::NUM_STATES; i++)
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "DolphinQt/Resources.h"
|
||||
#include "DolphinQt/Settings.h"
|
||||
|
||||
#include "VideoCommon/FreeLookCamera.h"
|
||||
#include "VideoCommon/RenderBase.h"
|
||||
#include "VideoCommon/VertexShaderManager.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
@ -238,12 +239,12 @@ void RenderWidget::OnFreeLookMouseMove(QMouseEvent* event)
|
||||
if (event->buttons() & Qt::RightButton)
|
||||
{
|
||||
// Camera Pitch and Yaw:
|
||||
VertexShaderManager::RotateView(mouse_move.y() / 200.f, mouse_move.x() / 200.f, 0.f);
|
||||
g_freelook_camera.Rotate(Common::Vec3{mouse_move.y() / 200.f, mouse_move.x() / 200.f, 0.f});
|
||||
}
|
||||
else if (event->buttons() & Qt::MidButton)
|
||||
{
|
||||
// Camera Roll:
|
||||
VertexShaderManager::RotateView(0.f, 0.f, mouse_move.x() / 200.f);
|
||||
g_freelook_camera.Rotate({0.f, 0.f, mouse_move.x() / 200.f});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user