CModelData: Remove usages of const_cast

Allows readers to know that these functions do affect member state.
This commit is contained in:
Lioncash 2020-08-01 23:45:47 -04:00
parent 25c017e0cc
commit 4e9b22962c
6 changed files with 14 additions and 14 deletions

View File

@ -46,7 +46,7 @@ SAdvancementDeltas CModelData::GetAdvancementDeltas(const CCharAnimTime& a, cons
} }
void CModelData::Render(const CStateManager& stateMgr, const zeus::CTransform& xf, const CActorLights* lights, 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); 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 { void CModelData::Touch(const CStateManager& stateMgr, int shaderIdx) const {
Touch(const_cast<CModelData&>(*this).GetRenderingModel(stateMgr), shaderIdx); Touch(GetRenderingModel(stateMgr), shaderIdx);
} }
void CModelData::RenderThermal(const zeus::CColor& mulColor, const zeus::CColor& addColor, 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, 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 || if ((x14_25_sortThermal && which == EWhichModel::ThermalHot) || x10_animData || !x1c_normalModel ||
drawFlags.x0_blendMode > 4) { drawFlags.x0_blendMode > 4) {
const_cast<CModelData*>(this)->x14_24_renderSorted = false; x14_24_renderSorted = false;
return; return;
} }
@ -333,11 +333,11 @@ void CModelData::RenderUnsortedParts(EWhichModel which, const zeus::CTransform&
model->DrawNormal(drawFlags, nullptr, nullptr); model->DrawNormal(drawFlags, nullptr, nullptr);
// Set ambient to white // Set ambient to white
CGraphics::DisableAllLights(); CGraphics::DisableAllLights();
const_cast<CModelData*>(this)->x14_24_renderSorted = true; x14_24_renderSorted = true;
} }
void CModelData::Render(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights, 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) { if (x14_25_sortThermal && which == EWhichModel::ThermalHot) {
zeus::CColor mul(drawFlags.x4_color.a(), drawFlags.x4_color.a()); zeus::CColor mul(drawFlags.x4_color.a(), drawFlags.x4_color.a());
RenderThermal(xf, mul, {0.f, 0.f, 0.f, 0.25f}, drawFlags); 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 // Set ambient to white
CGraphics::DisableAllLights(); CGraphics::DisableAllLights();
const_cast<CModelData*>(this)->x14_24_renderSorted = false; x14_24_renderSorted = false;
} }
} }

View File

@ -92,7 +92,7 @@ public:
SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const; SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const;
void Render(const CStateManager& stateMgr, const zeus::CTransform& xf, const CActorLights* lights, void Render(const CStateManager& stateMgr, const zeus::CTransform& xf, const CActorLights* lights,
const CModelFlags& drawFlags) const; const CModelFlags& drawFlags);
bool IsLoaded(int shaderIdx) const; bool IsLoaded(int shaderIdx) const;
static EWhichModel GetRenderingModel(const CStateManager& stateMgr); static EWhichModel GetRenderingModel(const CStateManager& stateMgr);
CSkinnedModel& PickAnimatedModel(EWhichModel which) const; CSkinnedModel& PickAnimatedModel(EWhichModel which) const;
@ -122,8 +122,8 @@ public:
void RenderThermal(const zeus::CTransform& xf, const zeus::CColor& mulColor, const zeus::CColor& addColor, void RenderThermal(const zeus::CTransform& xf, const zeus::CColor& mulColor, const zeus::CColor& addColor,
const CModelFlags& flags) const; const CModelFlags& flags) const;
void RenderUnsortedParts(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights, void RenderUnsortedParts(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) const; void Render(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights, const CModelFlags& drawFlags);
void InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights, void InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
const zeus::CColor& color0, const zeus::CColor& color1); const zeus::CColor& color0, const zeus::CColor& color1);

View File

@ -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) if (x70_hidden)
return; return;

View File

@ -21,7 +21,7 @@ class CSamusFaceReflection {
public: public:
explicit CSamusFaceReflection(CStateManager& stateMgr); explicit CSamusFaceReflection(CStateManager& stateMgr);
void PreDraw(const 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); void Update(float dt, const CStateManager& stateMgr, CRandom16& rand);
}; };

View File

@ -81,7 +81,7 @@ void CGunMotion::Update(float dt, CStateManager& mgr) {
xb8_24_animPlaying = false; 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); constexpr CModelFlags flags(0, 0, 3, zeus::skWhite);
x0_modelData.Render(mgr, xf, nullptr, flags); x0_modelData.Render(mgr, xf, nullptr, flags);
} }

View File

@ -31,7 +31,7 @@ public:
void BasePosition(bool bigStrikeReset); void BasePosition(bool bigStrikeReset);
void EnterFidget(CStateManager& mgr, SamusGun::EFidgetType type, s32 parm2); void EnterFidget(CStateManager& mgr, SamusGun::EFidgetType type, s32 parm2);
void Update(float dt, CStateManager& mgr); 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(); } s32 GetFreeLookSetId() const { return x4c_gunController.GetFreeLookSetId(); }
CGunController& GunController() { return x4c_gunController; } CGunController& GunController() { return x4c_gunController; }
bool IsAnimPlaying() const { return xb8_24_animPlaying; } bool IsAnimPlaying() const { return xb8_24_animPlaying; }