From 25c017e0cc914edaa687d7944ff26cafb636856c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 1 Aug 2020 23:33:47 -0400 Subject: [PATCH] CModelBoo: Make use of static inline variables Same behavior, but allows all the initializers to be in one place, rather than throughout the cpp file. --- Runtime/Graphics/CModel.hpp | 26 +++++++++++++------------- Runtime/Graphics/CModelBoo.cpp | 17 ----------------- 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/Runtime/Graphics/CModel.hpp b/Runtime/Graphics/CModel.hpp index 8e05fdf27..9f6918373 100644 --- a/Runtime/Graphics/CModel.hpp +++ b/Runtime/Graphics/CModel.hpp @@ -184,14 +184,14 @@ private: void WarmupDrawSurfaces() const; void WarmupDrawSurface(const CBooSurface& surf) const; - static zeus::CVector3f g_PlayerPosition; - static float g_ModSeconds; - static float g_TransformedTime; - static float g_TransformedTime2; - static CBooModel* g_LastModelCached; + static inline zeus::CVector3f g_PlayerPosition; + static inline float g_ModSeconds = 0.0f; + static inline float g_TransformedTime = 0.0f; + static inline float g_TransformedTime2 = 0.0f; + static inline CBooModel* g_LastModelCached = nullptr; - static bool g_DummyTextures; - static bool g_RenderModelBlack; + static inline bool g_DummyTextures = false; + static inline bool g_RenderModelBlack = false; public: ~CBooModel(); @@ -230,25 +230,25 @@ public: void ClearUniformCounter() { m_uniUpdateCount = 0; } static void ClearModelUniformCounters(); - static bool g_DrawingOccluders; + static inline bool g_DrawingOccluders = false; static void SetDrawingOccluders(bool occ) { g_DrawingOccluders = occ; } static void SetNewPlayerPositionAndTime(const zeus::CVector3f& pos); - static zeus::CVector3f g_ReflectViewPos; + static inline zeus::CVector3f g_ReflectViewPos; static void KillCachedViewDepState(); static void EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf, zeus::CMatrix4f* mtxsOut, float& alphaOut); - static boo::ObjToken g_shadowMap; - static zeus::CTransform g_shadowTexXf; + static inline boo::ObjToken g_shadowMap; + static inline zeus::CTransform g_shadowTexXf; static void EnableShadowMaps(const boo::ObjToken& map, const zeus::CTransform& texXf); static void DisableShadowMaps(); - static boo::ObjToken g_disintegrateTexture; + static inline boo::ObjToken g_disintegrateTexture; static void SetDisintegrateTexture(const boo::ObjToken& map) { g_disintegrateTexture = map; } - static boo::ObjToken g_reflectionCube; + static inline boo::ObjToken g_reflectionCube; static void SetReflectionCube(const boo::ObjToken& map) { g_reflectionCube = map; } static void SetDummyTextures(bool b) { g_DummyTextures = b; } diff --git a/Runtime/Graphics/CModelBoo.cpp b/Runtime/Graphics/CModelBoo.cpp index 5e1f4defe..a004b78c7 100644 --- a/Runtime/Graphics/CModelBoo.cpp +++ b/Runtime/Graphics/CModelBoo.cpp @@ -43,8 +43,6 @@ constexpr zeus::CMatrix4f DisintegratePost{ }; } // Anonymous namespace -bool CBooModel::g_DrawingOccluders = false; - void CBooModel::Shutdown() { g_shadowMap.reset(); g_disintegrateTexture.reset(); @@ -57,10 +55,6 @@ void CBooModel::ClearModelUniformCounters() { model->ClearUniformCounter(); } -zeus::CVector3f CBooModel::g_PlayerPosition = {}; -float CBooModel::g_ModSeconds = 0.f; -float CBooModel::g_TransformedTime = 0.f; -float CBooModel::g_TransformedTime2 = 0.f; void CBooModel::SetNewPlayerPositionAndTime(const zeus::CVector3f& pos) { g_PlayerPosition = pos; KillCachedViewDepState(); @@ -73,14 +67,8 @@ void CBooModel::SetNewPlayerPositionAndTime(const zeus::CVector3f& pos) { g_TransformedTime2 = 1.f / -(0.015f * std::sin(g_ModSeconds * 1.5f + 1.f) - 1.f); } -CBooModel* CBooModel::g_LastModelCached = nullptr; void CBooModel::KillCachedViewDepState() { g_LastModelCached = nullptr; } -bool CBooModel::g_DummyTextures = false; -bool CBooModel::g_RenderModelBlack = false; - -zeus::CVector3f CBooModel::g_ReflectViewPos = {}; - void CBooModel::EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf, zeus::CMatrix4f* mtxsOut, float& alphaOut) { zeus::CVector3f modelToPlayer = g_PlayerPosition - CGraphics::g_GXModelMatrix.origin; @@ -146,11 +134,6 @@ void CBooModel::EnsureViewDepStateCached(const CBooModel& model, const CBooSurfa } } -boo::ObjToken CBooModel::g_shadowMap; -zeus::CTransform CBooModel::g_shadowTexXf; -boo::ObjToken CBooModel::g_disintegrateTexture; -boo::ObjToken CBooModel::g_reflectionCube; - void CBooModel::EnableShadowMaps(const boo::ObjToken& map, const zeus::CTransform& texXf) { g_shadowMap = map; g_shadowTexXf = texXf;