From 52b0d4173cec0f643f37d426aef8f5ab1fdf3232 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 27 Sep 2017 09:36:26 -0700 Subject: No longer 'goth windlight only', sky parameters passed from settings object. --- indra/newview/llwaterparammanager.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'indra/newview/llwaterparammanager.cpp') diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index b484b6d709..689296a53a 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -52,7 +52,7 @@ #include "llagentcamera.h" #include "llviewerregion.h" -#include "llwlparammanager.h" +#include "llenvironment.h" #include "llwaterparamset.h" #include "curl/curl.h" @@ -187,8 +187,8 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) { if (shader->mShaderGroup == LLGLSLShader::SG_WATER) { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLWLParamManager::getInstance()->getRotatedLightDir().mV); -shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLightDir().mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, LLDrawPoolWater::sWaterFogColor.mV); shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, mWaterPlane.mV); shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, getFogDensity()); @@ -207,7 +207,9 @@ void LLWaterParamManager::applyParams(const LLSD& params, bool interpolate) if (interpolate) { - LLWLParamManager::getInstance()->mAnimator.startInterpolation(params); + // *LAPRAS + + //LLWLParamManager::getInstance()->mAnimator.startInterpolation(params); } else { -- cgit v1.3 From 23916be3dac32beebb17e0b9336b34176265783d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 29 Sep 2017 16:46:39 -0700 Subject: Moon is showing, sun still not working. --- indra/newview/llenvironment.cpp | 28 +-- indra/newview/llenvironment.h | 7 +- indra/newview/llsettingssky.cpp | 34 ++- indra/newview/llsettingssky.h | 55 ++++- indra/newview/llvosky.cpp | 416 ++++++++++++++++++---------------- indra/newview/llvosky.h | 34 +-- indra/newview/llwaterparammanager.cpp | 2 +- 7 files changed, 314 insertions(+), 262 deletions(-) (limited to 'indra/newview/llwaterparammanager.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index ceba7fda88..4192da450e 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -85,7 +85,7 @@ void LLEnvironment::update(const LLViewerCamera * cam) // mAnimator.update(mCurParams); // } - LLVector3 lightdir = mCurrentSky->getLightDirection(); + //LLVector3 lightdir = mCurrentSky->getLightDirection(); // update the shaders and the menu F32 camYaw = cam->getYaw(); @@ -95,7 +95,7 @@ void LLEnvironment::update(const LLViewerCamera * cam) // *TODO: potential optimization - this block may only need to be // executed some of the time. For example for water shaders only. { - LLVector3 lightNorm3(mCurrentSky->getLightDirection()); + LLVector3 lightNorm3( getLightDirection() ); lightNorm3 *= LLQuaternion(-(camYaw + SUN_DELTA_YAW), LLVector3(0.f, 1.f, 0.f)); mRotatedLight = LLVector4(lightNorm3, 0.f); @@ -125,16 +125,6 @@ void LLEnvironment::updateCloudScroll() LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; mCloudScrollDelta += cloud_delta; -// { -// LLVector2 v2(mCurrentSky->getCloudScrollRate()); -// static F32 xoffset(0.f); -// static F32 yoffset(0.f); -// -// xoffset += F32(delta_t * (v2[0] - 10.f) / 100.f); -// yoffset += F32(delta_t * (v2[1] - 10.f) / 100.f); -// -// LL_WARNS("RIDER") << "offset " << mCloudScrollDelta << " vs (" << xoffset << ", " << yoffset << ")" << LL_ENDL; -// } } @@ -223,24 +213,12 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) { stop_glerror(); - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mCurrentSky->getLightDirectionClamped().mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, getClampedLightDirection().mV); stop_glerror(); } shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, getSceneLightStrength()); -// { -// LLVector4 cloud_scroll(mCloudScroll[0], mCloudScroll[1], 0.0, 0.0); -// // val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset; -// // val.mV[1] = F32(i->second[1].asReal()) + mCloudScrollYOffset; -// // val.mV[2] = (F32)i->second[2].asReal(); -// // val.mV[3] = (F32)i->second[3].asReal(); -// -// stop_glerror(); -// shader->uniform4fv(LLSettingsSky::SETTING_CLOUD_POS_DENSITY1, 1, cloud_scroll.mV); -// stop_glerror(); -// } - } //-------------------------------------------------------------------------- diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 0e8f39b4bf..a1bdf2c38c 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -48,8 +48,6 @@ public: void update(const LLViewerCamera * cam); - LLVector4 getRotatedLightDir() const { return mRotatedLight; } - void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); void updateShaderUniforms(LLGLSLShader *shader); @@ -63,6 +61,9 @@ public: inline F32 getSceneLightStrength() const { return mSceneLightStrength; } inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; } + inline LLVector4 getLightDirection() const { return LLVector4(mCurrentSky->getLightDirection(), 0.0f); } + inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); } + inline LLVector4 getRotatedLight() const { return mRotatedLight; } private: static const F32 SUN_DELTA_YAW; @@ -70,7 +71,6 @@ private: typedef std::map NamedSkyMap_t; typedef std::map AssetSkyMap_t; - LLVector4 mRotatedLight; LLVector2 mCloudScrollDelta; // cumulative cloud delta LLSettingsSky::ptr_t mCurrentSky; @@ -79,6 +79,7 @@ private: AssetSkyMap_t mSkysById; F32 mSceneLightStrength; + LLVector4 mRotatedLight; void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky); void removeSky(const std::string &name); diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index 191ca2d2ec..d4d9172a75 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -43,7 +43,7 @@ //========================================================================= namespace { - const LLVector3 DUE_EAST(-1.0f, 0.0f, 0.0); + const LLVector3 DUE_EAST(0.0f, 0.0f, 1.0); LLTrace::BlockTimerStatHandle FTM_BLEND_ENVIRONMENT("Blending Environment Params"); LLTrace::BlockTimerStatHandle FTM_UPDATE_ENVIRONMENT("Update Environment Params"); @@ -52,6 +52,8 @@ namespace } +const F32 LLSettingsSky::DOME_OFFSET(0.96f); +const F32 LLSettingsSky::DOME_RADIUS(15000.f); //========================================================================= const std::string LLSettingsSky::SETTING_AMBIENT("ambient"); @@ -226,7 +228,7 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam F32 altitude = oldsettings[SETTING_LEGACY_SUN_ANGLE].asReal(); LLQuaternion sunquat = ::body_position_from_angles(azimuth, altitude); - LLQuaternion moonquat = ~sunquat; + LLQuaternion moonquat = ::body_position_from_angles(azimuth + F_PI, -altitude); newsettings[SETTING_SUN_ROTATION] = sunquat.getValue(); newsettings[SETTING_MOON_ROTATION] = moonquat.getValue(); @@ -302,8 +304,8 @@ LLSD LLSettingsSky::defaults() dfltsetting[SETTING_BLOOM_TEXTUREID] = LLUUID::null; dfltsetting[SETTING_CLOUD_TEXTUREID] = LLUUID::null; - dfltsetting[SETTING_MOON_TEXTUREID] = IMG_SUN; // gMoonTextureID; // These two are returned by the login... wow! - dfltsetting[SETTING_SUN_TEXUTUREID] = IMG_MOON; // gSunTextureID; + dfltsetting[SETTING_MOON_TEXTUREID] = IMG_MOON; // gMoonTextureID; // These two are returned by the login... wow! + dfltsetting[SETTING_SUN_TEXUTUREID] = IMG_SUN; // gSunTextureID; return dfltsetting; } @@ -327,6 +329,12 @@ void LLSettingsSky::calculateHeavnlyBodyPositions() mMoonDirection = DUE_EAST * getMoonRotation(); mMoonDirection.normalize(); + { // set direction (in CRF) and don't allow overriding + LLVector3 crf_sunDirection(mSunDirection.mV[2], mSunDirection.mV[0], mSunDirection.mV[1]); + + gSky.setSunDirection(crf_sunDirection, LLVector3(0, 0, 0)); + gSky.setOverrideSun(TRUE); + } // is the normal from the sun or the moon if (mSunDirection.mV[1] >= 0.0) @@ -338,7 +346,7 @@ void LLSettingsSky::calculateHeavnlyBodyPositions() // clamp v1 to 0 so sun never points up and causes weirdness on some machines LLVector3 vec(mSunDirection); vec.mV[1] = 0.0; - vec.normVec(); + vec.normalize(); mLightDirection = vec; } else @@ -348,16 +356,18 @@ void LLSettingsSky::calculateHeavnlyBodyPositions() // calculate the clamp lightnorm for sky (to prevent ugly banding in sky // when haze goes below the horizon - mLightDirectionClamped = mSunDirection; + mClampedLightDirection = mLightDirection; - if (mLightDirectionClamped.mV[1] < -0.1f) + if (mClampedLightDirection.mV[1] < -0.1f) { - mLightDirectionClamped.mV[1] = -0.1f; + mClampedLightDirection.mV[1] = -0.1f; + mClampedLightDirection.normalize(); } } void LLSettingsSky::calculateLightSettings() { +#if 0 LLColor3 vary_HazeColor; LLColor3 vary_SunlightColor; LLColor3 vary_AmbientColor; @@ -461,7 +471,7 @@ void LLSettingsSky::calculateLightSettings() mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; mFadeColor.setAlpha(1); - +#endif } LLSettingsSky::parammapping_t LLSettingsSky::getParameterMap() const @@ -495,7 +505,7 @@ void LLSettingsSky::applySpecial(void *ptarget) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mLightDirectionClamped.mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mClampedLightDirection.mV); shader->uniform4f(LLShaderMgr::GAMMA, getGama(), 0.0, 0.0, 1.0); @@ -529,8 +539,8 @@ namespace { LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude) { - static const LLVector3 VECT_ZENITH(0.f, 0.f, 1.f); - static const LLVector3 VECT_NORTHSOUTH(0.f, 1.f, 0.f); + static const LLVector3 VECT_ZENITH(0.f, 1.f, 0.f); + static const LLVector3 VECT_NORTHSOUTH(1.f, 0.f, 0.f); // Azimuth is traditionally calculated from North, we are going from East. LLQuaternion rot_azi; diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h index f6d1087442..0274661643 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -151,12 +151,14 @@ public: F32 getDomeOffset() const { - return mSettings[SETTING_DOME_OFFSET].asReal(); + return DOME_OFFSET; + //return mSettings[SETTING_DOME_OFFSET].asReal(); } F32 getDomeRadius() const { - return mSettings[SETTING_DOME_RADIUS].asReal(); + return DOME_RADIUS; + //return mSettings[SETTING_DOME_RADIUS].asReal(); } F32 getGama() const @@ -219,7 +221,6 @@ public: return mSettings[SETTING_SUN_TEXUTUREID].asUUID(); } - // Internal/calculated settings LLVector3 getLightDirection() const { @@ -227,6 +228,32 @@ public: return mLightDirection; }; + LLVector3 getClampedLightDirection() const + { + update(); + return mClampedLightDirection; + }; + + LLVector3 getSunDirection() const + { + update(); + return mSunDirection; + } + + LLVector3 getMoonDirection() const + { + update(); + return mMoonDirection; + } + + +#if 0 + LLVector3 getLightDirection() const + { + update(); + return mLightDirection; + }; + LLVector3 getLightDirectionClamped() const { update(); @@ -280,6 +307,7 @@ public: update(); return mFadeColor; } +#endif protected: LLSettingsSky(); @@ -299,15 +327,18 @@ private: LLVector3 mSunDirection; LLVector3 mMoonDirection; LLVector3 mLightDirection; - LLVector3 mLightDirectionClamped; - - LLColor3 mSunDiffuse; - LLColor3 mSunAmbient; - LLColor3 mMoonDiffuse; - LLColor3 mMoonAmbient; - - LLColor4 mTotalAmbient; - LLColor4 mFadeColor; + LLVector3 mClampedLightDirection; + + static const F32 DOME_RADIUS; + static const F32 DOME_OFFSET; + +// LLColor3 mSunDiffuse; +// LLColor3 mSunAmbient; +// LLColor3 mMoonDiffuse; +// LLColor3 mMoonAmbient; +// +// LLColor4 mTotalAmbient; +// LLColor4 mFadeColor; typedef std::map mapNameToUniformId_t; diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index dc6e6e9e45..71abad79b6 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -331,24 +331,24 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mBumpSunDir(0.f, 0.f, 1.f) { /// WL PARAMS - dome_radius = 1.f; - dome_offset_ratio = 0.f; - sunlight_color = LLColor3(); - ambient = LLColor3(); - gamma = 1.f; - lightnorm = LLVector4(); - blue_density = LLColor3(); - blue_horizon = LLColor3(); - haze_density = 0.f; - haze_horizon = 1.f; - density_multiplier = 0.f; - max_y = 0.f; - glow = LLColor3(); - cloud_shadow = 0.f; - cloud_color = LLColor3(); - cloud_scale = 0.f; - cloud_pos_density1 = LLColor3(); - cloud_pos_density2 = LLColor3(); +// dome_radius = 1.f; +// dome_offset_ratio = 0.f; +// sunlight_color = LLColor3(); +// ambient = LLColor3(); +// gamma = 1.f; +// lightnorm = LLVector4(); +// blue_density = LLColor3(); +// blue_horizon = LLColor3(); +// haze_density = 0.f; +// haze_horizon = 1.f; +// density_multiplier = 0.f; +// max_y = 0.f; +// glow = LLColor3(); +// cloud_shadow = 0.f; +// cloud_color = LLColor3(); +// cloud_scale = 0.f; +// cloud_pos_density1 = LLColor3(); +// cloud_pos_density2 = LLColor3(); mInitialized = FALSE; mbCanSelect = FALSE; @@ -369,11 +369,12 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mEarthCenter = LLVector3(mCameraPosAgent.mV[0], mCameraPosAgent.mV[1], -EARTH_RADIUS); // *LAPRAS - mSunDefaultPosition = LLEnvironment::instance().getCurrentSky()->getLightNormal(); + mSunDefaultPosition = LLEnvironment::instance().getCurrentSky()->getSunDirection(); if (gSavedSettings.getBOOL("SkyOverrideSimSunPosition")) { - initSunDirection(mSunDefaultPosition, LLVector3(0, 0, 0)); + + initSunDirection(LLVector3(mSunDefaultPosition.mV[2], mSunDefaultPosition.mV[0], mSunDefaultPosition.mV[1]), LLVector3(0, 0, 0)); } mAmbientScale = gSavedSettings.getF32("SkyAmbientScale"); mNightColorShift = gSavedSettings.getColor3("SkyNightColorShift"); @@ -569,33 +570,35 @@ void LLVOSky::initAtmospherics(void) // *LAPRAS // uniform parameters for convenience - LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky(); - - dome_radius = sky->getDomeRadius(); - dome_offset_ratio = sky->getDomeOffset(); - sunlight_color = sky->getSunlightColor(); - ambient = sky->getAmbientColor(); - gamma = sky->getGama(); - blue_density = sky->getBlueDensity(); - blue_horizon = sky->getBlueHorizon(); - haze_density = sky->getHazeDensity(); - haze_horizon = sky->getHazeHorizon(); - density_multiplier = sky->getDensityMultiplier(); - max_y = sky->getMaxY(); - glow = sky->getGlow(); - cloud_shadow = sky->getCloudShadow(); - cloud_color = sky->getCloudColor(); - cloud_scale = sky->getCloudScale(); - cloud_pos_density1 = sky->getCloudPosDensity1(); - cloud_pos_density2 = sky->getCloudPosDensity2(); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + +// dome_radius = psky->getDomeRadius(); +// dome_offset_ratio = psky->getDomeOffset(); +// sunlight_color = psky->getSunlightColor(); +// ambient = psky->getAmbientColor(); +// gamma = psky->getGama(); +// blue_density = psky->getBlueDensity(); +// blue_horizon = psky->getBlueHorizon(); +// haze_density = psky->getHazeDensity(); +// haze_horizon = psky->getHazeHorizon(); +// density_multiplier = psky->getDensityMultiplier(); +// max_y = psky->getMaxY(); +// glow = psky->getGlow(); +// cloud_shadow = psky->getCloudShadow(); +// cloud_color = psky->getCloudColor(); +// cloud_scale = psky->getCloudScale(); +// cloud_pos_density1 = psky->getCloudPosDensity1(); +// cloud_pos_density2 = psky->getCloudPosDensity2(); // light norm is different. We need the sun's direction, not the light direction // which could be from the moon. And we need to clamp it // just like for the gpu - LLVector3 sunDir = gSky.getSunDirection(); +// LLVector3 sunDir = gSky.getSunDirection(); + LLVector3 sunDir = psky->getSunDirection(); // CFR_TO_OGL - lightnorm = LLVector4(sunDir.mV[1], sunDir.mV[2], sunDir.mV[0], 0); +// lightnorm = LLVector4(sunDir.mV[1], sunDir.mV[2], sunDir.mV[0], 0); + lightnorm = LLVector4(sunDir, 0); unclamped_lightnorm = lightnorm; if(lightnorm.mV[1] < -0.1f) { @@ -676,6 +679,11 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity, LLVector2 vary_HorizontalProjection[2]) { + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + LLColor3 blue_density = psky->getBlueDensity(); + F32 max_y = psky->getMaxY(); + // project the direction ray onto the sky dome. F32 phi = acos(Pn[1]); F32 sinA = sin(F_PI - phi); @@ -684,7 +692,8 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo sinA = 0.01f; } - F32 Plen = dome_radius * sin(F_PI + phi + asin(dome_offset_ratio * sinA)) / sinA; +// F32 Plen = dome_radius * sin(F_PI + phi + asin(dome_offset_ratio * sinA)) / sinA; + F32 Plen = psky->getDomeRadius() * sin(F_PI + phi + asin(psky->getDomeOffset() * sinA)) / sinA; Pn *= Plen; @@ -705,7 +714,14 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo Pn /= Plen; // Initialize temp variables - LLColor3 sunlight = sunlight_color; + LLColor3 sunlight = psky->getSunlightColor(); + LLColor3 ambient = psky->getAmbientColor(); + LLColor3 blue_horizon = psky->getBlueHorizon(); + F32 haze_density = psky->getHazeDensity(); + F32 haze_horizon = psky->getHazeHorizon(); + F32 density_multiplier = psky->getDensityMultiplier(); + LLColor3 glow = psky->getGlow(); + F32 cloud_shadow = psky->getCloudShadow(); // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -766,7 +782,7 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo // Final atmosphere additive componentMultBy(vary_HazeColor, LLColor3::white - temp1); - sunlight = sunlight_color; + sunlight = psky->getSunlightColor(); temp2.mV[1] = llmax(0.f, lightnorm[1] * 2.f); temp2.mV[1] = 1.f / temp2.mV[1]; componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); @@ -807,8 +823,10 @@ LLColor3 LLVOSky::calcSkyColorWLFrag(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity, LLVector2 vary_HorizontalProjection[2]) { - LLColor3 res; + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + F32 gamma = psky->getGama(); + LLColor3 res; LLColor3 color0 = vary_HazeColor; if (!gPipeline.canUseWindLightShaders()) @@ -874,6 +892,7 @@ LLColor3 LLVOSky::createAmbientFromWL(LLColor3 ambient, LLColor3 sundiffuse, LLC void LLVOSky::calcAtmospherics(void) { + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); initAtmospherics(); LLColor3 vary_HazeColor; @@ -881,7 +900,16 @@ void LLVOSky::calcAtmospherics(void) LLColor3 vary_AmbientColor; { // Initialize temp variables - LLColor3 sunlight = sunlight_color; + LLColor3 sunlight = psky->getSunlightColor(); + LLColor3 ambient = psky->getAmbientColor(); + F32 gamma = psky->getGama(); + LLColor3 blue_density = psky->getBlueDensity(); + LLColor3 blue_horizon = psky->getBlueHorizon(); + F32 haze_density = psky->getHazeDensity(); + F32 haze_horizon = psky->getHazeHorizon(); + F32 density_multiplier = psky->getDensityMultiplier(); + F32 max_y = psky->getMaxY(); + F32 cloud_shadow = psky->getCloudShadow(); // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -1210,6 +1238,7 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) } mCameraPosAgent = drawable->getPositionAgent(); + mEarthCenter.mV[0] = mCameraPosAgent.mV[0]; mEarthCenter.mV[1] = mCameraPosAgent.mV[1]; @@ -1808,152 +1837,155 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H, LLFace *face = mFace[FACE_REFLECTION]; - if (!face->getVertexBuffer() || quads*4 != face->getGeomCount()) - { - face->setSize(quads * 4, quads * 6); - LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); - buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE); - face->setIndicesIndex(0); - face->setGeomIndex(0); - face->setVertexBuffer(buff); - } - - LLStrider verticesp; - LLStrider normalsp; - LLStrider texCoordsp; - LLStrider indicesp; - S32 index_offset; - - index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp); - if (-1 == index_offset) - { - return; - } - - LLColor3 hb_col3 = HB.getInterpColor(); - hb_col3.clamp(); - const LLColor4 hb_col = LLColor4(hb_col3); - - const F32 min_attenuation = 0.4f; - const F32 max_attenuation = 0.7f; - const F32 attenuation = min_attenuation - + cos_angle_of_view * (max_attenuation - min_attenuation); - - LLColor4 hb_refl_col = (1-attenuation) * hb_col + attenuation * mFogColor; - face->setFaceColor(hb_refl_col); - - LLVector3 v_far[2]; - v_far[0] = v_refl_corner[1]; - v_far[1] = v_refl_corner[3]; - - if(dt_clip > 0) - { - if (dt_clip >= 1) - { - for (S32 vtx = 0; vtx < 4; ++vtx) - { - F32 ratio = far_clip / v_refl_corner[vtx].length(); - *(verticesp++) = v_refl_corner[vtx] = ratio * v_refl_corner[vtx] + mCameraPosAgent; - } - const LLVector3 draw_pos = 0.25 * - (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); - face->mCenterAgent = draw_pos; - } - else - { - F32 ratio = far_clip / v_refl_corner[1].length(); - v_sprite_corner[1] = v_refl_corner[1] * ratio; - - ratio = far_clip / v_refl_corner[3].length(); - v_sprite_corner[3] = v_refl_corner[3] * ratio; - - v_refl_corner[1] = (1 - dt_clip) * v_refl_corner[1] + dt_clip * v_refl_corner[0]; - v_refl_corner[3] = (1 - dt_clip) * v_refl_corner[3] + dt_clip * v_refl_corner[2]; - v_sprite_corner[0] = v_refl_corner[1]; - v_sprite_corner[2] = v_refl_corner[3]; - - for (S32 vtx = 0; vtx < 4; ++vtx) - { - *(verticesp++) = v_sprite_corner[vtx] + mCameraPosAgent; - } - - const LLVector3 draw_pos = 0.25 * - (v_refl_corner[0] + v_sprite_corner[1] + v_refl_corner[2] + v_sprite_corner[3]); - face->mCenterAgent = draw_pos; - } - - *(texCoordsp++) = TEX0tt; - *(texCoordsp++) = TEX0t; - *(texCoordsp++) = TEX1tt; - *(texCoordsp++) = TEX1t; - - *indicesp++ = index_offset + 0; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 1; - - *indicesp++ = index_offset + 1; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 3; - - index_offset += 4; - } - - if (dt_clip < 1) - { - if (dt_clip <= 0) - { - const LLVector3 draw_pos = 0.25 * - (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); - face->mCenterAgent = draw_pos; - } - - const F32 raws_inv = 1.f/raws; - const F32 cols_inv = 1.f/cols; - LLVector3 left = v_refl_corner[0] - v_refl_corner[1]; - LLVector3 right = v_refl_corner[2] - v_refl_corner[3]; - left *= raws_inv; - right *= raws_inv; - - F32 dt_raw = dt; - - for (S32 raw = 0; raw < raws; ++raw) - { - F32 dt_v0 = raw * raws_inv; - F32 dt_v1 = (raw + 1) * raws_inv; - const LLVector3 BL = v_refl_corner[1] + (F32)raw * left; - const LLVector3 BR = v_refl_corner[3] + (F32)raw * right; - const LLVector3 EL = BL + left; - const LLVector3 ER = BR + right; - dt_v0 = dt_raw; - dt_raw = dt_v1 = dtReflection(EL, cos_dir_from_top[0], sin_dir_from_top, diff_angl_dir); - for (S32 col = 0; col < cols; ++col) - { - F32 dt_h0 = col * cols_inv; - *(verticesp++) = (1 - dt_h0) * EL + dt_h0 * ER + mCameraPosAgent; - *(verticesp++) = (1 - dt_h0) * BL + dt_h0 * BR + mCameraPosAgent; - F32 dt_h1 = (col + 1) * cols_inv; - *(verticesp++) = (1 - dt_h1) * EL + dt_h1 * ER + mCameraPosAgent; - *(verticesp++) = (1 - dt_h1) * BL + dt_h1 * BR + mCameraPosAgent; - - *(texCoordsp++) = LLVector2(dt_h0, dt_v1); - *(texCoordsp++) = LLVector2(dt_h0, dt_v0); - *(texCoordsp++) = LLVector2(dt_h1, dt_v1); - *(texCoordsp++) = LLVector2(dt_h1, dt_v0); - - *indicesp++ = index_offset + 0; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 1; - - *indicesp++ = index_offset + 1; - *indicesp++ = index_offset + 2; - *indicesp++ = index_offset + 3; - - index_offset += 4; - } - } - } - - face->getVertexBuffer()->flush(); + if (face) + { + if (!face->getVertexBuffer() || quads * 4 != face->getGeomCount()) + { + face->setSize(quads * 4, quads * 6); + LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); + buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE); + face->setIndicesIndex(0); + face->setGeomIndex(0); + face->setVertexBuffer(buff); + } + + LLStrider verticesp; + LLStrider normalsp; + LLStrider texCoordsp; + LLStrider indicesp; + S32 index_offset; + + index_offset = face->getGeometry(verticesp, normalsp, texCoordsp, indicesp); + if (-1 == index_offset) + { + return; + } + + LLColor3 hb_col3 = HB.getInterpColor(); + hb_col3.clamp(); + const LLColor4 hb_col = LLColor4(hb_col3); + + const F32 min_attenuation = 0.4f; + const F32 max_attenuation = 0.7f; + const F32 attenuation = min_attenuation + + cos_angle_of_view * (max_attenuation - min_attenuation); + + LLColor4 hb_refl_col = (1 - attenuation) * hb_col + attenuation * mFogColor; + face->setFaceColor(hb_refl_col); + + LLVector3 v_far[2]; + v_far[0] = v_refl_corner[1]; + v_far[1] = v_refl_corner[3]; + + if (dt_clip > 0) + { + if (dt_clip >= 1) + { + for (S32 vtx = 0; vtx < 4; ++vtx) + { + F32 ratio = far_clip / v_refl_corner[vtx].length(); + *(verticesp++) = v_refl_corner[vtx] = ratio * v_refl_corner[vtx] + mCameraPosAgent; + } + const LLVector3 draw_pos = 0.25 * + (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); + face->mCenterAgent = draw_pos; + } + else + { + F32 ratio = far_clip / v_refl_corner[1].length(); + v_sprite_corner[1] = v_refl_corner[1] * ratio; + + ratio = far_clip / v_refl_corner[3].length(); + v_sprite_corner[3] = v_refl_corner[3] * ratio; + + v_refl_corner[1] = (1 - dt_clip) * v_refl_corner[1] + dt_clip * v_refl_corner[0]; + v_refl_corner[3] = (1 - dt_clip) * v_refl_corner[3] + dt_clip * v_refl_corner[2]; + v_sprite_corner[0] = v_refl_corner[1]; + v_sprite_corner[2] = v_refl_corner[3]; + + for (S32 vtx = 0; vtx < 4; ++vtx) + { + *(verticesp++) = v_sprite_corner[vtx] + mCameraPosAgent; + } + + const LLVector3 draw_pos = 0.25 * + (v_refl_corner[0] + v_sprite_corner[1] + v_refl_corner[2] + v_sprite_corner[3]); + face->mCenterAgent = draw_pos; + } + + *(texCoordsp++) = TEX0tt; + *(texCoordsp++) = TEX0t; + *(texCoordsp++) = TEX1tt; + *(texCoordsp++) = TEX1t; + + *indicesp++ = index_offset + 0; + *indicesp++ = index_offset + 2; + *indicesp++ = index_offset + 1; + + *indicesp++ = index_offset + 1; + *indicesp++ = index_offset + 2; + *indicesp++ = index_offset + 3; + + index_offset += 4; + } + + if (dt_clip < 1) + { + if (dt_clip <= 0) + { + const LLVector3 draw_pos = 0.25 * + (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); + face->mCenterAgent = draw_pos; + } + + const F32 raws_inv = 1.f / raws; + const F32 cols_inv = 1.f / cols; + LLVector3 left = v_refl_corner[0] - v_refl_corner[1]; + LLVector3 right = v_refl_corner[2] - v_refl_corner[3]; + left *= raws_inv; + right *= raws_inv; + + F32 dt_raw = dt; + + for (S32 raw = 0; raw < raws; ++raw) + { + F32 dt_v0 = raw * raws_inv; + F32 dt_v1 = (raw + 1) * raws_inv; + const LLVector3 BL = v_refl_corner[1] + (F32)raw * left; + const LLVector3 BR = v_refl_corner[3] + (F32)raw * right; + const LLVector3 EL = BL + left; + const LLVector3 ER = BR + right; + dt_v0 = dt_raw; + dt_raw = dt_v1 = dtReflection(EL, cos_dir_from_top[0], sin_dir_from_top, diff_angl_dir); + for (S32 col = 0; col < cols; ++col) + { + F32 dt_h0 = col * cols_inv; + *(verticesp++) = (1 - dt_h0) * EL + dt_h0 * ER + mCameraPosAgent; + *(verticesp++) = (1 - dt_h0) * BL + dt_h0 * BR + mCameraPosAgent; + F32 dt_h1 = (col + 1) * cols_inv; + *(verticesp++) = (1 - dt_h1) * EL + dt_h1 * ER + mCameraPosAgent; + *(verticesp++) = (1 - dt_h1) * BL + dt_h1 * BR + mCameraPosAgent; + + *(texCoordsp++) = LLVector2(dt_h0, dt_v1); + *(texCoordsp++) = LLVector2(dt_h0, dt_v0); + *(texCoordsp++) = LLVector2(dt_h1, dt_v1); + *(texCoordsp++) = LLVector2(dt_h1, dt_v0); + + *indicesp++ = index_offset + 0; + *indicesp++ = index_offset + 2; + *indicesp++ = index_offset + 1; + + *indicesp++ = index_offset + 1; + *indicesp++ = index_offset + 2; + *indicesp++ = index_offset + 3; + + index_offset += 4; + } + } + } + + face->getVertexBuffer()->flush(); + } } diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index c865e8701c..32b5a7eba8 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -381,25 +381,25 @@ class LLVOSky : public LLStaticViewerObject { public: /// WL PARAMS - F32 dome_radius; - F32 dome_offset_ratio; - LLColor3 sunlight_color; - LLColor3 ambient; - F32 gamma; +// F32 dome_radius; +// F32 dome_offset_ratio; +// LLColor3 sunlight_color; +// LLColor3 ambient; +// F32 gamma; LLVector4 lightnorm; LLVector4 unclamped_lightnorm; - LLColor3 blue_density; - LLColor3 blue_horizon; - F32 haze_density; - F32 haze_horizon; - F32 density_multiplier; - F32 max_y; - LLColor3 glow; - F32 cloud_shadow; - LLColor3 cloud_color; - F32 cloud_scale; - LLColor3 cloud_pos_density1; - LLColor3 cloud_pos_density2; +// LLColor3 blue_density; +// LLColor3 blue_horizon; +// F32 haze_density; +// F32 haze_horizon; +// F32 density_multiplier; +// F32 max_y; +// LLColor3 glow; +// F32 cloud_shadow; +// LLColor3 cloud_color; +// F32 cloud_scale; +// LLColor3 cloud_pos_density1; +// LLColor3 cloud_pos_density2; public: void initAtmospherics(void); diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 689296a53a..6d1bb43258 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -187,7 +187,7 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) { if (shader->mShaderGroup == LLGLSLShader::SG_WATER) { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLightDir().mV); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLight().mV); shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, LLDrawPoolWater::sWaterFogColor.mV); shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, mWaterPlane.mV); -- cgit v1.3 From cc22ffc6d799544e8f2a9dfed6813081d908c88d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 13 Oct 2017 17:17:49 -0700 Subject: Watter settings active and start of new joystick button type. --- indra/newview/CMakeLists.txt | 2 + indra/newview/llappviewer.cpp | 1 - indra/newview/lldrawpoolwater.cpp | 116 ++++---- indra/newview/lldrawpoolwater.h | 5 +- indra/newview/llenvadapters.cpp | 18 ++ indra/newview/llenvadapters.h | 221 ++++++++++++-- indra/newview/llenvironment.cpp | 155 ++++++++-- indra/newview/llenvironment.h | 69 ++++- indra/newview/llfloatereditsky.cpp | 5 - indra/newview/llfloatereditwater.cpp | 381 ++++++++----------------- indra/newview/llfloatereditwater.h | 50 ++-- indra/newview/llfloaterenvironmentsettings.cpp | 18 +- indra/newview/lljoystickbutton.cpp | 184 +++++++++++- indra/newview/lljoystickbutton.h | 31 ++ indra/newview/llsettingssky.cpp | 15 +- indra/newview/llsettingssky.h | 8 +- indra/newview/llsettingswater.cpp | 268 +++++++++++++++++ indra/newview/llsettingswater.h | 234 +++++++++++++++ indra/newview/llstartup.cpp | 6 +- indra/newview/llviewerdisplay.cpp | 4 +- indra/newview/llviewershadermgr.cpp | 1 - indra/newview/llvosky.cpp | 6 +- indra/newview/llwaterparammanager.cpp | 34 ++- indra/newview/llwaterparammanager.h | 10 +- indra/newview/pipeline.cpp | 4 +- 25 files changed, 1401 insertions(+), 445 deletions(-) create mode 100644 indra/newview/llsettingswater.cpp create mode 100644 indra/newview/llsettingswater.h (limited to 'indra/newview/llwaterparammanager.cpp') 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 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 result; - result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky)); + std::pair 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 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 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((*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 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((*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,10 +31,14 @@ #include "llsd.h" #include "llsettingssky.h" +#include "llsettingswater.h" class LLViewerCamera; class LLGLSLShader; +//------------------------------------------------------------------------- + + //------------------------------------------------------------------------- class LLEnvironment : public LLSingleton { @@ -42,9 +46,44 @@ class LLEnvironment : public LLSingleton 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 NamedSkyMap_t; - typedef std::map AssetSkyMap_t; + typedef std::map NamedSettingMap_t; + typedef std::map 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("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 + // 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("make_default_cb"); mSaveButton = getChild("save"); + mWaterAdapter = boost::make_shared(); + 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("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("WaterFogColor")->setCommitCallback(boost::bind(&LLFloaterEditWater::onWaterFogColorMoved, this, _1, &water_mgr.mFogColor)); - //getChild("WaterGlow")->setCommitCallback(boost::bind(&LLFloaterEditWater::onColorControlAMoved, this, _1, &water_mgr.mFogColor)); + getChild("WaterFogColor")->setCommitCallback(boost::bind(&LLFloaterEditWater::onColorControlMoved, this, _1, &mWaterAdapter->mFogColor)); // fog density - getChild("WaterFogDensity")->setCommitCallback(boost::bind(&LLFloaterEditWater::onExpFloatControlMoved, this, _1, &water_mgr.mFogDensity)); - getChild("WaterUnderWaterFogMod")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mUnderWaterFogMod)); + getChild("WaterFogDensity")->setCommitCallback(boost::bind(&LLFloaterEditWater::onExpFloatControlMoved, this, _1, &mWaterAdapter->mFogDensity)); + getChild("WaterUnderWaterFogMod")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mUnderWaterFogMod)); // blue density - getChild("WaterNormalScaleX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlXMoved, this, _1, &water_mgr.mNormalScale)); - getChild("WaterNormalScaleY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlYMoved, this, _1, &water_mgr.mNormalScale)); - getChild("WaterNormalScaleZ")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlZMoved, this, _1, &water_mgr.mNormalScale)); + getChild("WaterNormalScaleX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlXMoved, this, _1, &mWaterAdapter->mNormalScale)); + getChild("WaterNormalScaleY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlYMoved, this, _1, &mWaterAdapter->mNormalScale)); + getChild("WaterNormalScaleZ")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector3ControlZMoved, this, _1, &mWaterAdapter->mNormalScale)); // fresnel - getChild("WaterFresnelScale")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mFresnelScale)); - getChild("WaterFresnelOffset")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mFresnelOffset)); + getChild("WaterFresnelScale")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mFresnelScale)); + getChild("WaterFresnelOffset")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mFresnelOffset)); // scale above/below - getChild("WaterScaleAbove")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mScaleAbove)); - getChild("WaterScaleBelow")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mScaleBelow)); + getChild("WaterScaleAbove")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mScaleAbove)); + getChild("WaterScaleBelow")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mScaleBelow)); // blur mult - getChild("WaterBlurMult")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &water_mgr.mBlurMultiplier)); + getChild("WaterBlurMult")->setCommitCallback(boost::bind(&LLFloaterEditWater::onFloatControlMoved, this, _1, &mWaterAdapter->mBlurMultiplier)); // wave direction - getChild("WaterWave1DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &water_mgr.mWave1Dir)); - getChild("WaterWave1DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &water_mgr.mWave1Dir)); - getChild("WaterWave2DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &water_mgr.mWave2Dir)); - getChild("WaterWave2DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &water_mgr.mWave2Dir)); + getChild("WaterWave1DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &mWaterAdapter->mWave1Dir)); + getChild("WaterWave1DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &mWaterAdapter->mWave1Dir)); + getChild("WaterWave2DirX")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlXMoved, this, _1, &mWaterAdapter->mWave2Dir)); + getChild("WaterWave2DirY")->setCommitCallback(boost::bind(&LLFloaterEditWater::onVector2ControlYMoved, this, _1, &mWaterAdapter->mWave2Dir)); LLTextureCtrl* texture_ctrl = getChild("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("WaterGlow")->setValue(col.mV[3]); - col.mV[3] = 1.0f; - getChild("WaterFogColor")->set(col); + getChild("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("WaterFogDensity")->setValue(water_mgr.mFogDensity.mExp); + mWaterAdapter->mFogDensity = pwater->getFogDensity(); + getChild("WaterFogDensity")->setValue(mWaterAdapter->mFogDensity.getExp()); - water_mgr.mUnderWaterFogMod.mX = - current_params.getFloat(water_mgr.mUnderWaterFogMod.mName, err); - getChild("WaterUnderWaterFogMod")->setValue(water_mgr.mUnderWaterFogMod.mX); + mWaterAdapter->mUnderWaterFogMod = pwater->getFogMod(); + getChild("WaterUnderWaterFogMod")->setValue(static_cast(mWaterAdapter->mUnderWaterFogMod)); - water_mgr.mNormalScale = current_params.getVector3(water_mgr.mNormalScale.mName, err); - getChild("WaterNormalScaleX")->setValue(water_mgr.mNormalScale.mX); - getChild("WaterNormalScaleY")->setValue(water_mgr.mNormalScale.mY); - getChild("WaterNormalScaleZ")->setValue(water_mgr.mNormalScale.mZ); + mWaterAdapter->mNormalScale = pwater->getNormalScale(); + getChild("WaterNormalScaleX")->setValue(mWaterAdapter->mNormalScale.getX()); + getChild("WaterNormalScaleY")->setValue(mWaterAdapter->mNormalScale.getY()); + getChild("WaterNormalScaleZ")->setValue(mWaterAdapter->mNormalScale.getZ()); // Fresnel - water_mgr.mFresnelScale.mX = current_params.getFloat(water_mgr.mFresnelScale.mName, err); - getChild("WaterFresnelScale")->setValue(water_mgr.mFresnelScale.mX); - water_mgr.mFresnelOffset.mX = current_params.getFloat(water_mgr.mFresnelOffset.mName, err); - getChild("WaterFresnelOffset")->setValue(water_mgr.mFresnelOffset.mX); + mWaterAdapter->mFresnelScale = pwater->getFresnelScale(); + getChild("WaterFresnelScale")->setValue(static_cast(mWaterAdapter->mFresnelScale)); + mWaterAdapter->mFresnelOffset = pwater->getFresnelOffset(); + getChild("WaterFresnelOffset")->setValue(static_cast(mWaterAdapter->mFresnelOffset)); // Scale Above/Below - water_mgr.mScaleAbove.mX = current_params.getFloat(water_mgr.mScaleAbove.mName, err); - getChild("WaterScaleAbove")->setValue(water_mgr.mScaleAbove.mX); - water_mgr.mScaleBelow.mX = current_params.getFloat(water_mgr.mScaleBelow.mName, err); - getChild("WaterScaleBelow")->setValue(water_mgr.mScaleBelow.mX); + mWaterAdapter->mScaleAbove = pwater->getScaleAbove(); + getChild("WaterScaleAbove")->setValue(static_cast(mWaterAdapter->mScaleAbove)); + mWaterAdapter->mScaleBelow = pwater->getScaleBelow(); + getChild("WaterScaleBelow")->setValue(static_cast(mWaterAdapter->mScaleBelow)); // blur mult - water_mgr.mBlurMultiplier.mX = current_params.getFloat(water_mgr.mBlurMultiplier.mName, err); - getChild("WaterBlurMult")->setValue(water_mgr.mBlurMultiplier.mX); + mWaterAdapter->mBlurMultiplier = pwater->getBlurMultiplier(); + getChild("WaterBlurMult")->setValue(static_cast(mWaterAdapter->mBlurMultiplier)); // wave directions - water_mgr.mWave1Dir = current_params.getVector2(water_mgr.mWave1Dir.mName, err); - getChild("WaterWave1DirX")->setValue(water_mgr.mWave1Dir.mX); - getChild("WaterWave1DirY")->setValue(water_mgr.mWave1Dir.mY); + mWaterAdapter->mWave1Dir = pwater->getWave1Dir(); + getChild("WaterWave1DirX")->setValue(mWaterAdapter->mWave1Dir.getU()); + getChild("WaterWave1DirY")->setValue(mWaterAdapter->mWave1Dir.getV()); - water_mgr.mWave2Dir = current_params.getVector2(water_mgr.mWave2Dir.mName, err); - getChild("WaterWave2DirX")->setValue(water_mgr.mWave2Dir.mX); - getChild("WaterWave2DirY")->setValue(water_mgr.mWave2Dir.mY); + mWaterAdapter->mWave2Dir = pwater->getWave2Dir(); + getChild("WaterWave2DirX")->setValue(mWaterAdapter->mWave2Dir.getU()); + getChild("WaterWave2DirY")->setValue(mWaterAdapter->mWave2Dir.getV()); LLTextureCtrl* textCtrl = getChild("WaterNormalMap"); - textCtrl->setImageAssetID(water_mgr.getNormalMapID()); -} - -// color control callbacks -void LLFloaterEditWater::onColorControlRMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast(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(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(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(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(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(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(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(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(rName)->setValue(color_ctrl->mR); - getChild(gName)->setValue(color_ctrl->mG); - getChild(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(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(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(ctrl); + LLSliderCtrl* sldr_ctrl = static_cast(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(ctrl); + LLSliderCtrl* sldr_ctrl = static_cast(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(ctrl); - - vector_ctrl->mY = sldr_ctrl->getValueF32(); + LLSliderCtrl* sldr_ctrl = static_cast(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(ctrl); - - floatControl->mX = sldr_ctrl->getValueF32() / floatControl->mMult; + LLSliderCtrl* sldr_ctrl = static_cast(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(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(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(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 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 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::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 r1("joystick_slide static LLDefaultChildRegistry::Register r2("joystick_turn"); static LLDefaultChildRegistry::Register r3("joystick_rotate"); static LLDefaultChildRegistry::Register r5("joystick_track"); - +static LLDefaultChildRegistry::Register 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 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 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(); + }; + + 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 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(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(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 ptr_t; typedef std::pair 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 +#include +#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(newsettings); + + return waterp; +} + +LLSettingsWater::ptr_t LLSettingsWater::buildDefaultWater() +{ + LLSD settings = LLSettingsWater::defaults(); + + LLSettingsWater::ptr_t skyp = boost::make_shared(settings); + + return skyp; +} + +LLSettingsWater::ptr_t LLSettingsWater::buildClone() +{ + LLSD settings = cloneSettings(); + + LLSettingsWater::ptr_t skyp = boost::make_shared(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 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 @@ -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; -- cgit v1.3 From 61e6632a713041e8e4ccebf72874767238bf8a48 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 3 Nov 2017 11:28:08 -0700 Subject: Initial day cycle impl. --- indra/newview/lldaycyclemanager.cpp | 3 + indra/newview/llenvironment.cpp | 469 +++++++++++++++++++++++-- indra/newview/llenvironment.h | 146 +++++--- indra/newview/llenvmanager.h | 1 + indra/newview/llfloatereditdaycycle.cpp | 1 + indra/newview/llfloatereditsky.cpp | 167 +++------ indra/newview/llfloatereditsky.h | 2 +- indra/newview/llfloatereditwater.cpp | 164 ++------- indra/newview/llfloatereditwater.h | 1 + indra/newview/llfloaterenvironmentsettings.cpp | 112 +++--- indra/newview/llfloaterenvironmentsettings.h | 1 + indra/newview/llsettingsbase.cpp | 24 +- indra/newview/llsettingsbase.h | 34 +- indra/newview/llsettingsdaycycle.cpp | 179 +++++++--- indra/newview/llsettingsdaycycle.h | 28 +- indra/newview/llsettingssky.cpp | 31 +- indra/newview/llsettingssky.h | 4 +- indra/newview/llsettingswater.cpp | 9 +- indra/newview/llsettingswater.h | 3 +- indra/newview/llwaterparammanager.cpp | 4 - indra/newview/llwlparammanager.cpp | 5 - 21 files changed, 875 insertions(+), 513 deletions(-) (limited to 'indra/newview/llwaterparammanager.cpp') diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp index 803e2b2fb2..23d442f3b6 100644 --- a/indra/newview/lldaycyclemanager.cpp +++ b/indra/newview/lldaycyclemanager.cpp @@ -30,6 +30,9 @@ #include "lldiriterator.h" +#include "llenvironment.h" +#include "llsettingsdaycycle.h" + void LLDayCycleManager::getPresetNames(preset_name_list_t& names) const { names.clear(); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index fbb713c6d8..9c654bbeb5 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -29,7 +29,6 @@ #include "llenvironment.h" #include "llagent.h" -#include "lldaycyclemanager.h" #include "llviewercontrol.h" // for gSavedSettings #include "llviewerregion.h" #include "llwlhandlers.h" @@ -40,6 +39,10 @@ #include "pipeline.h" #include "llsky.h" +#include "llviewershadermgr.h" + +#include "llsdserialize.h" +#include "lldiriterator.h" //========================================================================= namespace { @@ -53,21 +56,37 @@ const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS) //------------------------------------------------------------------------- LLEnvironment::LLEnvironment(): - mCurrentSky(), - mCurrentWater(), + mSelectedSky(), + mSelectedWater(), + mSelectedDayCycle(), mSkysById(), mSkysByName(), mWaterByName(), mWaterById(), + mDayCycleByName(), + mDayCycleById(), mUserPrefs() +{ +} + +void LLEnvironment::initSingleton() { LLSettingsSky::ptr_t p_default_sky = LLSettingsSky::buildDefaultSky(); addSky(p_default_sky); - mCurrentSky = p_default_sky; + mSelectedSky = p_default_sky; LLSettingsWater::ptr_t p_default_water = LLSettingsWater::buildDefaultWater(); addWater(p_default_water); - mCurrentWater = p_default_water; + mSelectedWater = p_default_water; + + LLSettingsDayCycle::ptr_t p_default_day = LLSettingsDayCycle::buildDefaultDayCycle(); + addDayCycle(p_default_day); + mSelectedDayCycle.reset(); + + applyAllSelected(); + + // LEGACY! + legacyLoadAllPresets(); } LLEnvironment::~LLEnvironment() @@ -79,10 +98,25 @@ void LLEnvironment::loadPreferences() mUserPrefs.load(); } +LLEnvironment::connection_t LLEnvironment::setSkyListChange(const LLEnvironment::change_signal_t::slot_type& cb) +{ + return mSkyListChange.connect(cb); +} + +LLEnvironment::connection_t LLEnvironment::setWaterListChange(const LLEnvironment::change_signal_t::slot_type& cb) +{ + return mWaterListChange.connect(cb); +} + +LLEnvironment::connection_t LLEnvironment::setDayCycleListChange(const LLEnvironment::change_signal_t::slot_type& cb) +{ + return mDayCycleListChange.connect(cb); +} + //------------------------------------------------------------------------- F32 LLEnvironment::getCamHeight() const { - return (mCurrentSky->getDomeOffset() * mCurrentSky->getDomeRadius()); + return (mSelectedSky->getDomeOffset() * mSelectedSky->getDomeRadius()); } F32 LLEnvironment::getWaterHeight() const @@ -92,7 +126,7 @@ F32 LLEnvironment::getWaterHeight() const bool LLEnvironment::getIsDayTime() const { - return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; + return mSelectedSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; } //------------------------------------------------------------------------- @@ -102,7 +136,13 @@ void LLEnvironment::update(const LLViewerCamera * cam) // update clouds, sun, and general updateCloudScroll(); - mCurrentSky->update(); + if (mSelectedDayCycle) + mSelectedDayCycle->update(); + + if (mSelectedSky) + mSelectedSky->update(); + if (mSelectedWater) + mSelectedWater->update(); // // update only if running // if (mAnimator.getIsRunning()) @@ -139,6 +179,11 @@ void LLEnvironment::update(const LLViewerCamera * cam) } } +void advanceDay(F32 delta) +{ + +} + void LLEnvironment::updateCloudScroll() { // This is a function of the environment rather than the sky, since it should @@ -147,7 +192,7 @@ void LLEnvironment::updateCloudScroll() F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); - LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; + LLVector2 cloud_delta = static_cast(delta_t)* (mSelectedSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; mCloudScrollDelta += cloud_delta; @@ -225,8 +270,8 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) if (gPipeline.canUseWindLightShaders()) { - updateGLVariablesForSettings(shader, mCurrentSky); - updateGLVariablesForSettings(shader, mCurrentWater); + updateGLVariablesForSettings(shader, mSelectedSky); + updateGLVariablesForSettings(shader, mSelectedWater); } if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) @@ -248,6 +293,176 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) } //-------------------------------------------------------------------------- +void LLEnvironment::selectSky(const std::string &name) +{ + LLSettingsSky::ptr_t next_sky = findSkyByName(name); + if (!next_sky) + { + LL_WARNS("ENVIRONMENT") << "Unable to select sky with unknown name '" << name << "'" << LL_ENDL; + return; + } + + selectSky(next_sky); +} + +void LLEnvironment::selectSky(const LLSettingsSky::ptr_t &sky) +{ + if (!sky) + { + mSelectedSky = mCurrentSky; + return; + } + mSelectedSky = sky; + mSelectedSky->setDirtyFlag(true); +} + +void LLEnvironment::applySky(const LLSettingsSky::ptr_t &sky) +{ + if (sky) + { + mCurrentSky = sky; + } + else + { + mCurrentSky = mSelectedSky; + } +} + +void LLEnvironment::selectWater(const std::string &name) +{ + LLSettingsWater::ptr_t next_water = findWaterByName(name); + + if (!next_water) + { + LL_WARNS("ENVIRONMENT") << "Unable to select water with unknown name '" << name << "'" << LL_ENDL; + return; + } + + selectWater(next_water); +} + +void LLEnvironment::selectWater(const LLSettingsWater::ptr_t &water) +{ + if (!water) + { + mSelectedWater = mCurrentWater; + return; + } + mSelectedWater = water; + mSelectedWater->setDirtyFlag(true); +} + +void LLEnvironment::applyWater(const LLSettingsWater::ptr_t water) +{ + if (water) + { + mCurrentWater = water; + } + else + { + mCurrentWater = mSelectedWater; + } +} + +void LLEnvironment::selectDayCycle(const std::string &name) +{ + LLSettingsDayCycle::ptr_t next_daycycle = findDayCycleByName(name); + + if (!next_daycycle) + { + LL_WARNS("ENVIRONMENT") << "Unable to select daycycle with unknown name '" << name << "'" << LL_ENDL; + return; + } + + mSelectedDayCycle = next_daycycle; + mSelectedDayCycle->setDirtyFlag(true); +} + +void LLEnvironment::selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) +{ + if (!daycycle) + { + mSelectedDayCycle = mCurrentDayCycle; + return; + } + + mSelectedDayCycle = daycycle; + mSelectedDayCycle->setDirtyFlag(true); +} + +void LLEnvironment::applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) +{ + if (daycycle) + { + mCurrentDayCycle = daycycle; + } + else + { + mCurrentDayCycle = mSelectedDayCycle; + } +} + +void LLEnvironment::clearAllSelected() +{ + if (mSelectedSky != mCurrentSky) + selectSky(); + if (mSelectedWater != mCurrentWater) + selectWater(); + if (mSelectedDayCycle != mCurrentDayCycle) + selectDayCycle(); +} + +void LLEnvironment::applyAllSelected() +{ + if (mSelectedSky != mCurrentSky) + applySky(); + if (mSelectedWater != mCurrentWater) + applyWater(); + if (mSelectedDayCycle != mCurrentDayCycle) + applyDayCycle(); +} + +LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const +{ + list_name_id_t list; + + list.reserve(mSkysByName.size()); + + for (NamedSettingMap_t::const_iterator it = mSkysByName.begin(); it != mSkysByName.end(); ++it) + { + list.push_back(std::vector::value_type((*it).second->getName(), (*it).second->getId())); + } + + return list; +} + +LLEnvironment::list_name_id_t LLEnvironment::getWaterList() const +{ + list_name_id_t list; + + list.reserve(mWaterByName.size()); + + for (NamedSettingMap_t::const_iterator it = mWaterByName.begin(); it != mWaterByName.end(); ++it) + { + list.push_back(std::vector::value_type((*it).second->getName(), (*it).second->getId())); + } + + return list; +} + +LLEnvironment::list_name_id_t LLEnvironment::getDayCycleList() const +{ + list_name_id_t list; + + list.reserve(mDayCycleByName.size()); + + for (NamedSettingMap_t::const_iterator it = mDayCycleByName.begin(); it != mDayCycleByName.end(); ++it) + { + list.push_back(std::vector::value_type((*it).second->getName(), (*it).second->getId())); + } + + return list; +} void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) { @@ -260,6 +475,7 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) if (!result.second) (*(result.first)).second = sky; + mSkyListChange(); } // void LLEnvironment::addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky) @@ -278,6 +494,7 @@ void LLEnvironment::removeSky(const std::string &name) NamedSettingMap_t::iterator it = mSkysByName.find(name); if (it != mSkysByName.end()) mSkysByName.erase(it); + mSkyListChange(); } // void LLEnvironment::removeSky(const LLUUID &id) @@ -289,19 +506,7 @@ void LLEnvironment::clearAllSkys() { mSkysByName.clear(); mSkysById.clear(); -} - -void LLEnvironment::selectSky(const std::string &name) -{ - LLSettingsSky::ptr_t next_sky = findSkyByName(name); - if (!next_sky) - { - LL_WARNS("ENVIRONMENT") << "Unable to select sky with unknown name '" << name << "'" << LL_ENDL; - return; - } - - mCurrentSky = next_sky; - mCurrentSky->setDirtyFlag(true); + mSkyListChange(); } void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) @@ -315,29 +520,17 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) if (!result.second) (*(result.first)).second = water; + mWaterListChange(); } //void LLEnvironment::addWater(const LLUUID &id, const LLSettingsSky::ptr_t &sky); -void LLEnvironment::selectWater(const std::string &name) -{ - LLSettingsWater::ptr_t next_water = findWaterByName(name); - - if (!next_water) - { - LL_WARNS("ENVIRONMENT") << "Unable to select water with unknown name '" << name << "'" << LL_ENDL; - return; - } - - mCurrentWater = next_water; - mCurrentWater->setDirtyFlag(true); -} - void LLEnvironment::removeWater(const std::string &name) { NamedSettingMap_t::iterator it = mWaterByName.find(name); if (it != mWaterByName.end()) mWaterByName.erase(it); + mWaterListChange(); } //void LLEnvironment::removeWater(const LLUUID &id); @@ -345,6 +538,39 @@ void LLEnvironment::clearAllWater() { mWaterByName.clear(); mWaterById.clear(); + mWaterListChange(); +} + +void LLEnvironment::addDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) +{ + std::string name = daycycle->getValue(LLSettingsDayCycle::SETTING_NAME).asString(); + + LL_WARNS("RIDER") << "Adding daycycle as '" << name << "'" << LL_ENDL; + + std::pair result; + result = mDayCycleByName.insert(NamedSettingMap_t::value_type(name, daycycle)); + + if (!result.second) + (*(result.first)).second = daycycle; + mDayCycleListChange(); +} + +//void LLEnvironment::addDayCycle(const LLUUID &id, const LLSettingsSky::ptr_t &sky); + +void LLEnvironment::removeDayCycle(const std::string &name) +{ + NamedSettingMap_t::iterator it = mDayCycleByName.find(name); + if (it != mDayCycleByName.end()) + mDayCycleByName.erase(it); + mDayCycleListChange(); +} + +//void LLEnvironment::removeDayCycle(const LLUUID &id); +void LLEnvironment::clearAllDayCycles() +{ + mDayCycleByName.clear(); + mWaterById.clear(); + mDayCycleListChange(); } LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const @@ -373,6 +599,19 @@ LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const return boost::static_pointer_cast((*it).second); } +LLSettingsDayCycle::ptr_t LLEnvironment::findDayCycleByName(std::string name) const +{ + NamedSettingMap_t::const_iterator it = mDayCycleByName.find(name); + + if (it == mDayCycleByName.end()) + { + LL_WARNS("ENVIRONMENT") << "Unable to find daycycle with unknown name '" << name << "'" << LL_ENDL; + return LLSettingsDayCycle::ptr_t(); + } + + return boost::static_pointer_cast((*it).second); +} + //========================================================================= LLEnvironment::UserPrefs::UserPrefs(): mUseRegionSettings(true), @@ -409,3 +648,157 @@ void LLEnvironment::UserPrefs::store() gSavedSettings.setBOOL("UseDayCycle", getUseDayCycle()); } } + + +//========================================================================= +// Transitional Code. +// static +std::string LLEnvironment::getSysDir(const std::string &subdir) +{ + return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight\\"+subdir, ""); +} + +// static +std::string LLEnvironment::getUserDir(const std::string &subdir) +{ + return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "windlight\\"+subdir, ""); +} + +LLSD LLEnvironment::legacyLoadPreset(const std::string& path) +{ + llifstream xml_file; + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); + + xml_file.open(path.c_str()); + if (!xml_file) + { + return LLSD(); + } + + LLSD params_data; + LLPointer parser = new LLSDXMLParser(); + parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED); + xml_file.close(); + + return params_data; +} + +void LLEnvironment::legacyLoadAllPresets() +{ + std::string dir; + std::string file; + + // System skies + { + dir = getSysDir("skies"); + LLDirIterator dir_iter(dir, "*.xml"); + while (dir_iter.next(file)) + { + std::string path = gDirUtilp->add(dir, file); + + LLSD data = legacyLoadPreset(path); + if (data) + { + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); + + LLSettingsSky::ptr_t sky = LLSettingsSky::buildFromLegacyPreset(name, data); + LLEnvironment::instance().addSky(sky); + } + } + } + + // User skies + { + dir = getUserDir("skies"); + LLDirIterator dir_iter(dir, "*.xml"); + while (dir_iter.next(file)) + { + std::string path = gDirUtilp->add(dir, file); + + LLSD data = legacyLoadPreset(path); + if (data) + { + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); + + LLSettingsSky::ptr_t sky = LLSettingsSky::buildFromLegacyPreset(name, data); + LLEnvironment::instance().addSky(sky); + } + } + } + + // System water + { + dir = getSysDir("water"); + LLDirIterator dir_iter(dir, "*.xml"); + while (dir_iter.next(file)) + { + std::string path = gDirUtilp->add(dir, file); + + LLSD data = legacyLoadPreset(path); + if (data) + { + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); + + LLSettingsWater::ptr_t water = LLSettingsWater::buildFromLegacyPreset(name, data); + LLEnvironment::instance().addWater(water); + } + } + } + + // User water + { + dir = getUserDir("water"); + LLDirIterator dir_iter(dir, "*.xml"); + while (dir_iter.next(file)) + { + std::string path = gDirUtilp->add(dir, file); + + LLSD data = legacyLoadPreset(path); + if (data) + { + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); + + LLSettingsWater::ptr_t water = LLSettingsWater::buildFromLegacyPreset(name, data); + LLEnvironment::instance().addWater(water); + } + } + } + + // System water + { + dir = getSysDir("days"); + LLDirIterator dir_iter(dir, "*.xml"); + while (dir_iter.next(file)) + { + std::string path = gDirUtilp->add(dir, file); + + LLSD data = legacyLoadPreset(path); + if (data) + { + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); + + LLSettingsDayCycle::ptr_t day = LLSettingsDayCycle::buildFromLegacyPreset(name, data); + LLEnvironment::instance().addDayCycle(day); + } + } + } + + // User water + { + dir = getUserDir("days"); + LLDirIterator dir_iter(dir, "*.xml"); + while (dir_iter.next(file)) + { + std::string path = gDirUtilp->add(dir, file); + + LLSD data = legacyLoadPreset(path); + if (data) + { + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); + + LLSettingsDayCycle::ptr_t day = LLSettingsDayCycle::buildFromLegacyPreset(name, data); + LLEnvironment::instance().addDayCycle(day); + } + } + } +} diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 493fff1769..a3fc9eef66 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -32,6 +32,7 @@ #include "llsettingssky.h" #include "llsettingswater.h" +#include "llsettingsdaycycle.h" class LLViewerCamera; class LLGLSLShader; @@ -52,22 +53,22 @@ public: public: UserPrefs(); - bool getUseRegionSettings() const { return mUseRegionSettings; } - bool getUseDayCycle() const { return mUseDayCycle; } - bool getUseFixedSky() const { return !getUseDayCycle(); } + 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; } + 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); + 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(); + void load(); + void store(); bool mUseRegionSettings; bool mUseDayCycle; @@ -77,66 +78,104 @@ public: std::string mDayCycleName; }; + typedef std::pair name_id_t; + typedef std::vector list_name_id_t; + typedef boost::signals2::signal change_signal_t; + typedef boost::signals2::connection connection_t; + virtual ~LLEnvironment(); - void loadPreferences(); - const UserPrefs & getPreferences() const { return mUserPrefs; } + void loadPreferences(); + const UserPrefs & getPreferences() const { return mUserPrefs; } + + LLSettingsSky::ptr_t getCurrentSky() const { return mSelectedSky; } + LLSettingsWater::ptr_t getCurrentWater() const { return mSelectedWater; } - LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentSky; } - LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentWater; } + void update(const LLViewerCamera * cam); + void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); + void updateShaderUniforms(LLGLSLShader *shader); + void addSky(const LLSettingsSky::ptr_t &sky); + void addWater(const LLSettingsWater::ptr_t &sky); + void addDayCycle(const LLSettingsDayCycle::ptr_t &day); - void update(const LLViewerCamera * cam); + void selectSky(const std::string &name); + void selectSky(const LLSettingsSky::ptr_t &sky = LLSettingsSky::ptr_t()); + void applySky(const LLSettingsSky::ptr_t &sky = LLSettingsSky::ptr_t()); + void selectWater(const std::string &name); + void selectWater(const LLSettingsWater::ptr_t &water = LLSettingsWater::ptr_t()); + void applyWater(const LLSettingsWater::ptr_t water = LLSettingsWater::ptr_t()); + void selectDayCycle(const std::string &name); + void selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle = LLSettingsDayCycle::ptr_t()); + void applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle = LLSettingsDayCycle::ptr_t()); + void clearAllSelected(); + void applyAllSelected(); - void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); - void updateShaderUniforms(LLGLSLShader *shader); + list_name_id_t getSkyList() const; + list_name_id_t getWaterList() const; + list_name_id_t getDayCycleList() const; - void addSky(const LLSettingsSky::ptr_t &sky); - void selectSky(const std::string &name); - LLSettingsSky::ptr_t findSkyByName(std::string name) const; - LLSettingsWater::ptr_t findWaterByName(std::string name) const; + LLSettingsSky::ptr_t findSkyByName(std::string name) const; + LLSettingsWater::ptr_t findWaterByName(std::string name) const; + LLSettingsDayCycle::ptr_t findDayCycleByName(std::string name) const; - void addWater(const LLSettingsWater::ptr_t &sky); - void selectWater(const std::string &name); + inline LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; } - 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" - 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; } - inline F32 getSceneLightStrength() const { return mSceneLightStrength; } - inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; } + inline LLVector4 getLightDirection() const { return LLVector4(mSelectedSky->getLightDirection(), 0.0f); } + inline LLVector4 getClampedLightDirection() const { return LLVector4(mSelectedSky->getClampedLightDirection(), 0.0f); } + inline LLVector4 getRotatedLight() const { return mRotatedLight; } - inline LLVector4 getLightDirection() const { return LLVector4(mCurrentSky->getLightDirection(), 0.0f); } - inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); } - inline LLVector4 getRotatedLight() const { return mRotatedLight; } + //------------------------------------------- + connection_t setSkyListChange(const change_signal_t::slot_type& cb); + connection_t setWaterListChange(const change_signal_t::slot_type& cb); + connection_t setDayCycleListChange(const change_signal_t::slot_type& cb); +protected: + virtual void initSingleton(); private: - static const F32 SUN_DELTA_YAW; - static const F32 NIGHTTIME_ELEVATION_COS; + static const F32 SUN_DELTA_YAW; + static const F32 NIGHTTIME_ELEVATION_COS; typedef std::map NamedSettingMap_t; typedef std::map AssetSettingMap_t; - LLVector2 mCloudScrollDelta; // cumulative cloud delta + LLVector2 mCloudScrollDelta; // cumulative cloud delta + + LLSettingsSky::ptr_t mSelectedSky; + LLSettingsWater::ptr_t mSelectedWater; + LLSettingsDayCycle::ptr_t mSelectedDayCycle; + + LLSettingsSky::ptr_t mCurrentSky; + LLSettingsWater::ptr_t mCurrentWater; + LLSettingsDayCycle::ptr_t mCurrentDayCycle; + + NamedSettingMap_t mSkysByName; + AssetSettingMap_t mSkysById; - LLSettingsSky::ptr_t mCurrentSky; - LLSettingsWater::ptr_t mCurrentWater; + NamedSettingMap_t mWaterByName; + AssetSettingMap_t mWaterById; - NamedSettingMap_t mSkysByName; - AssetSettingMap_t mSkysById; + NamedSettingMap_t mDayCycleByName; + AssetSettingMap_t mDayCycleById; - NamedSettingMap_t mWaterByName; - AssetSettingMap_t mWaterById; + F32 mSceneLightStrength; + LLVector4 mRotatedLight; - F32 mSceneLightStrength; - LLVector4 mRotatedLight; + UserPrefs mUserPrefs; - UserPrefs mUserPrefs; + change_signal_t mSkyListChange; + change_signal_t mWaterListChange; + change_signal_t mDayCycleListChange; //void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky); void removeSky(const std::string &name); @@ -148,7 +187,20 @@ private: //void removeWater(const LLUUID &id); void clearAllWater(); + //void addDayCycle(const LLUUID &id, const LLSettingsSky::ptr_t &sky); + void removeDayCycle(const std::string &name); + //void removeDayCycle(const LLUUID &id); + void clearAllDayCycles(); + + void updateCloudScroll(); + + //========================================================================= + void legacyLoadAllPresets(); + LLSD legacyLoadPreset(const std::string& path); + static std::string getSysDir(const std::string &subdir); + static std::string getUserDir(const std::string &subdir); + }; diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index 54bbf85e86..31a093ad5d 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -328,6 +328,7 @@ private: void onRegionChange(); + /// Emitted when user environment preferences change. prefs_change_signal_t mUsePrefsChangeSignal; diff --git a/indra/newview/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp index 5c0991b0b3..97d87ee13e 100644 --- a/indra/newview/llfloatereditdaycycle.cpp +++ b/indra/newview/llfloatereditdaycycle.cpp @@ -691,6 +691,7 @@ void LLFloaterEditDayCycle::onDayCycleNameEdited() void LLFloaterEditDayCycle::onDayCycleSelected() { + LLSD day_data; LLWLParamKey dc_key = getSelectedDayCycle(); bool can_edit = true; diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 5fd559c060..23744e5b07 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -87,6 +87,8 @@ BOOL LLFloaterEditSky::postBuild() mSaveButton = getChild("save"); mSkyAdapter = boost::make_shared(); + LLEnvironment::instance().setSkyListChange(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); + initCallbacks(); // // Create the sun position scrubber on the slider. @@ -124,7 +126,7 @@ void LLFloaterEditSky::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 + LLEnvironment::instance().clearAllSelected(); } } @@ -216,6 +218,10 @@ void LLFloaterEditSky::syncControls() LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); mEditSettings = psky; + std::string name = psky->getName(); + + mSkyPresetNameEditor->setText(name); + mSkyPresetCombo->setValue(name); // blue horizon mSkyAdapter->mBlueHorizon.setColor3( psky->getBlueHorizon() ); @@ -557,44 +563,16 @@ bool LLFloaterEditSky::isNewPreset() const void LLFloaterEditSky::refreshSkyPresetsList() { -#if 0 mSkyPresetCombo->removeall(); - LLWLParamManager::preset_name_list_t region_presets, user_presets, sys_presets; - LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); - -#if 0 // Disable editing region skies until the workflow is clear enough. - // Add region presets. - std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); - for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it) - { - std::string item_title = *it + " (" + region_name + ")"; - mSkyPresetCombo->add(item_title, LLWLParamKey(*it, LLEnvKey::SCOPE_REGION).toLLSD()); - } - if (region_presets.size() > 0) - { - mSkyPresetCombo->addSeparator(); - } -#endif + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getSkyList(); - // Add user presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } - if (user_presets.size() > 0) - { - mSkyPresetCombo->addSeparator(); - } - - // Add system presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) - { - mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mSkyPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } mSkyPresetCombo->setLabel(getString("combo_label")); -#endif } void LLFloaterEditSky::enableEditing(bool enable) @@ -629,63 +607,51 @@ void LLFloaterEditSky::saveRegionSky() #endif } -// LLWLParamKey LLFloaterEditSky::getSelectedSkyPreset() -// { -// LLWLParamKey key; -// -// if (mSkyPresetNameEditor->getVisible()) -// { -// key.name = mSkyPresetNameEditor->getText(); -// key.scope = LLEnvKey::SCOPE_LOCAL; -// } -// else -// { -// LLSD combo_val = mSkyPresetCombo->getValue(); -// -// if (!combo_val.isArray()) // manually typed text -// { -// key.name = combo_val.asString(); -// key.scope = LLEnvKey::SCOPE_LOCAL; -// } -// else -// { -// key.fromLLSD(combo_val); -// } -// } -// -// return key; -// } +std::string LLFloaterEditSky::getSelectedPresetName() const +{ + std::string name; + if (mSkyPresetNameEditor->getVisible()) + { + name = mSkyPresetNameEditor->getText(); + } + else + { + LLSD combo_val = mSkyPresetCombo->getValue(); + name = combo_val[0].asString(); + } + + return name; +} void LLFloaterEditSky::onSkyPresetNameEdited() { -#if 0 - // Disable saving a sky preset having empty name. - LLWLParamKey key = getSelectedSkyPreset(); - mSaveButton->setEnabled(!key.name.empty()); -#endif + std::string name = mSkyPresetNameEditor->getText(); + LLSettingsWater::ptr_t psky = LLEnvironment::instance().getCurrentWater(); + + psky->setName(name); } void LLFloaterEditSky::onSkyPresetSelected() { -#if 0 - LLWLParamKey key = getSelectedSkyPreset(); - LLWLParamSet sky_params; + std::string name; - if (!LLWLParamManager::instance().getParamSet(key, sky_params)) - { - // Manually entered string? - LL_WARNS("Windlight") << "No sky preset named " << key.toString() << LL_ENDL; - return; - } + name = getSelectedPresetName(); - LLEnvManagerNew::instance().useSkyParams(sky_params.getAll()); - //syncControls(); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(name); - bool can_edit = (key.scope == LLEnvKey::SCOPE_LOCAL || LLEnvManagerNew::canEditRegionSettings()); - enableEditing(can_edit); + if (!psky) + { + LL_WARNS("WATEREDIT") << "Could not find water preset" << LL_ENDL; + enableEditing(false); + return; + } + + psky = psky->buildClone(); + LLEnvironment::instance().selectSky(psky); + + syncControls(); + enableEditing(true); - mMakeDefaultCheckBox->setEnabled(key.scope == LLEnvKey::SCOPE_LOCAL); -#endif } bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& response) @@ -733,43 +699,11 @@ void LLFloaterEditSky::onSaveConfirmed() void LLFloaterEditSky::onBtnSave() { -#if 0 - LLWLParamKey selected_sky = getSelectedSkyPreset(); - LLWLParamManager& wl_mgr = LLWLParamManager::instance(); - - if (selected_sky.scope == LLEnvKey::SCOPE_REGION) - { - saveRegionSky(); - closeFloater(); - return; - } - - std::string name = selected_sky.name; - if (name.empty()) - { - // *TODO: show an alert - LL_WARNS() << "Empty sky preset name" << LL_ENDL; - return; - } - - // Don't allow overwriting system presets. - if (wl_mgr.isSystemPreset(name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLEnvironment::instance().addSky(psky); - // Save, ask for confirmation for overwriting an existing preset. - if (wl_mgr.hasParamSet(selected_sky)) - { - LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), boost::bind(&LLFloaterEditSky::onSaveAnswer, this, _1, _2)); - } - else - { - // new preset, hence no confirmation needed - onSaveConfirmed(); - } -#endif + LLEnvironment::instance().applySky(); + closeFloater(); } void LLFloaterEditSky::onBtnCancel() @@ -779,6 +713,7 @@ void LLFloaterEditSky::onBtnCancel() void LLFloaterEditSky::onSkyPresetListChange() { + refreshSkyPresetsList(); #if 0 LLWLParamKey key = getSelectedSkyPreset(); // preset being edited if (!LLWLParamManager::instance().hasParamSet(key)) diff --git a/indra/newview/llfloatereditsky.h b/indra/newview/llfloatereditsky.h index 51be50a481..36438becce 100644 --- a/indra/newview/llfloatereditsky.h +++ b/indra/newview/llfloatereditsky.h @@ -98,7 +98,7 @@ private: void refreshSkyPresetsList(); void enableEditing(bool enable); void saveRegionSky(); -// LLWLParamKey getSelectedSkyPreset(); + std::string getSelectedPresetName() const; void onSkyPresetNameEdited(); void onSkyPresetSelected(); diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp index b025680da1..2868a0609a 100644 --- a/indra/newview/llfloatereditwater.cpp +++ b/indra/newview/llfloatereditwater.cpp @@ -73,6 +73,8 @@ BOOL LLFloaterEditWater::postBuild() mWaterAdapter = boost::make_shared(); + LLEnvironment::instance().setWaterListChange(boost::bind(&LLFloaterEditWater::onWaterPresetListChange, this)); + initCallbacks(); refreshWaterPresetsList(); syncControls(); @@ -109,7 +111,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 + LLEnvironment::instance().clearAllSelected(); } } @@ -176,6 +178,10 @@ void LLFloaterEditWater::syncControls() LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); mEditSettings = pwater; + std::string name = pwater->getName(); + mWaterPresetNameEditor->setText(name); + mWaterPresetCombo->setValue(name); + //getChild("WaterGlow")->setValue(col.mV[3]); getChild("WaterFogColor")->set(LLColor4(pwater->getFogColor())); @@ -322,44 +328,16 @@ 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 - // If the region already has water params, add them to the list. - const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - if (region_settings.getWaterParams().size() != 0) - { - const std::string& region_name = gAgent.getRegion()->getName(); - mWaterPresetCombo->add(region_name, LLSD().with(0, region_name).with(1, LLEnvKey::SCOPE_REGION)); - mWaterPresetCombo->addSeparator(); - } -#endif - - std::list user_presets, system_presets; - LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getWaterList(); - // Add local user presets first. - for (std::list::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - const std::string& name = *it; - mWaterPresetCombo->add(name, LLSD().with(0, name).with(1, LLEnvKey::SCOPE_LOCAL)); // [, ] - } - - if (user_presets.size() > 0) - { - mWaterPresetCombo->addSeparator(); - } - - // Add local system presets. - for (std::list::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) - { - const std::string& name = *it; - mWaterPresetCombo->add(name, LLSD().with(0, name).with(1, LLEnvKey::SCOPE_LOCAL)); // [, ] - } + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mWaterPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } mWaterPresetCombo->setLabel(getString("combo_label")); -#endif } void LLFloaterEditWater::enableEditing(bool enable) @@ -406,36 +384,28 @@ LLEnvKey::EScope LLFloaterEditWater::getCurrentScope() const } #endif -#if 0 -void LLFloaterEditWater::getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const +std::string LLFloaterEditWater::getSelectedPresetName() const { - + std::string name; if (mWaterPresetNameEditor->getVisible()) { name = mWaterPresetNameEditor->getText(); - scope = LLEnvKey::SCOPE_LOCAL; } else { LLSD combo_val = mWaterPresetCombo->getValue(); - - if (!combo_val.isArray()) // manually typed text - { - name = combo_val.asString(); - scope = LLEnvKey::SCOPE_LOCAL; - } - else - { - name = combo_val[0].asString(); - scope = (LLEnvKey::EScope) combo_val[1].asInteger(); - } + name = combo_val[0].asString(); } + return name; } -#endif void LLFloaterEditWater::onWaterPresetNameEdited() { + std::string name = mWaterPresetNameEditor->getText(); + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + + pwater->setName(name); #if 0 // Disable saving a water preset having empty name. mSaveButton->setEnabled(!getCurrentPresetName().empty()); @@ -444,35 +414,24 @@ void LLFloaterEditWater::onWaterPresetNameEdited() void LLFloaterEditWater::onWaterPresetSelected() { -#if 0 - LLWaterParamSet water_params; std::string name; - LLEnvKey::EScope scope; - getSelectedPreset(name, scope); + name = getSelectedPresetName(); - // Display selected preset. - if (scope == LLEnvKey::SCOPE_REGION) - { - water_params.setAll(LLEnvManagerNew::instance().getRegionSettings().getWaterParams()); - } - else // local preset selected - { - if (!LLWaterParamManager::instance().getParamSet(name, water_params)) - { - // Manually entered string? - LL_WARNS("Windlight") << "No water preset named " << name << LL_ENDL; - return; - } - } + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(name); - LLEnvManagerNew::instance().useWaterParams(water_params.getAll()); + if (!pwater) + { + LL_WARNS("WATEREDIT") << "Could not find water preset" << LL_ENDL; + enableEditing(false); + return; + } - bool can_edit = (scope == LLEnvKey::SCOPE_LOCAL || LLEnvManagerNew::canEditRegionSettings()); - enableEditing(can_edit); + pwater = pwater->buildClone(); + LLEnvironment::instance().selectWater(pwater); - mMakeDefaultCheckBox->setEnabled(scope == LLEnvKey::SCOPE_LOCAL); -#endif + syncControls(); + enableEditing(true); } bool LLFloaterEditWater::onSaveAnswer(const LLSD& notification, const LLSD& response) @@ -521,44 +480,11 @@ void LLFloaterEditWater::onSaveConfirmed() void LLFloaterEditWater::onBtnSave() { -#if 0 - LLEnvKey::EScope scope; - std::string name; - getSelectedPreset(name, scope); - - if (scope == LLEnvKey::SCOPE_REGION) - { - saveRegionWater(); - closeFloater(); - return; - } - - if (name.empty()) - { - // *TODO: show an alert - LL_WARNS() << "Empty water preset name" << LL_ENDL; - return; - } - - // Don't allow overwriting system presets. - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - if (water_mgr.isSystemPreset(name)) - { - LLNotificationsUtil::add("WLNoEditDefault"); - return; - } + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + LLEnvironment::instance().addWater(pwater); - // Save, ask for confirmation for overwriting an existing preset. - if (water_mgr.hasParamSet(name)) - { - LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), boost::bind(&LLFloaterEditWater::onSaveAnswer, this, _1, _2)); - } - else - { - // new preset, hence no confirmation needed - onSaveConfirmed(); - } -#endif + LLEnvironment::instance().applyWater(); + closeFloater(); } void LLFloaterEditWater::onBtnCancel() @@ -568,23 +494,7 @@ void LLFloaterEditWater::onBtnCancel() void LLFloaterEditWater::onWaterPresetListChange() { -#if 0 - std::string name; - LLEnvKey::EScope scope; - getSelectedPreset(name, scope); // preset being edited - - if (scope == LLEnvKey::SCOPE_LOCAL && !LLWaterParamManager::instance().hasParamSet(name)) - { - // Preset we've been editing doesn't exist anymore. Close the floater. - closeFloater(false); - } - else - { - // A new preset has been added. - // Refresh the presets list, though it may not make sense as the floater is about to be closed. - refreshWaterPresetsList(); - } -#endif + refreshWaterPresetsList(); } void LLFloaterEditWater::onRegionSettingsChange() diff --git a/indra/newview/llfloatereditwater.h b/indra/newview/llfloatereditwater.h index 7d9e493ac2..081b939039 100644 --- a/indra/newview/llfloatereditwater.h +++ b/indra/newview/llfloatereditwater.h @@ -87,6 +87,7 @@ private: void enableEditing(bool enable); void saveRegionWater(); + std::string getSelectedPresetName() const; // std::string getCurrentPresetName() const; // LLEnvKey::EScope getCurrentScope() const; // void getSelectedPreset(std::string& name, LLEnvKey::EScope& scope) const; diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 39907b19a3..e25c5cedbf 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -70,10 +70,10 @@ BOOL LLFloaterEnvironmentSettings::postBuild() setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this)); + LLEnvironment::instance().setSkyListChange(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this)); + LLEnvironment::instance().setWaterListChange(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this)); + LLEnvironment::instance().setDayCycleListChange(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, 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; } @@ -84,6 +84,14 @@ void LLFloaterEnvironmentSettings::onOpen(const LLSD& key) refresh(); } +//virtual +void LLFloaterEnvironmentSettings::onClose(bool app_quitting) +{ + if (!app_quitting) + LLEnvironment::instance().clearAllSelected(); +} + + void LLFloaterEnvironmentSettings::onSwitchRegionSettings() { getChild("user_environment_settings")->setEnabled(mRegionSettingsRadioGroup->getSelectedIndex() != 0); @@ -133,6 +141,7 @@ void LLFloaterEnvironmentSettings::onBtnOK() use_region_settings); // *TODO: This triggers applying user preferences again, which is suboptimal. + LLEnvironment::instance().applyAllSelected(); closeFloater(); } @@ -173,9 +182,9 @@ void LLFloaterEnvironmentSettings::apply() // Update environment with the user choice. bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0; bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - std::string water_preset = mWaterPresetCombo->getValue().asString(); - std::string sky_preset = mSkyPresetCombo->getValue().asString(); - std::string day_cycle = mDayCyclePresetCombo->getValue().asString(); + std::string water_preset = mWaterPresetCombo->getValue()[0].asString(); + std::string sky_preset = mSkyPresetCombo->getValue()[0].asString(); + std::string day_cycle = mDayCyclePresetCombo->getValue()[0].asString(); LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); if (use_region_settings) @@ -186,18 +195,23 @@ void LLFloaterEnvironmentSettings::apply() { if (use_fixed_sky) { - /* LAPRAS */ - //env_mgr.useSkyPreset(sky_preset); - LLEnvironment::instance().selectSky(sky_preset); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(sky_preset); + if (psky) + LLEnvironment::instance().selectSky(psky); } else { - env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL); + LLSettingsDayCycle::ptr_t pday = LLEnvironment::instance().findDayCycleByName(day_cycle); + if (pday) + LLEnvironment::instance().selectDayCycle(pday); + +// LLEnvironment::instance().selectDayCycle(day_cycle); +// env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL); } - /* LAPRAS */ - //env_mgr.useWaterPreset(water_preset); - LLEnvironment::instance().selectWater(water_preset); + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(water_preset); + if (pwater) + LLEnvironment::instance().selectWater(pwater); } } @@ -209,76 +223,36 @@ void LLFloaterEnvironmentSettings::cancel() void LLFloaterEnvironmentSettings::populateWaterPresetsList() { - mWaterPresetCombo->removeall(); + mWaterPresetCombo->removeall(); - std::list user_presets, system_presets; - //LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getWaterList(); - // Add user presets first. - for (std::list::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mWaterPresetCombo->add(*it); - } - - if (user_presets.size() > 0) - { - mWaterPresetCombo->addSeparator(); - } - - // Add system presets. - for (std::list::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) - { - mWaterPresetCombo->add(*it); - } + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mWaterPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } } void LLFloaterEnvironmentSettings::populateSkyPresetsList() { mSkyPresetCombo->removeall(); - LLWLParamManager::preset_name_list_t region_presets; // unused as we don't list region presets here - LLWLParamManager::preset_name_list_t user_presets, sys_presets; - LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getSkyList(); - // Add user presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mSkyPresetCombo->add(*it); - } - - if (!user_presets.empty()) - { - mSkyPresetCombo->addSeparator(); - } - - // Add system presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) - { - mSkyPresetCombo->add(*it); - } + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mSkyPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } } void LLFloaterEnvironmentSettings::populateDayCyclePresetsList() { mDayCyclePresetCombo->removeall(); - LLDayCycleManager::preset_name_list_t user_days, sys_days; - LLDayCycleManager::instance().getPresetNames(user_days, sys_days); + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getDayCycleList(); - // Add user days. - for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) - { - mDayCyclePresetCombo->add(*it); - } - - if (user_days.size() > 0) - { - mDayCyclePresetCombo->addSeparator(); - } - - // Add system days. - for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it) - { - mDayCyclePresetCombo->add(*it); - } + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mDayCyclePresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } } diff --git a/indra/newview/llfloaterenvironmentsettings.h b/indra/newview/llfloaterenvironmentsettings.h index 0ab458a0f6..2236d57ff4 100644 --- a/indra/newview/llfloaterenvironmentsettings.h +++ b/indra/newview/llfloaterenvironmentsettings.h @@ -40,6 +40,7 @@ public: LLFloaterEnvironmentSettings(const LLSD &key); /*virtual*/ BOOL postBuild(); /*virtual*/ void onOpen(const LLSD& key); + /*virtual*/ void onClose(bool app_quitting); private: void onSwitchRegionSettings(); diff --git a/indra/newview/llsettingsbase.cpp b/indra/newview/llsettingsbase.cpp index 1f155776bf..a2e705d1fa 100644 --- a/indra/newview/llsettingsbase.cpp +++ b/indra/newview/llsettingsbase.cpp @@ -33,11 +33,16 @@ #include "llsdserialize.h" +//========================================================================= namespace { const F32 BREAK_POINT = 0.5; } +//========================================================================= +const std::string LLSettingsBase::SETTING_ID("id"); +const std::string LLSettingsBase::SETTING_NAME("name"); + //========================================================================= LLSettingsBase::LLSettingsBase(): mSettings(LLSD::emptyMap()), @@ -242,15 +247,16 @@ LLSD LLSettingsBase::cloneSettings() const LLSettingsBase::ptr_t LLSettingsBase::buildBlend(const ptr_t &begin, const ptr_t &end, F32 blendf) { - if (begin->getSettingType() != end->getSettingType()) - { - LL_WARNS("SETTINGS") << "Attempt to blend settings of different types! " << - begin->getSettingType() << "<->" << end->getSettingType() << LL_ENDL; - - return LLSettingsBase::ptr_t(); - } - - return begin->blend(end, blendf); +// if (begin->getSettingType() != end->getSettingType()) +// { +// LL_WARNS("SETTINGS") << "Attempt to blend settings of different types! " << +// begin->getSettingType() << "<->" << end->getSettingType() << LL_ENDL; +// +// return LLSettingsBase::ptr_t(); +// } + +// return begin->blend(end, blendf); + return LLSettingsBase::ptr_t(); } void LLSettingsBase::exportSettings(std::string name) const diff --git a/indra/newview/llsettingsbase.h b/indra/newview/llsettingsbase.h index f7015fb12b..205351c401 100644 --- a/indra/newview/llsettingsbase.h +++ b/indra/newview/llsettingsbase.h @@ -46,6 +46,9 @@ class LLSettingsBase: private boost::noncopyable friend class LLSettingsDayCycle; public: + static const std::string SETTING_ID; + static const std::string SETTING_NAME; + typedef std::map parammapping_t; typedef boost::shared_ptr ptr_t; @@ -63,6 +66,32 @@ public: inline bool isDirty() const { return mDirty; } inline void setDirtyFlag(bool dirty) { mDirty = dirty; } + inline LLUUID getId() const + { + return getValue(SETTING_ID).asUUID(); + } + + inline std::string getName() const + { + return getValue(SETTING_NAME).asString(); + } + + inline void setName(std::string val) + { + setValue(SETTING_NAME, val); + } + + inline void replaceSettings(LLSD settings) + { + mSettings = settings; + setDirtyFlag(true); + } + + inline LLSD getSettings() const + { + return mSettings; + } + //--------------------------------------------------------------------- // inline void setValue(const std::string &name, const LLSD &value) @@ -71,7 +100,7 @@ public: mDirty = true; } - inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) + inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) const { if (!mSettings.has(name)) return deflt; @@ -121,13 +150,14 @@ public: // TODO: This is temporary virtual void exportSettings(std::string name) const; + virtual void blend(const ptr_t &end, F32 blendf) = 0; + protected: LLSettingsBase(); LLSettingsBase(const LLSD setting); typedef std::set stringset_t; - virtual ptr_t blend(const ptr_t &end, F32 blendf) const = 0; // combining settings objects. Customize for specific setting types virtual void lerpSettings(const LLSettingsBase &other, F32 mix); diff --git a/indra/newview/llsettingsdaycycle.cpp b/indra/newview/llsettingsdaycycle.cpp index bda3c7c138..2d97ea865f 100644 --- a/indra/newview/llsettingsdaycycle.cpp +++ b/indra/newview/llsettingsdaycycle.cpp @@ -47,6 +47,8 @@ #include "llenvironment.h" +#include "llworld.h" + //========================================================================= namespace { @@ -55,7 +57,16 @@ namespace inline F32 get_wrapping_distance(F32 begin, F32 end) { - return 1.0 - fabs((begin + 1.0) - end); + if (begin < end) + { + return end - begin; + } + else if (begin > end) + { + return 1.0 - (begin - end); + } + + return 0; } LLSettingsDayCycle::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDayCycle::CycleTrack_t &collection, F32 key) @@ -81,11 +92,11 @@ namespace LLSettingsDayCycle::CycleTrack_t::iterator it = collection.lower_bound(key); if (it == collection.end()) - { // all offsets are lower, take the last one. + { // all keyframes are lower, take the last one. --it; // we know the range is not empty } else if ((*it).first > key) - { // the offset we are interested in is smaller than the found. + { // the keyframe we are interested in is smaller than the found. if (it == collection.begin()) it = collection.end(); --it; @@ -101,11 +112,13 @@ namespace const std::string LLSettingsDayCycle::SETTING_DAYLENGTH("day_length"); const std::string LLSettingsDayCycle::SETTING_KEYID("key_id"); const std::string LLSettingsDayCycle::SETTING_KEYNAME("key_name"); -const std::string LLSettingsDayCycle::SETTING_KEYOFFSET("key_offset"); +const std::string LLSettingsDayCycle::SETTING_KEYKFRAME("key_keyframe"); const std::string LLSettingsDayCycle::SETTING_NAME("name"); const std::string LLSettingsDayCycle::SETTING_TRACKS("tracks"); -const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours +const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 300); // 5 mins + +//const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours const S32 LLSettingsDayCycle::MAXIMUM_DAYLENGTH(604800); // 7 days const S32 LLSettingsDayCycle::TRACK_WATER(0); // water track is 0 @@ -113,13 +126,15 @@ const S32 LLSettingsDayCycle::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water //========================================================================= LLSettingsDayCycle::LLSettingsDayCycle(const LLSD &data) : - LLSettingsBase(data) + LLSettingsBase(data), + mHasParsed(false) { mDayTracks.resize(TRACK_MAX); } LLSettingsDayCycle::LLSettingsDayCycle() : - LLSettingsBase() + LLSettingsBase(), + mHasParsed(false) { mDayTracks.resize(TRACK_MAX); } @@ -132,8 +147,8 @@ LLSD LLSettingsDayCycle::defaults() dfltsetting[SETTING_NAME] = "_default_"; dfltsetting[SETTING_DAYLENGTH] = MINIMUM_DAYLENGTH; dfltsetting[SETTING_TRACKS] = LLSDArray( - LLSDArray(LLSDMap(SETTING_KEYOFFSET, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_")) - (LLSDMap(SETTING_KEYOFFSET, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_"))); + LLSDArray(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_")) + (LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_"))); return dfltsetting; } @@ -146,14 +161,14 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyPreset(const std::s newsettings[SETTING_DAYLENGTH] = MINIMUM_DAYLENGTH; LLSD watertrack = LLSDArray( - LLSDMap ( SETTING_KEYOFFSET, LLSD::Real(0.0f) ) + LLSDMap ( SETTING_KEYKFRAME, LLSD::Real(0.0f) ) ( SETTING_KEYNAME, "Default" )); LLSD skytrack = LLSD::emptyArray(); for (LLSD::array_const_iterator it = oldsettings.beginArray(); it != oldsettings.endArray(); ++it) { - LLSD entry = LLSDMap(SETTING_KEYOFFSET, (*it)[0].asReal()) + LLSD entry = LLSDMap(SETTING_KEYKFRAME, (*it)[0].asReal()) (SETTING_KEYNAME, (*it)[1].asString()); skytrack.append(entry); } @@ -185,7 +200,7 @@ void LLSettingsDayCycle::parseFromLLSD(LLSD &data) LLSD curtrack = tracks[i]; for (LLSD::array_const_iterator it = curtrack.beginArray(); it != curtrack.endArray(); ++it) { - F32 offset = (*it)[SETTING_KEYOFFSET].asReal(); + F32 keyframe = (*it)[SETTING_KEYKFRAME].asReal(); LLSettingsBase::ptr_t setting; if ((*it).has(SETTING_KEYNAME)) @@ -201,9 +216,10 @@ void LLSettingsDayCycle::parseFromLLSD(LLSD &data) } if (setting) - mDayTracks[i][offset] = setting; + mDayTracks[i][keyframe] = setting; } } + mHasParsed = true; } @@ -216,31 +232,85 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildClone() return dayp; } -LLSettingsBase::ptr_t LLSettingsDayCycle::blend(const LLSettingsBase::ptr_t &other, F32 mix) const +void LLSettingsDayCycle::blend(const LLSettingsBase::ptr_t &other, F32 mix) { LL_ERRS("DAYCYCLE") << "Day cycles are not blendable!" << LL_ENDL; - return LLSettingsBase::ptr_t(); } //========================================================================= -F32 LLSettingsDayCycle::secondsToOffset(S32 seconds) +F32 LLSettingsDayCycle::secondsToKeyframe(S32 seconds) { S32 daylength = getDayLength(); return static_cast(seconds % daylength) / static_cast(daylength); } -S32 LLSettingsDayCycle::offsetToSeconds(F32 offset) +S32 LLSettingsDayCycle::keyframeToSeconds(F32 keyframe) { S32 daylength = getDayLength(); - return static_cast(offset * static_cast(daylength)); + return static_cast(keyframe * static_cast(daylength)); } //========================================================================= void LLSettingsDayCycle::updateSettings() { + if (!mHasParsed) + parseFromLLSD(mSettings); + //F64Seconds time_now(LLWorld::instance().getSpaceTimeUSec()); + F64Seconds time_now(LLDate::now().secondsSinceEpoch()); + + // base class clears dirty flag so as to not trigger recursive update + LLSettingsBase::updateSettings(); + + if (!mBlendedWater) + { + mBlendedWater = LLEnvironment::instance().getCurrentWater()->buildClone(); + LLEnvironment::instance().selectWater(mBlendedWater); + } + + if (!mBlendedSky) + { + mBlendedSky = LLEnvironment::instance().getCurrentSky()->buildClone(); + LLEnvironment::instance().selectSky(mBlendedSky); + } + + + if ((time_now < mLastUpdateTime) || ((time_now - mLastUpdateTime) > static_cast(0.1))) + { + F64Seconds daylength = static_cast(getDayLength()); + F32 frame = fmod(time_now.value(), daylength.value()) / daylength.value(); + + CycleList_t::iterator itTrack = mDayTracks.begin(); + TrackBound_t bounds = getBoundingEntries(*itTrack, frame); + + mBlendedWater->replaceSettings((*bounds.first).second->getSettings()); + if (bounds.first != bounds.second) + { + F32 blendf = get_wrapping_distance((*bounds.first).first, frame) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + mBlendedWater->blend((*bounds.second).second, blendf); + } + + ++itTrack; + bounds = getBoundingEntries(*itTrack, frame); + + //_WARNS("RIDER") << "Sky blending: frame=" << frame << " start=" << F64Seconds((*bounds.first).first) << " end=" << F64Seconds((*bounds.second).first) << LL_ENDL; + + mBlendedSky->replaceSettings((*bounds.first).second->getSettings()); + if (bounds.first != bounds.second) + { + F32 blendf = get_wrapping_distance((*bounds.first).first, frame) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + //_WARNS("RIDER") << "Distance=" << get_wrapping_distance((*bounds.first).first, frame) << "/" << get_wrapping_distance((*bounds.first).first, (*bounds.second).first) << " Blend factor=" << blendf << LL_ENDL; + + mBlendedSky->blend((*bounds.second).second, blendf); + } + + mLastUpdateTime = time_now; + } + + // Always mark the day cycle as dirty.So that the blend check can be handled. + setDirtyFlag(true); } //========================================================================= @@ -251,40 +321,40 @@ void LLSettingsDayCycle::setDayLength(S32 seconds) setValue(SETTING_DAYLENGTH, seconds); } -LLSettingsDayCycle::OffsetList_t LLSettingsDayCycle::getTrackOffsets(S32 trackno) +LLSettingsDayCycle::KeyframeList_t LLSettingsDayCycle::getTrackKeyframes(S32 trackno) { if ((trackno < 1) || (trackno >= TRACK_MAX)) { LL_WARNS("DAYCYCLE") << "Attempt get track (#" << trackno << ") out of range!" << LL_ENDL; - return OffsetList_t(); + return KeyframeList_t(); } - OffsetList_t offsets; + KeyframeList_t keyframes; CycleTrack_t &track = mDayTracks[trackno]; - offsets.reserve(track.size()); + keyframes.reserve(track.size()); for (CycleTrack_t::iterator it = track.begin(); it != track.end(); ++it) { - offsets.push_back((*it).first); + keyframes.push_back((*it).first); } - return offsets; + return keyframes; } LLSettingsDayCycle::TimeList_t LLSettingsDayCycle::getTrackTimes(S32 trackno) { - OffsetList_t offsets = getTrackOffsets(trackno); + KeyframeList_t keyframes = getTrackKeyframes(trackno); - if (offsets.empty()) + if (keyframes.empty()) return TimeList_t(); TimeList_t times; - times.reserve(offsets.size()); - for (OffsetList_t::iterator it = offsets.begin(); it != offsets.end(); ++it) + times.reserve(keyframes.size()); + for (KeyframeList_t::iterator it = keyframes.begin(); it != keyframes.end(); ++it) { - times.push_back(offsetToSeconds(*it)); + times.push_back(keyframeToSeconds(*it)); } return times; @@ -292,13 +362,13 @@ LLSettingsDayCycle::TimeList_t LLSettingsDayCycle::getTrackTimes(S32 trackno) void LLSettingsDayCycle::setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 seconds) { - F32 offset = secondsToOffset(seconds); - setWaterAtOffset(water, offset); + F32 keyframe = secondsToKeyframe(seconds); + setWaterAtKeyframe(water, keyframe); } -void LLSettingsDayCycle::setWaterAtOffset(const LLSettingsWaterPtr_t &water, F32 offset) +void LLSettingsDayCycle::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe) { - mDayTracks[TRACK_WATER][offset] = water; + mDayTracks[TRACK_WATER][keyframe] = water; setDirtyFlag(true); } @@ -310,34 +380,33 @@ void LLSettingsDayCycle::setSkyAtOnTrack(const LLSettingsSkyPtr_t &sky, S32 seco LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL; return; } - F32 offset = secondsToOffset(seconds); + F32 keyframe = secondsToKeyframe(seconds); - mDayTracks[track][offset] = sky; + mDayTracks[track][keyframe] = sky; setDirtyFlag(true); - } -LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(CycleTrack_t &track, F32 offset) +LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(CycleTrack_t &track, F32 keyframe) { - return TrackBound_t(get_wrapping_atbefore(track, offset), get_wrapping_atafter(track, offset)); + return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); } -LLSettingsBase::ptr_t LLSettingsDayCycle::getBlendedEntry(CycleTrack_t &track, F32 offset) -{ - TrackBound_t bounds = getBoundingEntries(track, offset); - - if (bounds.first == track.end()) - return LLSettingsBase::ptr_t(); // Track is empty nothing to blend. - - if (bounds.first == bounds.second) - { // Single entry. Nothing to blend - return (*bounds.first).second; - } - - F32 blendf = get_wrapping_distance((*bounds.first).first, offset) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first); - - LLSettingsBase::ptr_t base = (*bounds.first).second; - return base->blend((*bounds.second).second, blendf); -} +// LLSettingsBase::ptr_t LLSettingsDayCycle::getBlendedEntry(CycleTrack_t &track, F32 keyframe) +// { +// TrackBound_t bounds = getBoundingEntries(track, keyframe); +// +// if (bounds.first == track.end()) +// return LLSettingsBase::ptr_t(); // Track is empty nothing to blend. +// +// if (bounds.first == bounds.second) +// { // Single entry. Nothing to blend +// return (*bounds.first).second; +// } +// +// F32 blendf = get_wrapping_distance((*bounds.first).first, keyframe) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first); +// +// LLSettingsBase::ptr_t base = (*bounds.first).second; +// return base->blend((*bounds.second).second, blendf); +// } //========================================================================= diff --git a/indra/newview/llsettingsdaycycle.h b/indra/newview/llsettingsdaycycle.h index 5eb704cdb7..f332b85dee 100644 --- a/indra/newview/llsettingsdaycycle.h +++ b/indra/newview/llsettingsdaycycle.h @@ -42,7 +42,7 @@ public: static const std::string SETTING_DAYLENGTH; static const std::string SETTING_KEYID; static const std::string SETTING_KEYNAME; - static const std::string SETTING_KEYOFFSET; + static const std::string SETTING_KEYKFRAME; static const std::string SETTING_NAME; static const std::string SETTING_TRACKS; @@ -56,7 +56,7 @@ public: typedef std::vector CycleList_t; typedef boost::shared_ptr ptr_t; typedef std::vector TimeList_t; - typedef std::vector OffsetList_t; + typedef std::vector KeyframeList_t; typedef std::pair TrackBound_t; //--------------------------------------------------------------------- @@ -71,7 +71,7 @@ public: virtual std::string getSettingType() const { return std::string("daycycle"); } // Settings status - virtual LLSettingsBase::ptr_t blend(const LLSettingsBase::ptr_t &other, F32 mix) const; + virtual void blend(const LLSettingsBase::ptr_t &other, F32 mix); static LLSD defaults(); @@ -83,11 +83,11 @@ public: void setDayLength(S32 seconds); - OffsetList_t getTrackOffsets(S32 track); + KeyframeList_t getTrackKeyframes(S32 track); TimeList_t getTrackTimes(S32 track); void setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 seconds); - void setWaterAtOffset(const LLSettingsWaterPtr_t &water, F32 offset); + void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe); LLSettingsSkyPtr_t getBlendedWaterAt(S32 seconds); void setSkyAtOnTrack(const LLSettingsSkyPtr_t &sky, S32 seconds, S32 track); @@ -98,23 +98,27 @@ protected: virtual void updateSettings(); + LLSettingsSkyPtr_t mBlendedSky; + LLSettingsWaterPtr_t mBlendedWater; CycleList_t mDayTracks; - F32 secondsToOffset(S32 seconds); - S32 offsetToSeconds(F32 offset); + bool mHasParsed; - LLSettingsBase::ptr_t getBlendedEntry(CycleTrack_t &track, F32 offset); + F32 secondsToKeyframe(S32 seconds); + S32 keyframeToSeconds(F32 keyframe); + + //LLSettingsBase::ptr_t getBlendedEntry(const CycleTrack_t &track, F32 keyframe); void parseFromLLSD(LLSD &data); // CycleList_t & getTrackRef(S32 trackno); - static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 offset); - static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 offset); - - static TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 offset); + static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 keyframe); + static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 keyframe); + static TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 keyframe); + F32Seconds mLastUpdateTime; private: }; diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index 782703c7f7..c420ebca1e 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -81,7 +81,6 @@ const std::string LLSettingsSky::SETTING_LIGHT_NORMAL("lightnorm"); const std::string LLSettingsSky::SETTING_MAX_Y("max_y"); const std::string LLSettingsSky::SETTING_MOON_ROTATION("moon_rotation"); const std::string LLSettingsSky::SETTING_MOON_TEXTUREID("moon_id"); -const std::string LLSettingsSky::SETTING_NAME("name"); const std::string LLSettingsSky::SETTING_STAR_BRIGHTNESS("star_brightness"); const std::string LLSettingsSky::SETTING_SUNLIGHT_COLOR("sunlight_color"); const std::string LLSettingsSky::SETTING_SUN_ROTATION("sun_rotation"); @@ -103,14 +102,12 @@ LLSettingsSky::LLSettingsSky(): { } -LLSettingsBase::ptr_t LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F32 blendf) const +void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F32 blendf) { LLSettingsSky::ptr_t other = boost::static_pointer_cast(end); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); - LLSettingsSky::ptr_t skyp = boost::make_shared(blenddata); - - return skyp; + replaceSettings(blenddata); } @@ -301,18 +298,18 @@ LLSettingsSky::ptr_t LLSettingsSky::buildClone() // Settings status -LLSettingsSky::ptr_t LLSettingsSky::blend(const LLSettingsSky::ptr_t &other, F32 mix) const -{ - 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(mSettings); - // the settings in the initial constructor are references to this' settings block. - // They will be replaced in the following lerp - skyp->lerpSettings(*other, mix); - - return skyp; -} +// LLSettingsSky::ptr_t LLSettingsSky::blend(const LLSettingsSky::ptr_t &other, F32 mix) const +// { +// 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(mSettings); +// // the settings in the initial constructor are references to this' settings block. +// // They will be replaced in the following lerp +// skyp->lerpSettings(*other, mix); +// +// return skyp; +// } LLSD LLSettingsSky::defaults() diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h index 977ab5141e..ade5a06553 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -56,7 +56,6 @@ public: static const std::string SETTING_MAX_Y; static const std::string SETTING_MOON_ROTATION; static const std::string SETTING_MOON_TEXTUREID; - static const std::string SETTING_NAME; static const std::string SETTING_STAR_BRIGHTNESS; static const std::string SETTING_SUNLIGHT_COLOR; static const std::string SETTING_SUN_ROTATION; @@ -77,7 +76,7 @@ public: virtual std::string getSettingType() const { return std::string("sky"); } // Settings status - ptr_t blend(const ptr_t &other, F32 mix) const; + virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf); static LLSD defaults(); @@ -414,7 +413,6 @@ public: protected: LLSettingsSky(); - virtual LLSettingsBase::ptr_t blend(const LLSettingsBase::ptr_t &end, F32 blendf) const; virtual stringset_t getSlerpKeys() const; diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp index 52448bd4af..9a6dfc15fd 100644 --- a/indra/newview/llsettingswater.cpp +++ b/indra/newview/llsettingswater.cpp @@ -56,7 +56,6 @@ 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"); @@ -195,14 +194,12 @@ LLSettingsWater::ptr_t LLSettingsWater::buildClone() return skyp; } -LLSettingsBase::ptr_t LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F32 blendf) const +void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F32 blendf) { LLSettingsWater::ptr_t other = boost::static_pointer_cast(end); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); - - LLSettingsWater::ptr_t waterp = boost::make_shared(blenddata); - - return waterp; + + replaceSettings(blenddata); } diff --git a/indra/newview/llsettingswater.h b/indra/newview/llsettingswater.h index 6a7e692c25..1550ba4004 100644 --- a/indra/newview/llsettingswater.h +++ b/indra/newview/llsettingswater.h @@ -39,7 +39,6 @@ public: 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; @@ -63,7 +62,7 @@ public: virtual std::string getSettingType() const { return std::string("water"); } // Settings status - virtual LLSettingsBase::ptr_t blend(const LLSettingsBase::ptr_t &end, F32 blendf) const; + virtual void blend(const LLSettingsBase::ptr_t &end, F32 blendf); static LLSD defaults(); diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index eb21f3c4b4..9e275fd108 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -135,10 +135,6 @@ 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; } diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index a6dc2b343b..966a7840cf 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -319,11 +319,6 @@ bool LLWLParamManager::loadPreset(const std::string& path) addParamSet(key, params_data); } - //*LAPRAS temp code testing conversion old preset to new settings. - LLSettingsSky::ptr_t test = LLSettingsSky::buildFromLegacyPreset(name, params_data); - LLEnvironment::instance().addSky(test); - //test->exportSettings(name); - return true; } -- cgit v1.3 From b227c86b450134f17ec0624655e1e4c5cb5ba89d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 13 Nov 2017 14:40:54 -0800 Subject: Remove the old wl environment code. --- indra/newview/CMakeLists.txt | 17 - indra/newview/lldaycyclemanager.h | 5 +- indra/newview/lldrawpoolwlsky.cpp | 3 - indra/newview/llenvmanager.cpp | 720 ------------------------- indra/newview/llenvmanager.h | 350 ------------ indra/newview/llfloatereditdaycycle.cpp | 87 ++- indra/newview/llfloatereditdaycycle.h | 26 +- indra/newview/llfloatereditsky.cpp | 16 - indra/newview/llfloaterenvironmentsettings.cpp | 4 +- indra/newview/llfloaterregioninfo.cpp | 38 +- indra/newview/llfloaterregioninfo.h | 5 - indra/newview/llstartup.cpp | 1 - indra/newview/llviewerdisplay.cpp | 1 - indra/newview/llviewermenu.cpp | 29 +- indra/newview/llviewershadermgr.cpp | 1 - indra/newview/llvosky.cpp | 1 - indra/newview/llwaterparammanager.cpp | 448 --------------- indra/newview/llwaterparammanager.h | 413 -------------- indra/newview/llwaterparamset.cpp | 266 --------- indra/newview/llwaterparamset.h | 165 ------ indra/newview/llwlanimator.cpp | 324 ----------- indra/newview/llwlanimator.h | 140 ----- indra/newview/llwldaycycle.cpp | 114 ++-- indra/newview/llwldaycycle.h | 7 +- indra/newview/llwlparammanager.cpp | 714 ------------------------ indra/newview/llwlparammanager.h | 329 ----------- indra/newview/llwlparamset.cpp | 426 --------------- indra/newview/llwlparamset.h | 246 --------- indra/newview/pipeline.cpp | 1 - 29 files changed, 156 insertions(+), 4741 deletions(-) delete mode 100644 indra/newview/llenvmanager.cpp delete mode 100644 indra/newview/llenvmanager.h delete mode 100644 indra/newview/llwaterparammanager.cpp delete mode 100644 indra/newview/llwaterparammanager.h delete mode 100644 indra/newview/llwaterparamset.cpp delete mode 100644 indra/newview/llwaterparamset.h delete mode 100644 indra/newview/llwlanimator.cpp delete mode 100644 indra/newview/llwlanimator.h delete mode 100644 indra/newview/llwlparammanager.cpp delete mode 100644 indra/newview/llwlparammanager.h delete mode 100644 indra/newview/llwlparamset.cpp delete mode 100644 indra/newview/llwlparamset.h (limited to 'indra/newview/llwaterparammanager.cpp') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 369ce6f24e..bbe32866f6 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -158,7 +158,6 @@ set(viewer_SOURCE_FILES llcurrencyuimanager.cpp llcylinder.cpp lldateutil.cpp - lldaycyclemanager.cpp lldebugmessagebox.cpp lldebugview.cpp lldeferredsounds.cpp @@ -183,7 +182,6 @@ set(viewer_SOURCE_FILES llemote.cpp llenvadapters.cpp llenvironment.cpp - llenvmanager.cpp llestateinfomodel.cpp lleventnotifier.cpp lleventpoll.cpp @@ -692,19 +690,13 @@ set(viewer_SOURCE_FILES llvowater.cpp llvowlsky.cpp llwatchdog.cpp - llwaterparammanager.cpp - llwaterparamset.cpp llwearableitemslist.cpp llwearablelist.cpp llweb.cpp llwebprofile.cpp llwind.cpp llwindowlistener.cpp - llwlanimator.cpp - llwldaycycle.cpp llwlhandlers.cpp - llwlparammanager.cpp - llwlparamset.cpp llworld.cpp llworldmap.cpp llworldmapmessage.cpp @@ -783,7 +775,6 @@ set(viewer_HEADER_FILES llcurrencyuimanager.h llcylinder.h lldateutil.h - lldaycyclemanager.h lldebugmessagebox.h lldebugview.h lldeferredsounds.h @@ -808,7 +799,6 @@ set(viewer_HEADER_FILES llemote.h llenvadapters.h llenvironment.h - llenvmanager.h llestateinfomodel.h lleventnotifier.h lleventpoll.h @@ -1311,19 +1301,13 @@ set(viewer_HEADER_FILES llvowater.h llvowlsky.h llwatchdog.h - llwaterparammanager.h - llwaterparamset.h llwearableitemslist.h llwearablelist.h llweb.h llwebprofile.h llwind.h llwindowlistener.h - llwlanimator.h - llwldaycycle.h llwlhandlers.h - llwlparammanager.h - llwlparamset.h llworld.h llworldmap.h llworldmapmessage.h @@ -2369,7 +2353,6 @@ if (LL_TESTS) include(LLAddBuildTest) SET(viewer_TEST_SOURCE_FILES llagentaccess.cpp - llwlparammanager.cpp ) set_source_files_properties( ${viewer_TEST_SOURCE_FILES} diff --git a/indra/newview/lldaycyclemanager.h b/indra/newview/lldaycyclemanager.h index 04db9d5dac..810212c92a 100644 --- a/indra/newview/lldaycyclemanager.h +++ b/indra/newview/lldaycyclemanager.h @@ -30,7 +30,6 @@ #include #include -#include "llwldaycycle.h" #include "llwlparammanager.h" /** @@ -46,14 +45,14 @@ class LLDayCycleManager : public LLSingleton public: typedef std::list preset_name_list_t; - typedef std::map dc_map_t; +// typedef std::map dc_map_t; typedef boost::signals2::signal modify_signal_t; void getPresetNames(preset_name_list_t& names) const; void getPresetNames(preset_name_list_t& user, preset_name_list_t& sys) const; void getUserPresetNames(preset_name_list_t& user) const; - bool getPreset(const std::string name, LLWLDayCycle& day_cycle) const; +// bool getPreset(const std::string name, LLWLDayCycle& day_cycle) const; bool getPreset(const std::string name, LLSD& day_cycle) const; bool presetExists(const std::string name) const; bool isSystemPreset(const std::string& name) const; diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 2ff4edabe3..f10c116555 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -81,9 +81,6 @@ LLDrawPoolWLSky::LLDrawPoolWLSky(void) : sCloudNoiseRawImage = NULL ; } } - - /* *LAPRAS */ -// LLWLParamManager::getInstance()->propagateParameters(); } LLDrawPoolWLSky::~LLDrawPoolWLSky() diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp deleted file mode 100644 index 5fc9231506..0000000000 --- a/indra/newview/llenvmanager.cpp +++ /dev/null @@ -1,720 +0,0 @@ -/** - * @file llenvmanager.cpp - * @brief Implementation of classes managing WindLight and water settings. - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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 "llagent.h" -#include "lldaycyclemanager.h" -#include "llviewercontrol.h" // for gSavedSettings -#include "llviewerregion.h" -#include "llwaterparammanager.h" -#include "llwlhandlers.h" -#include "llwlparammanager.h" -#include "lltrans.h" -#include "llenvmanager.h" - -std::string LLWLParamKey::toString() const -{ - switch (scope) - { - case SCOPE_LOCAL: - return name + std::string(" (") + LLTrans::getString("Local") + std::string(")"); - break; - case SCOPE_REGION: - return name + std::string(" (") + LLTrans::getString("Region") + std::string(")"); - break; - default: - return name + " (?)"; - } -} - -std::string LLEnvPrefs::getWaterPresetName() const -{ - if (mWaterPresetName.empty()) - { - LL_WARNS() << "Water preset name is empty" << LL_ENDL; - } - - return mWaterPresetName; -} - -std::string LLEnvPrefs::getSkyPresetName() const -{ - if (mSkyPresetName.empty()) - { - LL_WARNS() << "Sky preset name is empty" << LL_ENDL; - } - - return mSkyPresetName; -} - -std::string LLEnvPrefs::getDayCycleName() const -{ - if (mDayCycleName.empty()) - { - LL_WARNS() << "Day cycle name is empty" << LL_ENDL; - } - - return mDayCycleName; -} - -void LLEnvPrefs::setUseRegionSettings(bool val) -{ - mUseRegionSettings = val; -} - -void LLEnvPrefs::setUseWaterPreset(const std::string& name) -{ - mUseRegionSettings = false; - mWaterPresetName = name; -} - -void LLEnvPrefs::setUseSkyPreset(const std::string& name) -{ - mUseRegionSettings = false; - mUseDayCycle = false; - mSkyPresetName = name; -} - -void LLEnvPrefs::setUseDayCycle(const std::string& name) -{ - mUseRegionSettings = false; - mUseDayCycle = true; - mDayCycleName = name; -} - -//============================================================================= -LLEnvManagerNew::LLEnvManagerNew(): - mInterpNextChangeMessage(true), - mCurRegionUUID(LLUUID::null), - mLastReceivedID(LLUUID::null) -{ - - // Set default environment settings. - mUserPrefs.mUseRegionSettings = true; - mUserPrefs.mUseDayCycle = true; - mUserPrefs.mWaterPresetName = "Default"; - mUserPrefs.mSkyPresetName = "Default"; - mUserPrefs.mDayCycleName = "Default"; - - LL_DEBUGS("Windlight")<getName() : "Unknown region"; - - // Dump water presets. - LL_DEBUGS("Windlight") << "Waters:" << LL_ENDL; - if (region_settings.getWaterParams().size() != 0) - { - LL_DEBUGS("Windlight") << " - " << region_name << LL_ENDL; - } - LLWaterParamManager::preset_name_list_t water_presets; - LLWaterParamManager::instance().getPresetNames(water_presets); - for (LLWaterParamManager::preset_name_list_t::const_iterator it = water_presets.begin(); it != water_presets.end(); ++it) - { - LL_DEBUGS("Windlight") << " - " << *it << LL_ENDL; - } - - // Dump sky presets. - LL_DEBUGS("Windlight") << "Skies:" << LL_ENDL; - LLWLParamManager::preset_key_list_t sky_preset_keys; - LLWLParamManager::instance().getPresetKeys(sky_preset_keys); - for (LLWLParamManager::preset_key_list_t::const_iterator it = sky_preset_keys.begin(); it != sky_preset_keys.end(); ++it) - { - std::string preset_name = it->name; - std::string item_title; - - if (it->scope == LLEnvKey::SCOPE_LOCAL) // local preset - { - item_title = preset_name; - } - else // region preset - { - item_title = preset_name + " (" + region_name + ")"; - } - LL_DEBUGS("Windlight") << " - " << item_title << LL_ENDL; - } - - // Dump day cycles. - LL_DEBUGS("Windlight") << "Days:" << LL_ENDL; - const LLSD& cur_region_dc = region_settings.getWLDayCycle(); - if (cur_region_dc.size() != 0) - { - LL_DEBUGS("Windlight") << " - " << region_name << LL_ENDL; - } - LLDayCycleManager::preset_name_list_t days; - LLDayCycleManager::instance().getPresetNames(days); - for (LLDayCycleManager::preset_name_list_t::const_iterator it = days.begin(); it != days.end(); ++it) - { - LL_DEBUGS("Windlight") << " - " << *it << LL_ENDL; - } -} - -void LLEnvManagerNew::requestRegionSettings() -{ - LL_DEBUGS("Windlight") << LL_ENDL; - LLEnvironmentRequest::initiate(); -} - -bool LLEnvManagerNew::sendRegionSettings(const LLEnvironmentSettings& new_settings) -{ - LLSD metadata; - - metadata["regionID"] = gAgent.getRegion()->getRegionID(); - // add last received update ID to outbound message so simulator can handle concurrent updates - metadata["messageID"] = mLastReceivedID; - - return LLEnvironmentApply::initiateRequest(new_settings.makePacket(metadata)); -} - -boost::signals2::connection LLEnvManagerNew::setPreferencesChangeCallback(const prefs_change_signal_t::slot_type& cb) -{ - return mUsePrefsChangeSignal.connect(cb); -} - -boost::signals2::connection LLEnvManagerNew::setRegionSettingsChangeCallback(const region_settings_change_signal_t::slot_type& cb) -{ - return mRegionSettingsChangeSignal.connect(cb); -} - -boost::signals2::connection LLEnvManagerNew::setRegionSettingsAppliedCallback(const region_settings_applied_signal_t::slot_type& cb) -{ - return mRegionSettingsAppliedSignal.connect(cb); -} - -// static -bool LLEnvManagerNew::canEditRegionSettings() -{ - LLViewerRegion* region = gAgent.getRegion(); - BOOL owner_or_god = gAgent.isGodlike() || (region && region->getOwner() == gAgent.getID()); - BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); - - LL_DEBUGS("Windlight") << "Can edit region settings: " << (bool) owner_or_god_or_manager << LL_ENDL; - return owner_or_god_or_manager; -} - -// static -const std::string LLEnvManagerNew::getScopeString(LLEnvKey::EScope scope) -{ - switch(scope) - { - case LLEnvKey::SCOPE_LOCAL: - return LLTrans::getString("LocalSettings"); - case LLEnvKey::SCOPE_REGION: - return LLTrans::getString("RegionSettings"); - default: - return " (?)"; - } -} - -void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) -{ - // If the message was valid, grab the UUID from it and save it for next outbound update message. - mLastReceivedID = content[0]["messageID"].asUUID(); - - // Refresh cached region settings. - LL_WARNS("Windlight") << "Received region environment settings: " << content << LL_ENDL; - F32 sun_hour = 0; // *TODO - LLEnvironmentSettings new_settings(content[1], content[2], content[3], sun_hour); - mCachedRegionPrefs = new_settings; - - // Load region sky presets. - LLWLParamManager::instance().refreshRegionPresets(getRegionSettings().getSkyMap()); - - // If using server settings, update managers. - if (getUseRegionSettings()) - { - updateManagersFromPrefs(mInterpNextChangeMessage); - } - - // Let interested parties know about the region settings update. - mRegionSettingsChangeSignal(); - - // reset - mInterpNextChangeMessage = false; -} - -void LLEnvManagerNew::onRegionSettingsApplyResponse(bool ok) -{ - LL_DEBUGS("Windlight") << "Applying region settings " << (ok ? "succeeded" : "failed") << LL_ENDL; - - // Clear locally modified region settings because they have just been uploaded. - mNewRegionPrefs.clear(); - - mRegionSettingsAppliedSignal(ok); -} - -//-- private methods ---------------------------------------------------------- - -// virtual -void LLEnvManagerNew::initSingleton() -{ - LL_DEBUGS("Windlight") << "Initializing LLEnvManagerNew" << LL_ENDL; - - loadUserPrefs(); - - // preferences loaded, can set params - std::string preferred_day = getDayCycleName(); - if (!useDayCycle(preferred_day, LLEnvKey::SCOPE_LOCAL)) - { - LL_WARNS() << "No day cycle named " << preferred_day << ", reverting LLWLParamManager to defaults" << LL_ENDL; - LLWLParamManager::instance().setDefaultDay(); - } - - std::string sky = getSkyPresetName(); - if (!useSkyPreset(sky)) - { - LL_WARNS() << "No sky preset named " << sky << ", falling back to defaults" << LL_ENDL; - LLWLParamManager::instance().setDefaultSky(); - - // *TODO: Fix user preferences accordingly. - } - - LLWLParamManager::instance().resetAnimator(0.5 /*noon*/, getUseDayCycle()); -} - -void LLEnvManagerNew::updateSkyFromPrefs() -{ - bool success = true; - - // Sync sky with user prefs. - if (getUseRegionSettings()) // apply region-wide settings - { - success = useRegionSky(); - } - else // apply user-specified settings - { - if (getUseDayCycle()) - { - success = useDayCycle(getDayCycleName(), LLEnvKey::SCOPE_LOCAL); - } - else - { - success = useSkyPreset(getSkyPresetName()); - } - } - - // If something went wrong, fall back to defaults. - if (!success) - { - // *TODO: fix user prefs - useDefaultSky(); - } -} - -void LLEnvManagerNew::updateWaterFromPrefs(bool interpolate) -{ - LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); - LLSD target_water_params; - - // Determine new water settings based on user prefs. - - { - // Fall back to default water. - LLWaterParamSet default_water; - water_mgr.getParamSet("Default", default_water); - target_water_params = default_water.getAll(); - } - - if (getUseRegionSettings()) - { - // *TODO: make sure whether region settings belong to the current region? - const LLSD& region_water_params = getRegionSettings().getWaterParams(); - if (region_water_params.size() != 0) // region has no water settings - { - LL_DEBUGS("Windlight") << "Applying region water" << LL_ENDL; - target_water_params = region_water_params; - } - else - { - LL_DEBUGS("Windlight") << "Applying default water" << LL_ENDL; - } - } - else - { - std::string water = getWaterPresetName(); - LL_DEBUGS("Windlight") << "Applying water preset [" << water << "]" << LL_ENDL; - LLWaterParamSet params; - if (!water_mgr.getParamSet(water, params)) - { - LL_WARNS() << "No water preset named " << water << ", falling back to defaults" << LL_ENDL; - water_mgr.getParamSet("Default", params); - - // *TODO: Fix user preferences accordingly. - } - target_water_params = params.getAll(); - } - - // Sync water with user prefs. - water_mgr.applyParams(target_water_params, interpolate); -} - -void LLEnvManagerNew::updateManagersFromPrefs(bool interpolate) -{ - LL_DEBUGS("Windlight")<second); - } - return useDayCycleParams( - region_settings.getWLDayCycle(), - LLEnvKey::SCOPE_REGION, - region_settings.getDayTime()); -} - -bool LLEnvManagerNew::useRegionWater() -{ - const LLEnvironmentSettings& region_settings = getRegionSettings(); - const LLSD& region_water = region_settings.getWaterParams(); - - // If region is set to defaults, - if (region_water.size() == 0) - { - // well... apply the default water settings. - return useDefaultWater(); - } - - // Otherwise apply region water. - LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; - return useWaterParams(region_water); -} - -bool LLEnvManagerNew::useDefaultSky() -{ - return useDayCycle("Default", LLEnvKey::SCOPE_LOCAL); -} - -bool LLEnvManagerNew::useDefaultWater() -{ - return useWaterPreset("Default"); -} - - -void LLEnvManagerNew::onRegionChange() -{ - // Avoid duplicating region setting requests - // by checking whether the region is actually changing. - LLViewerRegion* regionp = gAgent.getRegion(); - LLUUID region_uuid = regionp ? regionp->getRegionID() : LLUUID::null; - if (region_uuid != mCurRegionUUID) - { - // Clear locally modified region settings. - mNewRegionPrefs.clear(); - - // *TODO: clear environment settings of the previous region? - - // Request environment settings of the new region. - mCurRegionUUID = region_uuid; - // for region crossings, interpolate the change; for teleports, don't - mInterpNextChangeMessage = (gAgent.getTeleportState() == LLAgent::TELEPORT_NONE); - LL_DEBUGS("Windlight") << (mInterpNextChangeMessage ? "Crossed" : "Teleported") - << " to new region: " << region_uuid - << LL_ENDL; - requestRegionSettings(); - } - else - { - LL_DEBUGS("Windlight") << "disregarding region change; interp: " - << (mInterpNextChangeMessage ? "true" : "false") - << " regionp: " << regionp - << " old: " << mCurRegionUUID - << " new: " << region_uuid - << LL_ENDL; - } -} diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h deleted file mode 100644 index 31a093ad5d..0000000000 --- a/indra/newview/llenvmanager.h +++ /dev/null @@ -1,350 +0,0 @@ -/** - * @file llenvmanager.h - * @brief Declaration of classes managing WindLight and water settings. - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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_LLENVMANAGER_H -#define LL_LLENVMANAGER_H - -#include "llmemory.h" -#include "llsd.h" - -class LLWLParamManager; -class LLWaterParamManager; -class LLWLAnimator; - -// generic key -struct LLEnvKey -{ -public: - // Note: enum ordering is important; for example, a region-level floater (1) will see local and region (all values that are <=) - typedef enum e_scope - { - SCOPE_LOCAL, // 0 - SCOPE_REGION//, // 1 - // SCOPE_ESTATE, // 2 - // etc. - } EScope; -}; - -struct LLWLParamKey : LLEnvKey -{ -public: - // scope and source of a param set (WL sky preset) - std::string name; - EScope scope; - - // for conversion from LLSD - static const int NAME_IDX = 0; - static const int SCOPE_IDX = 1; - - inline LLWLParamKey(const std::string& n, EScope s) - : name(n), scope(s) - { - } - - inline LLWLParamKey(LLSD llsd) - : name(llsd[NAME_IDX].asString()), scope(EScope(llsd[SCOPE_IDX].asInteger())) - { - } - - inline LLWLParamKey() // NOT really valid, just so std::maps can return a default of some sort - : name(""), scope(SCOPE_LOCAL) - { - } - - inline LLWLParamKey(std::string& stringVal) - { - size_t len = stringVal.length(); - if (len > 0) - { - name = stringVal.substr(0, len - 1); - scope = (EScope) atoi(stringVal.substr(len - 1, len).c_str()); - } - } - - inline std::string toStringVal() const - { - std::stringstream str; - str << name << scope; - return str.str(); - } - - inline LLSD toLLSD() const - { - LLSD llsd = LLSD::emptyArray(); - llsd.append(LLSD(name)); - llsd.append(LLSD(scope)); - return llsd; - } - - inline void fromLLSD(const LLSD& llsd) - { - name = llsd[NAME_IDX].asString(); - scope = EScope(llsd[SCOPE_IDX].asInteger()); - } - - inline bool operator <(const LLWLParamKey other) const - { - if (name < other.name) - { - return true; - } - else if (name > other.name) - { - return false; - } - else - { - return scope < other.scope; - } - } - - inline bool operator ==(const LLWLParamKey other) const - { - return (name == other.name) && (scope == other.scope); - } - - std::string toString() const; -}; - -class LLEnvironmentSettings -{ -public: - LLEnvironmentSettings() : - mWLDayCycle(LLSD::emptyMap()), - mSkyMap(LLSD::emptyMap()), - mWaterParams(LLSD::emptyMap()), - mDayTime(0.f) - {} - LLEnvironmentSettings(const LLSD& dayCycle, const LLSD& skyMap, const LLSD& waterParams, F64 dayTime) : - mWLDayCycle(dayCycle), - mSkyMap(skyMap), - mWaterParams(waterParams), - mDayTime(dayTime) - {} - ~LLEnvironmentSettings() {} - - void saveParams(const LLSD& dayCycle, const LLSD& skyMap, const LLSD& waterParams, F64 dayTime) - { - mWLDayCycle = dayCycle; - mSkyMap = skyMap; - mWaterParams = waterParams; - mDayTime = dayTime; - } - - const LLSD& getWLDayCycle() const - { - return mWLDayCycle; - } - - const LLSD& getWaterParams() const - { - return mWaterParams; - } - - const LLSD& getSkyMap() const - { - return mSkyMap; - } - - F64 getDayTime() const - { - return mDayTime; - } - - bool isEmpty() const - { - return mWLDayCycle.size() == 0; - } - - void clear() - { - *this = LLEnvironmentSettings(); - } - - LLSD makePacket(const LLSD& metadata) const - { - LLSD full_packet = LLSD::emptyArray(); - - // 0: metadata - full_packet.append(metadata); - - // 1: day cycle - full_packet.append(mWLDayCycle); - - // 2: map of sky setting names to sky settings (as LLSD) - full_packet.append(mSkyMap); - - // 3: water params - full_packet.append(mWaterParams); - - return full_packet; - } - -private: - LLSD mWLDayCycle, mWaterParams, mSkyMap; - F64 mDayTime; -}; - -/** - * User environment preferences. - */ -class LLEnvPrefs -{ -public: - LLEnvPrefs() : mUseRegionSettings(true), mUseDayCycle(true) {} - - bool getUseRegionSettings() const { return mUseRegionSettings; } - bool getUseDayCycle() const { return mUseDayCycle; } - bool getUseFixedSky() const { return !getUseDayCycle(); } - - std::string getWaterPresetName() const; - std::string getSkyPresetName() const; - std::string getDayCycleName() const; - - void setUseRegionSettings(bool val); - void setUseWaterPreset(const std::string& name); - void setUseSkyPreset(const std::string& name); - void setUseDayCycle(const std::string& name); - - bool mUseRegionSettings; - bool mUseDayCycle; - std::string mWaterPresetName; - std::string mSkyPresetName; - std::string mDayCycleName; -}; - -/** - * Setting: - * 1. Use region settings. - * 2. Use my setting: + | - */ -class LLEnvManagerNew : public LLSingleton -{ - LLSINGLETON(LLEnvManagerNew); - LOG_CLASS(LLEnvManagerNew); -public: - typedef boost::signals2::signal prefs_change_signal_t; - typedef boost::signals2::signal region_settings_change_signal_t; - typedef boost::signals2::signal region_settings_applied_signal_t; - - // getters to access user env. preferences - bool getUseRegionSettings() const; - bool getUseDayCycle() const; - bool getUseFixedSky() const; - std::string getWaterPresetName() const; - std::string getSkyPresetName() const; - std::string getDayCycleName() const; - - /// @return cached env. settings of the current region. - const LLEnvironmentSettings& getRegionSettings() const; - - /** - * Set new region settings without uploading them to the region. - * - * The override will be reset when the changes are applied to the region (=uploaded) - * or user teleports to another region. - */ - void setRegionSettings(const LLEnvironmentSettings& new_settings); - - // Change environment w/o changing user preferences. - bool usePrefs(); - bool useDefaults(); - bool useRegionSettings(); - bool useWaterPreset(const std::string& name); - bool useWaterParams(const LLSD& params); - bool useSkyPreset(const std::string& name); - bool useSkyParams(const LLSD& params); - bool useDayCycle(const std::string& name, LLEnvKey::EScope scope); - bool useDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time = 0.5); - - // setters for user env. preferences - void setUseRegionSettings(bool val); - void setUseWaterPreset(const std::string& name); - void setUseSkyPreset(const std::string& name); - void setUseDayCycle(const std::string& name); - void setUserPrefs( - const std::string& water_preset, - const std::string& sky_preset, - const std::string& day_cycle_preset, - bool use_fixed_sky, - bool use_region_settings); - - // debugging methods - void dumpUserPrefs(); - void dumpPresets(); - - // Misc. - void requestRegionSettings(); - bool sendRegionSettings(const LLEnvironmentSettings& new_settings); - boost::signals2::connection setPreferencesChangeCallback(const prefs_change_signal_t::slot_type& cb); - boost::signals2::connection setRegionSettingsChangeCallback(const region_settings_change_signal_t::slot_type& cb); - boost::signals2::connection setRegionSettingsAppliedCallback(const region_settings_applied_signal_t::slot_type& cb); - - static bool canEditRegionSettings(); /// @return true if we have access to editing region environment - static const std::string getScopeString(LLEnvKey::EScope scope); - - // Public callbacks. - void onRegionSettingsResponse(const LLSD& content); - void onRegionSettingsApplyResponse(bool ok); - -private: - /*virtual*/ void initSingleton(); - - void loadUserPrefs(); - void saveUserPrefs(); - - void updateSkyFromPrefs(); - void updateWaterFromPrefs(bool interpolate); - void updateManagersFromPrefs(bool interpolate); - - bool useRegionSky(); - bool useRegionWater(); - - bool useDefaultSky(); - bool useDefaultWater(); - - void onRegionChange(); - - - /// Emitted when user environment preferences change. - prefs_change_signal_t mUsePrefsChangeSignal; - - /// Emitted when region environment settings update comes. - region_settings_change_signal_t mRegionSettingsChangeSignal; - - /// Emitted when agent region changes. Move to LLAgent? - region_settings_applied_signal_t mRegionSettingsAppliedSignal; - - LLEnvPrefs mUserPrefs; /// User environment preferences. - LLEnvironmentSettings mCachedRegionPrefs; /// Cached region environment settings. - LLEnvironmentSettings mNewRegionPrefs; /// Not-yet-uploaded modified region env. settings. - bool mInterpNextChangeMessage; /// Interpolate env. settings on next region change. - LLUUID mCurRegionUUID; /// To avoid duplicated region env. settings requests. - LLUUID mLastReceivedID; /// Id of last received region env. settings. -}; - -#endif // LL_LLENVMANAGER_H - diff --git a/indra/newview/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp index 31b0b0c090..efeec72f6e 100644 --- a/indra/newview/llfloatereditdaycycle.cpp +++ b/indra/newview/llfloatereditdaycycle.cpp @@ -41,12 +41,11 @@ // newview #include "llagent.h" -#include "lldaycyclemanager.h" #include "llregioninfomodel.h" #include "llviewerregion.h" -#include "llwlparammanager.h" #include "llenvironment.h" +#include "lltrans.h" const F32 LLFloaterEditDayCycle::sHoursPerDay = 24.0f; @@ -128,6 +127,7 @@ void LLFloaterEditDayCycle::draw() void LLFloaterEditDayCycle::initCallbacks(void) { +#if 0 mDayCycleNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterEditDayCycle::onDayCycleNameEdited, this), NULL); mDayCyclesCombo->setCommitCallback(boost::bind(&LLFloaterEditDayCycle::onDayCycleSelected, this)); mDayCyclesCombo->setTextEntryCallback(boost::bind(&LLFloaterEditDayCycle::onDayCycleNameEdited, this)); @@ -143,58 +143,60 @@ void LLFloaterEditDayCycle::initCallbacks(void) mSaveButton->setRightMouseDownCallback(boost::bind(&LLFloaterEditDayCycle::dumpTrack, this)); getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterEditDayCycle::onBtnCancel, this)); -#if 0 // Connect to env manager events. LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); env_mgr.setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditDayCycle::onRegionSettingsChange, this)); gAgent.addRegionChangedCallback(boost::bind(&LLFloaterEditDayCycle::onRegionChange, this)); env_mgr.setRegionSettingsAppliedCallback(boost::bind(&LLFloaterEditDayCycle::onRegionSettingsApplied, this, _1)); -#endif - // Connect to day cycle manager events. LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEditDayCycle::onDayCycleListChange, this)); // Connect to sky preset list changes. LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditDayCycle::onSkyPresetListChange, this)); + // Connect to region info updates. LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditDayCycle::onRegionInfoUpdate, this)); +#endif } void LLFloaterEditDayCycle::syncTimeSlider() { +#if 0 // set time mTimeSlider->setCurSliderValue((F32)LLWLParamManager::getInstance()->mAnimator.getDayTime() * sHoursPerDay); +#endif } void LLFloaterEditDayCycle::loadTrack() { - // clear the slider - mKeysSlider->clear(); - mSliderToKey.clear(); - - // add sliders - - LL_DEBUGS() << "Adding " << LLWLParamManager::getInstance()->mDay.mTimeMap.size() << " keys to slider" << LL_ENDL; - - LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay; - for (std::map::iterator it = cur_dayp.mTimeMap.begin(); it != cur_dayp.mTimeMap.end(); ++it) - { - addSliderKey(it->first * sHoursPerDay, it->second); - } - - // set drop-down menu to match preset of currently-selected keyframe (one is automatically selected initially) - const std::string& cur_sldr = mKeysSlider->getCurSlider(); - if (strlen(cur_sldr.c_str()) > 0) // only do this if there is a curSldr, otherwise we put an invalid entry into the map - { - mSkyPresetsCombo->selectByValue(mSliderToKey[cur_sldr].keyframe.toStringVal()); - } - - syncTimeSlider(); +// // clear the slider +// mKeysSlider->clear(); +// mSliderToKey.clear(); +// +// // add sliders +// +// LL_DEBUGS() << "Adding " << LLWLParamManager::getInstance()->mDay.mTimeMap.size() << " keys to slider" << LL_ENDL; +// +// LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay; +// for (std::map::iterator it = cur_dayp.mTimeMap.begin(); it != cur_dayp.mTimeMap.end(); ++it) +// { +// addSliderKey(it->first * sHoursPerDay, it->second); +// } +// +// // set drop-down menu to match preset of currently-selected keyframe (one is automatically selected initially) +// const std::string& cur_sldr = mKeysSlider->getCurSlider(); +// if (strlen(cur_sldr.c_str()) > 0) // only do this if there is a curSldr, otherwise we put an invalid entry into the map +// { +// mSkyPresetsCombo->selectByValue(mSliderToKey[cur_sldr].keyframe.toStringVal()); +// } +// +// syncTimeSlider(); } void LLFloaterEditDayCycle::applyTrack() { +#if 0 LL_DEBUGS() << "Applying track (" << mSliderToKey.size() << ")" << LL_ENDL; // if no keys, do nothing @@ -223,10 +225,12 @@ void LLFloaterEditDayCycle::applyTrack() LLWLParamManager::getInstance()->mAnimator.update( LLWLParamManager::getInstance()->mCurParams); +#endif } void LLFloaterEditDayCycle::refreshSkyPresetsList() { +#if 0 // Don't allow selecting region skies for a local day cycle, // because thus we may end up with invalid day cycle. bool include_region_skies = getSelectedDayCycle().scope == LLEnvKey::SCOPE_REGION; @@ -272,10 +276,12 @@ void LLFloaterEditDayCycle::refreshSkyPresetsList() // set defaults on combo boxes mSkyPresetsCombo->selectFirstItem(); +#endif } void LLFloaterEditDayCycle::refreshDayCyclesList() { +#if 0 llassert(isNewDay() == false); mDayCyclesCombo->removeall(); @@ -311,10 +317,12 @@ void LLFloaterEditDayCycle::refreshDayCyclesList() } mDayCyclesCombo->setLabel(getString("combo_label")); +#endif } void LLFloaterEditDayCycle::onTimeSliderMoved() { +#if 0 /// get the slider value F32 val = mTimeSlider->getCurSliderValue() / sHoursPerDay; @@ -325,10 +333,12 @@ void LLFloaterEditDayCycle::onTimeSliderMoved() // then call update once LLWLParamManager::getInstance()->mAnimator.update( LLWLParamManager::getInstance()->mCurParams); +#endif } void LLFloaterEditDayCycle::onKeyTimeMoved() { +#if 0 if (mKeysSlider->getValue().size() == 0) { return; @@ -354,10 +364,12 @@ void LLFloaterEditDayCycle::onKeyTimeMoved() mTimeCtrl->setTime24(time24); applyTrack(); +#endif } void LLFloaterEditDayCycle::onKeyTimeChanged() { +#if 0 // if no keys, skipped if (mSliderToKey.size() == 0) { @@ -375,10 +387,12 @@ void LLFloaterEditDayCycle::onKeyTimeChanged() mSliderToKey[cur_sldr].time = time; applyTrack(); +#endif } void LLFloaterEditDayCycle::onKeyPresetChanged() { +#if 0 // do nothing if no sliders if (mKeysSlider->getValue().size() == 0) { @@ -402,10 +416,12 @@ void LLFloaterEditDayCycle::onKeyPresetChanged() // Apply changes to current day cycle. applyTrack(); +#endif } void LLFloaterEditDayCycle::onAddKey() { +#if 0 llassert_always(mSliderToKey.size() == mKeysSlider->getValue().size()); S32 max_sliders; @@ -444,8 +460,10 @@ void LLFloaterEditDayCycle::onAddKey() // apply the change to current day cycles applyTrack(); +#endif } +#if 0 void LLFloaterEditDayCycle::addSliderKey(F32 time, LLWLParamKey keyframe) { // make a slider @@ -465,7 +483,9 @@ void LLFloaterEditDayCycle::addSliderKey(F32 time, LLWLParamKey keyframe) llassert_always(mSliderToKey.size() == mKeysSlider->getValue().size()); } +#endif +#if 0 LLWLParamKey LLFloaterEditDayCycle::getSelectedDayCycle() { LLWLParamKey dc_key; @@ -492,6 +512,7 @@ LLWLParamKey LLFloaterEditDayCycle::getSelectedDayCycle() return dc_key; } +#endif bool LLFloaterEditDayCycle::isNewDay() const { @@ -500,6 +521,7 @@ bool LLFloaterEditDayCycle::isNewDay() const void LLFloaterEditDayCycle::dumpTrack() { +#if 0 LL_DEBUGS("Windlight") << "Dumping day cycle" << LL_ENDL; LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay; @@ -510,6 +532,7 @@ void LLFloaterEditDayCycle::dumpTrack() S32 m = (S32) ((time - h) * 60.0f); LL_DEBUGS("Windlight") << llformat("(%.3f) %02d:%02d", time, h, m) << " => " << it->second.name << LL_ENDL; } +#endif } void LLFloaterEditDayCycle::enableEditing(bool enable) @@ -523,6 +546,7 @@ void LLFloaterEditDayCycle::enableEditing(bool enable) void LLFloaterEditDayCycle::reset() { +#if 0 // clear the slider mKeysSlider->clear(); mSliderToKey.clear(); @@ -548,6 +572,7 @@ void LLFloaterEditDayCycle::reset() // Disable controls until a day cycle to edit is selected. enableEditing(false); } +#endif } void LLFloaterEditDayCycle::saveRegionDayCycle() @@ -602,6 +627,7 @@ bool LLFloaterEditDayCycle::getApplyProgress() const void LLFloaterEditDayCycle::onDeleteKey() { +#if 0 if (mSliderToKey.size() == 0) { return; @@ -631,6 +657,7 @@ void LLFloaterEditDayCycle::onDeleteKey() mTimeCtrl->setTime24(time24); applyTrack(); +#endif } void LLFloaterEditDayCycle::onRegionSettingsChange() @@ -656,6 +683,7 @@ void LLFloaterEditDayCycle::onRegionSettingsChange() void LLFloaterEditDayCycle::onRegionChange() { +#if 0 LL_DEBUGS("Windlight") << "Region changed" << LL_ENDL; // If we're editing the region day cycle @@ -663,6 +691,7 @@ void LLFloaterEditDayCycle::onRegionChange() { reset(); // undoes all unsaved changes } +#endif } void LLFloaterEditDayCycle::onRegionSettingsApplied(bool success) @@ -695,9 +724,11 @@ void LLFloaterEditDayCycle::onRegionInfoUpdate() void LLFloaterEditDayCycle::onDayCycleNameEdited() { +#if 0 // Disable saving a day cycle having empty name. LLWLParamKey key = getSelectedDayCycle(); mSaveButton->setEnabled(!key.name.empty()); +#endif } void LLFloaterEditDayCycle::onDayCycleSelected() @@ -741,6 +772,7 @@ void LLFloaterEditDayCycle::onDayCycleSelected() void LLFloaterEditDayCycle::onBtnSave() { +#if 0 LLDayCycleManager& day_mgr = LLDayCycleManager::instance(); LLWLParamKey selected_day = getSelectedDayCycle(); @@ -776,6 +808,7 @@ void LLFloaterEditDayCycle::onBtnSave() // new preset, hence no confirmation needed onSaveConfirmed(); } +#endif } void LLFloaterEditDayCycle::onBtnCancel() diff --git a/indra/newview/llfloatereditdaycycle.h b/indra/newview/llfloatereditdaycycle.h index e6e4fe39c1..50d60a2b56 100644 --- a/indra/newview/llfloatereditdaycycle.h +++ b/indra/newview/llfloatereditdaycycle.h @@ -29,8 +29,6 @@ #include "llfloater.h" -#include "llwlparammanager.h" // for LLWLParamKey - class LLCheckBoxCtrl; class LLComboBox; class LLLineEditor; @@ -70,10 +68,10 @@ private: void refreshDayCyclesList(); /// add a slider to the track - void addSliderKey(F32 time, LLWLParamKey keyframe); +// void addSliderKey(F32 time, LLWLParamKey keyframe); void initCallbacks(); - LLWLParamKey getSelectedDayCycle(); +// LLWLParamKey getSelectedDayCycle(); bool isNewDay() const; void dumpTrack(); void enableEditing(bool enable); @@ -109,15 +107,15 @@ private: static std::string getRegionName(); /// convenience class for holding keyframes mapped to sliders - struct SliderKey - { - public: - SliderKey(LLWLParamKey kf, F32 t) : keyframe(kf), time(t) {} - SliderKey() : keyframe(), time(0.f) {} // Don't use this default constructor - - LLWLParamKey keyframe; - F32 time; - }; +// struct SliderKey +// { +// public: +// SliderKey(LLWLParamKey kf, F32 t) : keyframe(kf), time(t) {} +// SliderKey() : keyframe(), time(0.f) {} // Don't use this default constructor +// +// LLWLParamKey keyframe; +// F32 time; +// }; static const F32 sHoursPerDay; @@ -131,7 +129,7 @@ private: LLButton* mSaveButton; // map of sliders to parameters - std::map mSliderToKey; +// std::map mSliderToKey; }; #endif // LL_LLFLOATEREDITDAYCYCLE_H diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index a779241cf4..ab9cb81db5 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -324,8 +324,6 @@ void LLFloaterEditSky::setColorSwatch(const std::string& name, const WLColorCont // color control callbacks void LLFloaterEditSky::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl) { - //LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLColorSwatchCtrl* swatch = static_cast(ctrl); LLColor4 color_vec(swatch->get().mV); @@ -701,20 +699,6 @@ void LLFloaterEditSky::onBtnCancel() void LLFloaterEditSky::onSkyPresetListChange() { refreshSkyPresetsList(); -#if 0 - LLWLParamKey key = getSelectedSkyPreset(); // preset being edited - if (!LLWLParamManager::instance().hasParamSet(key)) - { - // Preset we've been editing doesn't exist anymore. Close the floater. - closeFloater(false); - } - else - { - // A new preset has been added. - // Refresh the presets list, though it may not make sense as the floater is about to be closed. - refreshSkyPresetsList(); - } -#endif } void LLFloaterEditSky::onRegionSettingsChange() diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 6908363839..9a41d434ee 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -31,8 +31,6 @@ #include "llcombobox.h" #include "llradiogroup.h" -#include "lldaycyclemanager.h" - #include "llenvironment.h" @@ -259,7 +257,7 @@ void LLFloaterEnvironmentSettings::apply() void LLFloaterEnvironmentSettings::cancel() { // Revert environment to user preferences. - LLEnvManagerNew::instance().usePrefs(); +// LLEnvManagerNew::instance().usePrefs(); } void LLFloaterEnvironmentSettings::populateWaterPresetsList() diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 4f0603fe59..e0a56b9412 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -52,7 +52,6 @@ #include "llbutton.h" #include "llcheckboxctrl.h" #include "llcombobox.h" -#include "lldaycyclemanager.h" #include "llestateinfomodel.h" #include "llfilepicker.h" #include "llfloatergodtools.h" // for send_sim_wide_deletes() @@ -86,7 +85,6 @@ #include "llviewertexteditor.h" #include "llviewerwindow.h" #include "llvlcomposition.h" -#include "llwaterparammanager.h" #include "lltrans.h" #include "llagentui.h" #include "llmeshrepository.h" @@ -98,8 +96,6 @@ #include "llpanelexperiences.h" #include "llcorehttputil.h" -#include "llenvmanager.h" - const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; @@ -338,13 +334,13 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) { return; } - +#if 0 // We need to re-request environment setting here, // otherwise after we apply (send) updated region settings we won't get them back, // so our environment won't be updated. // This is also the way to know about externally changed region environment. LLEnvManagerNew::instance().requestRegionSettings(); - +#endif LLTabContainer* tab = floater->getChild("region_panels"); LLViewerRegion* region = gAgent.getRegion(); @@ -3117,16 +3113,16 @@ BOOL LLPanelEnvironmentInfo::postBuild() mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectDayCycle, this)); childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL); - getChild("apply_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance())); +// getChild("apply_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance())); childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); - getChild("cancel_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpPresets, LLEnvManagerNew::getInstance())); +// getChild("cancel_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpPresets, LLEnvManagerNew::getInstance())); - LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); - LLEnvManagerNew::instance().setRegionSettingsAppliedCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingsApplied, this, _1)); +// LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); +// LLEnvManagerNew::instance().setRegionSettingsAppliedCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingsApplied, this, _1)); - LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLPanelEnvironmentInfo::populateDayCyclesList, this)); - LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateSkyPresetsList, this)); - LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateWaterPresetsList, this)); +// LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLPanelEnvironmentInfo::populateDayCyclesList, this)); +// LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateSkyPresetsList, this)); +// LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateWaterPresetsList, this)); return TRUE; } @@ -3145,7 +3141,7 @@ void LLPanelEnvironmentInfo::onVisibilityChange(BOOL new_visibility) // display user's preferred environment. if (!new_visibility) { - LLEnvManagerNew::instance().usePrefs(); +// LLEnvManagerNew::instance().usePrefs(); } } @@ -3165,6 +3161,7 @@ bool LLPanelEnvironmentInfo::refreshFromRegion(LLViewerRegion* region) void LLPanelEnvironmentInfo::refresh() { +#if 0 if(gDisconnected) { return; @@ -3185,6 +3182,7 @@ void LLPanelEnvironmentInfo::refresh() setControlsEnabled(mEnableEditing); setDirty(false); +#endif } void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) @@ -3494,7 +3492,7 @@ void LLPanelEnvironmentInfo::onSwitchRegionSettings() if (use_defaults) { - LLEnvManagerNew::instance().useDefaults(); +// LLEnvManagerNew::instance().useDefaults(); } else { @@ -3530,7 +3528,7 @@ void LLPanelEnvironmentInfo::onSelectWaterPreset() if (getSelectedWaterParams(water_params)) { - LLEnvManagerNew::instance().useWaterParams(water_params); +// LLEnvManagerNew::instance().useWaterParams(water_params); } setDirty(true); @@ -3543,7 +3541,7 @@ void LLPanelEnvironmentInfo::onSelectSkyPreset() if (getSelectedSkyParams(params, dummy)) { - LLEnvManagerNew::instance().useSkyParams(params); +// LLEnvManagerNew::instance().useSkyParams(params); } setDirty(true); @@ -3557,7 +3555,7 @@ void LLPanelEnvironmentInfo::onSelectDayCycle() if (getSelectedDayCycleParams(day_cycle, sky_map, scope)) { - LLEnvManagerNew::instance().useDayCycleParams(day_cycle, (LLEnvKey::EScope) scope); +// LLEnvManagerNew::instance().useDayCycleParams(day_cycle, (LLEnvKey::EScope) scope); } setDirty(true); @@ -3583,6 +3581,7 @@ void LLPanelEnvironmentInfo::onBtnApply() { LL_DEBUGS("Windlight") << "Use fixed sky" << LL_ENDL; +#if 0 // Get selected sky params. LLSD params; std::string preset_name; @@ -3603,6 +3602,7 @@ void LLPanelEnvironmentInfo::onBtnApply() param_set.setAll(params); refs[LLWLParamKey(preset_name, LLEnvKey::SCOPE_LOCAL)] = param_set; // scope doesn't matter here sky_map = LLWLParamManager::createSkyMap(refs); +#endif } else // use day cycle { @@ -3703,7 +3703,7 @@ void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok) // "Unable to update environment settings because the last update your viewer saw was not the same // as the last update sent from the simulator. Try sending your update again, and if this // does not work, try leaving and returning to the region." - LLEnvManagerNew::instance().requestRegionSettings(); +// LLEnvManagerNew::instance().requestRegionSettings(); } } diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 105280bd99..bbdff84bf6 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -65,11 +65,6 @@ class LLPanelExperiences; class LLPanelRegionExperiences; class LLEventTimer; -class LLEnvironmentSettings; -class LLWLParamManager; -class LLWaterParamManager; -class LLWLParamSet; -class LLWaterParamSet; class LLFloaterRegionInfo : public LLFloater { diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 92b294678b..21c21ab908 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 "llwaterparammanager.h" #include "llagentlanguage.h" #include "llwearable.h" #include "llinventorybridge.h" diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index f25471d4f0..0c073f6be9 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 "llwaterparammanager.h" #include "llpostprocess.h" #include "llscenemonitor.h" diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 57eef7e776..647489666f 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -51,7 +51,6 @@ #include "llagentpilot.h" #include "llcompilequeue.h" #include "llconsole.h" -#include "lldaycyclemanager.h" #include "lldebugview.h" #include "llenvironment.h" #include "llfacebookconnect.h" @@ -121,9 +120,6 @@ #include "llworldmap.h" #include "pipeline.h" #include "llviewerjoystick.h" -#include "llwaterparammanager.h" -#include "llwlanimator.h" -#include "llwlparammanager.h" #include "llfloatercamera.h" #include "lluilistener.h" #include "llappearancemgr.h" @@ -135,6 +131,7 @@ #include "llstartup.h" #include "boost/unordered_map.hpp" #include "llcleanup.h" +#include "llviewershadermgr.h" using namespace LLAvatarAppearanceDefines; @@ -8509,30 +8506,6 @@ class LLWorldEnableEnvPreset : public view_listener_t { bool handleEvent(const LLSD& userdata) { - std::string item = userdata.asString(); - - if (item == "delete_water") - { - LLWaterParamManager::preset_name_list_t user_waters; - LLWaterParamManager::instance().getUserPresetNames(user_waters); - return !user_waters.empty(); - } - else if (item == "delete_sky") - { - LLWLParamManager::preset_name_list_t user_skies; - LLWLParamManager::instance().getUserPresetNames(user_skies); - return !user_skies.empty(); - } - else if (item == "delete_day_cycle") - { - LLDayCycleManager::preset_name_list_t user_days; - LLDayCycleManager::instance().getUserPresetNames(user_days); - return !user_days.empty(); - } - else - { - LL_WARNS() << "Unknown item" << LL_ENDL; - } return false; } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index f0924486df..e40d3da338 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -38,7 +38,6 @@ #include "llviewercontrol.h" #include "pipeline.h" #include "llworld.h" -#include "llwaterparammanager.h" #include "llsky.h" #include "llvosky.h" #include "llrender.h" diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 20afc7a41d..22cd14a830 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 "llwaterparammanager.h" #include "v3colorutil.h" #include "llsettingssky.h" diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp deleted file mode 100644 index 9e275fd108..0000000000 --- a/indra/newview/llwaterparammanager.cpp +++ /dev/null @@ -1,448 +0,0 @@ -/** - * @file llwaterparammanager.cpp - * @brief Implementation for the LLWaterParamManager class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, 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 "llwaterparammanager.h" - -#include "llrender.h" - -#include "pipeline.h" -#include "llsky.h" - -#include "lldiriterator.h" -#include "llfloaterreg.h" -#include "llsliderctrl.h" -#include "llspinctrl.h" -#include "llcheckboxctrl.h" -#include "lluictrlfactory.h" -#include "llviewercontrol.h" -#include "llviewercamera.h" -#include "llcombobox.h" -#include "lllineeditor.h" -#include "llsdserialize.h" - -#include "v4math.h" -#include "llviewercontrol.h" -#include "lldrawpoolwater.h" -#include "llagent.h" -#include "llagentcamera.h" -#include "llviewerregion.h" - -#include "llenvironment.h" -#include "llwaterparamset.h" - -#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"), - mDensitySliderValue(1.0f), - mWaterFogKS(1.0f) -{ -} - -LLWaterParamManager::~LLWaterParamManager() -{ -} - -void LLWaterParamManager::loadAllPresets() -{ - // First, load system (coming out of the box) water presets. - loadPresetsFromDir(getSysDir()); - - // Then load user presets. Note that user day presets will modify any system ones already loaded. - loadPresetsFromDir(getUserDir()); -} - -void LLWaterParamManager::loadPresetsFromDir(const std::string& dir) -{ - LL_DEBUGS("AppInit", "Shaders") << "Loading water presets from " << dir << LL_ENDL; - - LLDirIterator dir_iter(dir, "*.xml"); - while (1) - { - std::string file; - if (!dir_iter.next(file)) - { - break; // no more files - } - - std::string path = gDirUtilp->add(dir, file); - if (!loadPreset(path)) - { - LL_WARNS() << "Error loading water preset from " << path << LL_ENDL; - } - } -} - -bool LLWaterParamManager::loadPreset(const std::string& path) -{ - llifstream xml_file; - std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); - - xml_file.open(path.c_str()); - if (!xml_file) - { - return false; - } - - LL_DEBUGS("AppInit", "Shaders") << "Loading water " << name << LL_ENDL; - - LLSD params_data; - LLPointer parser = new LLSDXMLParser(); - parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED); - xml_file.close(); - - if (hasParamSet(name)) - { - setParamSet(name, params_data); - } - else - { - addParamSet(name, params_data); - } - - return true; -} - -void LLWaterParamManager::savePreset(const std::string & name) -{ - llassert(!name.empty()); - - // make an empty llsd - LLSD paramsData(LLSD::emptyMap()); - std::string pathName(getUserDir() + LLURI::escape(name) + ".xml"); - - // fill it with LLSD windlight params - paramsData = mParamList[name].getAll(); - - // write to file - llofstream presetsXML(pathName.c_str()); - LLPointer formatter = new LLSDXMLFormatter(); - formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); - presetsXML.close(); - - propagateParameters(); -} - -void LLWaterParamManager::propagateParameters(void) -{ - // bind the variables only if we're using shaders - if(gPipeline.canUseVertexShaders()) - { - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) - { - if (shaders_iter->mProgramObject != 0 - && shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER) - { - shaders_iter->mUniformsDirty = TRUE; - } - } - } - -#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); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, LLDrawPoolWater::sWaterFogColor.mV); - shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, mWaterPlane.mV); - shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, getFogDensity()); - shader->uniform1f(LLShaderMgr::WATER_FOGKS, mWaterFogKS); - shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0); - } -#endif -} - -void LLWaterParamManager::applyParams(const LLSD& params, bool interpolate) -{ - if (params.size() == 0) - { - LL_WARNS() << "Undefined water params" << LL_ENDL; - return; - } - - if (interpolate) - { - // *LAPRAS - - //LLWLParamManager::getInstance()->mAnimator.startInterpolation(params); - } - else - { - mCurParams.setAll(params); - } -} - -static LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERPARAM("Update Water Params"); - -void LLWaterParamManager::update(LLViewerCamera * cam) -{ - LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERPARAM); - - // update the shaders and the menu - propagateParameters(); - - // 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, gAgent.getRegion()->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)); - - LLVector3 sunMoonDir; - if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) - { - sunMoonDir = gSky.getSunDirection(); - } - else - { - sunMoonDir = gSky.getMoonDirection(); - } - sunMoonDir.normVec(); - mWaterFogKS = 1.f/llmax(sunMoonDir.mV[2], WATER_FOG_LIGHT_CLAMP); - - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) - { - if (shaders_iter->mProgramObject != 0 - && shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER) - { - shaders_iter->mUniformsDirty = TRUE; - } - } - } -} - -bool LLWaterParamManager::addParamSet(const std::string& name, LLWaterParamSet& param) -{ - // add a new one if not one there already - preset_map_t::iterator mIt = mParamList.find(name); - if(mIt == mParamList.end()) - { - mParamList[name] = param; - mPresetListChangeSignal(); - return true; - } - - return false; -} - -BOOL LLWaterParamManager::addParamSet(const std::string& name, LLSD const & param) -{ - LLWaterParamSet param_set; - param_set.setAll(param); - return addParamSet(name, param_set); -} - -bool LLWaterParamManager::getParamSet(const std::string& name, LLWaterParamSet& param) -{ - // find it and set it - preset_map_t::iterator mIt = mParamList.find(name); - if(mIt != mParamList.end()) - { - param = mParamList[name]; - param.mName = name; - return true; - } - - return false; -} - -bool LLWaterParamManager::hasParamSet(const std::string& name) -{ - LLWaterParamSet dummy; - return getParamSet(name, dummy); -} - -bool LLWaterParamManager::setParamSet(const std::string& name, LLWaterParamSet& param) -{ - mParamList[name] = param; - - return true; -} - -bool LLWaterParamManager::setParamSet(const std::string& name, const LLSD & param) -{ - // quick, non robust (we won't be working with files, but assets) check - if(!param.isMap()) - { - return false; - } - - mParamList[name].setAll(param); - - return true; -} - -bool LLWaterParamManager::removeParamSet(const std::string& name, bool delete_from_disk) -{ - // remove from param list - preset_map_t::iterator it = mParamList.find(name); - if (it == mParamList.end()) - { - LL_WARNS("WindLight") << "No water preset named " << name << LL_ENDL; - return false; - } - - mParamList.erase(it); - - // remove from file system if requested - if (delete_from_disk) - { - if (gDirUtilp->deleteFilesInDir(getUserDir(), LLURI::escape(name) + ".xml") < 1) - { - LL_WARNS("WindLight") << "Error removing water preset " << name << " from disk" << LL_ENDL; - } - } - - // signal interested parties - mPresetListChangeSignal(); - return true; -} - -bool LLWaterParamManager::isSystemPreset(const std::string& preset_name) const -{ - // *TODO: file system access is excessive here. - return gDirUtilp->fileExists(getSysDir() + LLURI::escape(preset_name) + ".xml"); -} - -void LLWaterParamManager::getPresetNames(preset_name_list_t& presets) const -{ - presets.clear(); - - for (preset_map_t::const_iterator it = mParamList.begin(); it != mParamList.end(); ++it) - { - presets.push_back(it->first); - } -} - -void LLWaterParamManager::getPresetNames(preset_name_list_t& user_presets, preset_name_list_t& system_presets) const -{ - user_presets.clear(); - system_presets.clear(); - - for (preset_map_t::const_iterator it = mParamList.begin(); it != mParamList.end(); ++it) - { - if (isSystemPreset(it->first)) - { - system_presets.push_back(it->first); - } - else - { - user_presets.push_back(it->first); - } - } -} - -void LLWaterParamManager::getUserPresetNames(preset_name_list_t& user_presets) const -{ - preset_name_list_t dummy; - getPresetNames(user_presets, dummy); -} - -boost::signals2::connection LLWaterParamManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb) -{ - return mPresetListChangeSignal.connect(cb); -} - -F32 LLWaterParamManager::getFogDensity(void) -{ - bool err; - - F32 fogDensity = mCurParams.getFloat("waterFogDensity", err); - - // modify if we're underwater - const F32 water_height = gAgent.getRegion() ? gAgent.getRegion()->getWaterHeight() : 0.f; - F32 camera_height = gAgentCamera.getCameraPositionAgent().mV[2]; - if(camera_height <= water_height) - { - // raise it to the underwater fog density modifier - fogDensity = pow(fogDensity, mCurParams.getFloat("underWaterFogMod", err)); - } - - return fogDensity; -} - -// virtual static -void LLWaterParamManager::initSingleton() -{ - LL_DEBUGS("Windlight") << "Initializing water" << LL_ENDL; - loadAllPresets(); -} - -// static -std::string LLWaterParamManager::getSysDir() -{ - return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", ""); -} - -// static -std::string LLWaterParamManager::getUserDir() -{ - return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "windlight/water", ""); -} diff --git a/indra/newview/llwaterparammanager.h b/indra/newview/llwaterparammanager.h deleted file mode 100644 index 392e287e3f..0000000000 --- a/indra/newview/llwaterparammanager.h +++ /dev/null @@ -1,413 +0,0 @@ -/** - * @file llwaterparammanager.h - * @brief Implementation for the LLWaterParamManager class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, 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_WATER_PARAMMANAGER_H -#define LL_WATER_PARAMMANAGER_H - -#include -#include -#include "llwaterparamset.h" -#include "llviewercamera.h" -#include "v4color.h" - -const F32 WATER_FOG_LIGHT_CLAMP = 0.3f; -#if 0 -// color control -struct WaterColorControl { - - F32 mR, mG, mB, mA, mI; /// the values - std::string mName; /// name to use to dereference params - std::string mSliderName; /// name of the slider in menu - bool mHasSliderName; /// only set slider name for true color types - - inline WaterColorControl(F32 red, F32 green, F32 blue, F32 alpha, - F32 intensity, const std::string& n, const std::string& sliderName = LLStringUtil::null) - : mR(red), mG(green), mB(blue), mA(alpha), mI(intensity), mName(n), mSliderName(sliderName) - { - // if there's a slider name, say we have one - mHasSliderName = false; - if (mSliderName != "") { - mHasSliderName = true; - } - } - - inline WaterColorControl & operator = (LLColor4 const & val) - { - mR = val.mV[0]; - mG = val.mV[1]; - mB = val.mV[2]; - mA = val.mV[3]; - return *this; - } - - inline operator LLColor4 (void) const - { - return LLColor4(mR, mG, mB, mA); - } - - inline WaterColorControl & operator = (LLVector4 const & val) - { - mR = val.mV[0]; - mG = val.mV[1]; - mB = val.mV[2]; - mA = val.mV[3]; - return *this; - } - - inline operator LLVector4 (void) const - { - return LLVector4(mR, mG, mB, mA); - } - - inline operator LLVector3 (void) const - { - return LLVector3(mR, mG, mB); - } - - inline void update(LLWaterParamSet & params) const - { - params.set(mName, mR, mG, mB, mA); - } -}; - -struct WaterVector3Control -{ - F32 mX; - F32 mY; - F32 mZ; - - std::string mName; - - // basic constructor - inline WaterVector3Control(F32 valX, F32 valY, F32 valZ, const std::string& n) - : mX(valX), mY(valY), mZ(valZ), mName(n) - { - } - - inline WaterVector3Control & operator = (LLVector3 const & val) - { - mX = val.mV[0]; - mY = val.mV[1]; - mZ = val.mV[2]; - - return *this; - } - - inline void update(LLWaterParamSet & params) const - { - params.set(mName, mX, mY, mZ); - } - -}; - -struct WaterVector2Control -{ - F32 mX; - F32 mY; - - std::string mName; - - // basic constructor - inline WaterVector2Control(F32 valX, F32 valY, const std::string& n) - : mX(valX), mY(valY), mName(n) - { - } - - inline WaterVector2Control & operator = (LLVector2 const & val) - { - mX = val.mV[0]; - mY = val.mV[1]; - - return *this; - } - - inline void update(LLWaterParamSet & params) const - { - params.set(mName, mX, mY); - } -}; - -// float slider control -struct WaterFloatControl -{ - F32 mX; - std::string mName; - F32 mMult; - - inline WaterFloatControl(F32 val, const std::string& n, F32 m=1.0f) - : mX(val), mName(n), mMult(m) - { - } - - inline WaterFloatControl & operator = (LLVector4 const & val) - { - mX = val.mV[0]; - - return *this; - } - - inline operator F32 (void) const - { - return mX; - } - - inline void update(LLWaterParamSet & params) const - { - params.set(mName, mX); - } -}; - -// float slider control -struct WaterExpFloatControl -{ - F32 mExp; - std::string mName; - F32 mBase; - - inline WaterExpFloatControl(F32 val, const std::string& n, F32 b) - : mExp(val), mName(n), mBase(b) - { - } - - inline WaterExpFloatControl & operator = (F32 val) - { - mExp = log(val) / log(mBase); - - return *this; - } - - inline operator F32 (void) const - { - return pow(mBase, mExp); - } - - inline void update(LLWaterParamSet & params) const - { - params.set(mName, pow(mBase, mExp)); - } -}; -#endif - -/// WindLight parameter manager class - what controls all the wind light shaders -class LLWaterParamManager : public LLSingleton -{ - LLSINGLETON(LLWaterParamManager); - ~LLWaterParamManager(); - LOG_CLASS(LLWaterParamManager); -public: - typedef std::list preset_name_list_t; - typedef std::map preset_map_t; - typedef boost::signals2::signal preset_list_signal_t; - - /// save the parameter presets to file - void savePreset(const std::string & name); - - /// send the parameters to the shaders - void propagateParameters(void); - - // display specified water - void applyParams(const LLSD& params, bool interpolate); - - /// update information for the shader - void update(LLViewerCamera * cam); - - /// Update shader uniforms that have changed. - void updateShaderUniforms(LLGLSLShader * shader); - - /// add a param to the list - bool addParamSet(const std::string& name, LLWaterParamSet& param); - - /// add a param to the list - BOOL addParamSet(const std::string& name, LLSD const & param); - - /// get a param from the list - bool getParamSet(const std::string& name, LLWaterParamSet& param); - - /// check whether the preset is in the list - bool hasParamSet(const std::string& name); - - /// set the param in the list with a new param - bool setParamSet(const std::string& name, LLWaterParamSet& param); - - /// set the param in the list with a new param - bool setParamSet(const std::string& name, LLSD const & param); - - /// gets rid of a parameter and any references to it - /// returns true if successful - bool removeParamSet(const std::string& name, bool delete_from_disk); - - /// @return true if the preset comes out of the box - bool isSystemPreset(const std::string& preset_name) const; - - /// @return all named water presets. - const preset_map_t& getPresets() const { return mParamList; } - - /// @return user and system preset names as a single list - void getPresetNames(preset_name_list_t& presets) const; - - /// @return user and system preset names separately - void getPresetNames(preset_name_list_t& user_presets, preset_name_list_t& system_presets) const; - - /// @return list of user presets names - void getUserPresetNames(preset_name_list_t& user_presets) const; - - /// Emitted when a preset gets added or deleted. - boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb); - - /// set the normap map we want for water - bool setNormalMapID(const LLUUID& img); - - void setDensitySliderValue(F32 val); - - /// getters for all the different things water param manager maintains - LLUUID getNormalMapID(void); - LLVector2 getWave1Dir(void); - LLVector2 getWave2Dir(void); - F32 getScaleAbove(void); - F32 getScaleBelow(void); - LLVector3 getNormalScale(void); - F32 getFresnelScale(void); - F32 getFresnelOffset(void); - F32 getBlurMultiplier(void); - F32 getFogDensity(void); - LLColor4 getFogColor(void); - -public: - - LLWaterParamSet mCurParams; -#if 0 - /// Atmospherics - WaterColorControl mFogColor; - WaterExpFloatControl mFogDensity; - WaterFloatControl mUnderWaterFogMod; - - /// wavelet scales and directions - WaterVector3Control mNormalScale; - WaterVector2Control mWave1Dir; - WaterVector2Control mWave2Dir; - - // controls how water is reflected and refracted - WaterFloatControl mFresnelScale; - WaterFloatControl mFresnelOffset; - WaterFloatControl mScaleAbove; - WaterFloatControl mScaleBelow; - WaterFloatControl mBlurMultiplier; -#endif - F32 mDensitySliderValue; - -private: - /*virtual*/ void initSingleton(); - void loadAllPresets(); - void loadPresetsFromDir(const std::string& dir); - bool loadPreset(const std::string& path); - - static std::string getSysDir(); - static std::string getUserDir(); - - LLVector4 mWaterPlane; - F32 mWaterFogKS; - - // list of all the parameters, listed by name - preset_map_t mParamList; - - preset_list_signal_t mPresetListChangeSignal; -}; - -inline void LLWaterParamManager::setDensitySliderValue(F32 val) -{ - val /= 10.0f; - val = 1.0f - val; - val *= val * val; -// val *= val; - mDensitySliderValue = val; -} - -inline LLUUID LLWaterParamManager::getNormalMapID() -{ - return mCurParams.mParamValues["normalMap"].asUUID(); -} - -inline bool LLWaterParamManager::setNormalMapID(const LLUUID& id) -{ - mCurParams.mParamValues["normalMap"] = id; - return true; -} - -inline LLVector2 LLWaterParamManager::getWave1Dir(void) -{ - bool err; - return mCurParams.getVector2("wave1Dir", err); -} - -inline LLVector2 LLWaterParamManager::getWave2Dir(void) -{ - bool err; - return mCurParams.getVector2("wave2Dir", err); -} - -inline F32 LLWaterParamManager::getScaleAbove(void) -{ - bool err; - return mCurParams.getFloat("scaleAbove", err); -} - -inline F32 LLWaterParamManager::getScaleBelow(void) -{ - bool err; - return mCurParams.getFloat("scaleBelow", err); -} - -inline LLVector3 LLWaterParamManager::getNormalScale(void) -{ - bool err; - return mCurParams.getVector3("normScale", err); -} - -inline F32 LLWaterParamManager::getFresnelScale(void) -{ - bool err; - return mCurParams.getFloat("fresnelScale", err); -} - -inline F32 LLWaterParamManager::getFresnelOffset(void) -{ - bool err; - return mCurParams.getFloat("fresnelOffset", err); -} - -inline F32 LLWaterParamManager::getBlurMultiplier(void) -{ - bool err; - return mCurParams.getFloat("blurMultiplier", err); -} - -inline LLColor4 LLWaterParamManager::getFogColor(void) -{ - bool err; - return LLColor4(mCurParams.getVector4("waterFogColor", err)); -} - -#endif diff --git a/indra/newview/llwaterparamset.cpp b/indra/newview/llwaterparamset.cpp deleted file mode 100644 index 9cc91d2246..0000000000 --- a/indra/newview/llwaterparamset.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/** - * @file llwaterparamset.cpp - * @brief Implementation for the LLWaterParamSet class. - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, 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 "llwaterparamset.h" -#include "llsd.h" - -#include "llwaterparammanager.h" -#include "lluictrlfactory.h" -#include "llsliderctrl.h" -#include "llviewertexturelist.h" -#include "llviewercontrol.h" -#include "lluuid.h" - -#include - -#include - -LLWaterParamSet::LLWaterParamSet(void) : - mName("Unnamed Preset") -{ - LLSD vec4; - LLSD vec3; - LLSD real(0.0f); - - vec4 = LLSD::emptyArray(); - vec4.append(22.f/255.f); - vec4.append(43.f/255.f); - vec4.append(54.f/255.f); - vec4.append(0.f/255.f); - - vec3 = LLSD::emptyArray(); - vec3.append(2); - vec3.append(2); - vec3.append(2); - - LLSD wave1, wave2; - wave1 = LLSD::emptyArray(); - wave2 = LLSD::emptyArray(); - wave1.append(0.5f); - wave1.append(-.17f); - wave2.append(0.58f); - wave2.append(-.67f); - - mParamValues.insert("waterFogColor", vec4); - mParamValues.insert("waterFogDensity", 16.0f); - mParamValues.insert("underWaterFogMod", 0.25f); - mParamValues.insert("normScale", vec3); - mParamValues.insert("fresnelScale", 0.5f); - mParamValues.insert("fresnelOffset", 0.4f); - mParamValues.insert("scaleAbove", 0.025f); - mParamValues.insert("scaleBelow", 0.2f); - mParamValues.insert("blurMultiplier", 0.01f); - mParamValues.insert("wave1Dir", wave1); - mParamValues.insert("wave2Dir", wave2); - mParamValues.insert("normalMap", DEFAULT_WATER_NORMAL); - -} - -void LLWaterParamSet::set(const std::string& paramName, float x) -{ - // handle case where no array - if(mParamValues[paramName].isReal()) - { - mParamValues[paramName] = x; - } - - // handle array - else if(mParamValues[paramName].isArray() && - mParamValues[paramName][0].isReal()) - { - mParamValues[paramName][0] = x; - } -} - -void LLWaterParamSet::set(const std::string& paramName, float x, float y) { - mParamValues[paramName][0] = x; - mParamValues[paramName][1] = y; -} - -void LLWaterParamSet::set(const std::string& paramName, float x, float y, float z) -{ - mParamValues[paramName][0] = x; - mParamValues[paramName][1] = y; - mParamValues[paramName][2] = z; -} - -void LLWaterParamSet::set(const std::string& paramName, float x, float y, float z, float w) -{ - mParamValues[paramName][0] = x; - mParamValues[paramName][1] = y; - mParamValues[paramName][2] = z; - mParamValues[paramName][3] = w; -} - -void LLWaterParamSet::set(const std::string& paramName, const float * val) -{ - mParamValues[paramName][0] = val[0]; - mParamValues[paramName][1] = val[1]; - mParamValues[paramName][2] = val[2]; - mParamValues[paramName][3] = val[3]; -} - -void LLWaterParamSet::set(const std::string& paramName, const LLVector4 & val) -{ - mParamValues[paramName][0] = val.mV[0]; - mParamValues[paramName][1] = val.mV[1]; - mParamValues[paramName][2] = val.mV[2]; - mParamValues[paramName][3] = val.mV[3]; -} - -void LLWaterParamSet::set(const std::string& paramName, const LLColor4 & val) -{ - mParamValues[paramName][0] = val.mV[0]; - mParamValues[paramName][1] = val.mV[1]; - mParamValues[paramName][2] = val.mV[2]; - mParamValues[paramName][3] = val.mV[3]; -} - -LLVector4 LLWaterParamSet::getVector4(const std::string& paramName, bool& error) -{ - - // test to see if right type - LLSD cur_val = mParamValues.get(paramName); - if (!cur_val.isArray() || cur_val.size() != 4) - { - error = true; - return LLVector4(0,0,0,0); - } - - LLVector4 val; - val.mV[0] = (F32) cur_val[0].asReal(); - val.mV[1] = (F32) cur_val[1].asReal(); - val.mV[2] = (F32) cur_val[2].asReal(); - val.mV[3] = (F32) cur_val[3].asReal(); - - error = false; - return val; -} - -LLVector3 LLWaterParamSet::getVector3(const std::string& paramName, bool& error) -{ - - // test to see if right type - LLSD cur_val = mParamValues.get(paramName); - if (!cur_val.isArray()|| cur_val.size() != 3) - { - error = true; - return LLVector3(0,0,0); - } - - LLVector3 val; - val.mV[0] = (F32) cur_val[0].asReal(); - val.mV[1] = (F32) cur_val[1].asReal(); - val.mV[2] = (F32) cur_val[2].asReal(); - - error = false; - return val; -} - -LLVector2 LLWaterParamSet::getVector2(const std::string& paramName, bool& error) -{ - // test to see if right type - LLSD cur_val = mParamValues.get(paramName); - if (!cur_val.isArray() || cur_val.size() != 2) - { - error = true; - return LLVector2(0,0); - } - - LLVector2 val; - val.mV[0] = (F32) cur_val[0].asReal(); - val.mV[1] = (F32) cur_val[1].asReal(); - - error = false; - return val; -} - -F32 LLWaterParamSet::getFloat(const std::string& paramName, bool& error) -{ - - // test to see if right type - LLSD cur_val = mParamValues.get(paramName); - if (cur_val.isArray() && cur_val.size() != 0) - { - error = false; - return (F32) cur_val[0].asReal(); - } - - if(cur_val.isReal()) - { - error = false; - return (F32) cur_val.asReal(); - } - - error = true; - return 0; -} - -// Added for interpolation effect in DEV-33645 -// Based on LLWLParamSet::mix, but written by Jacob without an intimate knowledge of how WindLight works. -// The function definition existed in the header but was never implemented. If you think there is something -// wrong with this, you're probably right. Ask Jacob, Q, or a member of the original WindLight team. -void LLWaterParamSet::mix(LLWaterParamSet& src, LLWaterParamSet& dest, F32 weight) -{ - // Setup - LLSD srcVal, destVal; // LLSD holders for get/set calls, reusable - - // Iterate through values - for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) - { - // If param exists in both src and dest, set the holder variables, otherwise skip - if(src.mParamValues.has(iter->first) && dest.mParamValues.has(iter->first)) - { - srcVal = src.mParamValues[iter->first]; - destVal = dest.mParamValues[iter->first]; - } - else - { - continue; - } - - if(iter->second.isReal()) // If it's a real, interpolate directly - { - iter->second = srcVal.asReal() + ((destVal.asReal() - srcVal.asReal()) * weight); - } - else if(iter->second.isArray() && iter->second[0].isReal() // If it's an array of reals, loop through the reals and interpolate on those - && iter->second.size() == srcVal.size() && iter->second.size() == destVal.size()) - { - // Actually do interpolation: old value + (difference in values * factor) - for(int i=0; i < iter->second.size(); ++i) - { - // iter->second[i] = (1.f-weight)*(F32)srcVal[i].asReal() + weight*(F32)destVal[i].asReal(); // old way of doing it -- equivalent but one more operation - iter->second[i] = srcVal[i].asReal() + ((destVal[i].asReal() - srcVal[i].asReal()) * weight); - } - } - else // Else, skip - { - continue; - } - } -} diff --git a/indra/newview/llwaterparamset.h b/indra/newview/llwaterparamset.h deleted file mode 100644 index 368cb0ccba..0000000000 --- a/indra/newview/llwaterparamset.h +++ /dev/null @@ -1,165 +0,0 @@ -/** - * @file llwlparamset.h - * @brief Interface for the LLWaterParamSet class. - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, 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_WATER_PARAM_SET_H -#define LL_WATER_PARAM_SET_H - -#include -#include - -#include "v4math.h" -#include "v4color.h" -#include "llviewershadermgr.h" -#include "llstringtable.h" - -class LLWaterParamSet; - -/// A class representing a set of parameter values for the Water shaders. -class LLWaterParamSet -{ - friend class LLWaterParamManager; - -public: - std::string mName; - -private: - - LLSD mParamValues; - std::vector mParamHashedNames; - - void updateHashedNames(); - -public: - - LLWaterParamSet(); - - /// Bind this set of parameter values to the uniforms of a particular shader. - void update(LLGLSLShader * shader) const; - - /// set the total llsd - void setAll(const LLSD& val); - - /// get the total llsd - const LLSD& getAll(); - - /// Set a float parameter. - /// \param paramName The name of the parameter to set. - /// \param x The float value to set. - void set(const std::string& paramName, float x); - - /// Set a float2 parameter. - /// \param paramName The name of the parameter to set. - /// \param x The x component's value to set. - /// \param y The y component's value to set. - void set(const std::string& paramName, float x, float y); - - /// Set a float3 parameter. - /// \param paramName The name of the parameter to set. - /// \param x The x component's value to set. - /// \param y The y component's value to set. - /// \param z The z component's value to set. - void set(const std::string& paramName, float x, float y, float z); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param x The x component's value to set. - /// \param y The y component's value to set. - /// \param z The z component's value to set. - /// \param w The w component's value to set. - void set(const std::string& paramName, float x, float y, float z, float w); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param val An array of the 4 float values to set the parameter to. - void set(const std::string& paramName, const float * val); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param val A struct of the 4 float values to set the parameter to. - void set(const std::string& paramName, const LLVector4 & val); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param val A struct of the 4 float values to set the parameter to. - void set(const std::string& paramName, const LLColor4 & val); - - /// Get a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param error A flag to set if it's not the proper return type - LLVector4 getVector4(const std::string& paramName, bool& error); - - /// Get a float3 parameter. - /// \param paramName The name of the parameter to set. - /// \param error A flag to set if it's not the proper return type - LLVector3 getVector3(const std::string& paramName, bool& error); - - /// Get a float2 parameter. - /// \param paramName The name of the parameter to set. - /// \param error A flag to set if it's not the proper return type - LLVector2 getVector2(const std::string& paramName, bool& error); - - /// Get an integer parameter - /// \param paramName The name of the parameter to set. - /// \param error A flag to set if it's not the proper return type - F32 getFloat(const std::string& paramName, bool& error); - - /// interpolate two parameter sets - /// \param src The parameter set to start with - /// \param dest The parameter set to end with - /// \param weight The amount to interpolate - void mix(LLWaterParamSet& src, LLWaterParamSet& dest, - F32 weight); - -}; - -inline void LLWaterParamSet::setAll(const LLSD& val) -{ - if(val.isMap()) { - LLSD::map_const_iterator mIt = val.beginMap(); - for(; mIt != val.endMap(); mIt++) - { - mParamValues[mIt->first] = mIt->second; - } - } - updateHashedNames(); -} - -inline void LLWaterParamSet::updateHashedNames() -{ - mParamHashedNames.clear(); - // Iterate through values - for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) - { - mParamHashedNames.push_back(LLStaticHashedString(iter->first)); - } -} - -inline const LLSD& LLWaterParamSet::getAll() -{ - return mParamValues; -} - -#endif // LL_WaterPARAM_SET_H diff --git a/indra/newview/llwlanimator.cpp b/indra/newview/llwlanimator.cpp deleted file mode 100644 index c8879e73eb..0000000000 --- a/indra/newview/llwlanimator.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/** - * @file llwlanimator.cpp - * @brief Implementation for the LLWLAnimator class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, 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 "llwlanimator.h" -#include "llsky.h" -#include "pipeline.h" -#include "llwlparammanager.h" -#include "llwaterparammanager.h" - -extern LLControlGroup gSavedSettings; - -F64 LLWLAnimator::INTERP_TOTAL_SECONDS = 3.f; - -LLWLAnimator::LLWLAnimator() : mStartTime(0.f), mDayRate(1.f), mDayTime(0.f), - mIsRunning(FALSE), mIsInterpolating(FALSE), mTimeType(TIME_LINDEN), - mInterpStartTime(), mInterpEndTime() -{ - mInterpBeginWL = new LLWLParamSet(); - mInterpBeginWater = new LLWaterParamSet(); - mInterpEndWater = new LLWaterParamSet(); -} - -void LLWLAnimator::update(LLWLParamSet& curParams) -{ - //llassert(mUseLindenTime != mUseLocalTime); - - F64 curTime; - curTime = getDayTime(); - - // don't do anything if empty - if(mTimeTrack.size() == 0) - { - return; - } - - // start it off - mFirstIt = mTimeTrack.begin(); - mSecondIt = mTimeTrack.begin(); - mSecondIt++; - - // grab the two tween iterators - while(mSecondIt != mTimeTrack.end() && curTime > mSecondIt->first) - { - mFirstIt++; - mSecondIt++; - } - - // scroll it around when you get to the end - if(mSecondIt == mTimeTrack.end() || mFirstIt->first > curTime) - { - mSecondIt = mTimeTrack.begin(); - mFirstIt = mTimeTrack.end(); - mFirstIt--; - } - - F32 weight = 0; - - if(mFirstIt->first < mSecondIt->first) - { - - // get the delta time and the proper weight - weight = F32 (curTime - mFirstIt->first) / - (mSecondIt->first - mFirstIt->first); - - // handle the ends - } - else if(mFirstIt->first > mSecondIt->first) - { - - // right edge of time line - if(curTime >= mFirstIt->first) - { - weight = F32 (curTime - mFirstIt->first) / - ((1 + mSecondIt->first) - mFirstIt->first); - // left edge of time line - } - else - { - weight = F32 ((1 + curTime) - mFirstIt->first) / - ((1 + mSecondIt->first) - mFirstIt->first); - } - - // handle same as whatever the last one is - } - else - { - weight = 1; - } - - if(mIsInterpolating) - { - // *TODO_JACOB: this is kind of laggy. Not sure why. The part that lags is the curParams.mix call, and none of the other mixes. It works, though. - clock_t current = clock(); - if(current >= mInterpEndTime) - { - mIsInterpolating = false; - return; - } - - // determine moving target for final interpolation value - // *TODO: this will not work with lazy loading of sky presets. - LLWLParamSet buf = LLWLParamSet(); - buf.setAll(LLWLParamManager::getInstance()->mParamList[mFirstIt->second].getAll()); // just give it some values, otherwise it has no params to begin with (see comment in constructor) - buf.mix(LLWLParamManager::getInstance()->mParamList[mFirstIt->second], LLWLParamManager::getInstance()->mParamList[mSecondIt->second], weight); // mix to determine moving target for interpolation finish (as below) - - // mix from previous value to moving target - weight = (current - mInterpStartTime) / (INTERP_TOTAL_SECONDS * CLOCKS_PER_SEC); - curParams.mix(*mInterpBeginWL, buf, weight); - - // mix water - LLWaterParamManager::getInstance()->mCurParams.mix(*mInterpBeginWater, *mInterpEndWater, weight); - } - else - { - // do the interpolation and set the parameters - // *TODO: this will not work with lazy loading of sky presets. - curParams.mix(LLWLParamManager::getInstance()->mParamList[mFirstIt->second], LLWLParamManager::getInstance()->mParamList[mSecondIt->second], weight); - } -} - -F64 LLWLAnimator::getDayTime() -{ - if(!mIsRunning) - { - return mDayTime; - } - else if(mTimeType == TIME_LINDEN) - { - F32 phase = gSky.getSunPhase() / F_PI; - - // we're not solving the non-linear equation that determines sun phase - // we're just linearly interpolating between the major points - - if (phase <= 5.0 / 4.0) - { - // mDayTime from 0.33 to 0.75 (6:00 to 21:00) - mDayTime = (1.0 / 3.0) * phase + (1.0 / 3.0); - } - else if (phase > 7.0 / 4.0) - { - // maximum value for phase is 2 - // mDayTime from 0.25 to 0.33 (3:00 to 6:00) - mDayTime = (1.0 / 3.0) - (1.0 / 3.0) * (2 - phase); - } - else - { - // phase == 3/2 is where day restarts (24:00) - // mDayTime from 0.75 to 0.999 and 0 to 0.25 (21:00 to 03:00) - mDayTime = phase - (1.0 / 2.0); - - if(mDayTime > 1) - { - mDayTime--; - } - } - - return mDayTime; - } - else if(mTimeType == TIME_LOCAL) - { - return getLocalTime(); - } - - // get the time; - mDayTime = (LLTimer::getElapsedSeconds() - mStartTime) / mDayRate; - - // clamp it - if(mDayTime < 0) - { - mDayTime = 0; - } - while(mDayTime > 1) - { - mDayTime--; - } - - return (F32)mDayTime; -} - -void LLWLAnimator::setDayTime(F64 dayTime) -{ - //retroactively set start time; - mStartTime = LLTimer::getElapsedSeconds() - dayTime * mDayRate; - mDayTime = dayTime; - - // clamp it - if(mDayTime < 0) - { - mDayTime = 0; - } - else if(mDayTime > 1) - { - mDayTime = 1; - } -} - - -void LLWLAnimator::setTrack(std::map& curTrack, - F32 dayRate, F64 dayTime, bool run) -{ - mTimeTrack = curTrack; - mDayRate = dayRate; - setDayTime(dayTime); - - mIsRunning = run; -} - -void LLWLAnimator::startInterpolation(const LLSD& targetWater) -{ - mInterpBeginWL->setAll(LLWLParamManager::getInstance()->mCurParams.getAll()); - mInterpBeginWater->setAll(LLWaterParamManager::getInstance()->mCurParams.getAll()); - - mInterpStartTime = clock(); - mInterpEndTime = mInterpStartTime + clock_t(INTERP_TOTAL_SECONDS) * CLOCKS_PER_SEC; - - // Don't set any ending WL -- this is continuously calculated as the animator updates since it's a moving target - mInterpEndWater->setAll(targetWater); - - mIsInterpolating = true; -} - -std::string LLWLAnimator::timeToString(F32 curTime) -{ - S32 hours; - S32 min; - bool isPM = false; - - // get hours and minutes - hours = (S32) (24.0 * curTime); - curTime -= ((F32) hours / 24.0f); - min = ll_round(24.0f * 60.0f * curTime); - - // handle case where it's 60 - if(min == 60) - { - hours++; - min = 0; - } - - // set for PM - if(hours >= 12 && hours < 24) - { - isPM = true; - } - - // convert to non-military notation - if(hours >= 24) - { - hours = 12; - } - else if(hours > 12) - { - hours -= 12; - } - else if(hours == 0) - { - hours = 12; - } - - // make the string - std::stringstream newTime; - newTime << hours << ":"; - - // double 0 - if(min < 10) - { - newTime << 0; - } - - // finish it - newTime << min << " "; - if(isPM) - { - newTime << "PM"; - } - else - { - newTime << "AM"; - } - - return newTime.str(); -} - -F64 LLWLAnimator::getLocalTime() -{ - char buffer[9]; - time_t rawtime; - struct tm* timeinfo; - - time(&rawtime); - timeinfo = localtime(&rawtime); - strftime(buffer, 9, "%H:%M:%S", timeinfo); - std::string timeStr(buffer); - - F64 tod = ((F64)atoi(timeStr.substr(0,2).c_str())) / 24.f + - ((F64)atoi(timeStr.substr(3,2).c_str())) / 1440.f + - ((F64)atoi(timeStr.substr(6,2).c_str())) / 86400.f; - return tod; -} diff --git a/indra/newview/llwlanimator.h b/indra/newview/llwlanimator.h deleted file mode 100644 index cbb12eb9b7..0000000000 --- a/indra/newview/llwlanimator.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @file llwlanimator.h - * @brief Interface for the LLWLAnimator class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, 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_WL_ANIMATOR_H -#define LL_WL_ANIMATOR_H - -#include "llwlparamset.h" -#include "llwaterparamset.h" -#include "llenvmanager.h" - -#include -#include - -class LLWLAnimator { -public: - typedef enum e_time - { - TIME_LINDEN, - TIME_LOCAL, - TIME_CUSTOM - } ETime; - - F64 mStartTime; - F32 mDayRate; - F64 mDayTime; - - // track to play - std::map mTimeTrack; - std::map::iterator mFirstIt, mSecondIt; - - // simple constructor - LLWLAnimator(); - - ~LLWLAnimator() - { - delete mInterpBeginWL; - delete mInterpBeginWater; - delete mInterpEndWater; - } - - // update the parameters - void update(LLWLParamSet& curParams); - - // get time in seconds - //F64 getTime(void); - - // returns a float 0 - 1 saying what time of day is it? - F64 getDayTime(void); - - // sets a float 0 - 1 saying what time of day it is - void setDayTime(F64 dayTime); - - // set an animation track - void setTrack(std::map& track, - F32 dayRate, F64 dayTime = 0, bool run = true); - - void deactivate() - { - mIsRunning = false; - } - - void activate(ETime time) - { - mIsRunning = true; - mTimeType = time; - } - - void startInterpolation(const LLSD& targetWater); - - bool getIsRunning() - { - return mIsRunning; - } - - bool getUseCustomTime() - { - return mTimeType == TIME_CUSTOM; - } - - bool getUseLocalTime() - { - return mTimeType == TIME_LOCAL; - } - - bool getUseLindenTime() - { - return mTimeType == TIME_LINDEN; - } - - void setTimeType(ETime time) - { - mTimeType = time; - } - - ETime getTimeType() - { - return mTimeType; - } - - /// convert the present time to a digital clock time - static std::string timeToString(F32 curTime); - - /// get local time between 0 and 1 - static F64 getLocalTime(); - -private: - ETime mTimeType; - bool mIsRunning, mIsInterpolating; - LLWLParamSet *mInterpBeginWL; - LLWaterParamSet *mInterpBeginWater, *mInterpEndWater; - clock_t mInterpStartTime, mInterpEndTime; - - static F64 INTERP_TOTAL_SECONDS; -}; - -#endif // LL_WL_ANIMATOR_H - diff --git a/indra/newview/llwldaycycle.cpp b/indra/newview/llwldaycycle.cpp index 106f17f61b..0a331d1823 100644 --- a/indra/newview/llwldaycycle.cpp +++ b/indra/newview/llwldaycycle.cpp @@ -46,6 +46,7 @@ LLWLDayCycle::~LLWLDayCycle() void LLWLDayCycle::loadDayCycle(const LLSD& day_data, LLWLParamKey::EScope scope) { +#if 0 LL_DEBUGS() << "Loading day cycle (day_data.size() = " << day_data.size() << ", scope = " << scope << ")" << LL_ENDL; mTimeMap.clear(); @@ -88,6 +89,7 @@ void LLWLDayCycle::loadDayCycle(const LLSD& day_data, LLWLParamKey::EScope scope // then add the keyframe addKeyframe((F32)day_data[i][0].asReal(), frame); } +#endif } void LLWLDayCycle::loadDayCycleFromFile(const std::string & fileName) @@ -158,35 +160,35 @@ LLSD LLWLDayCycle::asLLSD() return day_data; } -bool LLWLDayCycle::getSkyRefs(std::map& refs) const -{ - bool result = true; - LLWLParamManager& wl_mgr = LLWLParamManager::instance(); - - refs.clear(); - for (std::map::const_iterator iter = mTimeMap.begin(); iter != mTimeMap.end(); ++iter) - { - const LLWLParamKey& key = iter->second; - if (!wl_mgr.getParamSet(key, refs[key])) - { - LL_WARNS() << "Cannot find sky [" << key.name << "] referenced by a day cycle" << LL_ENDL; - result = false; - } - } - - return result; -} +// bool LLWLDayCycle::getSkyRefs(std::map& refs) const +// { +// bool result = true; +// LLWLParamManager& wl_mgr = LLWLParamManager::instance(); +// +// refs.clear(); +// for (std::map::const_iterator iter = mTimeMap.begin(); iter != mTimeMap.end(); ++iter) +// { +// const LLWLParamKey& key = iter->second; +// if (!wl_mgr.getParamSet(key, refs[key])) +// { +// LL_WARNS() << "Cannot find sky [" << key.name << "] referenced by a day cycle" << LL_ENDL; +// result = false; +// } +// } +// +// return result; +// } bool LLWLDayCycle::getSkyMap(LLSD& sky_map) const { - std::map refs; - - if (!getSkyRefs(refs)) - { - return false; - } - - sky_map = LLWLParamManager::createSkyMap(refs); +// std::map refs; +// +// if (!getSkyRefs(refs)) +// { +// return false; +// } +// +// sky_map = LLWLParamManager::createSkyMap(refs); return true; } @@ -235,23 +237,23 @@ bool LLWLDayCycle::changeKeyframeTime(F32 oldTime, F32 newTime) return addKeyframe(newTime, frame); } -bool LLWLDayCycle::changeKeyframeParam(F32 time, LLWLParamKey key) -{ - LL_DEBUGS() << "Changing key frame param (" << time << ", " << key.toLLSD() << ")" << LL_ENDL; - - // just remove and add back - // make sure param exists - LLWLParamSet tmp; - bool stat = LLWLParamManager::getInstance()->getParamSet(key, tmp); - if(stat == false) - { - LL_DEBUGS() << "Failed to change key frame param (" << time << ", " << key.toLLSD() << ")" << LL_ENDL; - return stat; - } - - mTimeMap[time] = key; - return true; -} +// bool LLWLDayCycle::changeKeyframeParam(F32 time, LLWLParamKey key) +// { +// LL_DEBUGS() << "Changing key frame param (" << time << ", " << key.toLLSD() << ")" << LL_ENDL; +// +// // just remove and add back +// // make sure param exists +// LLWLParamSet tmp; +// bool stat = LLWLParamManager::getInstance()->getParamSet(key, tmp); +// if(stat == false) +// { +// LL_DEBUGS() << "Failed to change key frame param (" << time << ", " << key.toLLSD() << ")" << LL_ENDL; +// return stat; +// } +// +// mTimeMap[time] = key; +// return true; +// } bool LLWLDayCycle::removeKeyframe(F32 time) @@ -285,19 +287,19 @@ bool LLWLDayCycle::getKeytime(LLWLParamKey frame, F32& key_time) const return false; } -bool LLWLDayCycle::getKeyedParam(F32 time, LLWLParamSet& param) -{ - // just scroll on through till you find it - std::map::iterator mIt = mTimeMap.find(time); - if(mIt != mTimeMap.end()) - { - return LLWLParamManager::getInstance()->getParamSet(mIt->second, param); - } - - // return error if not found - LL_DEBUGS() << "Key " << time << " not found" << LL_ENDL; - return false; -} +// bool LLWLDayCycle::getKeyedParam(F32 time, LLWLParamSet& param) +// { +// // just scroll on through till you find it +// std::map::iterator mIt = mTimeMap.find(time); +// if(mIt != mTimeMap.end()) +// { +// return LLWLParamManager::getInstance()->getParamSet(mIt->second, param); +// } +// +// // return error if not found +// LL_DEBUGS() << "Key " << time << " not found" << LL_ENDL; +// return false; +// } bool LLWLDayCycle::getKeyedParamName(F32 time, std::string & name) { diff --git a/indra/newview/llwldaycycle.h b/indra/newview/llwldaycycle.h index aef999f3ec..2f9a2e5c4a 100644 --- a/indra/newview/llwldaycycle.h +++ b/indra/newview/llwldaycycle.h @@ -32,8 +32,7 @@ class LLWLDayCycle; #include #include #include -#include "llwlparamset.h" -#include "llwlanimator.h" +#include "llenvmanager.h" struct LLWLParamKey; class LLWLDayCycle @@ -77,7 +76,7 @@ public: LLSD asLLSD(); // get skies referenced by this day cycle - bool getSkyRefs(std::map& refs) const; +// bool getSkyRefs(std::map& refs) const; // get referenced skies as LLSD bool getSkyMap(LLSD& sky_map) const; @@ -109,7 +108,7 @@ public: /// get the param set at a given time /// returns true if found one - bool getKeyedParam(F32 time, LLWLParamSet& param); +// bool getKeyedParam(F32 time, LLWLParamSet& param); /// get the name /// returns true if it found one diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp deleted file mode 100644 index 966a7840cf..0000000000 --- a/indra/newview/llwlparammanager.cpp +++ /dev/null @@ -1,714 +0,0 @@ -/** - * @file llwlparammanager.cpp - * @brief Implementation for the LLWLParamManager class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, 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 "llwlparammanager.h" - -#include "pipeline.h" -#include "llsky.h" - -#include "lldiriterator.h" -#include "llfloaterreg.h" -#include "llsliderctrl.h" -#include "llspinctrl.h" -#include "llcheckboxctrl.h" -#include "lluictrlfactory.h" -#include "llviewercamera.h" -#include "llcombobox.h" -#include "lllineeditor.h" -#include "llsdserialize.h" - -#include "v4math.h" -#include "llviewerdisplay.h" -#include "llviewercontrol.h" -#include "llviewerwindow.h" -#include "lldrawpoolwater.h" -#include "llagent.h" -#include "llviewerregion.h" - -#include "llwlparamset.h" -#include "llpostprocess.h" - -#include "llviewershadermgr.h" -#include "llglslshader.h" - -#include "curl/curl.h" -#include "llstreamtools.h" - -#include "llenvironment.h" - -LLWLParamManager::LLWLParamManager() : - - //set the defaults for the controls - - /// Sun Delta Terrain tweak variables. - mSunDeltaYaw(180.0f), - mSceneLightStrength(2.0f), -// mWLGamma(1.0f, "gamma"), - -// mBlueHorizon(0.25f, 0.25f, 1.0f, 1.0f, "blue_horizon", "WLBlueHorizon"), -// mHazeDensity(1.0f, "haze_density"), -// mBlueDensity(0.25f, 0.25f, 0.25f, 1.0f, "blue_density", "WLBlueDensity"), -// mDensityMult(1.0f, "density_multiplier", 1000), -// mHazeHorizon(1.0f, "haze_horizon"), -// mMaxAlt(4000.0f, "max_y"), - - // Lighting -// mLightnorm(0.f, 0.707f, -0.707f, 1.f, "lightnorm"), -// mSunlight(0.5f, 0.5f, 0.5f, 1.0f, "sunlight_color", "WLSunlight"), -// mAmbient(0.5f, 0.75f, 1.0f, 1.19f, "ambient", "WLAmbient"), -// mGlow(18.0f, 0.0f, -0.01f, 1.0f, "glow"), - - // Clouds -// mCloudColor(0.5f, 0.5f, 0.5f, 1.0f, "cloud_color", "WLCloudColor"), -// mCloudMain(0.5f, 0.5f, 0.125f, 1.0f, "cloud_pos_density1"), -// mCloudCoverage(0.0f, "cloud_shadow"), -// mCloudDetail(0.0f, 0.0f, 0.0f, 1.0f, "cloud_pos_density2"), -// mDistanceMult(1.0f, "distance_multiplier"), -// mCloudScale(0.42f, "cloud_scale"), - - // sky dome - mDomeOffset(0.96f), - mDomeRadius(15000.f) -{ -} - -LLWLParamManager::~LLWLParamManager() -{ -} - -void LLWLParamManager::clearParamSetsOfScope(LLWLParamKey::EScope scope) -{ - if (LLWLParamKey::SCOPE_LOCAL == scope) - { - LL_WARNS("Windlight") << "Tried to clear windlight sky presets from local system! This shouldn't be called..." << LL_ENDL; - return; - } - - std::set to_remove; - for(std::map::iterator iter = mParamList.begin(); iter != mParamList.end(); ++iter) - { - if(iter->first.scope == scope) - { - to_remove.insert(iter->first); - } - } - - for(std::set::iterator iter = to_remove.begin(); iter != to_remove.end(); ++iter) - { - mParamList.erase(*iter); - } -} - -// returns all skies referenced by the day cycle, with their final names -// side effect: applies changes to all internal structures! -std::map LLWLParamManager::finalizeFromDayCycle(LLWLParamKey::EScope scope) -{ - LL_DEBUGS() << "mDay before finalizing:" << LL_ENDL; - { - for (std::map::iterator iter = mDay.mTimeMap.begin(); iter != mDay.mTimeMap.end(); ++iter) - { - LLWLParamKey& key = iter->second; - LL_DEBUGS() << iter->first << "->" << key.name << LL_ENDL; - } - } - - std::map final_references; - - // Move all referenced to desired scope, renaming if necessary - // First, save skies referenced - std::map current_references; // all skies referenced by the day cycle, with their current names - // guard against skies with same name and different scopes - std::set inserted_names; - std::map conflicted_names; // integer later used as a count, for uniquely renaming conflicts - - LLWLDayCycle& cycle = mDay; - for(std::map::iterator iter = cycle.mTimeMap.begin(); - iter != cycle.mTimeMap.end(); - ++iter) - { - LLWLParamKey& key = iter->second; - std::string desired_name = key.name; - replace_newlines_with_whitespace(desired_name); // already shouldn't have newlines, but just in case - if(inserted_names.find(desired_name) == inserted_names.end()) - { - inserted_names.insert(desired_name); - } - else - { - // make exist in map - conflicted_names[desired_name] = 0; - } - current_references[key] = mParamList[key]; - } - - // forget all old skies in target scope, and rebuild, renaming as needed - clearParamSetsOfScope(scope); - for(std::map::iterator iter = current_references.begin(); iter != current_references.end(); ++iter) - { - const LLWLParamKey& old_key = iter->first; - - std::string desired_name(old_key.name); - replace_newlines_with_whitespace(desired_name); - - LLWLParamKey new_key(desired_name, scope); // name will be replaced later if necessary - - // if this sky is one with a non-unique name, rename via appending a number - // an existing preset of the target scope gets to keep its name - if (scope != old_key.scope && conflicted_names.find(desired_name) != conflicted_names.end()) - { - std::string& new_name = new_key.name; - - do - { - // if this executes more than once, this is an absurdly pathological case - // (e.g. "x" repeated twice, but "x 1" already exists, so need to use "x 2") - std::stringstream temp; - temp << desired_name << " " << (++conflicted_names[desired_name]); - new_name = temp.str(); - } while (inserted_names.find(new_name) != inserted_names.end()); - - // yay, found one that works - inserted_names.insert(new_name); // track names we consume here; shouldn't be necessary due to ++int? but just in case - - // *TODO factor out below into a rename()? - - LL_INFOS("Windlight") << "Renamed " << old_key.name << " (scope" << old_key.scope << ") to " - << new_key.name << " (scope " << new_key.scope << ")" << LL_ENDL; - - // update name in sky - iter->second.mName = new_name; - - // update keys in day cycle - for(std::map::iterator frame = cycle.mTimeMap.begin(); frame != cycle.mTimeMap.end(); ++frame) - { - if (frame->second == old_key) - { - frame->second = new_key; - } - } - - // add to master sky map - mParamList[new_key] = iter->second; - } - - final_references[new_key] = iter->second; - } - - LL_DEBUGS() << "mDay after finalizing:" << LL_ENDL; - { - for (std::map::iterator iter = mDay.mTimeMap.begin(); iter != mDay.mTimeMap.end(); ++iter) - { - LLWLParamKey& key = iter->second; - LL_DEBUGS() << iter->first << "->" << key.name << LL_ENDL; - } - } - - return final_references; -} - -// static -LLSD LLWLParamManager::createSkyMap(std::map refs) -{ - LLSD skies = LLSD::emptyMap(); - for(std::map::iterator iter = refs.begin(); iter != refs.end(); ++iter) - { - skies.insert(iter->first.name, iter->second.getAll()); - } - return skies; -} - -void LLWLParamManager::addAllSkies(const LLWLParamKey::EScope scope, const LLSD& sky_presets) -{ - for(LLSD::map_const_iterator iter = sky_presets.beginMap(); iter != sky_presets.endMap(); ++iter) - { - LLWLParamSet set; - set.setAll(iter->second); - mParamList[LLWLParamKey(iter->first, scope)] = set; - } -} - -void LLWLParamManager::refreshRegionPresets(const LLSD& region_sky_presets) -{ - // Remove all region sky presets because they may belong to a previously visited region. - clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); - - // Add all sky presets belonging to the current region. - addAllSkies(LLEnvKey::SCOPE_REGION, region_sky_presets); -} - -void LLWLParamManager::loadAllPresets() -{ - // First, load system (coming out of the box) sky presets. - loadPresetsFromDir(getSysDir()); - - // Then load user presets. Note that user day presets will modify any system ones already loaded. - loadPresetsFromDir(getUserDir()); -} - -void LLWLParamManager::loadPresetsFromDir(const std::string& dir) -{ - LL_INFOS("AppInit", "Shaders") << "Loading sky presets from " << dir << LL_ENDL; - - LLDirIterator dir_iter(dir, "*.xml"); - while (1) - { - std::string file; - if (!dir_iter.next(file)) - { - break; // no more files - } - - std::string path = gDirUtilp->add(dir, file); - if (!loadPreset(path)) - { - LL_WARNS() << "Error loading sky preset from " << path << LL_ENDL; - } - } -} - -bool LLWLParamManager::loadPreset(const std::string& path) -{ - llifstream xml_file; - std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); - - xml_file.open(path.c_str()); - if (!xml_file) - { - return false; - } - - LL_DEBUGS("AppInit", "Shaders") << "Loading sky " << name << LL_ENDL; - - LLSD params_data; - LLPointer parser = new LLSDXMLParser(); - parser->parse(xml_file, params_data, LLSDSerialize::SIZE_UNLIMITED); - xml_file.close(); - - LLWLParamKey key(name, LLEnvKey::SCOPE_LOCAL); - if (hasParamSet(key)) - { - setParamSet(key, params_data); - } - else - { - addParamSet(key, params_data); - } - - return true; -} - -void LLWLParamManager::savePreset(LLWLParamKey key) -{ - llassert(key.scope == LLEnvKey::SCOPE_LOCAL && !key.name.empty()); - - // make an empty llsd - LLSD paramsData(LLSD::emptyMap()); - std::string pathName(getUserDir() + escapeString(key.name) + ".xml"); - - // fill it with LLSD windlight params - paramsData = mParamList[key].getAll(); - - // write to file - llofstream presetsXML(pathName.c_str()); - LLPointer formatter = new LLSDXMLFormatter(); - formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); - presetsXML.close(); - - propagateParameters(); -} - -void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) -{ - if (gPipeline.canUseWindLightShaders()) - { - //LLEnvironment::instance().updateGLVariablesForSettings(shader, LLEnvironment::instance().getCurrentSky()); - mCurParams.update(shader); - } - - if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) - { - shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, mRotatedLightDir.mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - } - - else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) - { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mClampedLightDir.mV); - } - - shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); - -} - -static LLTrace::BlockTimerStatHandle FTM_UPDATE_WLPARAM("Update Windlight Params"); - -void LLWLParamManager::propagateParameters(void) -{ - LL_RECORD_BLOCK_TIME(FTM_UPDATE_WLPARAM); - - LLVector4 sunDir; - LLVector4 moonDir; - - // set the sun direction from SunAngle and EastAngle - F32 sinTheta = sin(mCurParams.getEastAngle()); - F32 cosTheta = cos(mCurParams.getEastAngle()); - - F32 sinPhi = sin(mCurParams.getSunAngle()); - F32 cosPhi = cos(mCurParams.getSunAngle()); - - sunDir.mV[0] = -sinTheta * cosPhi; - sunDir.mV[1] = sinPhi; - sunDir.mV[2] = cosTheta * cosPhi; - sunDir.mV[3] = 0; - - moonDir = -sunDir; - - // is the normal from the sun or the moon - if(sunDir.mV[1] >= 0) - { - mLightDir = sunDir; - } - else if(sunDir.mV[1] < 0 && sunDir.mV[1] > LLSky::NIGHTTIME_ELEVATION_COS) - { - // clamp v1 to 0 so sun never points up and causes weirdness on some machines - LLVector3 vec(sunDir.mV[0], sunDir.mV[1], sunDir.mV[2]); - vec.mV[1] = 0; - vec.normVec(); - mLightDir = LLVector4(vec, 0.f); - } - else - { - mLightDir = moonDir; - } - - // calculate the clamp lightnorm for sky (to prevent ugly banding in sky - // when haze goes below the horizon - mClampedLightDir = sunDir; - - if (mClampedLightDir.mV[1] < -0.1f) - { - mClampedLightDir.mV[1] = -0.1f; - } - - mCurParams.set("lightnorm", mLightDir); - - // bind the variables for all shaders only if we're using WindLight - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) - { - if (shaders_iter->mProgramObject != 0 - && (gPipeline.canUseWindLightShaders() - || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) - { - shaders_iter->mUniformsDirty = TRUE; - } - } - - // get the cfr version of the sun's direction - LLVector3 cfrSunDir(sunDir.mV[2], sunDir.mV[0], sunDir.mV[1]); - - // set direction and don't allow overriding - gSky.setSunDirection(cfrSunDir, LLVector3(0,0,0)); - gSky.setOverrideSun(TRUE); -} - -void LLWLParamManager::update(LLViewerCamera * cam) -{ - LL_RECORD_BLOCK_TIME(FTM_UPDATE_WLPARAM); - - // update clouds, sun, and general - mCurParams.updateCloudScrolling(); - - // update only if running - if(mAnimator.getIsRunning()) - { - mAnimator.update(mCurParams); - } - - // update the shaders and the menu - propagateParameters(); - - F32 camYaw = cam->getYaw(); - - stop_glerror(); - - // *TODO: potential optimization - this block may only need to be - // executed some of the time. For example for water shaders only. - { - F32 camYawDelta = mSunDeltaYaw * DEG_TO_RAD; - - LLVector3 lightNorm3(mLightDir); - lightNorm3 *= LLQuaternion(-(camYaw + camYawDelta), LLVector3(0.f, 1.f, 0.f)); - mRotatedLightDir = LLVector4(lightNorm3, 0.f); - - LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; - end_shaders = LLViewerShaderMgr::instance()->endShaders(); - for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) - { - if (shaders_iter->mProgramObject != 0 - && (gPipeline.canUseWindLightShaders() - || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) - { - shaders_iter->mUniformsDirty = TRUE; - } - } - } -} - -bool LLWLParamManager::applyDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time) -{ - mDay.loadDayCycle(params, scope); - resetAnimator(time, true); // set to specified time and start animator - return true; -} - -void LLWLParamManager::setDefaultDay() -{ - mDay.loadDayCycleFromFile("Default.xml"); -} - -bool LLWLParamManager::applySkyParams(const LLSD& params) -{ - mAnimator.deactivate(); - mCurParams.setAll(params); - return true; -} - -void LLWLParamManager::setDefaultSky() -{ - getParamSet(LLWLParamKey("Default", LLWLParamKey::SCOPE_LOCAL), mCurParams); -} - - -void LLWLParamManager::resetAnimator(F32 curTime, bool run) -{ - mAnimator.setTrack(mDay.mTimeMap, mDay.mDayRate, - curTime, run); - - return; -} - -bool LLWLParamManager::addParamSet(const LLWLParamKey& key, LLWLParamSet& param) -{ - // add a new one if not one there already - std::map::iterator mIt = mParamList.find(key); - if(mIt == mParamList.end()) - { - llassert(!key.name.empty()); - // *TODO: validate params - mParamList[key] = param; - mPresetListChangeSignal(); - return true; - } - - return false; -} - -BOOL LLWLParamManager::addParamSet(const LLWLParamKey& key, LLSD const & param) -{ - LLWLParamSet param_set; - param_set.setAll(param); - return addParamSet(key, param_set); -} - -bool LLWLParamManager::getParamSet(const LLWLParamKey& key, LLWLParamSet& param) -{ - // find it and set it - std::map::iterator mIt = mParamList.find(key); - if(mIt != mParamList.end()) - { - param = mParamList[key]; - param.mName = key.name; - return true; - } - - return false; -} - -bool LLWLParamManager::hasParamSet(const LLWLParamKey& key) -{ - LLWLParamSet dummy; - return getParamSet(key, dummy); -} - -bool LLWLParamManager::setParamSet(const LLWLParamKey& key, LLWLParamSet& param) -{ - llassert(!key.name.empty()); - // *TODO: validate params - mParamList[key] = param; - - return true; -} - -bool LLWLParamManager::setParamSet(const LLWLParamKey& key, const LLSD & param) -{ - llassert(!key.name.empty()); - // *TODO: validate params - - // quick, non robust (we won't be working with files, but assets) check - // this might not actually be true anymore.... - if(!param.isMap()) - { - return false; - } - - LLWLParamSet param_set; - param_set.setAll(param); - return setParamSet(key, param_set); -} - -void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_disk) -{ - // *NOTE: Removing a sky preset invalidates day cycles that refer to it. - - if (key.scope == LLEnvKey::SCOPE_REGION) - { - LL_WARNS() << "Removing region skies not supported" << LL_ENDL; - llassert(key.scope == LLEnvKey::SCOPE_LOCAL); - return; - } - - // remove from param list - std::map::iterator it = mParamList.find(key); - if (it == mParamList.end()) - { - LL_WARNS("WindLight") << "No sky preset named " << key.name << LL_ENDL; - return; - } - - mParamList.erase(it); - mDay.removeReferencesTo(key); - - // remove from file system if requested - if (delete_from_disk) - { - std::string path_name(getUserDir()); - std::string escaped_name = escapeString(key.name); - - if(gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml") < 1) - { - LL_WARNS("WindLight") << "Error removing sky preset " << key.name << " from disk" << LL_ENDL; - } - } - - // signal interested parties - mPresetListChangeSignal(); -} - -bool LLWLParamManager::isSystemPreset(const std::string& preset_name) const -{ - // *TODO: file system access is excessive here. - return gDirUtilp->fileExists(getSysDir() + escapeString(preset_name) + ".xml"); -} - -void LLWLParamManager::getPresetNames(preset_name_list_t& region, preset_name_list_t& user, preset_name_list_t& sys) const -{ - region.clear(); - user.clear(); - sys.clear(); - - for (std::map::const_iterator it = mParamList.begin(); it != mParamList.end(); it++) - { - const LLWLParamKey& key = it->first; - const std::string& name = key.name; - - if (key.scope == LLEnvKey::SCOPE_REGION) - { - region.push_back(name); - } - else - { - if (isSystemPreset(name)) - { - sys.push_back(name); - } - else - { - user.push_back(name); - } - } - } -} - -void LLWLParamManager::getUserPresetNames(preset_name_list_t& user) const -{ - preset_name_list_t region, sys; // unused - getPresetNames(region, user, sys); -} - -void LLWLParamManager::getPresetKeys(preset_key_list_t& keys) const -{ - keys.clear(); - - for (std::map::const_iterator it = mParamList.begin(); it != mParamList.end(); it++) - { - keys.push_back(it->first); - } -} - -boost::signals2::connection LLWLParamManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb) -{ - return mPresetListChangeSignal.connect(cb); -} - -// virtual static -void LLWLParamManager::initSingleton() -{ - LL_DEBUGS("Windlight") << "Initializing sky" << LL_ENDL; - - loadAllPresets(); - - // but use linden time sets it to what the estate is - mAnimator.setTimeType(LLWLAnimator::TIME_LINDEN); -} - -// static -std::string LLWLParamManager::getSysDir() -{ - return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", ""); -} - -// static -std::string LLWLParamManager::getUserDir() -{ - return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "windlight/skies", ""); -} - -// static -std::string LLWLParamManager::escapeString(const std::string& str) -{ - // Don't use LLURI::escape() because it doesn't encode '-' characters - // which may break handling of some system presets like "A-12AM". - char* curl_str = curl_escape(str.c_str(), str.size()); - std::string escaped_str(curl_str); - curl_free(curl_str); - - return escaped_str; -} - diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h deleted file mode 100644 index d475a26da6..0000000000 --- a/indra/newview/llwlparammanager.h +++ /dev/null @@ -1,329 +0,0 @@ -/** - * @file llwlparammanager.h - * @brief Implementation for the LLWLParamManager class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, 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_WLPARAMMANAGER_H -#define LL_WLPARAMMANAGER_H - -#include -#include -#include "llwlparamset.h" -#include "llwlanimator.h" -#include "llwldaycycle.h" -#include "llviewercamera.h" -#include "lltrans.h" -#include "llenvmanager.h" - -class LLGLSLShader; - -#if 0 -// color control -struct WLColorControl { - - F32 r, g, b, i; /// the values - std::string mName; /// name to use to dereference params - std::string mSliderName; /// name of the slider in menu - bool hasSliderName; /// only set slider name for true color types - bool isSunOrAmbientColor; /// flag for if it's the sun or ambient color controller - bool isBlueHorizonOrDensity; /// flag for if it's the Blue Horizon or Density color controller - - inline WLColorControl(F32 red, F32 green, F32 blue, F32 intensity, - const std::string& n, const std::string& sliderName = LLStringUtil::null) - : r(red), g(green), b(blue), i(intensity), mName(n), mSliderName(sliderName) - { - // if there's a slider name, say we have one - hasSliderName = false; - if (mSliderName != "") { - hasSliderName = true; - } - - // if it's the sun controller - isSunOrAmbientColor = false; - if (mSliderName == "WLSunlight" || mSliderName == "WLAmbient") { - isSunOrAmbientColor = true; - } - - isBlueHorizonOrDensity = false; - if (mSliderName == "WLBlueHorizon" || mSliderName == "WLBlueDensity") { - isBlueHorizonOrDensity = true; - } - } - - inline WLColorControl & operator = (LLVector4 const & val) { - r = val.mV[0]; - g = val.mV[1]; - b = val.mV[2]; - i = val.mV[3]; - return *this; - } - - inline operator LLVector4 (void) const { - return LLVector4(r, g, b, i); - } - - inline operator LLVector3 (void) const { - return LLVector3(r, g, b); - } - - inline void update(LLWLParamSet & params) const { - params.set(mName, r, g, b, i); - } -}; - -// float slider control -struct WLFloatControl { - F32 x; - std::string mName; - F32 mult; - - inline WLFloatControl(F32 val, const std::string& n, F32 m=1.0f) - : x(val), mName(n), mult(m) - { - } - - inline WLFloatControl & operator = (F32 val) { - x = val; - return *this; - } - - inline operator F32 (void) const { - return x; - } - - inline void update(LLWLParamSet & params) const { - params.set(mName, x); - } -}; - -#endif - -/// WindLight parameter manager class - what controls all the wind light shaders -class LLWLParamManager : public LLSingleton -{ - LLSINGLETON(LLWLParamManager); - ~LLWLParamManager(); - LOG_CLASS(LLWLParamManager); - -public: - typedef std::list preset_name_list_t; - typedef std::list preset_key_list_t; - typedef boost::signals2::signal preset_list_signal_t; - - /// save the parameter presets to file - void savePreset(const LLWLParamKey key); - - /// Set shader uniforms dirty, so they'll update automatically. - void propagateParameters(void); - - /// Update shader uniforms that have changed. - void updateShaderUniforms(LLGLSLShader * shader); - - /// setup the animator to run - void resetAnimator(F32 curTime, bool run); - - /// update information camera dependent parameters - void update(LLViewerCamera * cam); - - /// apply specified day cycle, setting time to noon by default - bool applyDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time = 0.5); - - /// Apply Default.xml map - void setDefaultDay(); - - /// apply specified fixed sky params - bool applySkyParams(const LLSD& params); - - void setDefaultSky(); - - // get where the light is pointing - inline LLVector4 getLightDir(void) const; - - // get where the light is pointing - inline LLVector4 getClampedLightDir(void) const; - - // get where the light is pointing - inline LLVector4 getRotatedLightDir(void) const; - - /// get the dome's offset - inline F32 getDomeOffset(void) const; - - /// get the radius of the dome - inline F32 getDomeRadius(void) const; - - /// add a param set (preset) to the list - bool addParamSet(const LLWLParamKey& key, LLWLParamSet& param); - - /// add a param set (preset) to the list - BOOL addParamSet(const LLWLParamKey& key, LLSD const & param); - - /// get a param set (preset) from the list - bool getParamSet(const LLWLParamKey& key, LLWLParamSet& param); - - /// check whether the preset is in the list - bool hasParamSet(const LLWLParamKey& key); - - /// set the param in the list with a new param - bool setParamSet(const LLWLParamKey& key, LLWLParamSet& param); - - /// set the param in the list with a new param - bool setParamSet(const LLWLParamKey& key, LLSD const & param); - - /// gets rid of a parameter and any references to it - /// ignores "delete_from_disk" if the scope is not local - void removeParamSet(const LLWLParamKey& key, bool delete_from_disk); - - /// clear parameter mapping of a given scope - void clearParamSetsOfScope(LLEnvKey::EScope scope); - - /// @return true if the preset comes out of the box - bool isSystemPreset(const std::string& preset_name) const; - - /// @return user and system preset names as a single list - void getPresetNames(preset_name_list_t& region, preset_name_list_t& user, preset_name_list_t& sys) const; - - /// @return user preset names - void getUserPresetNames(preset_name_list_t& user) const; - - /// @return keys of all known presets - void getPresetKeys(preset_key_list_t& keys) const; - - /// Emitted when a preset gets added or deleted. - boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb); - - /// add all skies in LLSD using the given scope - void addAllSkies(LLEnvKey::EScope scope, const LLSD& preset_map); - - /// refresh region-scope presets - void refreshRegionPresets(const LLSD& region_sky_presets); - - // returns all skies referenced by the current day cycle (in mDay), with their final names - // side effect: applies changes to all internal structures! (trashes all unreferenced skies in scope, keys in day cycle rescoped to scope, etc.) - std::map finalizeFromDayCycle(LLWLParamKey::EScope scope); - - // returns all skies in map (intended to be called with output from a finalize) - static LLSD createSkyMap(std::map map); - - /// escape string in a way different from LLURI::escape() - static std::string escapeString(const std::string& str); - - // helper variables - LLWLAnimator mAnimator; - - /// actual direction of the sun - LLVector4 mLightDir; - - /// light norm adjusted so haze works correctly - LLVector4 mRotatedLightDir; - - /// clamped light norm for shaders that - /// are adversely affected when the sun goes below the - /// horizon - LLVector4 mClampedLightDir; - - // list of params and how they're cycled for days - LLWLDayCycle mDay; - - LLWLParamSet mCurParams; - - /// Sun Delta Terrain tweak variables. - F32 mSunDeltaYaw; -#if 0 - WLFloatControl mWLGamma; -#endif - F32 mSceneLightStrength; - -#if 0 - /// Atmospherics - WLColorControl mBlueHorizon; - WLFloatControl mHazeDensity; - WLColorControl mBlueDensity; - WLFloatControl mDensityMult; - WLFloatControl mHazeHorizon; - WLFloatControl mMaxAlt; - - /// Lighting - WLColorControl mLightnorm; - WLColorControl mSunlight; - WLColorControl mAmbient; - WLColorControl mGlow; - - /// Clouds - WLColorControl mCloudColor; - WLColorControl mCloudMain; - WLFloatControl mCloudCoverage; - WLColorControl mCloudDetail; - WLFloatControl mDistanceMult; - WLFloatControl mCloudScale; -#endif - /// sky dome - F32 mDomeOffset; - F32 mDomeRadius; - - -private: - - friend class LLWLAnimator; - - void loadAllPresets(); - void loadPresetsFromDir(const std::string& dir); - bool loadPreset(const std::string& path); - - static std::string getSysDir(); - static std::string getUserDir(); - - /*virtual*/ void initSingleton(); - // list of all the parameters, listed by name - std::map mParamList; - - preset_list_signal_t mPresetListChangeSignal; -}; - -inline F32 LLWLParamManager::getDomeOffset(void) const -{ - return mDomeOffset; -} - -inline F32 LLWLParamManager::getDomeRadius(void) const -{ - return mDomeRadius; -} - -inline LLVector4 LLWLParamManager::getLightDir(void) const -{ - return mLightDir; -} - -inline LLVector4 LLWLParamManager::getClampedLightDir(void) const -{ - return mClampedLightDir; -} - -inline LLVector4 LLWLParamManager::getRotatedLightDir(void) const -{ - return mRotatedLightDir; -} - -#endif - diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp deleted file mode 100644 index a2ff2c0c95..0000000000 --- a/indra/newview/llwlparamset.cpp +++ /dev/null @@ -1,426 +0,0 @@ -/** - * @file llwlparamset.cpp - * @brief Implementation for the LLWLParamSet class. - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, 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 "llwlparamset.h" -#include "llwlanimator.h" - -#include "llwlparammanager.h" -#include "llglslshader.h" -#include "lluictrlfactory.h" -#include "llsliderctrl.h" -#include "pipeline.h" - -#include - -#include - -static LLStaticHashedString sStarBrightness("star_brightness"); -static LLStaticHashedString sPresetNum("preset_num"); -static LLStaticHashedString sSunAngle("sun_angle"); -static LLStaticHashedString sEastAngle("east_angle"); -static LLStaticHashedString sEnableCloudScroll("enable_cloud_scroll"); -static LLStaticHashedString sCloudScrollRate("cloud_scroll_rate"); -static LLStaticHashedString sLightNorm("lightnorm"); -static LLStaticHashedString sCloudDensity("cloud_pos_density1"); -static LLStaticHashedString sCloudScale("cloud_scale"); -static LLStaticHashedString sCloudShadow("cloud_shadow"); -static LLStaticHashedString sDensityMultiplier("density_multiplier"); -static LLStaticHashedString sDistanceMultiplier("distance_multiplier"); -static LLStaticHashedString sHazeDensity("haze_density"); -static LLStaticHashedString sHazeHorizon("haze_horizon"); -static LLStaticHashedString sMaxY("max_y"); - -LLWLParamSet::LLWLParamSet(void) : - mName("Unnamed Preset"), - mCloudScrollXOffset(0.f), mCloudScrollYOffset(0.f) -{} - -static LLTrace::BlockTimerStatHandle FTM_WL_PARAM_UPDATE("WL Param Update"); - -void LLWLParamSet::update(LLGLSLShader * shader) const -{ - LL_RECORD_BLOCK_TIME(FTM_WL_PARAM_UPDATE); - //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; - - LLSD::map_const_iterator i = mParamValues.beginMap(); - std::vector::const_iterator n = mParamHashedNames.begin(); - for(;(i != mParamValues.endMap()) && (n != mParamHashedNames.end());++i, n++) - { - const LLStaticHashedString& param = *n; - - // check that our pre-hashed names are still tracking the mParamValues map correctly - // - llassert(param.String() == i->first); - - if (param == sStarBrightness || param == sPresetNum || param == sSunAngle || - param == sEastAngle || param == sEnableCloudScroll || - param == sCloudScrollRate || param == sLightNorm ) - { - continue; - } - - if (param == sCloudDensity) - { - LLVector4 val; - val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset; - val.mV[1] = F32(i->second[1].asReal()) + mCloudScrollYOffset; - val.mV[2] = (F32) i->second[2].asReal(); - val.mV[3] = (F32) i->second[3].asReal(); - - stop_glerror(); - //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; - shader->uniform4fv(param, 1, val.mV); - stop_glerror(); - } - else if (param == sCloudScale || param == sCloudShadow || - param == sDensityMultiplier || param == sDistanceMultiplier || - param == sHazeDensity || param == sHazeHorizon || - param == sMaxY ) - { - F32 val = (F32) i->second[0].asReal(); - - stop_glerror(); - //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; - shader->uniform1f(param, val); - stop_glerror(); - } - else // param is the uniform name - { - // handle all the different cases - if (i->second.isArray() && i->second.size() == 4) - { - LLVector4 val; - - val.mV[0] = (F32) i->second[0].asReal(); - val.mV[1] = (F32) i->second[1].asReal(); - val.mV[2] = (F32) i->second[2].asReal(); - val.mV[3] = (F32) i->second[3].asReal(); - - stop_glerror(); - //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; - shader->uniform4fv(param, 1, val.mV); - stop_glerror(); - } - else if (i->second.isReal()) - { - F32 val = (F32) i->second.asReal(); - - stop_glerror(); - //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; - shader->uniform1f(param, val); - stop_glerror(); - } - else if (i->second.isInteger()) - { - S32 val = (S32) i->second.asInteger(); - - stop_glerror(); - //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; - shader->uniform1i(param, val); - stop_glerror(); - } - else if (i->second.isBoolean()) - { - S32 val = (i->second.asBoolean() ? 1 : 0); - - stop_glerror(); - //_WARNS("RIDER") << "pushing '" << param.String() << "' as " << val << LL_ENDL; - shader->uniform1i(param, val); - stop_glerror(); - } - } - } - - if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && !LLPipeline::sUnderWaterRender) - { - shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 2.2); - } else { - shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 1.0); - } -} - -void LLWLParamSet::set(const std::string& paramName, float x) -{ - // handle case where no array - if(mParamValues[paramName].isReal()) - { - mParamValues[paramName] = x; - } - - // handle array - else if(mParamValues[paramName].isArray() && - mParamValues[paramName][0].isReal()) - { - mParamValues[paramName][0] = x; - } -} - -void LLWLParamSet::set(const std::string& paramName, float x, float y) -{ - mParamValues[paramName][0] = x; - mParamValues[paramName][1] = y; -} - -void LLWLParamSet::set(const std::string& paramName, float x, float y, float z) -{ - mParamValues[paramName][0] = x; - mParamValues[paramName][1] = y; - mParamValues[paramName][2] = z; -} - -void LLWLParamSet::set(const std::string& paramName, float x, float y, float z, float w) -{ - mParamValues[paramName][0] = x; - mParamValues[paramName][1] = y; - mParamValues[paramName][2] = z; - mParamValues[paramName][3] = w; -} - -void LLWLParamSet::set(const std::string& paramName, const float * val) -{ - mParamValues[paramName][0] = val[0]; - mParamValues[paramName][1] = val[1]; - mParamValues[paramName][2] = val[2]; - mParamValues[paramName][3] = val[3]; -} - -void LLWLParamSet::set(const std::string& paramName, const LLVector4 & val) -{ - mParamValues[paramName][0] = val.mV[0]; - mParamValues[paramName][1] = val.mV[1]; - mParamValues[paramName][2] = val.mV[2]; - mParamValues[paramName][3] = val.mV[3]; -} - -void LLWLParamSet::set(const std::string& paramName, const LLColor4 & val) -{ - mParamValues[paramName][0] = val.mV[0]; - mParamValues[paramName][1] = val.mV[1]; - mParamValues[paramName][2] = val.mV[2]; - mParamValues[paramName][3] = val.mV[3]; -} - -LLVector4 LLWLParamSet::getVector(const std::string& paramName, bool& error) -{ - // test to see if right type - LLSD cur_val = mParamValues.get(paramName); - if (!cur_val.isArray()) - { - error = true; - return LLVector4(0,0,0,0); - } - - LLVector4 val; - val.mV[0] = (F32) cur_val[0].asReal(); - val.mV[1] = (F32) cur_val[1].asReal(); - val.mV[2] = (F32) cur_val[2].asReal(); - val.mV[3] = (F32) cur_val[3].asReal(); - - error = false; - return val; -} - -F32 LLWLParamSet::getFloat(const std::string& paramName, bool& error) -{ - // test to see if right type - LLSD cur_val = mParamValues.get(paramName); - if (cur_val.isArray() && cur_val.size() != 0) - { - error = false; - return (F32) cur_val[0].asReal(); - } - - if(cur_val.isReal()) - { - error = false; - return (F32) cur_val.asReal(); - } - - error = true; - return 0; -} - -void LLWLParamSet::setSunAngle(float val) -{ - // keep range 0 - 2pi - if(val > F_TWO_PI || val < 0) - { - F32 num = val / F_TWO_PI; - num -= floor(num); - val = F_TWO_PI * num; - } - - mParamValues["sun_angle"] = val; -} - - -void LLWLParamSet::setEastAngle(float val) -{ - // keep range 0 - 2pi - if(val > F_TWO_PI || val < 0) - { - F32 num = val / F_TWO_PI; - num -= floor(num); - val = F_TWO_PI * num; - } - - mParamValues["east_angle"] = val; -} - -void LLWLParamSet::mix(LLWLParamSet& src, LLWLParamSet& dest, F32 weight) -{ - // set up the iterators - - // keep cloud positions and coverage the same - /// TODO masking will do this later - F32 cloudPos1X = (F32) mParamValues["cloud_pos_density1"][0].asReal(); - F32 cloudPos1Y = (F32) mParamValues["cloud_pos_density1"][1].asReal(); - F32 cloudPos2X = (F32) mParamValues["cloud_pos_density2"][0].asReal(); - F32 cloudPos2Y = (F32) mParamValues["cloud_pos_density2"][1].asReal(); - F32 cloudCover = (F32) mParamValues["cloud_shadow"][0].asReal(); - - LLSD srcVal; - LLSD destVal; - - // Iterate through values - for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) - { - // If param exists in both src and dest, set the holder variables, otherwise skip - if(src.mParamValues.has(iter->first) && dest.mParamValues.has(iter->first)) - { - srcVal = src.mParamValues[iter->first]; - destVal = dest.mParamValues[iter->first]; - } - else - { - continue; - } - - if(iter->second.isReal()) // If it's a real, interpolate directly - { - iter->second = srcVal.asReal() + ((destVal.asReal() - srcVal.asReal()) * weight); - } - else if(iter->second.isArray() && iter->second[0].isReal() // If it's an array of reals, loop through the reals and interpolate on those - && iter->second.size() == srcVal.size() && iter->second.size() == destVal.size()) - { - // Actually do interpolation: old value + (difference in values * factor) - for(int i=0; i < iter->second.size(); ++i) - { - // iter->second[i] = (1.f-weight)*(F32)srcVal[i].asReal() + weight*(F32)destVal[i].asReal(); // old way of doing it -- equivalent but one more operation - iter->second[i] = srcVal[i].asReal() + ((destVal[i].asReal() - srcVal[i].asReal()) * weight); - } - } - else // Else, skip - { - continue; - } - } - - // now mix the extra parameters - setStarBrightness((1 - weight) * (F32) src.getStarBrightness() - + weight * (F32) dest.getStarBrightness()); - - llassert(src.getSunAngle() >= - F_PI && - src.getSunAngle() <= 3 * F_PI); - llassert(dest.getSunAngle() >= - F_PI && - dest.getSunAngle() <= 3 * F_PI); - llassert(src.getEastAngle() >= 0 && - src.getEastAngle() <= 4 * F_PI); - llassert(dest.getEastAngle() >= 0 && - dest.getEastAngle() <= 4 * F_PI); - - // sun angle and east angle require some handling to make sure - // they go in circles. Yes quaternions would work better. - F32 srcSunAngle = src.getSunAngle(); - F32 destSunAngle = dest.getSunAngle(); - F32 srcEastAngle = src.getEastAngle(); - F32 destEastAngle = dest.getEastAngle(); - - if(fabsf(srcSunAngle - destSunAngle) > F_PI) - { - if(srcSunAngle > destSunAngle) - { - destSunAngle += 2 * F_PI; - } - else - { - srcSunAngle += 2 * F_PI; - } - } - - if(fabsf(srcEastAngle - destEastAngle) > F_PI) - { - if(srcEastAngle > destEastAngle) - { - destEastAngle += 2 * F_PI; - } - else - { - srcEastAngle += 2 * F_PI; - } - } - - setSunAngle((1 - weight) * srcSunAngle + weight * destSunAngle); - setEastAngle((1 - weight) * srcEastAngle + weight * destEastAngle); - - // now setup the sun properly - - // reset those cloud positions - mParamValues["cloud_pos_density1"][0] = cloudPos1X; - mParamValues["cloud_pos_density1"][1] = cloudPos1Y; - mParamValues["cloud_pos_density2"][0] = cloudPos2X; - mParamValues["cloud_pos_density2"][1] = cloudPos2Y; - mParamValues["cloud_shadow"][0] = cloudCover; -} - -void LLWLParamSet::updateCloudScrolling(void) -{ - static LLTimer s_cloud_timer; - - F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); - - if(getEnableCloudScrollX()) - { - mCloudScrollXOffset += F32(delta_t * (getCloudScrollX() - 10.f) / 100.f); - } - if(getEnableCloudScrollY()) - { - mCloudScrollYOffset += F32(delta_t * (getCloudScrollY() - 10.f) / 100.f); - } -} - -void LLWLParamSet::updateHashedNames() -{ - mParamHashedNames.clear(); - // Iterate through values - for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter) - { - mParamHashedNames.push_back(LLStaticHashedString(iter->first)); - } -} - diff --git a/indra/newview/llwlparamset.h b/indra/newview/llwlparamset.h deleted file mode 100644 index 6e5f1d3a4b..0000000000 --- a/indra/newview/llwlparamset.h +++ /dev/null @@ -1,246 +0,0 @@ -/** - * @file llwlparamset.h - * @brief Interface for the LLWLParamSet class. - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, 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_WLPARAM_SET_H -#define LL_WLPARAM_SET_H - -#include -#include -#include - -#include "v4math.h" -#include "v4color.h" -#include "llstaticstringtable.h" - -class LLWLParamSet; -class LLGLSLShader; - -/// A class representing a set of parameter values for the WindLight shaders. -class LLWLParamSet { - - friend class LLWLParamManager; - -public: - std::string mName; - -private: - - LLSD mParamValues; - std::vector mParamHashedNames; - - float mCloudScrollXOffset, mCloudScrollYOffset; - - void updateHashedNames(); - -public: - - LLWLParamSet(); - - /// Update this set of shader uniforms from the parameter values. - void update(LLGLSLShader * shader) const; - - /// set the total llsd - void setAll(const LLSD& val); - - /// get the total llsd - const LLSD& getAll(); - - - /// Set a float parameter. - /// \param paramName The name of the parameter to set. - /// \param x The float value to set. - void set(const std::string& paramName, float x); - - /// Set a float2 parameter. - /// \param paramName The name of the parameter to set. - /// \param x The x component's value to set. - /// \param y The y component's value to set. - void set(const std::string& paramName, float x, float y); - - /// Set a float3 parameter. - /// \param paramName The name of the parameter to set. - /// \param x The x component's value to set. - /// \param y The y component's value to set. - /// \param z The z component's value to set. - void set(const std::string& paramName, float x, float y, float z); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param x The x component's value to set. - /// \param y The y component's value to set. - /// \param z The z component's value to set. - /// \param w The w component's value to set. - void set(const std::string& paramName, float x, float y, float z, float w); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param val An array of the 4 float values to set the parameter to. - void set(const std::string& paramName, const float * val); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param val A struct of the 4 float values to set the parameter to. - void set(const std::string& paramName, const LLVector4 & val); - - /// Set a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param val A struct of the 4 float values to set the parameter to. - void set(const std::string& paramName, const LLColor4 & val); - - /// Get a float4 parameter. - /// \param paramName The name of the parameter to set. - /// \param error A flag to set if it's not the proper return type - LLVector4 getVector(const std::string& paramName, bool& error); - - /// Get a float parameter - /// \param paramName The name of the parameter to set. - /// \param error A flag to set if it's not the proper return type - F32 getFloat(const std::string& paramName, bool& error); - - - // specific getters and setters - - - /// set the star's brightness - /// \param val brightness value - void setStarBrightness(F32 val); - - /// get the star brightness value; - F32 getStarBrightness(); - - void setSunAngle(F32 val); - F32 getSunAngle(); - - void setEastAngle(F32 val); - F32 getEastAngle(); - - - - /// set the cloud scroll x enable value - /// \param val scroll x value - void setEnableCloudScrollX(bool val); - - /// get the scroll x enable value; - bool getEnableCloudScrollX(); - - /// set the star's brightness - /// \param val scroll y bool value - void setEnableCloudScrollY(bool val); - - /// get the scroll enable y value; - bool getEnableCloudScrollY(); - - /// set the cloud scroll x enable value - /// \param val scroll x value - void setCloudScrollX(F32 val); - - /// get the scroll x enable value; - F32 getCloudScrollX(); - - /// set the star's brightness - /// \param val scroll y bool value - void setCloudScrollY(F32 val); - - /// get the scroll enable y value; - F32 getCloudScrollY(); - - /// interpolate two parameter sets - /// \param src The parameter set to start with - /// \param dest The parameter set to end with - /// \param weight The amount to interpolate - void mix(LLWLParamSet& src, LLWLParamSet& dest, - F32 weight); - - void updateCloudScrolling(void); -}; - -inline void LLWLParamSet::setAll(const LLSD& val) -{ - if(val.isMap()) { - mParamValues = val; - } - - updateHashedNames(); -} - -inline const LLSD& LLWLParamSet::getAll() -{ - return mParamValues; -} - -inline void LLWLParamSet::setStarBrightness(float val) { - mParamValues["star_brightness"] = val; -} - -inline F32 LLWLParamSet::getStarBrightness() { - return (F32) mParamValues["star_brightness"].asReal(); -} - -inline F32 LLWLParamSet::getSunAngle() { - return (F32) mParamValues["sun_angle"].asReal(); -} - -inline F32 LLWLParamSet::getEastAngle() { - return (F32) mParamValues["east_angle"].asReal(); -} - - -inline void LLWLParamSet::setEnableCloudScrollX(bool val) { - mParamValues["enable_cloud_scroll"][0] = val; -} - -inline bool LLWLParamSet::getEnableCloudScrollX() { - return mParamValues["enable_cloud_scroll"][0].asBoolean(); -} - -inline void LLWLParamSet::setEnableCloudScrollY(bool val) { - mParamValues["enable_cloud_scroll"][1] = val; -} - -inline bool LLWLParamSet::getEnableCloudScrollY() { - return mParamValues["enable_cloud_scroll"][1].asBoolean(); -} - - -inline void LLWLParamSet::setCloudScrollX(F32 val) { - mParamValues["cloud_scroll_rate"][0] = val; -} - -inline F32 LLWLParamSet::getCloudScrollX() { - return (F32) mParamValues["cloud_scroll_rate"][0].asReal(); -} - -inline void LLWLParamSet::setCloudScrollY(F32 val) { - mParamValues["cloud_scroll_rate"][1] = val; -} - -inline F32 LLWLParamSet::getCloudScrollY() { - return (F32) mParamValues["cloud_scroll_rate"][1].asReal(); -} - - -#endif // LL_WLPARAM_SET_H - diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 55c0a092bf..108a8e3e62 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -100,7 +100,6 @@ #include "llviewerstats.h" #include "llviewerjoystick.h" #include "llviewerdisplay.h" -#include "llwaterparammanager.h" #include "llspatialpartition.h" #include "llmutelist.h" #include "lltoolpie.h" -- cgit v1.3