From 6ba0641b790926e4d02c121d79422069bcaa1c44 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 5 Apr 2020 08:05:02 -0400 Subject: [PATCH] CCameraFilter: Make Draw() non-const Eliminates another usage of const_cast. --- Runtime/Camera/CCameraFilter.cpp | 8 +++++--- Runtime/Camera/CCameraFilter.hpp | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Runtime/Camera/CCameraFilter.cpp b/Runtime/Camera/CCameraFilter.cpp index 53ff45c88..426463ae5 100644 --- a/Runtime/Camera/CCameraFilter.cpp +++ b/Runtime/Camera/CCameraFilter.cpp @@ -104,9 +104,11 @@ void CCameraFilterPass::DisableFilter(float time) { } template -void CCameraFilterPass::Draw() const { - if (m_shader) - const_cast(*m_shader).DrawFilter(x8_shape, x18_curColor, GetT(x4_nextType == EFilterType::Passthru)); +void CCameraFilterPass::Draw() { + if (!m_shader) { + return; + } + m_shader->DrawFilter(x8_shape, x18_curColor, GetT(x4_nextType == EFilterType::Passthru)); } float CCameraFilterPassBase::GetT(bool invert) const { diff --git a/Runtime/Camera/CCameraFilter.hpp b/Runtime/Camera/CCameraFilter.hpp index 027bf2466..acea7d880 100644 --- a/Runtime/Camera/CCameraFilter.hpp +++ b/Runtime/Camera/CCameraFilter.hpp @@ -58,7 +58,7 @@ public: virtual void SetFilter(EFilterType type, EFilterShape shape, float time, const zeus::CColor& color, CAssetId txtr) = 0; virtual void DisableFilter(float time) = 0; - virtual void Draw() const = 0; + virtual void Draw() = 0; }; template @@ -69,7 +69,7 @@ public: void Update(float dt) override; void SetFilter(EFilterType type, EFilterShape shape, float time, const zeus::CColor& color, CAssetId txtr) override; void DisableFilter(float time) override; - void Draw() const override; + void Draw() override; }; class CCameraFilterPassPoly { @@ -107,8 +107,8 @@ class CCameraBlurPass { // bool x2d_noPersistentCopy = false; // u32 x30_persistentBuf = 0; - mutable std::optional m_shader; - mutable std::optional m_xrayShader; + std::optional m_shader; + std::optional m_xrayShader; public: void Draw(bool clearDepth = false);