CScanDisplay: Remove use of const_cast

The draw function is essentially not fully const in behavior, so we can
remove the const qualifiers where necessary.
This commit is contained in:
Lioncash 2020-03-29 21:44:07 -04:00
parent 2d8e94911a
commit 0d3bab4c14
4 changed files with 25 additions and 19 deletions

View File

@ -17,7 +17,7 @@ namespace urde {
void IHudDecoInterface::SetReticuleTransform(const zeus::CMatrix3f& xf) {} void IHudDecoInterface::SetReticuleTransform(const zeus::CMatrix3f& xf) {}
void IHudDecoInterface::SetDecoRotation(float angle) {} void IHudDecoInterface::SetDecoRotation(float angle) {}
void IHudDecoInterface::SetFrameColorValue(float v) {} void IHudDecoInterface::SetFrameColorValue(float v) {}
void IHudDecoInterface::Draw() const {} void IHudDecoInterface::Draw() {}
void IHudDecoInterface::ProcessInput(const CFinalInput& input) {} void IHudDecoInterface::ProcessInput(const CFinalInput& input) {}
float IHudDecoInterface::GetHudTextAlpha() const { return 1.f; } float IHudDecoInterface::GetHudTextAlpha() const { return 1.f; }
@ -325,11 +325,12 @@ void CHudDecoInterfaceScan::Update(float dt, const CStateManager& stateMgr) {
UpdateScanDisplay(stateMgr, dt); UpdateScanDisplay(stateMgr, dt);
} }
void CHudDecoInterfaceScan::Draw() const { void CHudDecoInterfaceScan::Draw() {
x18_scanDisplay.Draw(); x18_scanDisplay.Draw();
if (x10_loadedScanHudFlat) if (x10_loadedScanHudFlat) {
x10_loadedScanHudFlat->Draw(CGuiWidgetDrawParms::Default); x10_loadedScanHudFlat->Draw(CGuiWidgetDrawParms::Default);
} }
}
void CHudDecoInterfaceScan::ProcessInput(const CFinalInput& input) { x18_scanDisplay.ProcessInput(input); } void CHudDecoInterfaceScan::ProcessInput(const CFinalInput& input) { x18_scanDisplay.ProcessInput(input); }

View File

@ -28,7 +28,7 @@ public:
virtual void SetDamageTransform(const zeus::CMatrix3f& rotation, const zeus::CVector3f& position) = 0; virtual void SetDamageTransform(const zeus::CMatrix3f& rotation, const zeus::CVector3f& position) = 0;
virtual void SetFrameColorValue(float v); virtual void SetFrameColorValue(float v);
virtual void Update(float dt, const CStateManager& stateMgr) = 0; virtual void Update(float dt, const CStateManager& stateMgr) = 0;
virtual void Draw() const; virtual void Draw();
virtual void ProcessInput(const CFinalInput& input); virtual void ProcessInput(const CFinalInput& input);
virtual void UpdateCameraDebugSettings(float fov, float y, float z) = 0; virtual void UpdateCameraDebugSettings(float fov, float y, float z) = 0;
virtual void UpdateHudAlpha() = 0; virtual void UpdateHudAlpha() = 0;
@ -116,7 +116,7 @@ public:
const CScannableObjectInfo* GetCurrScanInfo(const CStateManager& stateMgr) const; const CScannableObjectInfo* GetCurrScanInfo(const CStateManager& stateMgr) const;
void UpdateScanDisplay(const CStateManager& stateMgr, float dt); void UpdateScanDisplay(const CStateManager& stateMgr, float dt);
void Update(float dt, const CStateManager& stateMgr) override; void Update(float dt, const CStateManager& stateMgr) override;
void Draw() const override; void Draw() override;
void ProcessInput(const CFinalInput& input) override; void ProcessInput(const CFinalInput& input) override;
void UpdateCameraDebugSettings(float fov, float y, float z) override; void UpdateCameraDebugSettings(float fov, float y, float z) override;
void UpdateHudAlpha() override; void UpdateHudAlpha() override;

View File

@ -35,20 +35,23 @@ void CScanDisplay::CDataDot::Update(float dt) {
} }
} }
void CScanDisplay::CDataDot::Draw(const zeus::CColor& col, float radius) const { void CScanDisplay::CDataDot::Draw(const zeus::CColor& col, float radius) {
if (x24_alpha == 0.f) if (x24_alpha == 0.f) {
return; return;
}
if (x0_dotState != EDotState::Hidden) { if (x0_dotState != EDotState::Hidden) {
zeus::CTransform xf = zeus::CTransform::Translate(xc_curPos.x(), 0.f, xc_curPos.y()); const zeus::CTransform xf = zeus::CTransform::Translate(xc_curPos.x(), 0.f, xc_curPos.y());
CGraphics::SetModelMatrix(xf); CGraphics::SetModelMatrix(xf);
zeus::CColor useColor = col; zeus::CColor useColor = col;
useColor.a() *= x24_alpha; useColor.a() *= x24_alpha;
CTexturedQuadFilter::Vert verts[4] = {{{-radius, 0.f, radius}, {0.f, 1.f}}, const CTexturedQuadFilter::Vert verts[4] = {
{{-radius, 0.f, radius}, {0.f, 1.f}},
{{-radius, 0.f, -radius}, {0.f, 0.f}}, {{-radius, 0.f, -radius}, {0.f, 0.f}},
{{radius, 0.f, radius}, {1.f, 1.f}}, {{radius, 0.f, radius}, {1.f, 1.f}},
{{radius, 0.f, -radius}, {1.f, 0.f}}}; {{radius, 0.f, -radius}, {1.f, 0.f}},
const_cast<CTexturedQuadFilter&>(m_quad).drawVerts(useColor, verts); };
m_quad.drawVerts(useColor, verts);
} }
} }
@ -418,16 +421,18 @@ void CScanDisplay::Update(float dt, float scanningTime) {
} }
} }
void CScanDisplay::Draw() const { void CScanDisplay::Draw() {
if (!x0_dataDot.IsLoaded()) if (!x0_dataDot.IsLoaded()) {
return; return;
}
// No Z-test or write // No Z-test or write
g_Renderer->SetViewportOrtho(true, -4096.f, 4096.f); g_Renderer->SetViewportOrtho(true, -4096.f, 4096.f);
// Additive alpha // Additive alpha
float vpRatio = g_Viewport.xc_height / 480.f; const float vpRatio = g_Viewport.xc_height / 480.f;
for (const CDataDot& dot : xbc_dataDots) for (CDataDot& dot : xbc_dataDots) {
dot.Draw(g_tweakGuiColors->GetScanDataDotColor(), g_tweakGui->GetScanDataDotRadius() * vpRatio); dot.Draw(g_tweakGuiColors->GetScanDataDotColor(), g_tweakGui->GetScanDataDotRadius() * vpRatio);
} }
}
} // namespace urde } // namespace urde

View File

@ -45,7 +45,7 @@ public:
public: public:
explicit CDataDot(const TLockedToken<CTexture>& dataDotTex) : m_quad(EFilterType::Add, dataDotTex) {} explicit CDataDot(const TLockedToken<CTexture>& dataDotTex) : m_quad(EFilterType::Add, dataDotTex) {}
void Update(float dt); void Update(float dt);
void Draw(const zeus::CColor& color, float radius) const; void Draw(const zeus::CColor& color, float radius);
float GetTransitionFactor() const { return x1c_transDur > 0.f ? x20_remTime / x1c_transDur : 0.f; } float GetTransitionFactor() const { return x1c_transDur > 0.f ? x20_remTime / x1c_transDur : 0.f; }
void StartTransitionTo(const zeus::CVector2f&, float); void StartTransitionTo(const zeus::CVector2f&, float);
void SetDestPosition(const zeus::CVector2f&); void SetDestPosition(const zeus::CVector2f&);
@ -90,7 +90,7 @@ public:
CGuiWidget* textGroup, CGuiModel* xmark, CGuiModel* abutton, CGuiModel* dash, float scanTime); CGuiWidget* textGroup, CGuiModel* xmark, CGuiModel* abutton, CGuiModel* dash, float scanTime);
void StopScan(); void StopScan();
void Update(float dt, float scanningTime); void Update(float dt, float scanningTime);
void Draw() const; void Draw();
EScanState GetScanState() const { return xc_state; } EScanState GetScanState() const { return xc_state; }
TUniqueId ScanTarget() const { return x10_objId; } TUniqueId ScanTarget() const { return x10_objId; }
}; };