2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 01:07:43 +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:
Lioncash
2020-03-18 01:14:36 -04:00
committed by Luke Street
parent 36ac0a8d78
commit 40fc3f9dd8
18 changed files with 141 additions and 112 deletions

View File

@@ -16,36 +16,45 @@ CGuiModel::CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId mod
xb8_model = sp->GetObj({SBIG('CMDL'), modelId});
}
bool CGuiModel::GetIsFinishedLoadingWidgetSpecific() const {
if (!xb8_model)
bool CGuiModel::GetIsFinishedLoadingWidgetSpecific() {
if (!xb8_model) {
return true;
if (!xb8_model.IsLoaded())
}
if (!xb8_model.IsLoaded()) {
return false;
}
xb8_model->GetInstance().Touch(0);
return xb8_model->IsLoaded(0);
}
void CGuiModel::Touch() const {
const CModel* model = xb8_model.GetObj();
if (model)
model->GetInstance().Touch(0);
void CGuiModel::Touch() {
CModel* const model = xb8_model.GetObj();
if (model == nullptr) {
return;
}
model->GetInstance().Touch(0);
}
void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const {
void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
CGraphics::SetModelMatrix(x34_worldXF);
if (!xb8_model)
if (!xb8_model) {
return;
if (!GetIsFinishedLoading())
}
if (!GetIsFinishedLoading()) {
return;
const CModel* model = xb8_model.GetObj();
if (!model)
}
CModel* const model = xb8_model.GetObj();
if (!model) {
return;
}
if (GetIsVisible()) {
SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(fmt("CGuiModel::Draw {}"), m_name).c_str(), zeus::skCyan);
zeus::CColor moduCol = xa8_color2;
moduCol.a() *= parms.x0_alphaMod;
xb0_frame->EnableLights(xcc_lightMask, const_cast<CBooModel&>(model->GetInstance()));
xb0_frame->EnableLights(xcc_lightMask, model->GetInstance());
// if (xb6_29_cullFaces)
// CGraphics::SetCullMode(ERglCullMode::Front);