From 3c4e25062de480e46500f52db95f38f820e67697 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 6 Mar 2020 00:21:35 -0500 Subject: [PATCH] CModelBoo: Make static data constexpr where applicable Gets rid of potential runtime-initializers. --- Runtime/Graphics/CModelBoo.cpp | 45 +++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/Runtime/Graphics/CModelBoo.cpp b/Runtime/Graphics/CModelBoo.cpp index e2992e644..3e98030af 100644 --- a/Runtime/Graphics/CModelBoo.cpp +++ b/Runtime/Graphics/CModelBoo.cpp @@ -18,10 +18,32 @@ #include namespace urde { -static logvisor::Module Log("urde::CBooModel"); -bool CBooModel::g_DrawingOccluders = false; +namespace { +logvisor::Module Log("urde::CBooModel"); +CBooModel* g_FirstModel = nullptr; -static CBooModel* g_FirstModel = nullptr; +constexpr zeus::CMatrix4f ReflectBaseMtx{ + 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 1.f, +}; + +constexpr zeus::CMatrix4f ReflectPostGL{ + 1.f, 0.f, 0.f, 0.f, 0.f, -1.f, 0.f, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, +}; + +constexpr zeus::CMatrix4f MBShadowPost0{ + 1.f, 0.f, 0.f, 0.f, 0.f, -1.f, 0.f, 1.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 1.f, +}; + +constexpr zeus::CMatrix4f MBShadowPost1{ + 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, -0.0625f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 1.f, +}; + +constexpr zeus::CMatrix4f DisintegratePost{ + 1.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 1.f, +}; +} // Anonymous namespace + +bool CBooModel::g_DrawingOccluders = false; void CBooModel::Shutdown() { g_shadowMap.reset(); @@ -59,12 +81,6 @@ bool CBooModel::g_RenderModelBlack = false; zeus::CVector3f CBooModel::g_ReflectViewPos = {}; -static const zeus::CMatrix4f ReflectBaseMtx = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, - 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 1.f}; - -static const zeus::CMatrix4f ReflectPostGL = {1.f, 0.f, 0.f, 0.f, 0.f, -1.f, 0.f, 1.f, - 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f}; - void CBooModel::EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf, zeus::CMatrix4f* mtxsOut, float& alphaOut) { zeus::CVector3f modelToPlayer = g_PlayerPosition - CGraphics::g_GXModelMatrix.origin; @@ -747,17 +763,6 @@ void CBooModel::UVAnimationBuffer::PadOutBuffer(u8*& bufStart, u8*& bufOut) { bufOut = bufStart + ROUND_UP_256(bufOut - bufStart); } -static const zeus::CMatrix4f MBShadowPost0(1.f, 0.f, 0.f, 0.f, - 0.f, -1.f, 0.f, 1.f, - 0.f, 0.f, 0.f, 1.f, - 0.f, 0.f, 0.f, 1.f); - -static const zeus::CMatrix4f MBShadowPost1(0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f, -0.0625f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, - 0.f, 1.f); - -static const zeus::CMatrix4f DisintegratePost(1.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, - 1.f); - void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet, const CModelFlags& flags, const CBooModel* parent) { u8* start = bufOut;