CEnvFxManager: Remove mutable keywords where applicable

We can just make the relevant functions non-const to remove the use of
mutable here.
This commit is contained in:
Lioncash 2020-04-10 02:57:54 -04:00
parent e13aa34509
commit f74c2d446f
2 changed files with 31 additions and 31 deletions

View File

@ -375,10 +375,10 @@ static zeus::CColor GetFlakeColor(const zeus::CMatrix4f& mvp, const CEnvFxShader
return zeus::CColor(1.f - zeus::clamp(0.f, screenHeight, 1.f), 1.f); return zeus::CColor(1.f - zeus::clamp(0.f, screenHeight, 1.f), 1.f);
} }
void CEnvFxManagerGrid::RenderSnowParticles(const zeus::CTransform& camXf) const { void CEnvFxManagerGrid::RenderSnowParticles(const zeus::CTransform& camXf) {
zeus::CVector3f xVec = 0.2f * camXf.basis[0]; const zeus::CVector3f xVec = 0.2f * camXf.basis[0];
zeus::CVector3f zVec = 0.2f * camXf.basis[2]; const zeus::CVector3f zVec = 0.2f * camXf.basis[2];
zeus::CMatrix4f mvp = CGraphics::GetPerspectiveProjectionMatrix(false) * CGraphics::g_GXModelView.toMatrix4f(); const zeus::CMatrix4f mvp = CGraphics::GetPerspectiveProjectionMatrix(false) * CGraphics::g_GXModelView.toMatrix4f();
auto* bufOut = m_instBuf.access(); auto* bufOut = m_instBuf.access();
for (const auto& particle : x1c_particles) { for (const auto& particle : x1c_particles) {
bufOut->positions[0] = particle.toVec3f(); bufOut->positions[0] = particle.toVec3f();
@ -396,26 +396,26 @@ void CEnvFxManagerGrid::RenderSnowParticles(const zeus::CTransform& camXf) const
CGraphics::DrawInstances(0, 4, x1c_particles.size()); CGraphics::DrawInstances(0, 4, x1c_particles.size());
} }
void CEnvFxManagerGrid::RenderRainParticles(const zeus::CTransform& camXf) const { void CEnvFxManagerGrid::RenderRainParticles(const zeus::CTransform& camXf) {
m_lineRenderer.Reset(); m_lineRenderer.Reset();
float zOffset = 2.f * (1.f - std::fabs(camXf.basis[2].dot(zeus::skUp))) + 1.f; const float zOffset = 2.f * (1.f - std::fabs(camXf.basis[2].dot(zeus::skUp))) + 1.f;
zeus::CColor color0(1.f, 10.f / 15.f); const zeus::CColor color0(1.f, 10.f / 15.f);
for (const auto& particle : x1c_particles) { for (const auto& particle : x1c_particles) {
zeus::CVector3f pos0 = particle.toVec3f(); const zeus::CVector3f pos0 = particle.toVec3f();
zeus::CVector3f pos1 = pos0; zeus::CVector3f pos1 = pos0;
pos1.z() += zOffset; pos1.z() += zOffset;
float uvy0 = pos0.z() * 10.f + m_uvyOffset; const float uvy0 = pos0.z() * 10.f + m_uvyOffset;
float uvy1 = pos1.z() * 10.f + m_uvyOffset; const float uvy1 = pos1.z() * 10.f + m_uvyOffset;
m_lineRenderer.AddVertex(pos0, zeus::skWhite, 1.f, {0.f, uvy0}); m_lineRenderer.AddVertex(pos0, zeus::skWhite, 1.f, {0.f, uvy0});
m_lineRenderer.AddVertex(pos1, zeus::skClear, 1.f, {0.f, uvy1}); m_lineRenderer.AddVertex(pos1, zeus::skClear, 1.f, {0.f, uvy1});
} }
m_lineRenderer.Render(g_Renderer->IsThermalVisorHotPass(), zeus::CColor(1.f, 0.15f)); m_lineRenderer.Render(g_Renderer->IsThermalVisorHotPass(), zeus::CColor(1.f, 0.15f));
} }
void CEnvFxManagerGrid::RenderUnderwaterParticles(const zeus::CTransform& camXf) const { void CEnvFxManagerGrid::RenderUnderwaterParticles(const zeus::CTransform& camXf) {
zeus::CVector3f xVec = 0.5f * camXf.basis[0]; const zeus::CVector3f xVec = 0.5f * camXf.basis[0];
zeus::CVector3f zVec = 0.5f * camXf.basis[2]; const zeus::CVector3f zVec = 0.5f * camXf.basis[2];
zeus::CMatrix4f mvp = CGraphics::GetPerspectiveProjectionMatrix(false) * CGraphics::g_GXModelView.toMatrix4f(); const zeus::CMatrix4f mvp = CGraphics::GetPerspectiveProjectionMatrix(false) * CGraphics::g_GXModelView.toMatrix4f();
auto* bufOut = m_instBuf.access(); auto* bufOut = m_instBuf.access();
for (const auto& particle : x1c_particles) { for (const auto& particle : x1c_particles) {
bufOut->positions[0] = particle.toVec3f(); bufOut->positions[0] = particle.toVec3f();
@ -434,7 +434,7 @@ void CEnvFxManagerGrid::RenderUnderwaterParticles(const zeus::CTransform& camXf)
} }
void CEnvFxManagerGrid::Render(const zeus::CTransform& xf, const zeus::CTransform& invXf, const zeus::CTransform& camXf, void CEnvFxManagerGrid::Render(const zeus::CTransform& xf, const zeus::CTransform& invXf, const zeus::CTransform& camXf,
float fxDensity, EEnvFxType fxType, const CEnvFxManager& parent) const { float fxDensity, EEnvFxType fxType, CEnvFxManager& parent) {
if (!x1c_particles.empty() && x14_block.first) { if (!x1c_particles.empty() && x14_block.first) {
CGraphics::SetModelMatrix(xf * zeus::CTransform::Translate(x4_position.toVec2f() / 256.f)); CGraphics::SetModelMatrix(xf * zeus::CTransform::Translate(x4_position.toVec2f() / 256.f));
parent.m_uniformData.mv = CGraphics::g_GXModelView.toMatrix4f(); parent.m_uniformData.mv = CGraphics::g_GXModelView.toMatrix4f();
@ -469,7 +469,7 @@ void CEnvFxManagerGrid::Render(const zeus::CTransform& xf, const zeus::CTransfor
} }
} }
void CEnvFxManager::SetupSnowTevs(const CStateManager& mgr) const { void CEnvFxManager::SetupSnowTevs(const CStateManager& mgr) {
mgr.GetCameraManager()->GetCurrentCamera(mgr); mgr.GetCameraManager()->GetCurrentCamera(mgr);
if (mgr.GetCameraManager()->GetFluidCounter() != 0) { if (mgr.GetCameraManager()->GetFluidCounter() != 0) {
g_Renderer->SetWorldFog(ERglFogMode::PerspExp, 0.f, 35.f, zeus::skBlack); g_Renderer->SetWorldFog(ERglFogMode::PerspExp, 0.f, 35.f, zeus::skBlack);
@ -535,7 +535,7 @@ void CEnvFxManager::SetupUnderwaterTevs(const zeus::CTransform& invXf, const CSt
// Swap: RGBR // Swap: RGBR
} }
void CEnvFxManager::Render(const CStateManager& mgr) const { void CEnvFxManager::Render(const CStateManager& mgr) {
EEnvFxType fxType = mgr.GetWorld()->GetNeededEnvFx(); EEnvFxType fxType = mgr.GetWorld()->GetNeededEnvFx();
if (fxType != EEnvFxType::None) { if (fxType != EEnvFxType::None) {
if (mgr.GetPlayer().GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Unmorphed || if (mgr.GetPlayer().GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Unmorphed ||
@ -562,7 +562,7 @@ void CEnvFxManager::Render(const CStateManager& mgr) const {
break; break;
} }
m_fogUniformBuf->load(&CGraphics::g_Fog, sizeof(CGraphics::g_Fog)); m_fogUniformBuf->load(&CGraphics::g_Fog, sizeof(CGraphics::g_Fog));
for (const auto& grid : x50_grids) for (auto& grid : x50_grids)
grid.Render(xf, invXf, camXf, x30_fxDensity, fxType, *this); grid.Render(xf, invXf, camXf, x30_fxDensity, fxType, *this);
// Backface cull // Backface cull

View File

@ -64,34 +64,34 @@ class CEnvFxManagerGrid {
std::pair<bool, float> x14_block = {false, FLT_MAX}; /* Blocked-bool, Z-coordinate */ std::pair<bool, float> x14_block = {false, FLT_MAX}; /* Blocked-bool, Z-coordinate */
std::vector<CVectorFixed8_8> x1c_particles; std::vector<CVectorFixed8_8> x1c_particles;
mutable hecl::VertexBufferPool<CEnvFxShaders::Instance>::Token m_instBuf; hecl::VertexBufferPool<CEnvFxShaders::Instance>::Token m_instBuf;
mutable hecl::UniformBufferPool<CEnvFxShaders::Uniform>::Token m_uniformBuf; hecl::UniformBufferPool<CEnvFxShaders::Uniform>::Token m_uniformBuf;
mutable CLineRenderer m_lineRenderer; CLineRenderer m_lineRenderer;
boo::ObjToken<boo::IShaderDataBinding> m_snowBinding; boo::ObjToken<boo::IShaderDataBinding> m_snowBinding;
boo::ObjToken<boo::IShaderDataBinding> m_underwaterBinding; boo::ObjToken<boo::IShaderDataBinding> m_underwaterBinding;
mutable float m_uvyOffset = 0.f; float m_uvyOffset = 0.f;
void RenderSnowParticles(const zeus::CTransform& camXf) const; void RenderSnowParticles(const zeus::CTransform& camXf);
void RenderRainParticles(const zeus::CTransform& camXf) const; void RenderRainParticles(const zeus::CTransform& camXf);
void RenderUnderwaterParticles(const zeus::CTransform& camXf) const; void RenderUnderwaterParticles(const zeus::CTransform& camXf);
public: public:
CEnvFxManagerGrid(const zeus::CVector2i& position, const zeus::CVector2i& extent, CEnvFxManagerGrid(const zeus::CVector2i& position, const zeus::CVector2i& extent,
std::vector<CVectorFixed8_8> initialParticles, int reserve, CEnvFxManager& parent, std::vector<CVectorFixed8_8> initialParticles, int reserve, CEnvFxManager& parent,
boo::IGraphicsDataFactory::Context& ctx); boo::IGraphicsDataFactory::Context& ctx);
void Render(const zeus::CTransform& xf, const zeus::CTransform& invXf, const zeus::CTransform& camXf, float fxDensity, void Render(const zeus::CTransform& xf, const zeus::CTransform& invXf, const zeus::CTransform& camXf, float fxDensity,
EEnvFxType fxType, const CEnvFxManager& parent) const; EEnvFxType fxType, CEnvFxManager& parent);
}; };
class CEnvFxManager { class CEnvFxManager {
friend class CEnvFxManagerGrid; friend class CEnvFxManagerGrid;
friend class CEnvFxShaders; friend class CEnvFxShaders;
mutable hecl::VertexBufferPool<CEnvFxShaders::Instance> m_instPool; hecl::VertexBufferPool<CEnvFxShaders::Instance> m_instPool;
mutable hecl::UniformBufferPool<CEnvFxShaders::Uniform> m_uniformPool; hecl::UniformBufferPool<CEnvFxShaders::Uniform> m_uniformPool;
mutable CEnvFxShaders::Uniform m_uniformData; CEnvFxShaders::Uniform m_uniformData;
boo::ObjToken<boo::IGraphicsBufferD> m_fogUniformBuf; boo::ObjToken<boo::IGraphicsBufferD> m_fogUniformBuf;
zeus::CAABox x0_particleBounds = zeus::CAABox(-63.5f, 63.5f); zeus::CAABox x0_particleBounds = zeus::CAABox(-63.5f, 63.5f);
@ -133,7 +133,7 @@ class CEnvFxManager {
void UpdateSnowParticles(const rstl::reserved_vector<CVectorFixed8_8, 256>& snowForces); void UpdateSnowParticles(const rstl::reserved_vector<CVectorFixed8_8, 256>& snowForces);
void UpdateRainParticles(const CVectorFixed8_8& zVec, const zeus::CVector3f& oopbtws, float dt); void UpdateRainParticles(const CVectorFixed8_8& zVec, const zeus::CVector3f& oopbtws, float dt);
void UpdateUnderwaterParticles(const CVectorFixed8_8& zVec); void UpdateUnderwaterParticles(const CVectorFixed8_8& zVec);
void SetupSnowTevs(const CStateManager& mgr) const; void SetupSnowTevs(const CStateManager& mgr);
void SetupRainTevs() const; void SetupRainTevs() const;
void SetupUnderwaterTevs(const zeus::CTransform& invXf, const CStateManager& mgr) const; void SetupUnderwaterTevs(const zeus::CTransform& invXf, const CStateManager& mgr) const;
@ -142,7 +142,7 @@ public:
void AsyncLoadResources(CStateManager& mgr); void AsyncLoadResources(CStateManager& mgr);
void Update(float, CStateManager& mgr); void Update(float, CStateManager& mgr);
void Render(const CStateManager& mgr) const; void Render(const CStateManager& mgr);
void SetFxDensity(s32, float); void SetFxDensity(s32, float);
void AreaLoaded(); void AreaLoaded();
void SetSplashRate(float f) { xb54_baseSplashRate = f; } void SetSplashRate(float f) { xb54_baseSplashRate = f; }