mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-16 20:17:03 +00:00
CModelBoo: Remove usages of const_cast
Many functions are modifying internals of CBooModel and const-casting is performed in order to work around functions being const when they really shouldn't be. This amends the function signatures in order to allow these functions to exist without const_cast, making code much nicer to read.
This commit is contained in:
@@ -53,14 +53,14 @@ void CAuiEnergyBarT01::Update(float dt) {
|
||||
CGuiWidget::Update(dt);
|
||||
}
|
||||
|
||||
void CAuiEnergyBarT01::Draw(const CGuiWidgetDrawParms& drawParms) const {
|
||||
void CAuiEnergyBarT01::Draw(const CGuiWidgetDrawParms& drawParms) {
|
||||
if (!xbc_tex || !xbc_tex.IsLoaded() || !xd8_coordFunc) {
|
||||
return;
|
||||
}
|
||||
SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(fmt("CAuiEnergyBarT01::Draw {}"), m_name).c_str(), zeus::skCyan);
|
||||
|
||||
CGraphics::SetModelMatrix(x34_worldXF);
|
||||
const_cast<CEnergyBarShader&>(m_energyBarShader).updateModelMatrix();
|
||||
m_energyBarShader.updateModelMatrix();
|
||||
|
||||
const float filledT = xe0_maxEnergy > 0.f ? xf8_filledEnergy / xe0_maxEnergy : 0.f;
|
||||
const float shadowT = xe0_maxEnergy > 0.f ? xfc_shadowEnergy / xe0_maxEnergy : 0.f;
|
||||
@@ -78,7 +78,7 @@ void CAuiEnergyBarT01::Draw(const CGuiWidgetDrawParms& drawParms) const {
|
||||
emptyColor *= xa8_color2;
|
||||
|
||||
for (size_t i = 0; i < m_verts.size(); ++i) {
|
||||
std::vector<CEnergyBarShader::Vertex>& verts = const_cast<CAuiEnergyBarT01&>(*this).m_verts[i];
|
||||
std::vector<CEnergyBarShader::Vertex>& verts = m_verts[i];
|
||||
verts.clear();
|
||||
|
||||
float start;
|
||||
@@ -118,8 +118,7 @@ void CAuiEnergyBarT01::Draw(const CGuiWidgetDrawParms& drawParms) const {
|
||||
}
|
||||
}
|
||||
|
||||
const_cast<CEnergyBarShader&>(m_energyBarShader)
|
||||
.draw(filledColor, m_verts[0], shadowColor, m_verts[1], emptyColor, m_verts[2], xbc_tex.GetObj());
|
||||
m_energyBarShader.draw(filledColor, m_verts[0], shadowColor, m_verts[1], emptyColor, m_verts[2], xbc_tex.GetObj());
|
||||
}
|
||||
|
||||
void CAuiEnergyBarT01::SetCurrEnergy(float e, ESetMode mode) {
|
||||
|
||||
Reference in New Issue
Block a user