diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index ac25b5984a..2c405dcbd3 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -380,7 +380,7 @@ namespace MWGui const std::string& tmip = Settings::general().mTextureMipmap; mTextureFilteringButton->setCaptionWithReplacing(textureMipmappingToStr(tmip)); - int waterTextureSize = Settings::Manager::getInt("rtt size", "Water"); + int waterTextureSize = Settings::water().mRttSize; if (waterTextureSize >= 512) mWaterTextureSize->setIndexSelected(0); if (waterTextureSize >= 1024) @@ -388,10 +388,10 @@ namespace MWGui if (waterTextureSize >= 2048) mWaterTextureSize->setIndexSelected(2); - int waterReflectionDetail = std::clamp(Settings::Manager::getInt("reflection detail", "Water"), 0, 5); + const int waterReflectionDetail = Settings::water().mReflectionDetail; mWaterReflectionDetail->setIndexSelected(waterReflectionDetail); - int waterRainRippleDetail = std::clamp(Settings::Manager::getInt("rain ripple detail", "Water"), 0, 2); + const int waterRainRippleDetail = Settings::water().mRainRippleDetail; mWaterRainRippleDetail->setIndexSelected(waterRainRippleDetail); updateMaxLightsComboBox(mMaxLights); @@ -531,21 +531,19 @@ namespace MWGui size = 1024; else if (pos == 2) size = 2048; - Settings::Manager::setInt("rtt size", "Water", size); + Settings::water().mRttSize.set(size); apply(); } void SettingsWindow::onWaterReflectionDetailChanged(MyGUI::ComboBox* _sender, size_t pos) { - unsigned int level = static_cast(std::min(pos, 5)); - Settings::Manager::setInt("reflection detail", "Water", level); + Settings::water().mReflectionDetail.set(static_cast(pos)); apply(); } void SettingsWindow::onWaterRainRippleDetailChanged(MyGUI::ComboBox* _sender, size_t pos) { - unsigned int level = static_cast(std::min(pos, 2)); - Settings::Manager::setInt("rain ripple detail", "Water", level); + Settings::water().mRainRippleDetail.set(static_cast(pos)); apply(); } diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index f823378e46..091ab99821 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -247,8 +247,7 @@ namespace MWRender void setDefaults(osg::Camera* camera) override { camera->setReferenceFrame(osg::Camera::RELATIVE_RF); - camera->setSmallFeatureCullingPixelSize( - Settings::Manager::getInt("small feature culling pixel size", "Water")); + camera->setSmallFeatureCullingPixelSize(Settings::water().mSmallFeatureCullingPixelSize); camera->setName("RefractionCamera"); camera->addCullCallback(new InheritViewPointCallback); camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); @@ -265,7 +264,7 @@ namespace MWRender camera->addChild(mClipCullNode); camera->setNodeMask(Mask_RenderToTexture); - if (Settings::Manager::getFloat("refraction scale", "Water") != 1) // TODO: to be removed with issue #5709 + if (Settings::water().mRefractionScale != 1) // TODO: to be removed with issue #5709 SceneUtil::ShadowManager::disableShadowsForStateSet(camera->getOrCreateStateSet()); } @@ -285,8 +284,7 @@ namespace MWRender void setWaterLevel(float waterLevel) { - const float refractionScale - = std::clamp(Settings::Manager::getFloat("refraction scale", "Water"), 0.f, 1.f); + const float refractionScale = Settings::water().mRefractionScale; mViewMatrix = osg::Matrix::scale(1, 1, refractionScale) * osg::Matrix::translate(0, 0, (1.0 - refractionScale) * waterLevel); @@ -328,8 +326,7 @@ namespace MWRender void setDefaults(osg::Camera* camera) override { camera->setReferenceFrame(osg::Camera::RELATIVE_RF); - camera->setSmallFeatureCullingPixelSize( - Settings::Manager::getInt("small feature culling pixel size", "Water")); + camera->setSmallFeatureCullingPixelSize(Settings::water().mSmallFeatureCullingPixelSize); camera->setName("ReflectionCamera"); camera->addCullCallback(new InheritViewPointCallback); @@ -384,7 +381,7 @@ namespace MWRender private: unsigned int calcNodeMask() { - int reflectionDetail = Settings::Manager::getInt("reflection detail", "Water"); + int reflectionDetail = Settings::water().mReflectionDetail; reflectionDetail = std::clamp(reflectionDetail, mInterior ? 2 : 0, 5); unsigned int extraMask = 0; if (reflectionDetail >= 1) @@ -525,9 +522,9 @@ namespace MWRender mWaterGeom->setStateSet(nullptr); mWaterGeom->setUpdateCallback(nullptr); - if (Settings::Manager::getBool("shader", "Water")) + if (Settings::water().mShader) { - unsigned int rttSize = Settings::Manager::getInt("rtt size", "Water"); + const unsigned int rttSize = Settings::water().mRttSize; mReflection = new Reflection(rttSize, mInterior); mReflection->setWaterLevel(mTop); @@ -536,7 +533,7 @@ namespace MWRender mReflection->addCullCallback(mCullCallback); mParent->addChild(mReflection); - if (Settings::Manager::getBool("refraction", "Water")) + if (Settings::water().mRefraction) { mRefraction = new Refraction(rttSize); mRefraction->setWaterLevel(mTop); @@ -693,7 +690,7 @@ namespace MWRender // use a define map to conditionally compile the shader std::map defineMap; defineMap["refraction_enabled"] = std::string(mRefraction ? "1" : "0"); - const auto rippleDetail = std::clamp(Settings::Manager::getInt("rain ripple detail", "Water"), 0, 2); + const int rippleDetail = Settings::water().mRainRippleDetail; defineMap["rain_ripple_detail"] = std::to_string(rippleDetail); defineMap["ripple_map_world_scale"] = std::to_string(RipplesSurface::mWorldScaleFactor); defineMap["ripple_map_size"] = std::to_string(RipplesSurface::mRTTSize) + ".0"; diff --git a/components/settings/categories/water.hpp b/components/settings/categories/water.hpp index 02b5f0c5dd..b88d38b023 100644 --- a/components/settings/categories/water.hpp +++ b/components/settings/categories/water.hpp @@ -21,9 +21,8 @@ namespace Settings SettingValue mShader{ mIndex, "Water", "shader" }; SettingValue mRttSize{ mIndex, "Water", "rtt size", makeMaxSanitizerInt(1) }; SettingValue mRefraction{ mIndex, "Water", "refraction" }; - SettingValue mReflectionDetail{ mIndex, "Water", "reflection detail", - makeEnumSanitizerInt({ 0, 1, 2, 3, 4, 5 }) }; - SettingValue mRainRippleDetail{ mIndex, "Water", "rain ripple detail", makeEnumSanitizerInt({ 0, 1, 2 }) }; + SettingValue mReflectionDetail{ mIndex, "Water", "reflection detail", makeClampSanitizerInt(0, 5) }; + SettingValue mRainRippleDetail{ mIndex, "Water", "rain ripple detail", makeClampSanitizerInt(0, 2) }; SettingValue mSmallFeatureCullingPixelSize{ mIndex, "Water", "small feature culling pixel size", makeMaxStrictSanitizerFloat(0) }; SettingValue mRefractionScale{ mIndex, "Water", "refraction scale", makeClampSanitizerFloat(0, 1) };