Merge branch 'settings_values_water' into 'master'

Use settings values for Water settings (#6876)

See merge request OpenMW/openmw!3500
macos_ci_fix
psi29a 1 year ago
commit 18d28ca475

@ -380,7 +380,7 @@ namespace MWGui
const std::string& tmip = Settings::general().mTextureMipmap; const std::string& tmip = Settings::general().mTextureMipmap;
mTextureFilteringButton->setCaptionWithReplacing(textureMipmappingToStr(tmip)); mTextureFilteringButton->setCaptionWithReplacing(textureMipmappingToStr(tmip));
int waterTextureSize = Settings::Manager::getInt("rtt size", "Water"); int waterTextureSize = Settings::water().mRttSize;
if (waterTextureSize >= 512) if (waterTextureSize >= 512)
mWaterTextureSize->setIndexSelected(0); mWaterTextureSize->setIndexSelected(0);
if (waterTextureSize >= 1024) if (waterTextureSize >= 1024)
@ -388,10 +388,10 @@ namespace MWGui
if (waterTextureSize >= 2048) if (waterTextureSize >= 2048)
mWaterTextureSize->setIndexSelected(2); mWaterTextureSize->setIndexSelected(2);
int waterReflectionDetail = std::clamp(Settings::Manager::getInt("reflection detail", "Water"), 0, 5); const int waterReflectionDetail = Settings::water().mReflectionDetail;
mWaterReflectionDetail->setIndexSelected(waterReflectionDetail); 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); mWaterRainRippleDetail->setIndexSelected(waterRainRippleDetail);
updateMaxLightsComboBox(mMaxLights); updateMaxLightsComboBox(mMaxLights);
@ -531,21 +531,19 @@ namespace MWGui
size = 1024; size = 1024;
else if (pos == 2) else if (pos == 2)
size = 2048; size = 2048;
Settings::Manager::setInt("rtt size", "Water", size); Settings::water().mRttSize.set(size);
apply(); apply();
} }
void SettingsWindow::onWaterReflectionDetailChanged(MyGUI::ComboBox* _sender, size_t pos) void SettingsWindow::onWaterReflectionDetailChanged(MyGUI::ComboBox* _sender, size_t pos)
{ {
unsigned int level = static_cast<unsigned int>(std::min<size_t>(pos, 5)); Settings::water().mReflectionDetail.set(static_cast<int>(pos));
Settings::Manager::setInt("reflection detail", "Water", level);
apply(); apply();
} }
void SettingsWindow::onWaterRainRippleDetailChanged(MyGUI::ComboBox* _sender, size_t pos) void SettingsWindow::onWaterRainRippleDetailChanged(MyGUI::ComboBox* _sender, size_t pos)
{ {
unsigned int level = static_cast<unsigned int>(std::min<size_t>(pos, 2)); Settings::water().mRainRippleDetail.set(static_cast<int>(pos));
Settings::Manager::setInt("rain ripple detail", "Water", level);
apply(); apply();
} }

@ -247,8 +247,7 @@ namespace MWRender
void setDefaults(osg::Camera* camera) override void setDefaults(osg::Camera* camera) override
{ {
camera->setReferenceFrame(osg::Camera::RELATIVE_RF); camera->setReferenceFrame(osg::Camera::RELATIVE_RF);
camera->setSmallFeatureCullingPixelSize( camera->setSmallFeatureCullingPixelSize(Settings::water().mSmallFeatureCullingPixelSize);
Settings::Manager::getInt("small feature culling pixel size", "Water"));
camera->setName("RefractionCamera"); camera->setName("RefractionCamera");
camera->addCullCallback(new InheritViewPointCallback); camera->addCullCallback(new InheritViewPointCallback);
camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
@ -265,7 +264,7 @@ namespace MWRender
camera->addChild(mClipCullNode); camera->addChild(mClipCullNode);
camera->setNodeMask(Mask_RenderToTexture); 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()); SceneUtil::ShadowManager::disableShadowsForStateSet(camera->getOrCreateStateSet());
} }
@ -285,8 +284,7 @@ namespace MWRender
void setWaterLevel(float waterLevel) void setWaterLevel(float waterLevel)
{ {
const float refractionScale const float refractionScale = Settings::water().mRefractionScale;
= std::clamp(Settings::Manager::getFloat("refraction scale", "Water"), 0.f, 1.f);
mViewMatrix = osg::Matrix::scale(1, 1, refractionScale) mViewMatrix = osg::Matrix::scale(1, 1, refractionScale)
* osg::Matrix::translate(0, 0, (1.0 - refractionScale) * waterLevel); * osg::Matrix::translate(0, 0, (1.0 - refractionScale) * waterLevel);
@ -328,8 +326,7 @@ namespace MWRender
void setDefaults(osg::Camera* camera) override void setDefaults(osg::Camera* camera) override
{ {
camera->setReferenceFrame(osg::Camera::RELATIVE_RF); camera->setReferenceFrame(osg::Camera::RELATIVE_RF);
camera->setSmallFeatureCullingPixelSize( camera->setSmallFeatureCullingPixelSize(Settings::water().mSmallFeatureCullingPixelSize);
Settings::Manager::getInt("small feature culling pixel size", "Water"));
camera->setName("ReflectionCamera"); camera->setName("ReflectionCamera");
camera->addCullCallback(new InheritViewPointCallback); camera->addCullCallback(new InheritViewPointCallback);
@ -384,7 +381,7 @@ namespace MWRender
private: private:
unsigned int calcNodeMask() unsigned int calcNodeMask()
{ {
int reflectionDetail = Settings::Manager::getInt("reflection detail", "Water"); int reflectionDetail = Settings::water().mReflectionDetail;
reflectionDetail = std::clamp(reflectionDetail, mInterior ? 2 : 0, 5); reflectionDetail = std::clamp(reflectionDetail, mInterior ? 2 : 0, 5);
unsigned int extraMask = 0; unsigned int extraMask = 0;
if (reflectionDetail >= 1) if (reflectionDetail >= 1)
@ -525,9 +522,9 @@ namespace MWRender
mWaterGeom->setStateSet(nullptr); mWaterGeom->setStateSet(nullptr);
mWaterGeom->setUpdateCallback(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 = new Reflection(rttSize, mInterior);
mReflection->setWaterLevel(mTop); mReflection->setWaterLevel(mTop);
@ -536,7 +533,7 @@ namespace MWRender
mReflection->addCullCallback(mCullCallback); mReflection->addCullCallback(mCullCallback);
mParent->addChild(mReflection); mParent->addChild(mReflection);
if (Settings::Manager::getBool("refraction", "Water")) if (Settings::water().mRefraction)
{ {
mRefraction = new Refraction(rttSize); mRefraction = new Refraction(rttSize);
mRefraction->setWaterLevel(mTop); mRefraction->setWaterLevel(mTop);
@ -693,7 +690,7 @@ namespace MWRender
// use a define map to conditionally compile the shader // use a define map to conditionally compile the shader
std::map<std::string, std::string> defineMap; std::map<std::string, std::string> defineMap;
defineMap["refraction_enabled"] = std::string(mRefraction ? "1" : "0"); 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["rain_ripple_detail"] = std::to_string(rippleDetail);
defineMap["ripple_map_world_scale"] = std::to_string(RipplesSurface::mWorldScaleFactor); defineMap["ripple_map_world_scale"] = std::to_string(RipplesSurface::mWorldScaleFactor);
defineMap["ripple_map_size"] = std::to_string(RipplesSurface::mRTTSize) + ".0"; defineMap["ripple_map_size"] = std::to_string(RipplesSurface::mRTTSize) + ".0";

@ -21,9 +21,8 @@ namespace Settings
SettingValue<bool> mShader{ mIndex, "Water", "shader" }; SettingValue<bool> mShader{ mIndex, "Water", "shader" };
SettingValue<int> mRttSize{ mIndex, "Water", "rtt size", makeMaxSanitizerInt(1) }; SettingValue<int> mRttSize{ mIndex, "Water", "rtt size", makeMaxSanitizerInt(1) };
SettingValue<bool> mRefraction{ mIndex, "Water", "refraction" }; SettingValue<bool> mRefraction{ mIndex, "Water", "refraction" };
SettingValue<int> mReflectionDetail{ mIndex, "Water", "reflection detail", SettingValue<int> mReflectionDetail{ mIndex, "Water", "reflection detail", makeClampSanitizerInt(0, 5) };
makeEnumSanitizerInt({ 0, 1, 2, 3, 4, 5 }) }; SettingValue<int> mRainRippleDetail{ mIndex, "Water", "rain ripple detail", makeClampSanitizerInt(0, 2) };
SettingValue<int> mRainRippleDetail{ mIndex, "Water", "rain ripple detail", makeEnumSanitizerInt({ 0, 1, 2 }) };
SettingValue<float> mSmallFeatureCullingPixelSize{ mIndex, "Water", "small feature culling pixel size", SettingValue<float> mSmallFeatureCullingPixelSize{ mIndex, "Water", "small feature culling pixel size",
makeMaxStrictSanitizerFloat(0) }; makeMaxStrictSanitizerFloat(0) };
SettingValue<float> mRefractionScale{ mIndex, "Water", "refraction scale", makeClampSanitizerFloat(0, 1) }; SettingValue<float> mRefractionScale{ mIndex, "Water", "refraction scale", makeClampSanitizerFloat(0, 1) };

Loading…
Cancel
Save