1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 15:29:55 +00:00

Move declaration private static member variables of LightManager to .cpp

There is no need to expose them to other translation units.
This commit is contained in:
elsid 2022-07-08 17:20:23 +02:00
parent 4211cf1c24
commit 9ac3bb753e
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
2 changed files with 20 additions and 18 deletions

View file

@ -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<std::string, LightingMethod> 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<std::string, LightingMethod> 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)
{

View file

@ -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<std::string, LightingMethod> sLightingMethodSettingMap;
std::shared_ptr<PPLightBuffer> mPPLightBuffer;
};