diff --git a/apps/openmw/mwrender/fogmanager.cpp b/apps/openmw/mwrender/fogmanager.cpp index 68b615e565..ef8de1cb2e 100644 --- a/apps/openmw/mwrender/fogmanager.cpp +++ b/apps/openmw/mwrender/fogmanager.cpp @@ -7,20 +7,10 @@ #include #include #include -#include +#include #include -namespace -{ - float DLLandFogStart; - float DLLandFogEnd; - float DLUnderwaterFogStart; - float DLUnderwaterFogEnd; - float DLInteriorFogStart; - float DLInteriorFogEnd; -} - namespace MWRender { FogManager::FogManager() @@ -29,17 +19,10 @@ namespace MWRender , mUnderwaterFogStart(0.f) , mUnderwaterFogEnd(std::numeric_limits::max()) , mFogColor(osg::Vec4f()) - , mDistantFog(Settings::Manager::getBool("use distant fog", "Fog")) , mUnderwaterColor(Fallback::Map::getColour("Water_UnderwaterColor")) , mUnderwaterWeight(Fallback::Map::getFloat("Water_UnderwaterColorWeight")) , mUnderwaterIndoorFog(Fallback::Map::getFloat("Water_UnderwaterIndoorFog")) { - DLLandFogStart = Settings::Manager::getFloat("distant land fog start", "Fog"); - DLLandFogEnd = Settings::Manager::getFloat("distant land fog end", "Fog"); - DLUnderwaterFogStart = Settings::Manager::getFloat("distant underwater fog start", "Fog"); - DLUnderwaterFogEnd = Settings::Manager::getFloat("distant underwater fog end", "Fog"); - DLInteriorFogStart = Settings::Manager::getFloat("distant interior fog start", "Fog"); - DLInteriorFogEnd = Settings::Manager::getFloat("distant interior fog end", "Fog"); } void FogManager::configure(float viewDistance, const MWWorld::Cell& cell) @@ -47,13 +30,14 @@ namespace MWRender osg::Vec4f color = SceneUtil::colourFromRGB(cell.getMood().mFogColor); const float fogDensity = cell.getMood().mFogDensity; - if (mDistantFog) + if (Settings::fog().mUseDistantFog) { float density = std::max(0.2f, fogDensity); - mLandFogStart = DLInteriorFogEnd * (1.0f - density) + DLInteriorFogStart * density; - mLandFogEnd = DLInteriorFogEnd; - mUnderwaterFogStart = DLUnderwaterFogStart; - mUnderwaterFogEnd = DLUnderwaterFogEnd; + mLandFogStart = Settings::fog().mDistantInteriorFogEnd * (1.0f - density) + + Settings::fog().mDistantInteriorFogStart * density; + mLandFogEnd = Settings::fog().mDistantInteriorFogEnd; + mUnderwaterFogStart = Settings::fog().mDistantUnderwaterFogStart; + mUnderwaterFogEnd = Settings::fog().mDistantUnderwaterFogEnd; mFogColor = color; } else @@ -63,12 +47,13 @@ namespace MWRender void FogManager::configure(float viewDistance, float fogDepth, float underwaterFog, float dlFactor, float dlOffset, const osg::Vec4f& color) { - if (mDistantFog) + if (Settings::fog().mUseDistantFog) { - mLandFogStart = dlFactor * (DLLandFogStart - dlOffset * DLLandFogEnd); - mLandFogEnd = dlFactor * (1.0f - dlOffset) * DLLandFogEnd; - mUnderwaterFogStart = DLUnderwaterFogStart; - mUnderwaterFogEnd = DLUnderwaterFogEnd; + mLandFogStart + = dlFactor * (Settings::fog().mDistantLandFogStart - dlOffset * Settings::fog().mDistantLandFogEnd); + mLandFogEnd = dlFactor * (1.0f - dlOffset) * Settings::fog().mDistantLandFogEnd; + mUnderwaterFogStart = Settings::fog().mDistantUnderwaterFogStart; + mUnderwaterFogEnd = Settings::fog().mDistantUnderwaterFogEnd; } else { diff --git a/apps/openmw/mwrender/fogmanager.hpp b/apps/openmw/mwrender/fogmanager.hpp index a0a2f71047..a704f0efdc 100644 --- a/apps/openmw/mwrender/fogmanager.hpp +++ b/apps/openmw/mwrender/fogmanager.hpp @@ -29,8 +29,6 @@ namespace MWRender float mUnderwaterFogStart; float mUnderwaterFogEnd; osg::Vec4f mFogColor; - bool mDistantFog; - osg::Vec4f mUnderwaterColor; float mUnderwaterWeight; float mUnderwaterIndoorFog; diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 7d23ff9622..21cad8a51f 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -159,7 +159,7 @@ namespace MWRender : mNear(0.f) , mFar(0.f) , mWindSpeed(0.f) - , mSkyBlendingStartCoef(Settings::Manager::getFloat("sky blending start", "Fog")) + , mSkyBlendingStartCoef(Settings::fog().mSkyBlendingStart) { } @@ -306,7 +306,7 @@ namespace MWRender Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, DetourNavigator::Navigator& navigator, const MWWorld::GroundcoverStore& groundcoverStore, SceneUtil::UnrefQueue& unrefQueue) - : mSkyBlending(Settings::Manager::getBool("sky blending", "Fog")) + : mSkyBlending(Settings::fog().mSkyBlending) , mViewer(viewer) , mRootNode(rootNode) , mResourceSystem(resourceSystem) @@ -330,8 +330,7 @@ namespace MWRender resourceSystem->getSceneManager()->setParticleSystemMask(MWRender::Mask_ParticleSystem); // Shadows and radial fog have problems with fixed-function mode. - bool forceShaders = Settings::Manager::getBool("radial fog", "Fog") - || Settings::Manager::getBool("exponential fog", "Fog") + bool forceShaders = Settings::fog().mRadialFog || Settings::fog().mExponentialFog || Settings::Manager::getBool("soft particles", "Shaders") || Settings::Manager::getBool("force shaders", "Shaders") || Settings::Manager::getBool("enable shadows", "Shadows") @@ -401,8 +400,8 @@ namespace MWRender globalDefines["clamp"] = Settings::Manager::getBool("clamp lighting", "Shaders") ? "1" : "0"; globalDefines["preLightEnv"] = Settings::Manager::getBool("apply lighting to environment maps", "Shaders") ? "1" : "0"; - bool exponentialFog = Settings::Manager::getBool("exponential fog", "Fog"); - globalDefines["radialFog"] = (exponentialFog || Settings::Manager::getBool("radial fog", "Fog")) ? "1" : "0"; + const bool exponentialFog = Settings::fog().mExponentialFog; + globalDefines["radialFog"] = (exponentialFog || Settings::fog().mRadialFog) ? "1" : "0"; globalDefines["exponentialFog"] = exponentialFog ? "1" : "0"; globalDefines["skyBlending"] = mSkyBlending ? "1" : "0"; globalDefines["refraction_enabled"] = "0"; diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 27478f0571..5b8a25da17 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -279,7 +279,7 @@ namespace MWRender if (enableSkyRTT) { - mSkyRTT = new SkyRTT(Settings::Manager::getVector2("sky rtt resolution", "Fog"), mEarlyRenderBinRoot); + mSkyRTT = new SkyRTT(Settings::fog().mSkyRttResolution, mEarlyRenderBinRoot); skyroot->addChild(mSkyRTT); mRootNode = new osg::Group; skyroot->addChild(mRootNode); diff --git a/apps/openmw_test_suite/fx/technique.cpp b/apps/openmw_test_suite/fx/technique.cpp index ef0cfe948c..e59cca43cf 100644 --- a/apps/openmw_test_suite/fx/technique.cpp +++ b/apps/openmw_test_suite/fx/technique.cpp @@ -101,9 +101,6 @@ namespace })) , mImageManager(mVFS.get()) { - Settings::Manager::setBool("radial fog", "Fog", true); - Settings::Manager::setBool("exponential fog", "Fog", false); - Settings::Manager::setBool("stereo enabled", "Stereo", false); } void compile(const std::string& name) diff --git a/apps/openmw_test_suite/openmw_test_suite.cpp b/apps/openmw_test_suite/openmw_test_suite.cpp index fb5c879fc1..a2b9f1ae73 100644 --- a/apps/openmw_test_suite/openmw_test_suite.cpp +++ b/apps/openmw_test_suite/openmw_test_suite.cpp @@ -1,5 +1,11 @@ #include +#include "components/misc/strings/conversion.hpp" +#include "components/settings/parser.hpp" +#include "components/settings/values.hpp" + +#include + #ifdef WIN32 // we cannot use GTEST_API_ before main if we're building standalone exe application, // and we're linking GoogleTest / GoogleMock as DLLs and not linking gtest_main / gmock_main @@ -9,6 +15,18 @@ int main(int argc, char** argv) GTEST_API_ int main(int argc, char** argv) { #endif + const std::filesystem::path settingsDefaultPath = std::filesystem::path{ OPENMW_PROJECT_SOURCE_DIR } / "files" + / Misc::StringUtils::stringToU8String("settings-default.cfg"); + + Settings::SettingsFileParser parser; + parser.loadSettingsFile(settingsDefaultPath, Settings::Manager::mDefaultSettings); + + Settings::StaticValues::initDefaults(); + + Settings::Manager::mUserSettings = Settings::Manager::mDefaultSettings; + + Settings::StaticValues::init(); + testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/components/fx/pass.cpp b/components/fx/pass.cpp index 7cd54f8dbc..7a7329d755 100644 --- a/components/fx/pass.cpp +++ b/components/fx/pass.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "stateupdater.hpp" @@ -261,8 +262,8 @@ float omw_EstimateFogCoverageFromUV(vec2 uv) { "@uboStruct", StateUpdater::getStructDefinition() }, { "@ubo", mUBO ? "1" : "0" }, { "@normals", technique.getNormals() ? "1" : "0" }, { "@reverseZ", SceneUtil::AutoDepth::isReversed() ? "1" : "0" }, - { "@radialFog", Settings::Manager::getBool("radial fog", "Fog") ? "1" : "0" }, - { "@exponentialFog", Settings::Manager::getBool("exponential fog", "Fog") ? "1" : "0" }, + { "@radialFog", Settings::fog().mRadialFog ? "1" : "0" }, + { "@exponentialFog", Settings::fog().mExponentialFog ? "1" : "0" }, { "@hdr", technique.getHDR() ? "1" : "0" }, { "@in", mLegacyGLSL ? "varying" : "in" }, { "@out", mLegacyGLSL ? "varying" : "out" }, { "@position", "gl_Position" }, { "@texture1D", mLegacyGLSL ? "texture1D" : "texture" },