From 4e9b22962c000768480083178198848186ec0268 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 1 Aug 2020 23:45:47 -0400 Subject: [PATCH] CModelData: Remove usages of const_cast Allows readers to know that these functions do affect member state. --- Runtime/Character/CModelData.cpp | 14 +++++++------- Runtime/Character/CModelData.hpp | 6 +++--- Runtime/MP1/CSamusFaceReflection.cpp | 2 +- Runtime/MP1/CSamusFaceReflection.hpp | 2 +- Runtime/Weapon/CGunMotion.cpp | 2 +- Runtime/Weapon/CGunMotion.hpp | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Runtime/Character/CModelData.cpp b/Runtime/Character/CModelData.cpp index 05077c929..34099fa5c 100644 --- a/Runtime/Character/CModelData.cpp +++ b/Runtime/Character/CModelData.cpp @@ -46,7 +46,7 @@ SAdvancementDeltas CModelData::GetAdvancementDeltas(const CCharAnimTime& a, cons } void CModelData::Render(const CStateManager& stateMgr, const zeus::CTransform& xf, const CActorLights* lights, - const CModelFlags& drawFlags) const { + const CModelFlags& drawFlags) { Render(GetRenderingModel(stateMgr), xf, lights, drawFlags); } @@ -284,7 +284,7 @@ void CModelData::Touch(EWhichModel which, int shaderIdx) const { } void CModelData::Touch(const CStateManager& stateMgr, int shaderIdx) const { - Touch(const_cast(*this).GetRenderingModel(stateMgr), shaderIdx); + Touch(GetRenderingModel(stateMgr), shaderIdx); } void CModelData::RenderThermal(const zeus::CColor& mulColor, const zeus::CColor& addColor, @@ -312,10 +312,10 @@ void CModelData::RenderThermal(const zeus::CTransform& xf, const zeus::CColor& m } void CModelData::RenderUnsortedParts(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights, - const CModelFlags& drawFlags) const { + const CModelFlags& drawFlags) { if ((x14_25_sortThermal && which == EWhichModel::ThermalHot) || x10_animData || !x1c_normalModel || drawFlags.x0_blendMode > 4) { - const_cast(this)->x14_24_renderSorted = false; + x14_24_renderSorted = false; return; } @@ -333,11 +333,11 @@ void CModelData::RenderUnsortedParts(EWhichModel which, const zeus::CTransform& model->DrawNormal(drawFlags, nullptr, nullptr); // Set ambient to white CGraphics::DisableAllLights(); - const_cast(this)->x14_24_renderSorted = true; + x14_24_renderSorted = true; } void CModelData::Render(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights, - const CModelFlags& drawFlags) const { + const CModelFlags& drawFlags) { if (x14_25_sortThermal && which == EWhichModel::ThermalHot) { zeus::CColor mul(drawFlags.x4_color.a(), drawFlags.x4_color.a()); RenderThermal(xf, mul, {0.f, 0.f, 0.f, 0.25f}, drawFlags); @@ -373,7 +373,7 @@ void CModelData::Render(EWhichModel which, const zeus::CTransform& xf, const CAc // Set ambient to white CGraphics::DisableAllLights(); - const_cast(this)->x14_24_renderSorted = false; + x14_24_renderSorted = false; } } diff --git a/Runtime/Character/CModelData.hpp b/Runtime/Character/CModelData.hpp index 90f510eb7..886c2da9d 100644 --- a/Runtime/Character/CModelData.hpp +++ b/Runtime/Character/CModelData.hpp @@ -92,7 +92,7 @@ public: SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const; void Render(const CStateManager& stateMgr, const zeus::CTransform& xf, const CActorLights* lights, - const CModelFlags& drawFlags) const; + const CModelFlags& drawFlags); bool IsLoaded(int shaderIdx) const; static EWhichModel GetRenderingModel(const CStateManager& stateMgr); CSkinnedModel& PickAnimatedModel(EWhichModel which) const; @@ -122,8 +122,8 @@ public: void RenderThermal(const zeus::CTransform& xf, const zeus::CColor& mulColor, const zeus::CColor& addColor, const CModelFlags& flags) const; void RenderUnsortedParts(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights, - const CModelFlags& drawFlags) const; - void Render(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights, const CModelFlags& drawFlags) const; + const CModelFlags& drawFlags); + void Render(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights, const CModelFlags& drawFlags); void InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights, const zeus::CColor& color0, const zeus::CColor& color1); diff --git a/Runtime/MP1/CSamusFaceReflection.cpp b/Runtime/MP1/CSamusFaceReflection.cpp index 8a8e2c5af..5754dd92c 100644 --- a/Runtime/MP1/CSamusFaceReflection.cpp +++ b/Runtime/MP1/CSamusFaceReflection.cpp @@ -31,7 +31,7 @@ void CSamusFaceReflection::PreDraw(const CStateManager& mgr) { } } -void CSamusFaceReflection::Draw(const CStateManager& mgr) const { +void CSamusFaceReflection::Draw(const CStateManager& mgr) { if (x70_hidden) return; diff --git a/Runtime/MP1/CSamusFaceReflection.hpp b/Runtime/MP1/CSamusFaceReflection.hpp index 23674de17..e44fb60b8 100644 --- a/Runtime/MP1/CSamusFaceReflection.hpp +++ b/Runtime/MP1/CSamusFaceReflection.hpp @@ -21,7 +21,7 @@ class CSamusFaceReflection { public: explicit CSamusFaceReflection(CStateManager& stateMgr); void PreDraw(const CStateManager& stateMgr); - void Draw(const CStateManager& stateMgr) const; + void Draw(const CStateManager& stateMgr); void Update(float dt, const CStateManager& stateMgr, CRandom16& rand); }; diff --git a/Runtime/Weapon/CGunMotion.cpp b/Runtime/Weapon/CGunMotion.cpp index e12e9ba63..85e6d6246 100644 --- a/Runtime/Weapon/CGunMotion.cpp +++ b/Runtime/Weapon/CGunMotion.cpp @@ -81,7 +81,7 @@ void CGunMotion::Update(float dt, CStateManager& mgr) { xb8_24_animPlaying = false; } -void CGunMotion::Draw(const CStateManager& mgr, const zeus::CTransform& xf) const { +void CGunMotion::Draw(const CStateManager& mgr, const zeus::CTransform& xf) { constexpr CModelFlags flags(0, 0, 3, zeus::skWhite); x0_modelData.Render(mgr, xf, nullptr, flags); } diff --git a/Runtime/Weapon/CGunMotion.hpp b/Runtime/Weapon/CGunMotion.hpp index 197493829..64cd18341 100644 --- a/Runtime/Weapon/CGunMotion.hpp +++ b/Runtime/Weapon/CGunMotion.hpp @@ -31,7 +31,7 @@ public: void BasePosition(bool bigStrikeReset); void EnterFidget(CStateManager& mgr, SamusGun::EFidgetType type, s32 parm2); void Update(float dt, CStateManager& mgr); - void Draw(const CStateManager& mgr, const zeus::CTransform& xf) const; + void Draw(const CStateManager& mgr, const zeus::CTransform& xf); s32 GetFreeLookSetId() const { return x4c_gunController.GetFreeLookSetId(); } CGunController& GunController() { return x4c_gunController; } bool IsAnimPlaying() const { return xb8_24_animPlaying; }