diff options
| author | Rider Linden <rider@lindenlab.com> | 2017-10-13 17:17:49 -0700 | 
|---|---|---|
| committer | Rider Linden <rider@lindenlab.com> | 2017-10-13 17:17:49 -0700 | 
| commit | cc22ffc6d799544e8f2a9dfed6813081d908c88d (patch) | |
| tree | 0b02af15c41104fb253cd7a9e705fa1f3f9fd829 /indra/newview | |
| parent | e4b035d0cd3eaa76fd82643c17e3631c67387a54 (diff) | |
Watter settings active and start of new joystick button type.
Diffstat (limited to 'indra/newview')
25 files changed, 1401 insertions, 445 deletions
| diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index d8d1c0b51e..b46e0971e2 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -537,6 +537,7 @@ set(viewer_SOURCE_FILES      llselectmgr.cpp      llsettingsbase.cpp      llsettingssky.cpp +    llsettingswater.cpp      llshareavatarhandler.cpp      llsidepanelappearance.cpp      llsidepanelinventory.cpp @@ -1153,6 +1154,7 @@ set(viewer_HEADER_FILES      llselectmgr.h      llsettingsbase.h      llsettingssky.h +    llsettingswater.h      llsidepanelappearance.h      llsidepanelinventory.h      llsidepanelinventorysubpanel.h diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 529bd429a4..3794c19bb1 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -170,7 +170,6 @@  #include "llviewerparcelmgr.h"  #include "llworldmapview.h"  #include "llpostprocess.h" -#include "llwaterparammanager.h"  #include "lldebugview.h"  #include "llconsole.h" diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index df06ad31e6..567172e647 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -46,7 +46,9 @@  #include "llworld.h"  #include "pipeline.h"  #include "llviewershadermgr.h" -#include "llwaterparammanager.h" +#include "llenvironment.h" +#include "llsettingssky.h" +#include "llsettingswater.h"  const LLUUID TRANSPARENT_WATER_TEXTURE("2bfd3884-7e27-69b9-ba3a-3e673f680004");  const LLUUID OPAQUE_WATER_TEXTURE("43c32285-d658-1793-c123-bf86315de055"); @@ -58,10 +60,10 @@ BOOL deferred_render = FALSE;  BOOL LLDrawPoolWater::sSkipScreenCopy = FALSE;  BOOL LLDrawPoolWater::sNeedsReflectionUpdate = TRUE;  BOOL LLDrawPoolWater::sNeedsDistortionUpdate = TRUE; -LLColor4 LLDrawPoolWater::sWaterFogColor = LLColor4(0.2f, 0.5f, 0.5f, 0.f); +//LLColor4 LLDrawPoolWater::sWaterFogColor = LLColor4(0.2f, 0.5f, 0.5f, 0.f);  F32 LLDrawPoolWater::sWaterFogEnd = 0.f; -LLVector3 LLDrawPoolWater::sLightDir; +//LLVector3 LLDrawPoolWater::sLightDir;  LLDrawPoolWater::LLDrawPoolWater() :  	LLFacePool(POOL_WATER) @@ -110,8 +112,6 @@ void LLDrawPoolWater::prerender()  	// got rid of modulation by light color since it got a little too  	// green at sunset and sl-57047 (underwater turns black at 8:00) -	sWaterFogColor = LLWaterParamManager::instance().getFogColor(); -	sWaterFogColor.mV[3] = 0;  } @@ -488,29 +488,50 @@ void LLDrawPoolWater::shade()  	LLVector3 light_dir;  	LLColor3 light_color; -	if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) 	  -    { 	  -        light_dir  = gSky.getSunDirection(); 	  -        light_dir.normVec(); 	 -		light_color = gSky.getSunDiffuseColor(); -		if(gSky.mVOSkyp) { -	        light_diffuse = gSky.mVOSkyp->getSun().getColorCached(); 	  -			light_diffuse.normVec(); 	  -		} -        light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); 	  -        light_diffuse *= light_exp + 0.25f; 	  -    } 	  -    else  	  -    { 	  -        light_dir       = gSky.getMoonDirection(); 	  -        light_dir.normVec(); 	  -		light_color = gSky.getMoonDiffuseColor(); -        light_diffuse   = gSky.mVOSkyp->getMoon().getColorCached(); 	  -        light_diffuse.normVec(); 	  -        light_diffuse *= 0.5f; 	  -        light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); 	  +    LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); +    LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + +    light_dir = psky->getLightDirection(); +    if (LLEnvironment::instance().getIsDayTime()) +    { +        light_color = psky->getSunAmbient(); +        light_diffuse = psky->getSunDiffuse();  +        light_diffuse.normalize(); +        light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f); +        light_diffuse *= (light_exp + 0.25f); +    } +    else +    { +        light_color = psky->getMoonAmbient(); +        light_diffuse = psky->getMoonDiffuse(); +        light_diffuse.normalize(); +        light_diffuse *= 0.5f; +        light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f);      } +// 	if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) 	  +//     { 	  +//         light_dir  = gSky.getSunDirection(); 	  +//         light_dir.normVec(); 	 +// 		light_color = gSky.getSunDiffuseColor(); +// 		if(gSky.mVOSkyp) { +// 	        light_diffuse = gSky.mVOSkyp->getSun().getColorCached(); 	  +// 			light_diffuse.normVec(); 	  +// 		} +//         light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); 	  +//         light_diffuse *= light_exp + 0.25f; 	  +//     } 	  +//     else  	  +//     { 	  +//         light_dir       = gSky.getMoonDirection(); 	  +//         light_dir.normVec(); 	  +// 		light_color = gSky.getMoonDiffuseColor(); +//         light_diffuse   = gSky.mVOSkyp->getMoon().getColorCached(); 	  +//         light_diffuse.normVec(); 	  +//         light_diffuse *= 0.5f; 	  +//         light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); 	  +//     } +  	light_exp *= light_exp;  	light_exp *= light_exp;  	light_exp *= light_exp; @@ -518,9 +539,11 @@ void LLDrawPoolWater::shade()  	light_exp *= 256.f;  	light_exp = light_exp > 32.f ? light_exp : 32.f; +    light_diffuse *= 6.f; +  	LLGLSLShader* shader; -	F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight(); +	F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - LLEnvironment::instance().getWaterHeight();  	if (eyedepth < 0.f && LLPipeline::sWaterReflections)  	{ @@ -551,7 +574,7 @@ void LLDrawPoolWater::shade()  		shader->bind();  	} -	sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f; +	sTime = (F32)LLFrameTimer::getElapsedSeconds() * 0.5f;  	S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX); @@ -565,12 +588,10 @@ void LLDrawPoolWater::shade()  	//bind normal map  	S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP); -	LLWaterParamManager * param_mgr = &LLWaterParamManager::instance(); -  	// change mWaterNormp if needed -	if (mWaterNormp->getID() != param_mgr->getNormalMapID()) +	if (mWaterNormp->getID() != pwater->getNormalMapID())  	{ -		mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID()); +		mWaterNormp = LLViewerTextureManager::getFetchedTexture(pwater->getNormalMapID());  	}  	mWaterNormp->addTextureStats(1024.f*1024.f); @@ -588,9 +609,8 @@ void LLDrawPoolWater::shade()  	if (screentex > -1)  	{ -		shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); -		shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY,  -			param_mgr->getFogDensity()); +		shader->uniform3fv(LLShaderMgr::WATER_FOGCOLOR, 1, pwater->getFogColor().mV); +        shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, pwater->getFogDensity());  		gPipeline.mWaterDis.bindTexture(0, screentex);  	} @@ -600,8 +620,9 @@ void LLDrawPoolWater::shade()  	if (mVertexShaderLevel == 1)  	{ -		sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue; -		shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV); +        LLColor4 fog_color(pwater->getFogColor(), 0.f); +        fog_color[3] = pwater->getFogDensity(); +        shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, fog_color.mV);  	}  	F32 screenRes[] =  @@ -615,25 +636,20 @@ void LLDrawPoolWater::shade()  	S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP);  	stop_glerror(); -	light_dir.normVec(); -	sLightDir = light_dir; -	 -	light_diffuse *= 6.f; -  	//shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix);  	shader->uniform1f(LLShaderMgr::WATER_WATERHEIGHT, eyedepth);  	shader->uniform1f(LLShaderMgr::WATER_TIME, sTime);  	shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV);  	shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV);  	shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp); -	shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV); -	shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV); +	shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, pwater->getWave1Dir().mV); +	shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, pwater->getWave2Dir().mV);  	shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV); -	shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, param_mgr->getNormalScale().mV); -	shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, param_mgr->getFresnelScale()); -	shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, param_mgr->getFresnelOffset()); -	shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, param_mgr->getBlurMultiplier()); +	shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, pwater->getNormalScale().mV); +	shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, pwater->getFresnelScale()); +	shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, pwater->getFresnelOffset()); +    shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, pwater->getBlurMultiplier());  	F32 sunAngle = llmax(0.f, light_dir.mV[2]);  	F32 scaledAngle = 1.f - sunAngle; @@ -648,12 +664,12 @@ void LLDrawPoolWater::shade()  	if (LLViewerCamera::getInstance()->cameraUnderWater())  	{  		water_color.setVec(1.f, 1.f, 1.f, 0.4f); -		shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow()); +		shader->uniform1f(LLShaderMgr::WATER_REFSCALE, pwater->getScaleBelow());  	}  	else  	{  		water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); -		shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove()); +		shader->uniform1f(LLShaderMgr::WATER_REFSCALE, pwater->getScaleAbove());  	}  	if (water_color.mV[3] > 0.9f) diff --git a/indra/newview/lldrawpoolwater.h b/indra/newview/lldrawpoolwater.h index aeeba179d6..55f892d249 100644 --- a/indra/newview/lldrawpoolwater.h +++ b/indra/newview/lldrawpoolwater.h @@ -46,9 +46,8 @@ public:  	static BOOL sSkipScreenCopy;  	static BOOL sNeedsReflectionUpdate;  	static BOOL sNeedsDistortionUpdate; -	static LLVector3 sLightDir; - -	static LLColor4 sWaterFogColor; +// 	static LLVector3 sLightDir; +//	static LLColor4 sWaterFogColor;  	static F32 sWaterFogEnd;  	enum diff --git a/indra/newview/llenvadapters.cpp b/indra/newview/llenvadapters.cpp index 8bed0737dd..34fd862655 100644 --- a/indra/newview/llenvadapters.cpp +++ b/indra/newview/llenvadapters.cpp @@ -28,6 +28,7 @@  #include "llenvadapters.h"  #include "llsettingssky.h" +#include "llsettingswater.h"  //=========================================================================  LLSkySettingsAdapter::LLSkySettingsAdapter(): @@ -53,3 +54,20 @@ LLSkySettingsAdapter::LLSkySettingsAdapter():  {  } + +LLWatterSettingsAdapter::LLWatterSettingsAdapter(): +    mFogColor(LLColor4((22.f / 255.f), (43.f / 255.f), (54.f / 255.f), (0.0f)), LLSettingsWater::SETTING_FOG_COLOR, "WaterFogColor"), +    mFogDensity(4, LLSettingsWater::SETTING_FOG_DENSITY, 2), +    mUnderWaterFogMod(0.25, LLSettingsWater::SETTING_FOG_MOD), +    mNormalScale(LLVector3(2.f, 2.f, 2.f), LLSettingsWater::SETTING_NORMAL_SCALE), +    mFresnelScale(0.5f, LLSettingsWater::SETTING_FRESNEL_SCALE), +    mFresnelOffset(0.4f, LLSettingsWater::SETTING_FRESNEL_OFFSET), +    mScaleAbove(0.025f, LLSettingsWater::SETTING_SCALE_ABOVE), +    mScaleBelow(0.2f, LLSettingsWater::SETTING_SCALE_BELOW), +    mBlurMultiplier(0.1f, LLSettingsWater::SETTING_BLUR_MULTIPILER), +    mWave1Dir(LLVector2(0.5f, 0.5f), LLSettingsWater::SETTING_WAVE1_DIR), +    mWave2Dir(LLVector2(0.5f, 0.5f), LLSettingsWater::SETTING_WAVE2_DIR) + +{ + +} diff --git a/indra/newview/llenvadapters.h b/indra/newview/llenvadapters.h index fc7a47be1b..3241e43191 100644 --- a/indra/newview/llenvadapters.h +++ b/indra/newview/llenvadapters.h @@ -185,6 +185,169 @@ private:      F32 mult;  }; +class WLXFloatControl +{ +public: +    inline WLXFloatControl(F32 val, const std::string& n, F32 b):  +        mExp(val), +        mBase(b), +        mName(n) +    { +    } + +    inline WLXFloatControl & operator = (F32 val) +    { +        mExp = log(val) / log(mBase); + +        return *this; +    } + +    inline operator F32 (void) const +    { +        return pow(mBase, mExp); +    } + +    inline void update(const LLSettingsBase::ptr_t &psetting) const +    { +        psetting->setValue(mName, pow(mBase, mExp)); +    } + +    inline F32 getExp() const +    { +        return mExp; +    } + +    inline void setExp(F32 val) +    { +        mExp = val; +    } + +    inline F32 getBase() const +    { +        return mBase; +    } + +    inline void setBase(F32 val) +    { +        mBase = val; +    } + +private: +    F32 mExp; +    F32 mBase; +    std::string mName; +}; + +class WLVect2Control +{ +public: +    inline WLVect2Control(LLVector2 val, const std::string& n):  +        mU(val.mV[0]),  +        mV(val.mV[1]),  +        mName(n) +    { +    } + +    inline WLVect2Control & operator = (const LLVector2 & val) +    { +        mU = val.mV[0]; +        mV = val.mV[1]; + +        return *this; +    } + +    inline void update(const LLSettingsBase::ptr_t &psetting) const +    { +        psetting->setValue(mName, LLVector2(mU, mV)); +    } + +    inline F32 getU() const +    { +        return mU; +    } + +    inline void setU(F32 val) +    { +        mU = val; +    } + +    inline F32 getV() const +    { +        return mV; +    } + +    inline void setV(F32 val) +    { +        mV = val; +    } + +private: +    F32 mU; +    F32 mV; +    std::string mName; +}; + +class WLVect3Control +{ +public: +    inline WLVect3Control(LLVector3 val, const std::string& n): +        mX(val.mV[0]), +        mY(val.mV[1]), +        mZ(val.mV[2]), +        mName(n) +    { +    } + +    inline WLVect3Control & operator = (const LLVector3 & val) +    { +        mX = val.mV[0]; +        mY = val.mV[1]; +        mZ = val.mV[2]; + +        return *this; +    } + +    inline void update(const LLSettingsBase::ptr_t &psetting) const +    { +        psetting->setValue(mName, LLVector3(mX, mY, mZ)); +    } + +    inline F32 getX() const +    { +        return mX; +    } + +    inline void setX(F32 val) +    { +        mX = val; +    } + +    inline F32 getY() const +    { +        return mY; +    } + +    inline void setY(F32 val) +    { +        mY = val; +    } + +    inline F32 getZ() const +    { +        return mZ; +    } + +    inline void setZ(F32 val) +    { +        mZ = val; +    } + +private: +    F32 mX; +    F32 mY; +    F32 mZ; +    std::string mName; +};  //-------------------------------------------------------------------------  class LLSkySettingsAdapter @@ -194,32 +357,54 @@ public:      LLSkySettingsAdapter(); -    WLFloatControl mWLGamma; +    WLFloatControl  mWLGamma;      /// Atmospherics -    WLColorControl mBlueHorizon; -    WLFloatControl mHazeDensity; -    WLColorControl mBlueDensity; -    WLFloatControl mDensityMult; -    WLFloatControl mHazeHorizon; -    WLFloatControl mMaxAlt; +    WLColorControl  mBlueHorizon; +    WLFloatControl  mHazeDensity; +    WLColorControl  mBlueDensity; +    WLFloatControl  mDensityMult; +    WLFloatControl  mHazeHorizon; +    WLFloatControl  mMaxAlt;      /// Lighting -    WLColorControl mLightnorm; -    WLColorControl mSunlight; -    WLColorControl mAmbient; -    WLColorControl mGlow; +    WLColorControl  mLightnorm; +    WLColorControl  mSunlight; +    WLColorControl  mAmbient; +    WLColorControl  mGlow;      /// Clouds -    WLColorControl mCloudColor; -    WLColorControl mCloudMain; -    WLFloatControl mCloudCoverage; -    WLColorControl mCloudDetail; -    WLFloatControl mDistanceMult; -    WLFloatControl mCloudScale; +    WLColorControl  mCloudColor; +    WLColorControl  mCloudMain; +    WLFloatControl  mCloudCoverage; +    WLColorControl  mCloudDetail; +    WLFloatControl  mDistanceMult; +    WLFloatControl  mCloudScale; +}; + +class LLWatterSettingsAdapter +{ +public: +    typedef std::shared_ptr<LLWatterSettingsAdapter> ptr_t; + +    LLWatterSettingsAdapter(); +    WLColorControl  mFogColor; +    WLXFloatControl mFogDensity; +    WLFloatControl  mUnderWaterFogMod; + +    /// wavelet scales and directions +    WLVect3Control  mNormalScale; +    WLVect2Control  mWave1Dir; +    WLVect2Control  mWave2Dir; + +    // controls how water is reflected and refracted +    WLFloatControl  mFresnelScale; +    WLFloatControl  mFresnelOffset; +    WLFloatControl  mScaleAbove; +    WLFloatControl  mScaleBelow; +    WLFloatControl  mBlurMultiplier;  };  #endif // LL_ENVIRONMENT_H - diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 4192da450e..921f3ef910 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -32,44 +32,69 @@  #include "lldaycyclemanager.h"  #include "llviewercontrol.h" // for gSavedSettings  #include "llviewerregion.h" -#include "llwaterparammanager.h"  #include "llwlhandlers.h"  #include "lltrans.h"  #include "lltrace.h"  #include "llfasttimer.h"  #include "llviewercamera.h"  #include "pipeline.h" +#include "llsky.h"  //========================================================================= -const F32 LLEnvironment::SUN_DELTA_YAW(F_PI);   // 180deg  -  namespace  {      LLTrace::BlockTimerStatHandle   FTM_ENVIRONMENT_UPDATE("Update Environment Tick");      LLTrace::BlockTimerStatHandle   FTM_SHADER_PARAM_UPDATE("Update Shader Parameters");  } +//========================================================================= +const F32 LLEnvironment::SUN_DELTA_YAW(F_PI);   // 180deg  +const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS); +  //-------------------------------------------------------------------------  LLEnvironment::LLEnvironment():      mCurrentSky(), +    mCurrentWater(),      mSkysById(), -    mSkysByName() +    mSkysByName(), +    mWaterByName(), +    mWaterById(), +    mUserPrefs()  {      LLSettingsSky::ptr_t p_default_sky = LLSettingsSky::buildDefaultSky();      addSky(p_default_sky);      mCurrentSky = p_default_sky; + +    LLSettingsWater::ptr_t p_default_water = LLSettingsWater::buildDefaultWater(); +    addWater(p_default_water); +    mCurrentWater = p_default_water;  }  LLEnvironment::~LLEnvironment()  {  } +void LLEnvironment::loadPreferences() +{ +    mUserPrefs.load(); +} +  //-------------------------------------------------------------------------  F32 LLEnvironment::getCamHeight() const  {      return (mCurrentSky->getDomeOffset() * mCurrentSky->getDomeRadius());  } +F32 LLEnvironment::getWaterHeight() const +{ +    return gAgent.getRegion()->getWaterHeight(); +} + +bool LLEnvironment::getIsDayTime() const +{ +    return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; +} +  //-------------------------------------------------------------------------  void LLEnvironment::update(const LLViewerCamera * cam)  { @@ -201,6 +226,7 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader)      if (gPipeline.canUseWindLightShaders())      {          updateGLVariablesForSettings(shader, mCurrentSky); +        updateGLVariablesForSettings(shader, mCurrentWater);      }      if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) @@ -229,35 +255,35 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky)      LL_WARNS("RIDER") << "Adding sky as '" << name << "'" << LL_ENDL; -    std::pair<NamedSkyMap_t::iterator, bool> result; -    result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky)); +    std::pair<NamedSettingMap_t::iterator, bool> result; +    result = mSkysByName.insert(NamedSettingMap_t::value_type(name, sky));      if (!result.second)          (*(result.first)).second = sky;  } -void LLEnvironment::addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky) -{ -    //     std::string name = sky->getValue(LLSettingsSky::SETTING_NAME).asString(); -    //  -    //     std::pair<NamedSkyMap_t::iterator, bool> result; -    //     result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky)); -    //  -    //     if (!result.second) -    //         (*(result.first)).second = sky; -} +// void LLEnvironment::addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky) +// { +//     //     std::string name = sky->getValue(LLSettingsSky::SETTING_NAME).asString(); +//     //  +//     //     std::pair<NamedSkyMap_t::iterator, bool> result; +//     //     result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky)); +//     //  +//     //     if (!result.second) +//     //         (*(result.first)).second = sky; +// }  void LLEnvironment::removeSky(const std::string &name)  { -    NamedSkyMap_t::iterator it = mSkysByName.find(name); +    NamedSettingMap_t::iterator it = mSkysByName.find(name);      if (it != mSkysByName.end())          mSkysByName.erase(it);  } -void LLEnvironment::removeSky(const LLUUID &id) -{ - -} +// void LLEnvironment::removeSky(const LLUUID &id) +// { +//  +// }  void LLEnvironment::clearAllSkys()  { @@ -267,12 +293,95 @@ void LLEnvironment::clearAllSkys()  void LLEnvironment::selectSky(const std::string &name)  { -    NamedSkyMap_t::iterator it = mSkysByName.find(name); +    NamedSettingMap_t::iterator it = mSkysByName.find(name);      if (it == mSkysByName.end()) +    { +        LL_WARNS("ENVIRONMENT") << "Unable to select sky with unknown name '" << name << "'" << LL_ENDL;          return; +    } -    mCurrentSky = (*it).second; +    mCurrentSky = boost::static_pointer_cast<LLSettingsSky>((*it).second);      mCurrentSky->setDirtyFlag(true);  } +void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) +{ +    std::string name = water->getValue(LLSettingsWater::SETTING_NAME).asString(); + +    LL_WARNS("RIDER") << "Adding water as '" << name << "'" << LL_ENDL; + +    std::pair<NamedSettingMap_t::iterator, bool> result; +    result = mWaterByName.insert(NamedSettingMap_t::value_type(name, water)); + +    if (!result.second) +        (*(result.first)).second = water; +} + +//void LLEnvironment::addWater(const LLUUID &id, const LLSettingsSky::ptr_t &sky); + +void LLEnvironment::selectWater(const std::string &name) +{ +    NamedSettingMap_t::iterator it = mWaterByName.find(name); + +    if (it == mWaterByName.end()) +    { +        LL_WARNS("ENVIRONMENT") << "Unable to select water with unknown name '" << name << "'" << LL_ENDL; +        return; +    } + +    mCurrentWater = boost::static_pointer_cast<LLSettingsWater>((*it).second); +    mCurrentWater->setDirtyFlag(true); +} + +void LLEnvironment::removeWater(const std::string &name) +{ +    NamedSettingMap_t::iterator it = mWaterByName.find(name); +    if (it != mWaterByName.end()) +        mWaterByName.erase(it); +} + +//void LLEnvironment::removeWater(const LLUUID &id); +void LLEnvironment::clearAllWater() +{ +    mWaterByName.clear(); +    mWaterById.clear(); +} + + +//========================================================================= +LLEnvironment::UserPrefs::UserPrefs(): +    mUseRegionSettings(true), +    mUseDayCycle(true), +    mPersistEnvironment(false), +    mWaterPresetName(), +    mSkyPresetName(), +    mDayCycleName() +{} + + +void LLEnvironment::UserPrefs::load() +{ +    mPersistEnvironment = gSavedSettings.getBOOL("EnvironmentPersistAcrossLogin"); + +    mWaterPresetName = gSavedSettings.getString("WaterPresetName"); +    mSkyPresetName = gSavedSettings.getString("SkyPresetName"); +    mDayCycleName = gSavedSettings.getString("DayCycleName"); + +    mUseRegionSettings = mPersistEnvironment ? gSavedSettings.getBOOL("UseEnvironmentFromRegion") : true; +    mUseDayCycle = mPersistEnvironment ? gSavedSettings.getBOOL("UseDayCycle") : true; +} + +void LLEnvironment::UserPrefs::store() +{ +    gSavedSettings.setBOOL("EnvironmentPersistAcrossLogin", mPersistEnvironment); +    if (mPersistEnvironment) +    { +        gSavedSettings.setString("WaterPresetName", getWaterPresetName()); +        gSavedSettings.setString("SkyPresetName", getSkyPresetName()); +        gSavedSettings.setString("DayCycleName", getDayCycleName()); + +        gSavedSettings.setBOOL("UseEnvironmentFromRegion", getUseRegionSettings()); +        gSavedSettings.setBOOL("UseDayCycle", getUseDayCycle()); +    } +} diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index a1bdf2c38c..7506b37e3e 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -31,20 +31,59 @@  #include "llsd.h"  #include "llsettingssky.h" +#include "llsettingswater.h"  class LLViewerCamera;  class LLGLSLShader;  //------------------------------------------------------------------------- + + +//-------------------------------------------------------------------------  class LLEnvironment : public LLSingleton<LLEnvironment>  {      LLSINGLETON(LLEnvironment);      LOG_CLASS(LLEnvironment);  public: +    class UserPrefs +    { +        friend class LLEnvironment; +    public: +        UserPrefs(); + +        bool        getUseRegionSettings() const { return mUseRegionSettings; } +        bool        getUseDayCycle() const { return mUseDayCycle; } +        bool        getUseFixedSky() const { return !getUseDayCycle(); } + +        std::string getWaterPresetName() const { return mWaterPresetName; } +        std::string getSkyPresetName() const { return mSkyPresetName; } +        std::string getDayCycleName() const { return mDayCycleName; } + +        void setUseRegionSettings(bool val); +        void setUseWaterPreset(const std::string& name); +        void setUseSkyPreset(const std::string& name); +        void setUseDayCycle(const std::string& name); + +    private: +        void load(); +        void store(); + +        bool			mUseRegionSettings; +        bool			mUseDayCycle; +        bool            mPersistEnvironment; +        std::string		mWaterPresetName; +        std::string		mSkyPresetName; +        std::string		mDayCycleName; +    }; +      virtual ~LLEnvironment(); +    void                    loadPreferences(); +    const UserPrefs &       getPreferences() const { return mUserPrefs; } +      LLSettingsSky::ptr_t    getCurrentSky() const { return mCurrentSky; } +    LLSettingsWater::ptr_t  getCurrentWater() const { return mCurrentWater; }      void                    update(const LLViewerCamera * cam); @@ -53,10 +92,15 @@ public:      void                    addSky(const LLSettingsSky::ptr_t &sky);      void                    selectSky(const std::string &name); +    void                    addWater(const LLSettingsWater::ptr_t &sky); +    void                    selectWater(const std::string &name);      inline LLVector2        getCloudScrollDelta() const { return mCloudScrollDelta; }      F32                     getCamHeight() const; +    F32                     getWaterHeight() const; +    bool                    getIsDayTime() const;   // "Day Time" is defined as the sun above the horizon. +    bool                    getIsNightTime() const { return !getIsDayTime(); } // "Not Day Time"       inline F32              getSceneLightStrength() const { return mSceneLightStrength; }      inline void             setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; } @@ -65,27 +109,40 @@ public:      inline LLVector4        getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); }      inline LLVector4        getRotatedLight() const { return mRotatedLight; } +  private:      static const F32        SUN_DELTA_YAW; +    static const F32        NIGHTTIME_ELEVATION_COS; -    typedef std::map<std::string, LLSettingsSky::ptr_t> NamedSkyMap_t; -    typedef std::map<LLUUID, LLSettingsSky::ptr_t> AssetSkyMap_t; +    typedef std::map<std::string, LLSettingsBase::ptr_t> NamedSettingMap_t; +    typedef std::map<LLUUID, LLSettingsBase::ptr_t> AssetSettingMap_t;      LLVector2               mCloudScrollDelta;  // cumulative cloud delta      LLSettingsSky::ptr_t    mCurrentSky; +    LLSettingsWater::ptr_t  mCurrentWater; + +    NamedSettingMap_t       mSkysByName; +    AssetSettingMap_t       mSkysById; -    NamedSkyMap_t           mSkysByName; -    AssetSkyMap_t           mSkysById; +    NamedSettingMap_t       mWaterByName; +    AssetSettingMap_t       mWaterById;      F32                     mSceneLightStrength;      LLVector4               mRotatedLight; -    void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky); +    UserPrefs               mUserPrefs; + +    //void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky);      void removeSky(const std::string &name); -    void removeSky(const LLUUID &id); +    //void removeSky(const LLUUID &id);      void clearAllSkys(); +    //void addWater(const LLUUID &id, const LLSettingsSky::ptr_t &sky); +    void removeWater(const std::string &name); +    //void removeWater(const LLUUID &id); +    void clearAllWater(); +      void updateCloudScroll();  }; diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 1ca61e758f..40f86e3778 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -145,11 +145,6 @@ void LLFloaterEditSky::initCallbacks(void)  	mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnSave, this));  	getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); -    // *LAPRAS -    // TODO: -// 	LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditSky::onRegionSettingsChange, this)); -// 	LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); -  	// Connect to region info updates.  	LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditSky::onRegionInfoUpdate, this)); diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp index 43b44eae37..41180b5da8 100644 --- a/indra/newview/llfloatereditwater.cpp +++ b/indra/newview/llfloatereditwater.cpp @@ -28,6 +28,8 @@  #include "llfloatereditwater.h" +#include <boost/make_shared.hpp> +  // libs  #include "llbutton.h"  #include "llcheckboxctrl.h" @@ -42,16 +44,22 @@  #include "llagent.h"  #include "llregioninfomodel.h"  #include "llviewerregion.h" -#include "llwaterparammanager.h" + +#include "llenvironment.h" +#include "llsettingswater.h" +#include "llenvadapters.h" + +#include "v3colorutil.h"  #undef max // Fixes a Windows compiler error -LLFloaterEditWater::LLFloaterEditWater(const LLSD &key) -:	LLFloater(key) -,	mWaterPresetNameEditor(NULL) -,	mWaterPresetCombo(NULL) -,	mMakeDefaultCheckBox(NULL) -,	mSaveButton(NULL) +LLFloaterEditWater::LLFloaterEditWater(const LLSD &key):	 +    LLFloater(key),	 +    mWaterPresetNameEditor(NULL), +    mWaterPresetCombo(NULL), +    mMakeDefaultCheckBox(NULL), +    mSaveButton(NULL), +    mWaterAdapter()  {  } @@ -63,6 +71,8 @@ BOOL LLFloaterEditWater::postBuild()  	mMakeDefaultCheckBox = getChild<LLCheckBoxCtrl>("make_default_cb");  	mSaveButton = getChild<LLButton>("save"); +    mWaterAdapter = boost::make_shared<LLWatterSettingsAdapter>(); +  	initCallbacks();  	refreshWaterPresetsList();  	syncControls(); @@ -99,7 +109,7 @@ void LLFloaterEditWater::onClose(bool app_quitting)  {  	if (!app_quitting) // there's no point to change environment if we're quitting  	{ -		LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment +//		LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment  	}  } @@ -119,44 +129,38 @@ void LLFloaterEditWater::initCallbacks(void)  	mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditWater::onBtnSave, this));  	getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterEditWater::onBtnCancel, this)); -	LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditWater::onRegionSettingsChange, this)); -	LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditWater::onWaterPresetListChange, this)); -  	// Connect to region info updates.  	LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditWater::onRegionInfoUpdate, this));  	//------------------------------------------------------------------------- -	LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - -	getChild<LLUICtrl>("WaterFogColor")->setCommitCallback(boost::bind(&LLFloaterEditWater::onWaterFogColorMoved, this, _1, &water_mgr.mFogColor)); -	//getChild<LLUICtrl>("WaterGlow")->setCommitCallback(boost::bind(&LLFloaterEditWater::onColorControlAMoved, this, _1, &water_mgr.mFogColor)); +    getChild<LLUICtrl>("WaterFogColor")->setCommitCallback(boost::bind(&LLFloaterEditWater::onColorControlMoved, this, _1, &mWaterAdapter->mFogColor));  	// fog density -	getChild<LLUICtrl>("WaterFogDensity")->setCommitCallback(boost::bind(&LLFloaterEditWater::onExpFloatControlMoved, this, _1, &water_mgr.mFogDensity)); -	getChild<LLUICtrl>("WaterUnderWaterFogMod")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mUnderWaterFogMod)); +    getChild<LLUICtrl>("WaterFogDensity")->setCommitCallback(boost::bind(&LLFloaterEditWater::onExpFloatControlMoved, this, _1, &mWaterAdapter->mFogDensity)); +    getChild<LLUICtrl>("WaterUnderWaterFogMod")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mUnderWaterFogMod));  	// blue density -	getChild<LLUICtrl>("WaterNormalScaleX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlXMoved, this, _1, &water_mgr.mNormalScale)); -	getChild<LLUICtrl>("WaterNormalScaleY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlYMoved, this, _1, &water_mgr.mNormalScale)); -	getChild<LLUICtrl>("WaterNormalScaleZ")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlZMoved, this, _1, &water_mgr.mNormalScale)); +    getChild<LLUICtrl>("WaterNormalScaleX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlXMoved, this, _1, &mWaterAdapter->mNormalScale)); +    getChild<LLUICtrl>("WaterNormalScaleY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlYMoved, this, _1, &mWaterAdapter->mNormalScale)); +    getChild<LLUICtrl>("WaterNormalScaleZ")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlZMoved, this, _1, &mWaterAdapter->mNormalScale));  	// fresnel -	getChild<LLUICtrl>("WaterFresnelScale")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mFresnelScale)); -	getChild<LLUICtrl>("WaterFresnelOffset")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mFresnelOffset)); +    getChild<LLUICtrl>("WaterFresnelScale")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mFresnelScale)); +    getChild<LLUICtrl>("WaterFresnelOffset")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mFresnelOffset));  	// scale above/below -	getChild<LLUICtrl>("WaterScaleAbove")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mScaleAbove)); -	getChild<LLUICtrl>("WaterScaleBelow")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mScaleBelow)); +    getChild<LLUICtrl>("WaterScaleAbove")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mScaleAbove)); +    getChild<LLUICtrl>("WaterScaleBelow")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mScaleBelow));  	// blur mult -	getChild<LLUICtrl>("WaterBlurMult")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mBlurMultiplier)); +    getChild<LLUICtrl>("WaterBlurMult")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mBlurMultiplier));  	// wave direction -	getChild<LLUICtrl>("WaterWave1DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &water_mgr.mWave1Dir)); -	getChild<LLUICtrl>("WaterWave1DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &water_mgr.mWave1Dir)); -	getChild<LLUICtrl>("WaterWave2DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &water_mgr.mWave2Dir)); -	getChild<LLUICtrl>("WaterWave2DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &water_mgr.mWave2Dir)); +    getChild<LLUICtrl>("WaterWave1DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &mWaterAdapter->mWave1Dir)); +    getChild<LLUICtrl>("WaterWave1DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &mWaterAdapter->mWave1Dir)); +    getChild<LLUICtrl>("WaterWave2DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &mWaterAdapter->mWave2Dir)); +    getChild<LLUICtrl>("WaterWave2DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &mWaterAdapter->mWave2Dir));  	LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("WaterNormalMap");  	texture_ctrl->setDefaultImageAssetID(DEFAULT_WATER_NORMAL); @@ -169,304 +173,128 @@ void LLFloaterEditWater::syncControls()  {  	// *TODO: Eliminate slow getChild() calls. -	bool err; +    LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); +    mEditSettings = pwater; -	LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - -	LLWaterParamSet& current_params = water_mgr.mCurParams; - -	// blue horizon -	water_mgr.mFogColor = current_params.getVector4(water_mgr.mFogColor.mName, err); - -	LLColor4 col = water_mgr.getFogColor();  	//getChild<LLUICtrl>("WaterGlow")->setValue(col.mV[3]); -	col.mV[3] = 1.0f; -	getChild<LLColorSwatchCtrl>("WaterFogColor")->set(col); +    getChild<LLColorSwatchCtrl>("WaterFogColor")->set(LLColor4(pwater->getFogColor()));  	// fog and wavelets -	water_mgr.mFogDensity.mExp = -		log(current_params.getFloat(water_mgr.mFogDensity.mName, err)) / -		log(water_mgr.mFogDensity.mBase); -	water_mgr.setDensitySliderValue(water_mgr.mFogDensity.mExp); -	getChild<LLUICtrl>("WaterFogDensity")->setValue(water_mgr.mFogDensity.mExp); +    mWaterAdapter->mFogDensity = pwater->getFogDensity(); +    getChild<LLUICtrl>("WaterFogDensity")->setValue(mWaterAdapter->mFogDensity.getExp()); -	water_mgr.mUnderWaterFogMod.mX = -		current_params.getFloat(water_mgr.mUnderWaterFogMod.mName, err); -	getChild<LLUICtrl>("WaterUnderWaterFogMod")->setValue(water_mgr.mUnderWaterFogMod.mX); +    mWaterAdapter->mUnderWaterFogMod = pwater->getFogMod(); +	getChild<LLUICtrl>("WaterUnderWaterFogMod")->setValue(static_cast<F32>(mWaterAdapter->mUnderWaterFogMod)); -	water_mgr.mNormalScale = current_params.getVector3(water_mgr.mNormalScale.mName, err); -	getChild<LLUICtrl>("WaterNormalScaleX")->setValue(water_mgr.mNormalScale.mX); -	getChild<LLUICtrl>("WaterNormalScaleY")->setValue(water_mgr.mNormalScale.mY); -	getChild<LLUICtrl>("WaterNormalScaleZ")->setValue(water_mgr.mNormalScale.mZ); +    mWaterAdapter->mNormalScale = pwater->getNormalScale(); +    getChild<LLUICtrl>("WaterNormalScaleX")->setValue(mWaterAdapter->mNormalScale.getX()); +	getChild<LLUICtrl>("WaterNormalScaleY")->setValue(mWaterAdapter->mNormalScale.getY()); +	getChild<LLUICtrl>("WaterNormalScaleZ")->setValue(mWaterAdapter->mNormalScale.getZ());  	// Fresnel -	water_mgr.mFresnelScale.mX = current_params.getFloat(water_mgr.mFresnelScale.mName, err); -	getChild<LLUICtrl>("WaterFresnelScale")->setValue(water_mgr.mFresnelScale.mX); -	water_mgr.mFresnelOffset.mX = current_params.getFloat(water_mgr.mFresnelOffset.mName, err); -	getChild<LLUICtrl>("WaterFresnelOffset")->setValue(water_mgr.mFresnelOffset.mX); +    mWaterAdapter->mFresnelScale = pwater->getFresnelScale(); +	getChild<LLUICtrl>("WaterFresnelScale")->setValue(static_cast<F32>(mWaterAdapter->mFresnelScale)); +    mWaterAdapter->mFresnelOffset = pwater->getFresnelOffset(); +    getChild<LLUICtrl>("WaterFresnelOffset")->setValue(static_cast<F32>(mWaterAdapter->mFresnelOffset));  	// Scale Above/Below -	water_mgr.mScaleAbove.mX = current_params.getFloat(water_mgr.mScaleAbove.mName, err); -	getChild<LLUICtrl>("WaterScaleAbove")->setValue(water_mgr.mScaleAbove.mX); -	water_mgr.mScaleBelow.mX = current_params.getFloat(water_mgr.mScaleBelow.mName, err); -	getChild<LLUICtrl>("WaterScaleBelow")->setValue(water_mgr.mScaleBelow.mX); +    mWaterAdapter->mScaleAbove = pwater->getScaleAbove(); +    getChild<LLUICtrl>("WaterScaleAbove")->setValue(static_cast<F32>(mWaterAdapter->mScaleAbove)); +    mWaterAdapter->mScaleBelow = pwater->getScaleBelow(); +    getChild<LLUICtrl>("WaterScaleBelow")->setValue(static_cast<F32>(mWaterAdapter->mScaleBelow));  	// blur mult -	water_mgr.mBlurMultiplier.mX = current_params.getFloat(water_mgr.mBlurMultiplier.mName, err); -	getChild<LLUICtrl>("WaterBlurMult")->setValue(water_mgr.mBlurMultiplier.mX); +    mWaterAdapter->mBlurMultiplier = pwater->getBlurMultiplier(); +    getChild<LLUICtrl>("WaterBlurMult")->setValue(static_cast<F32>(mWaterAdapter->mBlurMultiplier));  	// wave directions -	water_mgr.mWave1Dir = current_params.getVector2(water_mgr.mWave1Dir.mName, err); -	getChild<LLUICtrl>("WaterWave1DirX")->setValue(water_mgr.mWave1Dir.mX); -	getChild<LLUICtrl>("WaterWave1DirY")->setValue(water_mgr.mWave1Dir.mY); +    mWaterAdapter->mWave1Dir = pwater->getWave1Dir(); +	getChild<LLUICtrl>("WaterWave1DirX")->setValue(mWaterAdapter->mWave1Dir.getU()); +	getChild<LLUICtrl>("WaterWave1DirY")->setValue(mWaterAdapter->mWave1Dir.getV()); -	water_mgr.mWave2Dir = current_params.getVector2(water_mgr.mWave2Dir.mName, err); -	getChild<LLUICtrl>("WaterWave2DirX")->setValue(water_mgr.mWave2Dir.mX); -	getChild<LLUICtrl>("WaterWave2DirY")->setValue(water_mgr.mWave2Dir.mY); +    mWaterAdapter->mWave2Dir = pwater->getWave2Dir(); +	getChild<LLUICtrl>("WaterWave2DirX")->setValue(mWaterAdapter->mWave2Dir.getU()); +    getChild<LLUICtrl>("WaterWave2DirY")->setValue(mWaterAdapter->mWave2Dir.getV());  	LLTextureCtrl* textCtrl = getChild<LLTextureCtrl>("WaterNormalMap"); -	textCtrl->setImageAssetID(water_mgr.getNormalMapID()); -} - -// color control callbacks -void LLFloaterEditWater::onColorControlRMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ -	LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - -	color_ctrl->mR = sldr_ctrl->getValueF32(); - -	// move i if it's the max -	if (color_ctrl->mR >= color_ctrl->mG -		&& color_ctrl->mR >= color_ctrl->mB -		&& color_ctrl->mHasSliderName) -	{ -		color_ctrl->mI = color_ctrl->mR; -		std::string name = color_ctrl->mSliderName; -		name.append("I"); - -		getChild<LLUICtrl>(name)->setValue(color_ctrl->mR); -	} - -	color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - -	LLWaterParamManager::getInstance()->propagateParameters(); -} - -void LLFloaterEditWater::onColorControlGMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ -	LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - -	color_ctrl->mG = sldr_ctrl->getValueF32(); - -	// move i if it's the max -	if (color_ctrl->mG >= color_ctrl->mR -		&& color_ctrl->mG >= color_ctrl->mB -		&& color_ctrl->mHasSliderName) -	{ -		color_ctrl->mI = color_ctrl->mG; -		std::string name = color_ctrl->mSliderName; -		name.append("I"); - -		getChild<LLUICtrl>(name)->setValue(color_ctrl->mG); - -	} - -	color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - -	LLWaterParamManager::getInstance()->propagateParameters(); -} - -void LLFloaterEditWater::onColorControlBMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ -	LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - -	color_ctrl->mB = sldr_ctrl->getValueF32(); - -	// move i if it's the max -	if (color_ctrl->mB >= color_ctrl->mR -		&& color_ctrl->mB >= color_ctrl->mG -		&& color_ctrl->mHasSliderName) -	{ -		color_ctrl->mI = color_ctrl->mB; -		std::string name = color_ctrl->mSliderName; -		name.append("I"); - -		getChild<LLUICtrl>(name)->setValue(color_ctrl->mB); -	} - -	color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - -	LLWaterParamManager::getInstance()->propagateParameters(); -} - -void LLFloaterEditWater::onColorControlAMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ -	LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - -	color_ctrl->mA = sldr_ctrl->getValueF32(); - -	color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - -	LLWaterParamManager::getInstance()->propagateParameters(); +	textCtrl->setImageAssetID(pwater->getNormalMapID());  } -void LLFloaterEditWater::onColorControlIMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ -	LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - -	color_ctrl->mI = sldr_ctrl->getValueF32(); - -	// only for sliders where we pass a name -	if (color_ctrl->mHasSliderName) -	{ -		// set it to the top -		F32 maxVal = std::max(std::max(color_ctrl->mR, color_ctrl->mG), color_ctrl->mB); -		F32 iVal; - -		iVal = color_ctrl->mI; - -		// get the names of the other sliders -		std::string rName = color_ctrl->mSliderName; -		rName.append("R"); -		std::string gName = color_ctrl->mSliderName; -		gName.append("G"); -		std::string bName = color_ctrl->mSliderName; -		bName.append("B"); - -		// handle if at 0 -		if (iVal == 0) -		{ -			color_ctrl->mR = 0; -			color_ctrl->mG = 0; -			color_ctrl->mB = 0; - -		// if all at the start -		// set them all to the intensity -		} -		else if (maxVal == 0) -		{ -			color_ctrl->mR = iVal; -			color_ctrl->mG = iVal; -			color_ctrl->mB = iVal; -		} -		else -		{ -			// add delta amounts to each -			F32 delta = (iVal - maxVal) / maxVal; -			color_ctrl->mR *= (1.0f + delta); -			color_ctrl->mG *= (1.0f + delta); -			color_ctrl->mB *= (1.0f + delta); -		} - -		// set the sliders to the new vals -		getChild<LLUICtrl>(rName)->setValue(color_ctrl->mR); -		getChild<LLUICtrl>(gName)->setValue(color_ctrl->mG); -		getChild<LLUICtrl>(bName)->setValue(color_ctrl->mB); -	} - -	// now update the current parameters and send them to shaders -	color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); -	LLWaterParamManager::getInstance()->propagateParameters(); -} -  // vector control callbacks -void LLFloaterEditWater::onVector3ControlXMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl) +void LLFloaterEditWater::onVector3ControlXMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl)  {  	LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); -	vector_ctrl->mX = sldr_ctrl->getValueF32(); - -	vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - -	LLWaterParamManager::getInstance()->propagateParameters(); +	vector_ctrl->setX( sldr_ctrl->getValueF32() ); +	vector_ctrl->update(mEditSettings);  }  // vector control callbacks -void LLFloaterEditWater::onVector3ControlYMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl) +void LLFloaterEditWater::onVector3ControlYMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl)  {  	LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); -	vector_ctrl->mY = sldr_ctrl->getValueF32(); - -	vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - -	LLWaterParamManager::getInstance()->propagateParameters(); +    vector_ctrl->setY(sldr_ctrl->getValueF32()); +    vector_ctrl->update(mEditSettings);  }  // vector control callbacks -void LLFloaterEditWater::onVector3ControlZMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl) +void LLFloaterEditWater::onVector3ControlZMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl)  { -	LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); +    LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); -	vector_ctrl->mZ = sldr_ctrl->getValueF32(); - -	vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - -	LLWaterParamManager::getInstance()->propagateParameters(); +    vector_ctrl->setZ(sldr_ctrl->getValueF32()); +    vector_ctrl->update(mEditSettings);  }  // vector control callbacks -void LLFloaterEditWater::onVector2ControlXMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl) +void LLFloaterEditWater::onVector2ControlXMoved(LLUICtrl* ctrl, WLVect2Control* vector_ctrl)  { -	LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); +    LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); -	vector_ctrl->mX = sldr_ctrl->getValueF32(); - -	vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - -	LLWaterParamManager::getInstance()->propagateParameters(); +    vector_ctrl->setU(sldr_ctrl->getValueF32()); +    vector_ctrl->update(mEditSettings);  }  // vector control callbacks -void LLFloaterEditWater::onVector2ControlYMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl) +void LLFloaterEditWater::onVector2ControlYMoved(LLUICtrl* ctrl, WLVect2Control* vector_ctrl)  { -	LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - -	vector_ctrl->mY = sldr_ctrl->getValueF32(); +    LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); -	vector_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); - -	LLWaterParamManager::getInstance()->propagateParameters(); +    vector_ctrl->setV(sldr_ctrl->getValueF32()); +    vector_ctrl->update(mEditSettings);  } -void LLFloaterEditWater::onFloatControlMoved(LLUICtrl* ctrl, WaterFloatControl* floatControl) +void LLFloaterEditWater::onFloatControlMoved(LLUICtrl* ctrl, WLFloatControl* floatControl)  { -	LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - -	floatControl->mX = sldr_ctrl->getValueF32() / floatControl->mMult; +    LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); -	floatControl->update(LLWaterParamManager::getInstance()->mCurParams); -	LLWaterParamManager::getInstance()->propagateParameters(); +    floatControl->setValue(sldr_ctrl->getValueF32()); +    floatControl->update(mEditSettings);  } -void LLFloaterEditWater::onExpFloatControlMoved(LLUICtrl* ctrl, WaterExpFloatControl* expFloatControl) +void LLFloaterEditWater::onExpFloatControlMoved(LLUICtrl* ctrl, WLXFloatControl* expFloatControl)  {  	LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); -	F32 val = sldr_ctrl->getValueF32(); -	expFloatControl->mExp = val; -	LLWaterParamManager::getInstance()->setDensitySliderValue(val); - -	expFloatControl->update(LLWaterParamManager::getInstance()->mCurParams); -	LLWaterParamManager::getInstance()->propagateParameters(); +    expFloatControl->setExp(sldr_ctrl->getValueF32()); +    expFloatControl->update(mEditSettings);  } -void LLFloaterEditWater::onWaterFogColorMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) +void LLFloaterEditWater::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl)  {  	LLColorSwatchCtrl* swatch = static_cast<LLColorSwatchCtrl*>(ctrl);  	*color_ctrl = swatch->get(); - -	color_ctrl->update(LLWaterParamManager::getInstance()->mCurParams); -	LLWaterParamManager::getInstance()->propagateParameters(); +	color_ctrl->update(mEditSettings);  }  void LLFloaterEditWater::onNormalMapPicked(LLUICtrl* ctrl)  {  	LLTextureCtrl* textCtrl = static_cast<LLTextureCtrl*>(ctrl);  	LLUUID textID = textCtrl->getImageAssetID(); -	LLWaterParamManager::getInstance()->setNormalMapID(textID); +    mEditSettings->setNormalMapID(textID);  }  //============================================================================= @@ -494,6 +322,7 @@ bool LLFloaterEditWater::isNewPreset() const  void LLFloaterEditWater::refreshWaterPresetsList()  { +#if 0  	mWaterPresetCombo->removeall();  #if 0 // *TODO: enable when we have a clear workflow to edit existing region environment @@ -530,6 +359,7 @@ void LLFloaterEditWater::refreshWaterPresetsList()  	}  	mWaterPresetCombo->setLabel(getString("combo_label")); +#endif  }  void LLFloaterEditWater::enableEditing(bool enable) @@ -544,6 +374,7 @@ void LLFloaterEditWater::enableEditing(bool enable)  void LLFloaterEditWater::saveRegionWater()  { +#if 0  	llassert(getCurrentScope() == LLEnvKey::SCOPE_REGION); // make sure we're editing region water  	LL_DEBUGS("Windlight") << "Saving region water preset" << LL_ENDL; @@ -552,8 +383,10 @@ void LLFloaterEditWater::saveRegionWater()  	// *TODO: save to cached region settings.  	LL_WARNS("Windlight") << "Saving region water is not fully implemented yet" << LL_ENDL; +#endif  } +#if 0  std::string LLFloaterEditWater::getCurrentPresetName() const  {  	std::string name; @@ -561,7 +394,9 @@ std::string LLFloaterEditWater::getCurrentPresetName() const  	getSelectedPreset(name, scope);  	return name;  } +#endif +#if 0  LLEnvKey::EScope LLFloaterEditWater::getCurrentScope() const  {  	std::string name; @@ -569,9 +404,12 @@ LLEnvKey::EScope LLFloaterEditWater::getCurrentScope() const  	getSelectedPreset(name, scope);  	return scope;  } +#endif +#if 0  void LLFloaterEditWater::getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const  { +  	if (mWaterPresetNameEditor->getVisible())  	{  		name = mWaterPresetNameEditor->getText(); @@ -592,16 +430,21 @@ void LLFloaterEditWater::getSelectedPreset(std::string& name, LLEnvKey::EScope&  			scope = (LLEnvKey::EScope) combo_val[1].asInteger();  		}  	} +  } +#endif  void LLFloaterEditWater::onWaterPresetNameEdited()  { +#if 0  	// Disable saving a water preset having empty name.  	mSaveButton->setEnabled(!getCurrentPresetName().empty()); +#endif  }  void LLFloaterEditWater::onWaterPresetSelected()  { +#if 0  	LLWaterParamSet water_params;  	std::string name;  	LLEnvKey::EScope scope; @@ -629,23 +472,26 @@ void LLFloaterEditWater::onWaterPresetSelected()  	enableEditing(can_edit);  	mMakeDefaultCheckBox->setEnabled(scope == LLEnvKey::SCOPE_LOCAL); +#endif  }  bool LLFloaterEditWater::onSaveAnswer(const LLSD& notification, const LLSD& response)  { -	S32 option = LLNotificationsUtil::getSelectedOption(notification, response); +#if 0 +  	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);  	// If they choose save, do it.  Otherwise, don't do anything  	if (option == 0)  	{  		onSaveConfirmed();  	} - +#endif  	return false;  }  void LLFloaterEditWater::onSaveConfirmed()  { +#if 0  	// Save currently displayed water params to the selected preset.  	std::string name = getCurrentPresetName(); @@ -670,10 +516,12 @@ void LLFloaterEditWater::onSaveConfirmed()  	}  	closeFloater(); +#endif  }  void LLFloaterEditWater::onBtnSave()  { +#if 0  	LLEnvKey::EScope scope;  	std::string name;  	getSelectedPreset(name, scope); @@ -710,6 +558,7 @@ void LLFloaterEditWater::onBtnSave()  		// new preset, hence no confirmation needed  		onSaveConfirmed();  	} +#endif  }  void LLFloaterEditWater::onBtnCancel() @@ -719,6 +568,7 @@ void LLFloaterEditWater::onBtnCancel()  void LLFloaterEditWater::onWaterPresetListChange()  { +#if 0  	std::string name;  	LLEnvKey::EScope scope;  	getSelectedPreset(name, scope); // preset being edited @@ -734,10 +584,12 @@ void LLFloaterEditWater::onWaterPresetListChange()  		// Refresh the presets list, though it may not make sense as the floater is about to be closed.  		refreshWaterPresetsList();  	} +#endif  }  void LLFloaterEditWater::onRegionSettingsChange()  { +#if 0  	// If creating a new preset, don't bother.  	if (isNewPreset())  	{ @@ -755,10 +607,12 @@ void LLFloaterEditWater::onRegionSettingsChange()  	{  		refreshWaterPresetsList();  	} +#endif  }  void LLFloaterEditWater::onRegionInfoUpdate()  { +#if 0  	bool can_edit = true;  	// If we've selected the region water for editing. @@ -769,4 +623,5 @@ void LLFloaterEditWater::onRegionInfoUpdate()  	}  	enableEditing(can_edit); +#endif  } diff --git a/indra/newview/llfloatereditwater.h b/indra/newview/llfloatereditwater.h index 2211bca59f..7d9e493ac2 100644 --- a/indra/newview/llfloatereditwater.h +++ b/indra/newview/llfloatereditwater.h @@ -28,18 +28,22 @@  #define LL_LLFLOATEREDITWATER_H  #include "llfloater.h" -#include "llenvmanager.h" // for LLEnvKey +#include "llsettingswater.h"  class LLButton;  class LLCheckBoxCtrl;  class LLComboBox;  class LLLineEditor; -struct WaterVector2Control; -struct WaterVector3Control; -struct WaterColorControl; -struct WaterFloatControl; -struct WaterExpFloatControl; +class WLVect2Control; +class WLVect3Control; +class WLColorControl; +class WLFloatControl; +class WLXFloatControl; + +class LLWatterSettingsAdapter; + +typedef boost::shared_ptr<LLWatterSettingsAdapter> LLWaterSettingsAdapterPtr;  class LLFloaterEditWater : public LLFloater  { @@ -60,29 +64,22 @@ private:  	void syncControls(); /// sync up sliders with parameters -	// general purpose callbacks for dealing with color controllers -	void onColorControlRMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); -	void onColorControlGMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); -	void onColorControlBMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); -	void onColorControlAMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); -	void onColorControlIMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); +    void onVector3ControlXMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl); +    void onVector3ControlYMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl); +    void onVector3ControlZMoved(LLUICtrl* ctrl, WLVect3Control* vector_ctrl); -	void onVector3ControlXMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl); -	void onVector3ControlYMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl); -	void onVector3ControlZMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl); +    void onVector2ControlXMoved(LLUICtrl* ctrl, WLVect2Control* vector_ctrl); +    void onVector2ControlYMoved(LLUICtrl* ctrl, WLVect2Control* vector_ctrl); -	void onVector2ControlXMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl); -	void onVector2ControlYMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl); +    void onFloatControlMoved(LLUICtrl* ctrl, WLFloatControl* floatControl); -	void onFloatControlMoved(LLUICtrl* ctrl, WaterFloatControl* floatControl); +    void onExpFloatControlMoved(LLUICtrl* ctrl, WLXFloatControl* expFloatControl); -	void onExpFloatControlMoved(LLUICtrl* ctrl, WaterExpFloatControl* expFloatControl); - -	void onWaterFogColorMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl); +    void onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl);  	void onNormalMapPicked(LLUICtrl* ctrl); /// handle if they choose a new normal map -	//-- WL stuff ends -------------------------------------------------------- +    //-- WL stuff ends --------------------------------------------------------  	void reset();  	bool isNewPreset() const; @@ -90,9 +87,9 @@ private:  	void enableEditing(bool enable);  	void saveRegionWater(); -	std::string			getCurrentPresetName() const; -	LLEnvKey::EScope	getCurrentScope() const; -	void				getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const; +//	std::string			getCurrentPresetName() const; +// 	LLEnvKey::EScope	getCurrentScope() const; +//	void				getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const;  	void onWaterPresetNameEdited();  	void onWaterPresetSelected(); @@ -110,6 +107,9 @@ private:  	LLComboBox*		mWaterPresetCombo;  	LLCheckBoxCtrl*	mMakeDefaultCheckBox;  	LLButton*		mSaveButton; + +    LLWaterSettingsAdapterPtr   mWaterAdapter; +    LLSettingsWater::ptr_t      mEditSettings;  };  #endif // LL_LLFLOATEREDITWATER_H diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 3a059e92dc..39907b19a3 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -32,10 +32,6 @@  #include "llradiogroup.h"  #include "lldaycyclemanager.h" -#include "llenvmanager.h" -#include "llwaterparammanager.h" -#include "llwlparamset.h" -#include "llwlparammanager.h"  #include "llenvironment.h" @@ -74,10 +70,10 @@ BOOL LLFloaterEnvironmentSettings::postBuild()  	setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this)); -	LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::refresh, this)); -	LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this)); -	LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this)); -	LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this)); +// 	LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::refresh, this)); +//	LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this)); +// 	LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this)); +// 	LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this));  	return TRUE;  } @@ -199,7 +195,9 @@ void LLFloaterEnvironmentSettings::apply()  			env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL);  		} -		env_mgr.useWaterPreset(water_preset); +        /* LAPRAS */ +        //env_mgr.useWaterPreset(water_preset); +        LLEnvironment::instance().selectWater(water_preset);  	}  } @@ -214,7 +212,7 @@ void LLFloaterEnvironmentSettings::populateWaterPresetsList()  	mWaterPresetCombo->removeall();  	std::list<std::string> user_presets, system_presets; -	LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); +	//LLWaterParamManager::instance().getPresetNames(user_presets, system_presets);  	// Add user presets first.  	for (std::list<std::string>::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index 59e14e6cc0..5b35d5c3a5 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -48,7 +48,7 @@ static LLDefaultChildRegistry::Register<LLJoystickAgentSlide> r1("joystick_slide  static LLDefaultChildRegistry::Register<LLJoystickAgentTurn> r2("joystick_turn");  static LLDefaultChildRegistry::Register<LLJoystickCameraRotate> r3("joystick_rotate");  static LLDefaultChildRegistry::Register<LLJoystickCameraTrack> r5("joystick_track"); - +static LLDefaultChildRegistry::Register<LLJoystickQuaternion> r6("joystick_quat");  const F32 NUDGE_TIME = 0.25f;		// in seconds @@ -646,3 +646,185 @@ void LLJoystickCameraTrack::onHeldDown()  		gAgentCamera.setPanDownKey(getOrbitRate());  	}  } + +//------------------------------------------------------------------------------- +// LLJoystickQuaternion +//------------------------------------------------------------------------------- + +LLJoystickQuaternion::Params::Params() +{ +} + +LLJoystickQuaternion::LLJoystickQuaternion(const LLJoystickQuaternion::Params &p): +    LLJoystick(p), +    mInLeft(false), +    mInTop(false), +    mInRight(false), +    mInBottom(false) +{ +} + +void LLJoystickQuaternion::setToggleState(BOOL left, BOOL top, BOOL right, BOOL bottom) +{ +    mInLeft = left; +    mInTop = top; +    mInRight = right; +    mInBottom = bottom; +} + +BOOL LLJoystickQuaternion::handleMouseDown(S32 x, S32 y, MASK mask) +{ +    updateSlop(); + +    // Set initial offset based on initial click location +    S32 horiz_center = getRect().getWidth() / 2; +    S32 vert_center = getRect().getHeight() / 2; + +    S32 dx = x - horiz_center; +    S32 dy = y - vert_center; + +    if (dy > dx && dy > -dx) +    { +        // top +        mInitialOffset.mX = 0; +        mInitialOffset.mY = (mVertSlopNear + mVertSlopFar) / 2; +        mInitialQuadrant = JQ_UP; +    } +    else if (dy > dx && dy <= -dx) +    { +        // left +        mInitialOffset.mX = -(mHorizSlopNear + mHorizSlopFar) / 2; +        mInitialOffset.mY = 0; +        mInitialQuadrant = JQ_LEFT; +    } +    else if (dy <= dx && dy <= -dx) +    { +        // bottom +        mInitialOffset.mX = 0; +        mInitialOffset.mY = -(mVertSlopNear + mVertSlopFar) / 2; +        mInitialQuadrant = JQ_DOWN; +    } +    else +    { +        // right +        mInitialOffset.mX = (mHorizSlopNear + mHorizSlopFar) / 2; +        mInitialOffset.mY = 0; +        mInitialQuadrant = JQ_RIGHT; +    } + +    return LLJoystick::handleMouseDown(x, y, mask); +} + +BOOL LLJoystickQuaternion::handleMouseUp(S32 x, S32 y, MASK mask) +{ +    return LLJoystick::handleMouseUp(x, y, mask); +} + +void LLJoystickQuaternion::onHeldDown() +{ +    updateSlop(); + +    S32 dx = mLastMouse.mX - mFirstMouse.mX + mInitialOffset.mX; +    S32 dy = mLastMouse.mY - mFirstMouse.mY + mInitialOffset.mY; + +    // left-right rotation +    if (dx > mHorizSlopNear) +    { +    } +    else if (dx < -mHorizSlopNear) +    { +    } + +    // over/under rotation +    if (dy > mVertSlopNear) +    { +    } +    else if (dy < -mVertSlopNear) +    { +    } +} + +void LLJoystickQuaternion::draw() +{ +    LLGLSUIDefault gls_ui; + +    getImageUnselected()->draw(0, 0); +    LLPointer<LLUIImage> image = getImageSelected(); + +    if (mInTop) +    { +        drawRotatedImage(getImageSelected(), 0); +    } + +    if (mInRight) +    { +        drawRotatedImage(getImageSelected(), 1); +    } + +    if (mInBottom) +    { +        drawRotatedImage(getImageSelected(), 2); +    } + +    if (mInLeft) +    { +        drawRotatedImage(getImageSelected(), 3); +    } +} + +F32 LLJoystickQuaternion::getOrbitRate() +{ +    return 1; +} + +void LLJoystickQuaternion::updateSlop() +{ +    // small fixed slop region +    mVertSlopNear = 16; +    mVertSlopFar = 32; + +    mHorizSlopNear = 16; +    mHorizSlopFar = 32; +} + +void LLJoystickQuaternion::drawRotatedImage(LLPointer<LLUIImage> image, S32 rotations) +{ +    S32 width = image->getWidth(); +    S32 height = image->getHeight(); +    LLTexture* texture = image->getImage(); + +    /* +    * Scale  texture coordinate system +    * to handle the different between image size and size of texture. +    */ +    F32 uv[][2] = +    { +        { (F32)width / texture->getWidth(), (F32)height / texture->getHeight() }, +        { 0.f, (F32)height / texture->getHeight() }, +        { 0.f, 0.f }, +        { (F32)width / texture->getWidth(), 0.f } +    }; + +    gGL.getTexUnit(0)->bind(texture); + +    gGL.color4fv(UI_VERTEX_COLOR.mV); + +    gGL.begin(LLRender::QUADS); +    { +        gGL.texCoord2fv(uv[(rotations + 0) % 4]); +        gGL.vertex2i(width, height); + +        gGL.texCoord2fv(uv[(rotations + 1) % 4]); +        gGL.vertex2i(0, height); + +        gGL.texCoord2fv(uv[(rotations + 2) % 4]); +        gGL.vertex2i(0, 0); + +        gGL.texCoord2fv(uv[(rotations + 3) % 4]); +        gGL.vertex2i(width, 0); +    } +    gGL.end(); +} + + + diff --git a/indra/newview/lljoystickbutton.h b/indra/newview/lljoystickbutton.h index 4e6c774cad..ae8de1bf32 100644 --- a/indra/newview/lljoystickbutton.h +++ b/indra/newview/lljoystickbutton.h @@ -178,4 +178,35 @@ public:  	virtual void	onHeldDown();  }; +//  +class LLJoystickQuaternion : +    public LLJoystick +{ +public: +    struct Params : +        public LLInitParam::Block<Params, LLJoystick::Params> +    { +        Params(); +    }; + +    LLJoystickQuaternion(const LLJoystickQuaternion::Params &); + +    virtual void	setToggleState(BOOL left, BOOL top, BOOL right, BOOL bottom); + +    virtual BOOL	handleMouseDown(S32 x, S32 y, MASK mask); +    virtual BOOL	handleMouseUp(S32 x, S32 y, MASK mask); +    virtual void	onHeldDown(); +    virtual void	draw(); + +protected: +    F32				getOrbitRate(); +    virtual void	updateSlop(); +    void			drawRotatedImage(LLPointer<LLUIImage> image, S32 rotations); + +    BOOL			mInLeft; +    BOOL			mInTop; +    BOOL			mInRight; +    BOOL			mInBottom; +}; +  #endif  // LL_LLJOYSTICKBUTTON_H diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index 898cdad7be..c91d4e59ce 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -47,8 +47,8 @@ namespace      const LLVector3 VECT_ZENITH(0.f, 1.f, 0.f);      const LLVector3 VECT_NORTHSOUTH(1.f, 0.f, 0.f); -    LLTrace::BlockTimerStatHandle FTM_BLEND_ENVIRONMENT("Blending Environment Params"); -    LLTrace::BlockTimerStatHandle FTM_UPDATE_ENVIRONMENT("Update Environment Params"); +    LLTrace::BlockTimerStatHandle FTM_BLEND_SKYVALUES("Blending Sky Environment"); +    LLTrace::BlockTimerStatHandle FTM_UPDATE_SKYVALUES("Update Sky Environment");      LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude);      void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude); @@ -266,8 +266,7 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam      }      LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsSky>(newsettings); -    skyp->update(); - +       return skyp;      } @@ -293,11 +292,11 @@ LLSettingsSky::ptr_t LLSettingsSky::buildClone()  LLSettingsSky::ptr_t LLSettingsSky::blend(const LLSettingsSky::ptr_t &other, F32 mix) const  { -    LL_RECORD_BLOCK_TIME(FTM_BLEND_ENVIRONMENT); +    LL_RECORD_BLOCK_TIME(FTM_BLEND_SKYVALUES);      LL_INFOS("WINDLIGHT", "SKY", "EEP") << "Blending new sky settings object." << LL_ENDL;      LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsSky>(mSettings); -    // the settings in the initial constructor are references tho this' settings block.   +    // the settings in the initial constructor are references to this' settings block.        // They will be replaced in the following lerp      skyp->lerpSettings(*other, mix); @@ -329,7 +328,7 @@ LLSD LLSettingsSky::defaults()      dfltsetting[SETTING_DOME_OFFSET]        = LLSD::Real(0.96f);      dfltsetting[SETTING_DOME_RADIUS]        = LLSD::Real(15000.f);      dfltsetting[SETTING_GAMMA]              = LLSD::Real(1.0); -    dfltsetting[SETTING_GLOW]               = LLColor4(5.000, 0.0010, -0.4799, 1.0).getValue();   // *RIDER: This is really weird for a color... TODO: check if right. +    dfltsetting[SETTING_GLOW]               = LLColor4(5.000, 0.0010, -0.4799, 1.0).getValue();      dfltsetting[SETTING_HAZE_DENSITY]       = LLSD::Real(0.6999);      dfltsetting[SETTING_HAZE_HORIZON]       = LLSD::Real(0.1899);      dfltsetting[SETTING_LIGHT_NORMAL]       = LLVector4(0.0000, 0.9126, -0.4086, 0.0000).getValue(); @@ -350,7 +349,7 @@ LLSD LLSettingsSky::defaults()  void LLSettingsSky::updateSettings()  { -    LL_RECORD_BLOCK_TIME(FTM_UPDATE_ENVIRONMENT); +    LL_RECORD_BLOCK_TIME(FTM_UPDATE_SKYVALUES);      LL_INFOS("WINDLIGHT", "SKY", "EEP") << "WL Parameters are dirty.  Reticulating Splines..." << LL_ENDL;      // base class clears dirty flag so as to not trigger recursive update diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h index 012244d1f9..8052651030 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -62,10 +62,6 @@ public:      static const std::string SETTING_SUN_ROTATION;      static const std::string SETTING_SUN_TEXUTUREID; -    static const std::string SETTING_LEGACY_EAST_ANGLE; -    static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; -    static const std::string SETTING_LEGACY_SUN_ANGLE; -      typedef boost::shared_ptr<LLSettingsSky> ptr_t;      typedef std::pair<F32, F32> azimalt_t; @@ -428,6 +424,10 @@ protected:  private: +    static const std::string SETTING_LEGACY_EAST_ANGLE; +    static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; +    static const std::string SETTING_LEGACY_SUN_ANGLE; +      void        calculateHeavnlyBodyPositions();      void        calculateLightSettings(); diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp new file mode 100644 index 0000000000..7efa89e6f1 --- /dev/null +++ b/indra/newview/llsettingswater.cpp @@ -0,0 +1,268 @@ +/** +* @file llsettingswater.h +* @author optional +* @brief A base class for asset based settings groups. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" +#include "llviewercontrol.h" +#include "llsettingswater.h" +#include <algorithm> +#include <boost/make_shared.hpp> +#include "lltrace.h" +#include "llfasttimer.h" +#include "v3colorutil.h" + +#include "llglslshader.h" +#include "llviewershadermgr.h" + +#include "llenvironment.h" + +#include "llagent.h" +#include "pipeline.h" + +//========================================================================= +namespace +{ +    LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment"); +    LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment"); + +    LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude); +    void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude); +} + +//========================================================================= +const std::string LLSettingsWater::SETTING_BLUR_MULTIPILER("blur_multiplier"); +const std::string LLSettingsWater::SETTING_FOG_COLOR("water_fog_color"); +const std::string LLSettingsWater::SETTING_FOG_DENSITY("water_fog_density"); +const std::string LLSettingsWater::SETTING_FOG_MOD("underwater_fog_mod"); +const std::string LLSettingsWater::SETTING_FRESNEL_OFFSET("fresnel_offset"); +const std::string LLSettingsWater::SETTING_FRESNEL_SCALE("fresnel_scale"); +const std::string LLSettingsWater::SETTING_NAME("name"); +const std::string LLSettingsWater::SETTING_NORMAL_MAP("normal_map"); +const std::string LLSettingsWater::SETTING_NORMAL_SCALE("normal_scale"); +const std::string LLSettingsWater::SETTING_SCALE_ABOVE("scale_above"); +const std::string LLSettingsWater::SETTING_SCALE_BELOW("scale_below"); +const std::string LLSettingsWater::SETTING_WAVE1_DIR("wave1_direction"); +const std::string LLSettingsWater::SETTING_WAVE2_DIR("wave2_direction"); + +const std::string LLSettingsWater::SETTING_LEGACY_BLUR_MULTIPILER("blurMultiplier"); +const std::string LLSettingsWater::SETTING_LEGACY_FOG_COLOR("waterFogColor"); +const std::string LLSettingsWater::SETTING_LEGACY_FOG_DENSITY("waterFogDensity"); +const std::string LLSettingsWater::SETTING_LEGACY_FOG_MOD("underWaterFogMod"); +const std::string LLSettingsWater::SETTING_LEGACY_FRESNEL_OFFSET("fresnelOffset"); +const std::string LLSettingsWater::SETTING_LEGACY_FRESNEL_SCALE("fresnelScale"); +const std::string LLSettingsWater::SETTING_LEGACY_NORMAL_MAP("normalMap"); +const std::string LLSettingsWater::SETTING_LEGACY_NORMAL_SCALE("normScale"); +const std::string LLSettingsWater::SETTING_LEGACY_SCALE_ABOVE("scaleAbove"); +const std::string LLSettingsWater::SETTING_LEGACY_SCALE_BELOW("scaleBelow"); +const std::string LLSettingsWater::SETTING_LEGACY_WAVE1_DIR("wave1Dir"); +const std::string LLSettingsWater::SETTING_LEGACY_WAVE2_DIR("wave2Dir"); + +const F32 LLSettingsWater::WATER_FOG_LIGHT_CLAMP(0.3f); + +const LLUUID LLSettingsWater::DEFAULT_WATER_NORMAL_ID(DEFAULT_WATER_NORMAL); + + +//========================================================================= +LLSettingsWater::LLSettingsWater(const LLSD &data) : +    LLSettingsBase(data) +{ +} + +LLSettingsWater::LLSettingsWater() : +    LLSettingsBase() +{ +} + +//========================================================================= +LLSD LLSettingsWater::defaults() +{ +    LLSD dfltsetting; + +    // Magic constants copied form defaults.xml  +    dfltsetting[SETTING_BLUR_MULTIPILER] = LLSD::Real(0.04000f); +    dfltsetting[SETTING_FOG_COLOR] = LLColor3(0.0156f, 0.1490f, 0.2509f).getValue(); +    dfltsetting[SETTING_FOG_DENSITY] = LLSD::Real(2.0f); +    dfltsetting[SETTING_FOG_MOD] = LLSD::Real(0.25f); +    dfltsetting[SETTING_FRESNEL_OFFSET] = LLSD::Real(0.5f); +    dfltsetting[SETTING_FRESNEL_SCALE] = LLSD::Real(0.3999); +    dfltsetting[SETTING_NORMAL_MAP] = LLSD::UUID(DEFAULT_WATER_NORMAL_ID); +    dfltsetting[SETTING_NORMAL_SCALE] = LLVector3(2.0f, 2.0f, 2.0f).getValue(); +    dfltsetting[SETTING_SCALE_ABOVE] = LLSD::Real(0.0299f); +    dfltsetting[SETTING_SCALE_BELOW] = LLSD::Real(0.2000f); +    dfltsetting[SETTING_WAVE1_DIR] = LLVector2(1.04999f, -0.42000f).getValue(); +    dfltsetting[SETTING_WAVE2_DIR] = LLVector2(1.10999f, -1.16000f).getValue(); + +    return dfltsetting; +} + + +LLSettingsWater::ptr_t LLSettingsWater::buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings) +{ +    LLSD newsettings(defaults()); + +    newsettings[SETTING_NAME] = name; + + +    if (oldsettings.has(SETTING_LEGACY_BLUR_MULTIPILER)) +    { +        newsettings[SETTING_BLUR_MULTIPILER] = LLSD::Real(oldsettings[SETTING_LEGACY_BLUR_MULTIPILER].asReal()); +    } +    if (oldsettings.has(SETTING_LEGACY_FOG_COLOR)) +    { +        newsettings[SETTING_FOG_COLOR] = LLColor3(oldsettings[SETTING_LEGACY_FOG_COLOR]).getValue(); +    } +    if (oldsettings.has(SETTING_LEGACY_FOG_DENSITY)) +    { +        newsettings[SETTING_FOG_DENSITY] = LLSD::Real(oldsettings[SETTING_LEGACY_FOG_DENSITY]); +    } +    if (oldsettings.has(SETTING_LEGACY_FOG_MOD)) +    { +        newsettings[SETTING_FOG_MOD] = LLSD::Real(oldsettings[SETTING_LEGACY_FOG_MOD].asReal()); +    } +    if (oldsettings.has(SETTING_LEGACY_FRESNEL_OFFSET)) +    { +        newsettings[SETTING_FRESNEL_OFFSET] = LLSD::Real(oldsettings[SETTING_LEGACY_FRESNEL_OFFSET].asReal()); +    } +    if (oldsettings.has(SETTING_LEGACY_FRESNEL_SCALE)) +    { +        newsettings[SETTING_FRESNEL_SCALE] = LLSD::Real(oldsettings[SETTING_LEGACY_FRESNEL_SCALE].asReal()); +    } +    if (oldsettings.has(SETTING_LEGACY_NORMAL_MAP)) +    { +        newsettings[SETTING_NORMAL_MAP] = LLSD::UUID(oldsettings[SETTING_LEGACY_NORMAL_MAP].asUUID()); +    } +    if (oldsettings.has(SETTING_LEGACY_NORMAL_SCALE)) +    { +        newsettings[SETTING_NORMAL_SCALE] = LLVector3(oldsettings[SETTING_LEGACY_NORMAL_SCALE]).getValue(); +    } +    if (oldsettings.has(SETTING_LEGACY_SCALE_ABOVE)) +    { +        newsettings[SETTING_SCALE_ABOVE] = LLSD::Real(oldsettings[SETTING_LEGACY_SCALE_ABOVE].asReal()); +    } +    if (oldsettings.has(SETTING_LEGACY_SCALE_BELOW)) +    { +        newsettings[SETTING_SCALE_BELOW] = LLSD::Real(oldsettings[SETTING_LEGACY_SCALE_BELOW].asReal()); +    } +    if (oldsettings.has(SETTING_LEGACY_WAVE1_DIR)) +    { +        newsettings[SETTING_WAVE1_DIR] = LLVector2(oldsettings[SETTING_LEGACY_WAVE1_DIR]).getValue(); +    } +    if (oldsettings.has(SETTING_LEGACY_WAVE2_DIR)) +    { +        newsettings[SETTING_WAVE2_DIR] = LLVector2(oldsettings[SETTING_LEGACY_WAVE2_DIR]).getValue(); +    } + +    LLSettingsWater::ptr_t waterp = boost::make_shared<LLSettingsWater>(newsettings); + +    return waterp; +} + +LLSettingsWater::ptr_t LLSettingsWater::buildDefaultWater() +{ +    LLSD settings = LLSettingsWater::defaults(); + +    LLSettingsWater::ptr_t skyp = boost::make_shared<LLSettingsWater>(settings); + +    return skyp; +} + +LLSettingsWater::ptr_t LLSettingsWater::buildClone() +{ +    LLSD settings = cloneSettings(); + +    LLSettingsWater::ptr_t skyp = boost::make_shared<LLSettingsWater>(settings); + +    return skyp; +} + +//========================================================================= + +LLSettingsWater::parammapping_t LLSettingsWater::getParameterMap() const +{ +    static parammapping_t param_map; + +    if (param_map.empty()) +    { +        param_map[SETTING_FOG_COLOR] = LLShaderMgr::WATER_FOGCOLOR; +        param_map[SETTING_FOG_DENSITY] = LLShaderMgr::WATER_FOGDENSITY; + + +    } +    return param_map; +} + +void LLSettingsWater::applySpecial(void *ptarget) +{ +    LLGLSLShader *shader = (LLGLSLShader *)ptarget; + +    shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, getWaterPlane().mV); +    shader->uniform1f(LLShaderMgr::WATER_FOGKS, getWaterFogKS()); + +    shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLight().mV); +    shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); +    shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); + + +} + +//========================================================================= +void LLSettingsWater::updateSettings() +{ +    LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERVALUES); +    LL_INFOS("WINDLIGHT", "WATER", "EEP") << "Water Parameters are dirty.  Reticulating Splines..." << LL_ENDL; + +    // base class clears dirty flag so as to not trigger recursive update +    LLSettingsBase::updateSettings(); + +    // only do this if we're dealing with shaders +    if (gPipeline.canUseVertexShaders()) +    { +        //transform water plane to eye space +        glh::vec3f norm(0.f, 0.f, 1.f); +        glh::vec3f p(0.f, 0.f, LLEnvironment::instance().getWaterHeight() + 0.1f); + +        F32 modelView[16]; +        for (U32 i = 0; i < 16; i++) +        { +            modelView[i] = (F32)gGLModelView[i]; +        } + +        glh::matrix4f mat(modelView); +        glh::matrix4f invtrans = mat.inverse().transpose(); +        glh::vec3f enorm; +        glh::vec3f ep; +        invtrans.mult_matrix_vec(norm, enorm); +        enorm.normalize(); +        mat.mult_matrix_vec(p, ep); + +        mWaterPlane = LLVector4(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); + +        LLVector4 light_direction = LLEnvironment::instance().getLightDirection(); + +        mWaterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); +    } + +} diff --git a/indra/newview/llsettingswater.h b/indra/newview/llsettingswater.h new file mode 100644 index 0000000000..d8c9ff5cc6 --- /dev/null +++ b/indra/newview/llsettingswater.h @@ -0,0 +1,234 @@ +/** +* @file llsettingssky.h +* @author optional +* @brief A base class for asset based settings groups. +* +* $LicenseInfo:2011&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2017, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA +* $/LicenseInfo$ +*/ + +#ifndef LL_SETTINGS_WATER_H +#define LL_SETTINGS_WATER_H + +#include "llsettingsbase.h" + +class LLSettingsWater : public LLSettingsBase +{ +public: +    static const std::string SETTING_BLUR_MULTIPILER; +    static const std::string SETTING_FOG_COLOR; +    static const std::string SETTING_FOG_DENSITY; +    static const std::string SETTING_FOG_MOD; +    static const std::string SETTING_FRESNEL_OFFSET; +    static const std::string SETTING_FRESNEL_SCALE; +    static const std::string SETTING_NAME; +    static const std::string SETTING_NORMAL_MAP; +    static const std::string SETTING_NORMAL_SCALE; +    static const std::string SETTING_SCALE_ABOVE; +    static const std::string SETTING_SCALE_BELOW; +    static const std::string SETTING_WAVE1_DIR; +    static const std::string SETTING_WAVE2_DIR; + +    static const LLUUID DEFAULT_WATER_NORMAL_ID; + +    typedef boost::shared_ptr<LLSettingsWater> ptr_t; + +    //--------------------------------------------------------------------- +    LLSettingsWater(const LLSD &data); +    virtual ~LLSettingsWater() { }; + +    static ptr_t    buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); +    static ptr_t    buildDefaultWater(); +    ptr_t           buildClone(); + +    //--------------------------------------------------------------------- +    virtual std::string getSettingType() const { return std::string("water"); } + +    // Settings status  +    ptr_t blend(const ptr_t &other, F32 mix) const; + +    static LLSD defaults(); + +    //--------------------------------------------------------------------- +    F32 getBlurMultiplier() const +    {    +        return mSettings[SETTING_BLUR_MULTIPILER].asReal(); +    } + +    void setBlurMultiplier(F32 val) +    { +        setValue(SETTING_BLUR_MULTIPILER, val); +    } + +    LLColor3 getFogColor() const +    { +        return LLColor3(mSettings[SETTING_FOG_COLOR]); +    } + +    void setFogColor(LLColor3 val) +    { +        setValue(SETTING_FOG_COLOR, val); +    } + +    F32 getFogDensity() const +    { +        return mSettings[SETTING_FOG_DENSITY].asReal(); +    } + +    void setFogDensity(F32 val) +    { +        setValue(SETTING_FOG_DENSITY, val); +    } + +    F32 getFogMod() const +    { +        return mSettings[SETTING_FOG_MOD].asReal(); +    } + +    void setFogMod(F32 val) +    { +        setValue(SETTING_FOG_MOD, val); +    } + +    F32 getFresnelOffset() const +    { +        return mSettings[SETTING_FRESNEL_OFFSET].asReal(); +    } + +    void setFresnelOffset(F32 val) +    { +        setValue(SETTING_FRESNEL_OFFSET, val); +    } + +    F32 getFresnelScale() const +    { +        return mSettings[SETTING_FRESNEL_SCALE].asReal(); +    } + +    void setFresnelScale(F32 val) +    { +        setValue(SETTING_FRESNEL_SCALE, val); +    } + +    LLUUID getNormalMapID() const +    { +        return mSettings[SETTING_NORMAL_MAP].asUUID(); +    } + +    void setNormalMapID(LLUUID val) +    { +        setValue(SETTING_NORMAL_MAP, val); +    } + +    LLVector3 getNormalScale() const +    { +        return LLVector3(mSettings[SETTING_NORMAL_SCALE]); +    } + +    void setNormalScale(LLVector3 val) +    { +        setValue(SETTING_NORMAL_SCALE, val); +    } + +    F32 getScaleAbove() const +    { +        return mSettings[SETTING_SCALE_ABOVE].asReal(); +    } + +    void setScaleAbove(F32 val) +    { +        setValue(SETTING_SCALE_ABOVE, val); +    } + +    F32 getScaleBelow() const +    { +        return mSettings[SETTING_SCALE_BELOW].asReal(); +    } + +    void setScaleBelow(F32 val) +    { +        setValue(SETTING_SCALE_BELOW, val); +    } + +    LLVector2 getWave1Dir() const +    { +        return LLVector2(mSettings[SETTING_WAVE1_DIR]); +    } + +    void setWave1Dir(LLVector2 val) +    { +        setValue(SETTING_WAVE1_DIR, val); +    } + +    LLVector2 getWave2Dir() const +    { +        return LLVector2(mSettings[SETTING_WAVE2_DIR]); +    } + +    void setWave2Dir(LLVector2 val) +    { +        setValue(SETTING_WAVE2_DIR, val); +    } + +    //------------------------------------------- +    LLVector4 getWaterPlane() const +    { +        update(); +        return mWaterPlane; +    } + +    F32 getWaterFogKS() const +    { +        update(); +        return mWaterFogKS; +    } + +protected: +    LLSettingsWater(); + +    virtual void        updateSettings(); + +    virtual parammapping_t getParameterMap() const; + +    virtual void        applySpecial(void *); + + +private: +    static const std::string SETTING_LEGACY_BLUR_MULTIPILER; +    static const std::string SETTING_LEGACY_FOG_COLOR; +    static const std::string SETTING_LEGACY_FOG_DENSITY; +    static const std::string SETTING_LEGACY_FOG_MOD; +    static const std::string SETTING_LEGACY_FRESNEL_OFFSET; +    static const std::string SETTING_LEGACY_FRESNEL_SCALE; +    static const std::string SETTING_LEGACY_NORMAL_MAP; +    static const std::string SETTING_LEGACY_NORMAL_SCALE; +    static const std::string SETTING_LEGACY_SCALE_ABOVE; +    static const std::string SETTING_LEGACY_SCALE_BELOW; +    static const std::string SETTING_LEGACY_WAVE1_DIR; +    static const std::string SETTING_LEGACY_WAVE2_DIR; + +    static const F32    WATER_FOG_LIGHT_CLAMP; + +    LLVector4           mWaterPlane; +    F32                 mWaterFogKS; +}; + +#endif diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 485b88e4c7..e50a4a0b5d 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -180,7 +180,6 @@  #include "llnamebox.h"  #include "llnameeditor.h"  #include "llpostprocess.h" -#include "llwlparammanager.h"  #include "llwaterparammanager.h"  #include "llagentlanguage.h"  #include "llwearable.h" @@ -197,6 +196,9 @@  #include "llexperiencelog.h"  #include "llcleanup.h" +#include "llenvironment.h" +#include "llenvmanager.h" +  #include "llstacktrace.h"  #if LL_WINDOWS @@ -1461,7 +1463,7 @@ bool idle_startup()  		LLGLState::checkStates();  		LLGLState::checkTextureChannels(); -		LLEnvManagerNew::getInstance()->usePrefs(); // Load all presets and settings +        LLEnvironment::instance().loadPreferences();  		gSky.init(initial_sun_direction);  		LLGLState::checkStates(); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index dcf42a201b..f25471d4f0 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -74,7 +74,6 @@  #include "llviewerregion.h"  #include "lldrawpoolwater.h"  #include "lldrawpoolbump.h" -#include "llwlparammanager.h"  #include "llwaterparammanager.h"  #include "llpostprocess.h"  #include "llscenemonitor.h" @@ -203,7 +202,6 @@ void display_update_camera()  	// update all the sky/atmospheric/water settings      LLEnvironment::instance().update(LLViewerCamera::getInstance()); -	LLWaterParamManager::getInstance()->update(LLViewerCamera::getInstance());  	// Update land visibility too  	LLWorld::getInstance()->setLandFarClip(final_far); @@ -920,7 +918,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)  				gPipeline.mScreen.bindTarget();  				if (LLPipeline::sUnderWaterRender && !gPipeline.canUseWindLightShaders())  				{ -					const LLColor4 &col = LLDrawPoolWater::sWaterFogColor; +					const LLColor4 &col = LLEnvironment::instance().getCurrentWater()->getFogColor();  					glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f);  				}  				gPipeline.mScreen.clear(); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 683ff7558a..f0924486df 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -3430,7 +3430,6 @@ std::string LLViewerShaderMgr::getShaderDirPrefix(void)  void LLViewerShaderMgr::updateShaderUniforms(LLGLSLShader * shader)  {      LLEnvironment::instance().updateShaderUniforms(shader); -	LLWaterParamManager::getInstance()->updateShaderUniforms(shader);  }  LLViewerShaderMgr::shader_iter LLViewerShaderMgr::beginShaders() const diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 93ca7945ba..20afc7a41d 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -48,7 +48,6 @@  #include "llworld.h"  #include "pipeline.h"  #include "lldrawpoolwlsky.h" -#include "llwlparammanager.h"  #include "llwaterparammanager.h"  #include "v3colorutil.h" @@ -1952,11 +1951,12 @@ void LLVOSky::updateFog(const F32 distance)  	}  	else  	{ +        LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater();  		F32 depth = water_height - camera_height;  		// get the water param manager variables -		float water_fog_density = LLWaterParamManager::getInstance()->getFogDensity(); -		LLColor4 water_fog_color(LLDrawPoolWater::sWaterFogColor.mV); +        float water_fog_density = pwater->getFogDensity(); +		LLColor4 water_fog_color(pwater->getFogColor());  		// adjust the color based on depth.  We're doing linear approximations  		float depth_scale = gSavedSettings.getF32("WaterGLFogDepthScale"); diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 6d1bb43258..eb21f3c4b4 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -58,17 +58,17 @@  #include "curl/curl.h"  LLWaterParamManager::LLWaterParamManager() : -	mFogColor(22.f/255.f, 43.f/255.f, 54.f/255.f, 0.0f, 0.0f, "waterFogColor", "WaterFogColor"), -	mFogDensity(4, "waterFogDensity", 2), -	mUnderWaterFogMod(0.25, "underWaterFogMod"), -	mNormalScale(2.f, 2.f, 2.f, "normScale"), -	mFresnelScale(0.5f, "fresnelScale"), -	mFresnelOffset(0.4f, "fresnelOffset"), -	mScaleAbove(0.025f, "scaleAbove"), -	mScaleBelow(0.2f, "scaleBelow"), -	mBlurMultiplier(0.1f, "blurMultiplier"), -	mWave1Dir(.5f, .5f, "wave1Dir"), -	mWave2Dir(.5f, .5f, "wave2Dir"), +// 	mFogColor(22.f/255.f, 43.f/255.f, 54.f/255.f, 0.0f, 0.0f, "waterFogColor", "WaterFogColor"), +// 	mFogDensity(4, "waterFogDensity", 2), +// 	mUnderWaterFogMod(0.25, "underWaterFogMod"), +// 	mNormalScale(2.f, 2.f, 2.f, "normScale"), +// 	mFresnelScale(0.5f, "fresnelScale"), +// 	mFresnelOffset(0.4f, "fresnelOffset"), +// 	mScaleAbove(0.025f, "scaleAbove"), +// 	mScaleBelow(0.2f, "scaleBelow"), +// 	mBlurMultiplier(0.1f, "blurMultiplier"), +// 	mWave1Dir(.5f, .5f, "wave1Dir"), +// 	mWave2Dir(.5f, .5f, "wave2Dir"),  	mDensitySliderValue(1.0f),  	mWaterFogKS(1.0f)  { @@ -135,6 +135,10 @@ bool LLWaterParamManager::loadPreset(const std::string& path)  		addParamSet(name, params_data);  	} +    //*LAPRAS temp code testing conversion old preset to new settings. +    LLSettingsWater::ptr_t test = LLSettingsWater::buildFromLegacyPreset(name, params_data); +    LLEnvironment::instance().addWater(test); +  	return true;  } @@ -175,16 +179,19 @@ void LLWaterParamManager::propagateParameters(void)  		}  	} -	bool err; -	F32 fog_density_slider =  +#if 0 +    bool err; +    F32 fog_density_slider =   		log(mCurParams.getFloat(mFogDensity.mName, err)) /   		log(mFogDensity.mBase);  	setDensitySliderValue(fog_density_slider); +#endif  }  void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader)  { +#if 0  	if (shader->mShaderGroup == LLGLSLShader::SG_WATER)  	{  		shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLight().mV); @@ -195,6 +202,7 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader)  		shader->uniform1f(LLShaderMgr::WATER_FOGKS, mWaterFogKS);  		shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0);  	} +#endif  }  void LLWaterParamManager::applyParams(const LLSD& params, bool interpolate) diff --git a/indra/newview/llwaterparammanager.h b/indra/newview/llwaterparammanager.h index 3f169e439a..392e287e3f 100644 --- a/indra/newview/llwaterparammanager.h +++ b/indra/newview/llwaterparammanager.h @@ -34,7 +34,7 @@  #include "v4color.h"  const F32 WATER_FOG_LIGHT_CLAMP = 0.3f; - +#if 0  // color control  struct WaterColorControl { @@ -209,7 +209,7 @@ struct WaterExpFloatControl  		params.set(mName, pow(mBase, mExp));  	}  }; - +#endif  /// WindLight parameter manager class - what controls all the wind light shaders  class LLWaterParamManager : public LLSingleton<LLWaterParamManager> @@ -298,7 +298,7 @@ public:  public:  	LLWaterParamSet mCurParams; - +#if 0  	/// Atmospherics  	WaterColorControl mFogColor;  	WaterExpFloatControl mFogDensity; @@ -315,8 +315,8 @@ public:  	WaterFloatControl mScaleAbove;  	WaterFloatControl mScaleBelow;  	WaterFloatControl mBlurMultiplier; -	 -	F32 mDensitySliderValue; +#endif	 +    F32 mDensitySliderValue;  private:  	/*virtual*/ void initSingleton(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index fb2e27d492..e8338f3e8c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -115,6 +115,8 @@  #include "llprogressview.h"  #include "llcleanup.h" +#include "llenvironment.h" +  #ifdef _DEBUG  // Debug indices is disabled for now for debug performance - djs 4/24/02  //#define DEBUG_INDICES @@ -9949,7 +9951,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)  			gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); -			LLColor4& col = LLDrawPoolWater::sWaterFogColor; +			LLColor3 col = LLEnvironment::instance().getCurrentWater()->getFogColor();  			glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f);  			mWaterDis.bindTarget();  			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER1; | 
