From 9ac3bb753e0c3f7f567c6fe87dba85dcedb3f863 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 8 Jul 2022 17:20:23 +0200 Subject: [PATCH] Move declaration private static member variables of LightManager to .cpp There is no need to expose them to other translation units. --- components/sceneutil/lightmanager.cpp | 32 +++++++++++++++++---------- components/sceneutil/lightmanager.hpp | 6 ----- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index 9b63a9b825..be3fe4679b 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -24,6 +24,10 @@ namespace { + constexpr int maxLightsLowerLimit = 2; + constexpr int maxLightsUpperLimit = 64; + constexpr int ffpMaxLights = 8; + bool sortLights(const SceneUtil::LightManager::LightSourceViewBound* left, const SceneUtil::LightManager::LightSourceViewBound* right) { static auto constexpr illuminationBias = 81.f; @@ -70,6 +74,15 @@ namespace namespace SceneUtil { + namespace + { + const std::unordered_map lightingMethodSettingMap = { + {"legacy", LightingMethod::FFP}, + {"shaders compatibility", LightingMethod::PerObjectUniform}, + {"shaders", LightingMethod::SingleUBO}, + }; + } + static int sLightId = 0; // Handles a GLSL shared layout by using configured offsets and strides to fill a continuous buffer, making the data upload to GPU simpler. @@ -756,16 +769,10 @@ namespace SceneUtil mTemplate->configureLayout(offsets[0], offsets[1], offsets[2], totalBlockSize, stride); } - const std::unordered_map LightManager::sLightingMethodSettingMap = { - {"legacy", LightingMethod::FFP}, - {"shaders compatibility", LightingMethod::PerObjectUniform}, - {"shaders", LightingMethod::SingleUBO}, - }; - LightingMethod LightManager::getLightingMethodFromString(const std::string& value) { - auto it = LightManager::sLightingMethodSettingMap.find(value); - if (it != LightManager::sLightingMethodSettingMap.end()) + auto it = lightingMethodSettingMap.find(value); + if (it != lightingMethodSettingMap.end()) return it->second; constexpr const char* fallback = "shaders compatibility"; @@ -775,7 +782,7 @@ namespace SceneUtil std::string LightManager::getLightingMethodString(LightingMethod method) { - for (const auto& p : LightManager::sLightingMethodSettingMap) + for (const auto& p : lightingMethodSettingMap) if (p.second == method) return p.first; return ""; @@ -801,7 +808,7 @@ namespace SceneUtil if (ffp) { - initFFP(sFFPMaxLights); + initFFP(ffpMaxLights); return; } @@ -819,7 +826,8 @@ namespace SceneUtil hasLoggedWarnings = true; } - int targetLights = std::clamp(Settings::Manager::getInt("max lights", "Shaders"), sMaxLightsLowerLimit, sMaxLightsUpperLimit); + const int targetLights = std::clamp(Settings::Manager::getInt("max lights", "Shaders"), + maxLightsLowerLimit, maxLightsUpperLimit); if (!supportsUBO || !supportsGPU4 || lightingMethod == LightingMethod::PerObjectUniform) initPerObjectUniform(targetLights); @@ -902,7 +910,7 @@ namespace SceneUtil if (usingFFP()) return; - setMaxLights(std::clamp(Settings::Manager::getInt("max lights", "Shaders"), sMaxLightsLowerLimit, sMaxLightsUpperLimit)); + setMaxLights(std::clamp(Settings::Manager::getInt("max lights", "Shaders"), maxLightsLowerLimit, maxLightsUpperLimit)); if (getLightingMethod() == LightingMethod::PerObjectUniform) { diff --git a/components/sceneutil/lightmanager.hpp b/components/sceneutil/lightmanager.hpp index ba226cb7ef..c69f7a74fb 100644 --- a/components/sceneutil/lightmanager.hpp +++ b/components/sceneutil/lightmanager.hpp @@ -360,12 +360,6 @@ namespace SceneUtil SupportedMethods mSupported; - static constexpr auto sMaxLightsLowerLimit = 2; - static constexpr auto sMaxLightsUpperLimit = 64; - static constexpr auto sFFPMaxLights = 8; - - static const std::unordered_map sLightingMethodSettingMap; - std::shared_ptr mPPLightBuffer; };