Use settings values for Water settings

macos_ci_fix
elsid 1 year ago
parent febfa353e0
commit 7ac402390a
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -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<unsigned int>(std::min<size_t>(pos, 5));
Settings::Manager::setInt("reflection detail", "Water", level);
Settings::water().mReflectionDetail.set(static_cast<int>(pos));
apply();
}
void SettingsWindow::onWaterRainRippleDetailChanged(MyGUI::ComboBox* _sender, size_t pos)
{
unsigned int level = static_cast<unsigned int>(std::min<size_t>(pos, 2));
Settings::Manager::setInt("rain ripple detail", "Water", level);
Settings::water().mRainRippleDetail.set(static_cast<int>(pos));
apply();
}

@ -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<std::string, std::string> 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";

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

Loading…
Cancel
Save