From cdfd66eec27355930a50309273961ad4bc7e4606 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 5 Apr 2011 22:58:53 -0700 Subject: STORM-610 : Changes to water color and density in the Environment Editor now persist between sessions. --- indra/newview/app_settings/settings.xml | 27 +++++++++++++++++++++++++++ indra/newview/llwaterparammanager.cpp | 28 ++++++++++++++++++++++++++++ indra/newview/llwaterparammanager.h | 6 ++++++ 3 files changed, 61 insertions(+) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 3048f8d492..3d89d294f2 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11926,6 +11926,33 @@ Value 0 + WaterFogColor + + Comment + Water fog color + Persist + 1 + Type + Color4 + Value + + 22 + 43 + 54 + 0 + + + WaterFogDensity + + Comment + Water fog density + Persist + 1 + Type + F32 + Value + 16.0 + WaterGLFogDensityScale Comment diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index d239347810..3d3d43e20d 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -72,6 +72,7 @@ LLWaterParamManager::LLWaterParamManager() : mWave1Dir(.5f, .5f, "wave1Dir"), mWave2Dir(.5f, .5f, "wave2Dir"), mDensitySliderValue(1.0f), + mPrevFogDensity(16.0f), // 2^4 mWaterFogKS(1.0f) { } @@ -265,6 +266,20 @@ void LLWaterParamManager::update(LLViewerCamera * cam) // update the shaders and the menu propagateParameters(); + // If water fog color has been changed, save it. + if (mPrevFogColor != mFogColor) + { + gSavedSettings.setColor4("WaterFogColor", mFogColor); + mPrevFogColor = mFogColor; + } + + // If water fog density has been changed, save it. + if (mPrevFogDensity != mFogDensity) + { + gSavedSettings.setF32("WaterFogDensity", mFogDensity); + mPrevFogDensity = mFogDensity; + } + // sync menus if they exist LLFloaterWater* waterfloater = LLFloaterReg::findTypedInstance("env_water"); if(waterfloater) @@ -449,7 +464,20 @@ LLWaterParamManager * LLWaterParamManager::instance() sInstance->loadAllPresets(LLStringUtil::null); sInstance->getParamSet("Default", sInstance->mCurParams); + sInstance->initOverrides(); } return sInstance; } + +void LLWaterParamManager::initOverrides() +{ + // Override fog color from the current preset with the saved setting. + LLColor4 fog_color_override = gSavedSettings.getColor4("WaterFogColor"); + mCurParams.set("waterFogColor", mPrevFogColor = mFogColor = fog_color_override); + + // Do the same with fog density. + F32 fog_density = gSavedSettings.getF32("WaterFogDensity"); + mCurParams.set("waterFogDensity", mPrevFogDensity = mFogDensity = fog_density); + setDensitySliderValue(mFogDensity.mExp); +} diff --git a/indra/newview/llwaterparammanager.h b/indra/newview/llwaterparammanager.h index c479f1861c..f465034c39 100644 --- a/indra/newview/llwaterparammanager.h +++ b/indra/newview/llwaterparammanager.h @@ -284,6 +284,9 @@ public: // singleton pattern implementation static LLWaterParamManager * instance(); +private: + void initOverrides(); + public: LLWaterParamSet mCurParams; @@ -314,6 +317,9 @@ private: LLVector4 mWaterPlane; F32 mWaterFogKS; + LLColor4 mPrevFogColor; + F32 mPrevFogDensity; + // our parameter manager singleton instance static LLWaterParamManager * sInstance; }; -- cgit v1.2.3