From 150fba7c5cd24ad9ab343e762bfd15032e6a9462 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 21 Sep 2017 15:58:13 -0700 Subject: Still not working. Black Sky. --- indra/newview/llenvironment.cpp | 271 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100644 indra/newview/llenvironment.cpp (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp new file mode 100644 index 0000000000..dec2930970 --- /dev/null +++ b/indra/newview/llenvironment.cpp @@ -0,0 +1,271 @@ +/** + * @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 "llenvironment.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 "lltrace.h" +#include "llfasttimer.h" +#include "llviewercamera.h" +#include "pipeline.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"); +} + +//------------------------------------------------------------------------- +LLEnvironment::LLEnvironment(): + mCurrentSky(), + mSkysById(), + mSkysByName() +{ + LLSettingsSky::ptr_t p_default_sky = LLSettingsSky::buildDefaultSky(); + addSky(p_default_sky); + mCurrentSky = p_default_sky; +} + +LLEnvironment::~LLEnvironment() +{ +} + +//------------------------------------------------------------------------- +void LLEnvironment::update(const LLViewerCamera * cam) +{ + LL_RECORD_BLOCK_TIME(FTM_ENVIRONMENT_UPDATE); + + // update clouds, sun, and general + updateCloudScroll(); + mCurrentSky->update(); + +// // update only if running +// if (mAnimator.getIsRunning()) +// { +// mAnimator.update(mCurParams); +// } + + LLVector3 lightdir = mCurrentSky->getLightDirection(); + // update the shaders and the menu + + 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. + { + LLVector3 lightNorm3(mCurrentSky->getLightDirection()); + + lightNorm3 *= LLQuaternion(-(camYaw + SUN_DELTA_YAW), LLVector3(0.f, 1.f, 0.f)); + mRotatedLight = 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; + } + } + } +} + +void LLEnvironment::updateCloudScroll() +{ + // This is a function of the environment rather than the sky, since it should + // persist through sky transitions. + static LLTimer s_cloud_timer; + + F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); + + LLVector2 cloud_delta = static_cast(delta_t) * (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; + + mCloudScroll += cloud_delta; + +} + +void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting) +{ + LL_RECORD_BLOCK_TIME(FTM_SHADER_PARAM_UPDATE); + + //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; + LLSettingsBase::parammapping_t params = psetting->getParameterMap(); + for (LLSettingsBase::parammapping_t::iterator it = params.begin(); it != params.end(); ++it) + { + if (!psetting->mSettings.has((*it).first)) + continue; + + LLSD value = psetting->mSettings[(*it).first]; + LLSD::Type setting_type = value.type(); + + stop_glerror(); + switch (setting_type) + { + case LLSD::TypeInteger: + shader->uniform1i((*it).second, value.asInteger()); + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; + break; + case LLSD::TypeReal: + shader->uniform1f((*it).second, value.asReal()); + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; + break; + + case LLSD::TypeBoolean: + shader->uniform1i((*it).second, value.asBoolean() ? 1 : 0); + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; + break; + + case LLSD::TypeArray: + { + LLVector4 vect4(value); + //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; + shader->uniform4fv((*it).second, 4, vect4.mV); + + break; + } + + // case LLSD::TypeMap: + // case LLSD::TypeString: + // case LLSD::TypeUUID: + // case LLSD::TypeURI: + // case LLSD::TypeBinary: + // case LLSD::TypeDate: + default: + break; + } + stop_glerror(); + } + //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; + +// psetting->applySpecial(shader); + + if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && !LLPipeline::sUnderWaterRender) + { + shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 2.2); + } + else + { + shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 1.0); + } + +} + +void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) +{ + + if (gPipeline.canUseWindLightShaders()) + { + updateGLVariablesForSettings(shader, mCurrentSky); + } + + if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) + { + stop_glerror(); + shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, mRotatedLight.mV); + shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); + stop_glerror(); + } + else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) + { + stop_glerror(); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mCurrentSky->getLightDirectionClamped().mV); + stop_glerror(); + } + + shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mCurrentSky->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(); + } + + +} +//-------------------------------------------------------------------------- + +void LLEnvironment::addSky(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); + if (it != mSkysByName.end()) + mSkysByName.erase(it); +} + +void LLEnvironment::removeSky(const LLUUID &id) +{ + +} + +void LLEnvironment::clearAllSkys() +{ + mSkysByName.clear(); + mSkysById.clear(); +} + -- cgit v1.2.3 From 0d414c1fb579dffc122c4d021a84cd126c612e54 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 26 Sep 2017 09:19:20 -0700 Subject: Clouds still funky but better. --- indra/newview/llenvironment.cpp | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index dec2930970..84a1f2c1ab 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -117,9 +117,20 @@ 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)* (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; +// } - mCloudScroll += cloud_delta; } @@ -158,7 +169,7 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS { LLVector4 vect4(value); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; - shader->uniform4fv((*it).second, 4, vect4.mV); + shader->uniform4fv((*it).second, 1, vect4.mV); break; } @@ -176,7 +187,7 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS } //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; -// psetting->applySpecial(shader); + psetting->applySpecial(shader); if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && !LLPipeline::sUnderWaterRender) { @@ -213,17 +224,17 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mCurrentSky->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(); - } +// { +// 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(); +// } } -- cgit v1.2.3 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/llenvironment.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 84a1f2c1ab..ceba7fda88 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -34,7 +34,6 @@ #include "llviewerregion.h" #include "llwaterparammanager.h" #include "llwlhandlers.h" -#include "llwlparammanager.h" #include "lltrans.h" #include "lltrace.h" #include "llfasttimer.h" @@ -65,6 +64,12 @@ LLEnvironment::~LLEnvironment() { } +//------------------------------------------------------------------------- +F32 LLEnvironment::getCamHeight() const +{ + return (mCurrentSky->getDomeOffset() * mCurrentSky->getDomeRadius()); +} + //------------------------------------------------------------------------- void LLEnvironment::update(const LLViewerCamera * cam) { @@ -222,7 +227,7 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) stop_glerror(); } - shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mCurrentSky->getSceneLightStrength()); + shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, getSceneLightStrength()); // { // LLVector4 cloud_scroll(mCloudScroll[0], mCloudScroll[1], 0.0, 0.0); @@ -244,6 +249,8 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) { std::string name = sky->getValue(LLSettingsSky::SETTING_NAME).asString(); + LL_WARNS("RIDER") << "Adding sky as '" << name << "'" << LL_ENDL; + std::pair result; result = mSkysByName.insert(NamedSkyMap_t::value_type(name, sky)); @@ -280,3 +287,14 @@ void LLEnvironment::clearAllSkys() mSkysById.clear(); } +void LLEnvironment::selectSky(const std::string &name) +{ + NamedSkyMap_t::iterator it = mSkysByName.find(name); + + if (it == mSkysByName.end()) + return; + + mCurrentSky = (*it).second; + mCurrentSky->setDirtyFlag(true); +} + -- cgit v1.2.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 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'indra/newview/llenvironment.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(); -// } - } //-------------------------------------------------------------------------- -- cgit v1.2.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/llenvironment.cpp | 155 ++++++++++++++++++++++++++++++++++------ 1 file changed, 132 insertions(+), 23 deletions(-) (limited to 'indra/newview/llenvironment.cpp') 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()); + } +} -- cgit v1.2.3 From 2161788711f6d89564afc933707b6a0b8c1b0562 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 20 Oct 2017 16:37:03 -0700 Subject: Day cycles start --- indra/newview/llenvironment.cpp | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 921f3ef910..fbb713c6d8 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -293,15 +293,14 @@ void LLEnvironment::clearAllSkys() void LLEnvironment::selectSky(const std::string &name) { - NamedSettingMap_t::iterator it = mSkysByName.find(name); - - if (it == mSkysByName.end()) + 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 = boost::static_pointer_cast((*it).second); + mCurrentSky = next_sky; mCurrentSky->setDirtyFlag(true); } @@ -322,15 +321,15 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) void LLEnvironment::selectWater(const std::string &name) { - NamedSettingMap_t::iterator it = mWaterByName.find(name); + LLSettingsWater::ptr_t next_water = findWaterByName(name); - if (it == mWaterByName.end()) + if (!next_water) { LL_WARNS("ENVIRONMENT") << "Unable to select water with unknown name '" << name << "'" << LL_ENDL; return; } - mCurrentWater = boost::static_pointer_cast((*it).second); + mCurrentWater = next_water; mCurrentWater->setDirtyFlag(true); } @@ -348,6 +347,31 @@ void LLEnvironment::clearAllWater() mWaterById.clear(); } +LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const +{ + NamedSettingMap_t::const_iterator it = mSkysByName.find(name); + + if (it == mSkysByName.end()) + { + LL_WARNS("ENVIRONMENT") << "Unable to find sky with unknown name '" << name << "'" << LL_ENDL; + return LLSettingsSky::ptr_t(); + } + + return boost::static_pointer_cast((*it).second); +} + +LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const +{ + NamedSettingMap_t::const_iterator it = mWaterByName.find(name); + + if (it == mWaterByName.end()) + { + LL_WARNS("ENVIRONMENT") << "Unable to find water with unknown name '" << name << "'" << LL_ENDL; + return LLSettingsWater::ptr_t(); + } + + return boost::static_pointer_cast((*it).second); +} //========================================================================= LLEnvironment::UserPrefs::UserPrefs(): -- cgit v1.2.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/llenvironment.cpp | 469 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 431 insertions(+), 38 deletions(-) (limited to 'indra/newview/llenvironment.cpp') 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); + } + } + } +} -- cgit v1.2.3 From fe846ec9942af5ad2ab6a4aad9e8561ba9bc1fba Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Nov 2017 16:02:20 -0800 Subject: Day cycles and animated sky/water blending. --- indra/newview/llenvironment.cpp | 214 +++++++++++++++++++++++++++------------- 1 file changed, 146 insertions(+), 68 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 9c654bbeb5..01ee6d6d54 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -43,6 +43,8 @@ #include "llsdserialize.h" #include "lldiriterator.h" + +#include //========================================================================= namespace { @@ -51,6 +53,11 @@ namespace } //========================================================================= +const F32Seconds LLEnvironment::TRANSITION_INSTANT(0.0f); +const F32Seconds LLEnvironment::TRANSITION_FAST(1.0f); +const F32Seconds LLEnvironment::TRANSITION_DEFAULT(5.0f); +const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); + const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS); @@ -73,20 +80,23 @@ void LLEnvironment::initSingleton() { LLSettingsSky::ptr_t p_default_sky = LLSettingsSky::buildDefaultSky(); addSky(p_default_sky); - mSelectedSky = p_default_sky; + mCurrentSky = p_default_sky; LLSettingsWater::ptr_t p_default_water = LLSettingsWater::buildDefaultWater(); addWater(p_default_water); - mSelectedWater = p_default_water; + mCurrentWater = p_default_water; LLSettingsDayCycle::ptr_t p_default_day = LLSettingsDayCycle::buildDefaultDayCycle(); addDayCycle(p_default_day); - mSelectedDayCycle.reset(); + mCurrentDayCycle.reset(); applyAllSelected(); // LEGACY! legacyLoadAllPresets(); + + LLEnvironmentRequest::initiate(); + gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::onRegionChange, this)); } LLEnvironment::~LLEnvironment() @@ -113,10 +123,16 @@ LLEnvironment::connection_t LLEnvironment::setDayCycleListChange(const LLEnviron return mDayCycleListChange.connect(cb); } + +void LLEnvironment::onRegionChange() +{ + LLEnvironmentRequest::initiate(); +} + //------------------------------------------------------------------------- F32 LLEnvironment::getCamHeight() const { - return (mSelectedSky->getDomeOffset() * mSelectedSky->getDomeRadius()); + return (mCurrentSky->getDomeOffset() * mCurrentSky->getDomeRadius()); } F32 LLEnvironment::getWaterHeight() const @@ -126,32 +142,34 @@ F32 LLEnvironment::getWaterHeight() const bool LLEnvironment::getIsDayTime() const { - return mSelectedSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; + return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; } //------------------------------------------------------------------------- void LLEnvironment::update(const LLViewerCamera * cam) { LL_RECORD_BLOCK_TIME(FTM_ENVIRONMENT_UPDATE); + //F32Seconds now(LLDate::now().secondsSinceEpoch()); + static LLFrameTimer timer; + + F32Seconds delta(timer.getElapsedTimeAndResetF32()); + + if (mBlenderSky) + mBlenderSky->update(delta); + if (mBlenderWater) + mBlenderWater->update(delta); // update clouds, sun, and general updateCloudScroll(); - if (mSelectedDayCycle) - mSelectedDayCycle->update(); - if (mSelectedSky) - mSelectedSky->update(); - if (mSelectedWater) - mSelectedWater->update(); + if (mCurrentDayCycle) + mCurrentDayCycle->update(); -// // update only if running -// if (mAnimator.getIsRunning()) -// { -// mAnimator.update(mCurParams); -// } + if (mCurrentSky) + mCurrentSky->update(); + if (mCurrentWater) + mCurrentWater->update(); - //LLVector3 lightdir = mCurrentSky->getLightDirection(); - // update the shaders and the menu F32 camYaw = cam->getYaw(); @@ -179,11 +197,6 @@ 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 @@ -192,7 +205,7 @@ void LLEnvironment::updateCloudScroll() F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); - LLVector2 cloud_delta = static_cast(delta_t)* (mSelectedSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; + LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; mCloudScrollDelta += cloud_delta; @@ -270,8 +283,8 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) if (gPipeline.canUseWindLightShaders()) { - updateGLVariablesForSettings(shader, mSelectedSky); - updateGLVariablesForSettings(shader, mSelectedWater); + updateGLVariablesForSettings(shader, mCurrentSky); + updateGLVariablesForSettings(shader, mCurrentWater); } if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) @@ -293,7 +306,7 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) } //-------------------------------------------------------------------------- -void LLEnvironment::selectSky(const std::string &name) +void LLEnvironment::selectSky(const std::string &name, F32Seconds transition) { LLSettingsSky::ptr_t next_sky = findSkyByName(name); if (!next_sky) @@ -302,33 +315,57 @@ void LLEnvironment::selectSky(const std::string &name) return; } - selectSky(next_sky); + selectSky(next_sky, transition); } -void LLEnvironment::selectSky(const LLSettingsSky::ptr_t &sky) +void LLEnvironment::selectSky(const LLSettingsSky::ptr_t &sky, F32Seconds transition) { if (!sky) { - mSelectedSky = mCurrentSky; + mCurrentSky = mSelectedSky; + mBlenderSky.reset(); return; } mSelectedSky = sky; - mSelectedSky->setDirtyFlag(true); + if (fabs(transition.value()) <= F_ALMOST_ZERO) + { + mBlenderSky.reset(); + mCurrentSky = sky; + mCurrentSky->setDirtyFlag(true); + mSelectedSky = sky; + } + else + { + LLSettingsSky::ptr_t skytarget = mCurrentSky->buildClone(); + + mBlenderSky = boost::make_shared( skytarget, mCurrentSky, sky, transition ); + mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::onSkyTransitionDone, this, _1)); + mCurrentSky = skytarget; + mSelectedSky = sky; + } +} + +void LLEnvironment::onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender) +{ + mCurrentSky = mSelectedSky; + mBlenderSky.reset(); } void LLEnvironment::applySky(const LLSettingsSky::ptr_t &sky) { +#if 0 if (sky) { mCurrentSky = sky; } else { - mCurrentSky = mSelectedSky; + mCurrentSky = mCurrentSky; } +#endif } -void LLEnvironment::selectWater(const std::string &name) +void LLEnvironment::selectWater(const std::string &name, F32Seconds transition) { LLSettingsWater::ptr_t next_water = findWaterByName(name); @@ -338,33 +375,57 @@ void LLEnvironment::selectWater(const std::string &name) return; } - selectWater(next_water); + selectWater(next_water, transition); } -void LLEnvironment::selectWater(const LLSettingsWater::ptr_t &water) +void LLEnvironment::selectWater(const LLSettingsWater::ptr_t &water, F32Seconds transition) { if (!water) { - mSelectedWater = mCurrentWater; + mCurrentWater = mSelectedWater; + mBlenderWater.reset(); return; } mSelectedWater = water; - mSelectedWater->setDirtyFlag(true); + if (fabs(transition.value()) <= F_ALMOST_ZERO) + { + mBlenderWater.reset(); + mCurrentWater = water; + mCurrentWater->setDirtyFlag(true); + mSelectedWater = water; + } + else + { + LLSettingsWater::ptr_t watertarget = mCurrentWater->buildClone(); + + mBlenderWater = boost::make_shared(watertarget, mCurrentWater, water, transition); + mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::onWaterTransitionDone, this, _1)); + mCurrentWater = watertarget; + mSelectedWater = water; + } +} + +void LLEnvironment::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender) +{ + mCurrentWater = mSelectedWater; + mBlenderWater.reset(); } void LLEnvironment::applyWater(const LLSettingsWater::ptr_t water) { +#if 0 if (water) { mCurrentWater = water; } else { - mCurrentWater = mSelectedWater; + mCurrentWater = mCurrentWater; } +#endif } -void LLEnvironment::selectDayCycle(const std::string &name) +void LLEnvironment::selectDayCycle(const std::string &name, F32Seconds transition) { LLSettingsDayCycle::ptr_t next_daycycle = findDayCycleByName(name); @@ -374,51 +435,56 @@ void LLEnvironment::selectDayCycle(const std::string &name) return; } - mSelectedDayCycle = next_daycycle; - mSelectedDayCycle->setDirtyFlag(true); + selectDayCycle(next_daycycle, transition); } -void LLEnvironment::selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) +void LLEnvironment::selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle, F32Seconds transition) { if (!daycycle) { - mSelectedDayCycle = mCurrentDayCycle; return; } - mSelectedDayCycle = daycycle; - mSelectedDayCycle->setDirtyFlag(true); + mCurrentDayCycle = daycycle; + + daycycle->startDayCycle(); + selectWater(daycycle->getCurrentWater(), transition); + selectSky(daycycle->getCurrentSky(), transition); } void LLEnvironment::applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) { +#if 0 if (daycycle) { mCurrentDayCycle = daycycle; } else { - mCurrentDayCycle = mSelectedDayCycle; + mCurrentDayCycle = mCurrentDayCycle; } +#endif } void LLEnvironment::clearAllSelected() { - if (mSelectedSky != mCurrentSky) +#if 0 + if (mCurrentSky != mCurrentSky) selectSky(); - if (mSelectedWater != mCurrentWater) + if (mCurrentWater != mCurrentWater) selectWater(); - if (mSelectedDayCycle != mCurrentDayCycle) + if (mCurrentDayCycle != mCurrentDayCycle) selectDayCycle(); +#endif } void LLEnvironment::applyAllSelected() { - if (mSelectedSky != mCurrentSky) + if (mCurrentSky != mCurrentSky) applySky(); - if (mSelectedWater != mCurrentWater) + if (mCurrentWater != mCurrentWater) applyWater(); - if (mSelectedDayCycle != mCurrentDayCycle) + if (mCurrentDayCycle != mCurrentDayCycle) applyDayCycle(); } @@ -428,7 +494,7 @@ LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const list.reserve(mSkysByName.size()); - for (NamedSettingMap_t::const_iterator it = mSkysByName.begin(); it != mSkysByName.end(); ++it) + 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())); } @@ -442,7 +508,7 @@ LLEnvironment::list_name_id_t LLEnvironment::getWaterList() const list.reserve(mWaterByName.size()); - for (NamedSettingMap_t::const_iterator it = mWaterByName.begin(); it != mWaterByName.end(); ++it) + 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())); } @@ -456,7 +522,7 @@ LLEnvironment::list_name_id_t LLEnvironment::getDayCycleList() const list.reserve(mDayCycleByName.size()); - for (NamedSettingMap_t::const_iterator it = mDayCycleByName.begin(); it != mDayCycleByName.end(); ++it) + 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())); } @@ -470,8 +536,8 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) LL_WARNS("RIDER") << "Adding sky as '" << name << "'" << LL_ENDL; - std::pair result; - result = mSkysByName.insert(NamedSettingMap_t::value_type(name, sky)); + std::pair result; + result = mSkysByName.insert(namedSettingMap_t::value_type(name, sky)); if (!result.second) (*(result.first)).second = sky; @@ -491,7 +557,7 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) void LLEnvironment::removeSky(const std::string &name) { - NamedSettingMap_t::iterator it = mSkysByName.find(name); + namedSettingMap_t::iterator it = mSkysByName.find(name); if (it != mSkysByName.end()) mSkysByName.erase(it); mSkyListChange(); @@ -515,8 +581,8 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) LL_WARNS("RIDER") << "Adding water as '" << name << "'" << LL_ENDL; - std::pair result; - result = mWaterByName.insert(NamedSettingMap_t::value_type(name, water)); + std::pair result; + result = mWaterByName.insert(namedSettingMap_t::value_type(name, water)); if (!result.second) (*(result.first)).second = water; @@ -527,7 +593,7 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) void LLEnvironment::removeWater(const std::string &name) { - NamedSettingMap_t::iterator it = mWaterByName.find(name); + namedSettingMap_t::iterator it = mWaterByName.find(name); if (it != mWaterByName.end()) mWaterByName.erase(it); mWaterListChange(); @@ -547,8 +613,8 @@ void LLEnvironment::addDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) LL_WARNS("RIDER") << "Adding daycycle as '" << name << "'" << LL_ENDL; - std::pair result; - result = mDayCycleByName.insert(NamedSettingMap_t::value_type(name, daycycle)); + std::pair result; + result = mDayCycleByName.insert(namedSettingMap_t::value_type(name, daycycle)); if (!result.second) (*(result.first)).second = daycycle; @@ -559,7 +625,7 @@ void LLEnvironment::addDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) void LLEnvironment::removeDayCycle(const std::string &name) { - NamedSettingMap_t::iterator it = mDayCycleByName.find(name); + namedSettingMap_t::iterator it = mDayCycleByName.find(name); if (it != mDayCycleByName.end()) mDayCycleByName.erase(it); mDayCycleListChange(); @@ -575,7 +641,7 @@ void LLEnvironment::clearAllDayCycles() LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const { - NamedSettingMap_t::const_iterator it = mSkysByName.find(name); + namedSettingMap_t::const_iterator it = mSkysByName.find(name); if (it == mSkysByName.end()) { @@ -588,7 +654,7 @@ LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const { - NamedSettingMap_t::const_iterator it = mWaterByName.find(name); + namedSettingMap_t::const_iterator it = mWaterByName.find(name); if (it == mWaterByName.end()) { @@ -601,7 +667,7 @@ LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const LLSettingsDayCycle::ptr_t LLEnvironment::findDayCycleByName(std::string name) const { - NamedSettingMap_t::const_iterator it = mDayCycleByName.find(name); + namedSettingMap_t::const_iterator it = mDayCycleByName.find(name); if (it == mDayCycleByName.end()) { @@ -649,9 +715,21 @@ void LLEnvironment::UserPrefs::store() } } - //========================================================================= // Transitional Code. +void LLEnvironment::onLegacyRegionSettings(LLSD data) +{ + LLUUID regionId = data[0]["regionID"].asUUID(); + + LLSettingsDayCycle::ptr_t regionday; + if (data[1].isUndefined()) + regionday = LLEnvironment::findDayCycleByName("Default"); + else + regionday = LLSettingsDayCycle::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); + + selectDayCycle(regionday, TRANSITION_DEFAULT); +} + // static std::string LLEnvironment::getSysDir(const std::string &subdir) { -- cgit v1.2.3 From b37eb2642f6e6e4d1e32a49c7ab31f70321cd979 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 10 Nov 2017 16:17:25 -0800 Subject: Remove delete preset dialog, Initial settings for selection level (Region/Parcel/Local) --- indra/newview/llenvironment.cpp | 249 ++++++++++++++++++++++++---------------- 1 file changed, 148 insertions(+), 101 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 01ee6d6d54..8b879710da 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -65,15 +65,19 @@ const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS) LLEnvironment::LLEnvironment(): mSelectedSky(), mSelectedWater(), - mSelectedDayCycle(), + mSelectedDay(), mSkysById(), mSkysByName(), mWaterByName(), mWaterById(), mDayCycleByName(), mDayCycleById(), - mUserPrefs() + mUserPrefs(), + mSelectedEnvironment(ENV_LOCAL) { + mSetSkys.resize(ENV_END); + mSetWater.resize(ENV_END); + mSetDays.resize(ENV_END); } void LLEnvironment::initSingleton() @@ -86,16 +90,14 @@ void LLEnvironment::initSingleton() addWater(p_default_water); mCurrentWater = p_default_water; - LLSettingsDayCycle::ptr_t p_default_day = LLSettingsDayCycle::buildDefaultDayCycle(); + LLSettingsDay::ptr_t p_default_day = LLSettingsDay::buildDefaultDayCycle(); addDayCycle(p_default_day); - mCurrentDayCycle.reset(); - - applyAllSelected(); + mCurrentDay.reset(); // LEGACY! legacyLoadAllPresets(); - LLEnvironmentRequest::initiate(); + requestRegionEnvironment(); gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::onRegionChange, this)); } @@ -108,6 +110,17 @@ void LLEnvironment::loadPreferences() mUserPrefs.load(); } +void LLEnvironment::updatePreferences() +{ + /*NOOP for now. TODO record prefs and store.*/ +} + +bool LLEnvironment::canEdit() const +{ + return true; +} + + LLEnvironment::connection_t LLEnvironment::setSkyListChange(const LLEnvironment::change_signal_t::slot_type& cb) { return mSkyListChange.connect(cb); @@ -125,10 +138,32 @@ LLEnvironment::connection_t LLEnvironment::setDayCycleListChange(const LLEnviron void LLEnvironment::onRegionChange() +{ + requestRegionEnvironment(); +} + +void LLEnvironment::requestRegionEnvironment() { LLEnvironmentRequest::initiate(); } +void LLEnvironment::onLegacyRegionSettings(LLSD data) +{ + LLUUID regionId = data[0]["regionID"].asUUID(); + + LLSettingsDay::ptr_t regionday; + if (data[1].isUndefined()) + regionday = LLEnvironment::findDayCycleByName("Default"); + else + regionday = LLSettingsDay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); + + setSkyFor(ENV_REGION, LLSettingsSky::ptr_t()); + setWaterFor(ENV_REGION, LLSettingsWater::ptr_t()); + setDayFor(ENV_REGION, regionday); + + applyChosenEnvironment(); +} + //------------------------------------------------------------------------- F32 LLEnvironment::getCamHeight() const { @@ -162,8 +197,8 @@ void LLEnvironment::update(const LLViewerCamera * cam) // update clouds, sun, and general updateCloudScroll(); - if (mCurrentDayCycle) - mCurrentDayCycle->update(); + if (mCurrentDay) + mCurrentDay->update(); if (mCurrentSky) mCurrentSky->update(); @@ -351,20 +386,6 @@ void LLEnvironment::onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender) mBlenderSky.reset(); } -void LLEnvironment::applySky(const LLSettingsSky::ptr_t &sky) -{ -#if 0 - if (sky) - { - mCurrentSky = sky; - } - else - { - mCurrentSky = mCurrentSky; - } -#endif -} - void LLEnvironment::selectWater(const std::string &name, F32Seconds transition) { LLSettingsWater::ptr_t next_water = findWaterByName(name); @@ -411,23 +432,9 @@ void LLEnvironment::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blende mBlenderWater.reset(); } -void LLEnvironment::applyWater(const LLSettingsWater::ptr_t water) -{ -#if 0 - if (water) - { - mCurrentWater = water; - } - else - { - mCurrentWater = mCurrentWater; - } -#endif -} - void LLEnvironment::selectDayCycle(const std::string &name, F32Seconds transition) { - LLSettingsDayCycle::ptr_t next_daycycle = findDayCycleByName(name); + LLSettingsDay::ptr_t next_daycycle = findDayCycleByName(name); if (!next_daycycle) { @@ -438,56 +445,127 @@ void LLEnvironment::selectDayCycle(const std::string &name, F32Seconds transitio selectDayCycle(next_daycycle, transition); } -void LLEnvironment::selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle, F32Seconds transition) +void LLEnvironment::selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seconds transition) { if (!daycycle) { return; } - mCurrentDayCycle = daycycle; + mCurrentDay = daycycle; daycycle->startDayCycle(); selectWater(daycycle->getCurrentWater(), transition); selectSky(daycycle->getCurrentSky(), transition); } -void LLEnvironment::applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) + +void LLEnvironment::setSelectedEnvironment(EnvSelection_t env) +{ + if (env == mSelectedEnvironment) + { // No action to take + return; + } + + mSelectedEnvironment = env; + applyChosenEnvironment(); +} + +void LLEnvironment::applyChosenEnvironment() { -#if 0 - if (daycycle) + mSelectedSky.reset(); + mSelectedWater.reset(); + mSelectedDay.reset(); + + for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) { - mCurrentDayCycle = daycycle; + if (mSetDays[idx] && !mSelectedSky && !mSelectedWater) + selectDayCycle(mSetDays[idx]); + if (mSetSkys[idx] && !mSelectedSky) + selectSky(mSetSkys[idx]); + if (mSetWater[idx] && !mSelectedWater) + selectWater(mSetWater[idx]); + if (mSelectedSky && mSelectedWater) + return; } - else + + if (!mSelectedSky) + selectSky("Default"); + if (!mSelectedWater) + selectWater("Default"); +} + +LLSettingsSky::ptr_t LLEnvironment::getChosenSky() const +{ + for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) + { + if (mSetSkys[idx]) + return mSetSkys[idx]; + } + + return LLSettingsSky::ptr_t(); +} + +LLSettingsWater::ptr_t LLEnvironment::getChosenWater() const +{ + for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) { - mCurrentDayCycle = mCurrentDayCycle; + if (mSetWater[idx]) + return mSetWater[idx]; } -#endif + + return LLSettingsWater::ptr_t(); +} + +LLSettingsDay::ptr_t LLEnvironment::getChosenDay() const +{ + for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) + { + if (mSetDays[idx]) + return mSetDays[idx]; + } + + return LLSettingsDay::ptr_t(); +} + +void LLEnvironment::setSkyFor(EnvSelection_t env, const LLSettingsSky::ptr_t &sky) +{ + mSetSkys[env] = sky; } -void LLEnvironment::clearAllSelected() +LLSettingsSky::ptr_t LLEnvironment::getSkyFor(EnvSelection_t env) const { -#if 0 - if (mCurrentSky != mCurrentSky) - selectSky(); - if (mCurrentWater != mCurrentWater) - selectWater(); - if (mCurrentDayCycle != mCurrentDayCycle) - selectDayCycle(); -#endif + return mSetSkys[env]; } -void LLEnvironment::applyAllSelected() +void LLEnvironment::setWaterFor(EnvSelection_t env, const LLSettingsWater::ptr_t &water) { - if (mCurrentSky != mCurrentSky) - applySky(); - if (mCurrentWater != mCurrentWater) - applyWater(); - if (mCurrentDayCycle != mCurrentDayCycle) - applyDayCycle(); + mSetWater[env] = water; } +LLSettingsWater::ptr_t LLEnvironment::getWaterFor(EnvSelection_t env) const +{ + return mSetWater[env]; +} + +void LLEnvironment::setDayFor(EnvSelection_t env, const LLSettingsDay::ptr_t &day) +{ + mSetDays[env] = day; +} + +LLSettingsDay::ptr_t LLEnvironment::getDayFor(EnvSelection_t env) const +{ + return mSetDays[env]; +} + +void LLEnvironment::clearUserSettings() +{ + mSetSkys[ENV_LOCAL].reset(); + mSetWater[ENV_LOCAL].reset(); + mSetDays[ENV_LOCAL].reset(); +} + + LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const { list_name_id_t list; @@ -544,17 +622,6 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) mSkyListChange(); } -// 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) { namedSettingMap_t::iterator it = mSkysByName.find(name); @@ -563,11 +630,6 @@ void LLEnvironment::removeSky(const std::string &name) mSkyListChange(); } -// void LLEnvironment::removeSky(const LLUUID &id) -// { -// -// } - void LLEnvironment::clearAllSkys() { mSkysByName.clear(); @@ -589,7 +651,6 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) mWaterListChange(); } -//void LLEnvironment::addWater(const LLUUID &id, const LLSettingsSky::ptr_t &sky); void LLEnvironment::removeWater(const std::string &name) { @@ -599,7 +660,6 @@ void LLEnvironment::removeWater(const std::string &name) mWaterListChange(); } -//void LLEnvironment::removeWater(const LLUUID &id); void LLEnvironment::clearAllWater() { mWaterByName.clear(); @@ -607,9 +667,9 @@ void LLEnvironment::clearAllWater() mWaterListChange(); } -void LLEnvironment::addDayCycle(const LLSettingsDayCycle::ptr_t &daycycle) +void LLEnvironment::addDayCycle(const LLSettingsDay::ptr_t &daycycle) { - std::string name = daycycle->getValue(LLSettingsDayCycle::SETTING_NAME).asString(); + std::string name = daycycle->getValue(LLSettingsDay::SETTING_NAME).asString(); LL_WARNS("RIDER") << "Adding daycycle as '" << name << "'" << LL_ENDL; @@ -665,17 +725,17 @@ 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 +LLSettingsDay::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 LLSettingsDay::ptr_t(); } - return boost::static_pointer_cast((*it).second); + return boost::static_pointer_cast((*it).second); } //========================================================================= @@ -717,19 +777,6 @@ void LLEnvironment::UserPrefs::store() //========================================================================= // Transitional Code. -void LLEnvironment::onLegacyRegionSettings(LLSD data) -{ - LLUUID regionId = data[0]["regionID"].asUUID(); - - LLSettingsDayCycle::ptr_t regionday; - if (data[1].isUndefined()) - regionday = LLEnvironment::findDayCycleByName("Default"); - else - regionday = LLSettingsDayCycle::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); - - selectDayCycle(regionday, TRANSITION_DEFAULT); -} - // static std::string LLEnvironment::getSysDir(const std::string &subdir) { @@ -855,7 +902,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsDayCycle::ptr_t day = LLSettingsDayCycle::buildFromLegacyPreset(name, data); + LLSettingsDay::ptr_t day = LLSettingsDay::buildFromLegacyPreset(name, data); LLEnvironment::instance().addDayCycle(day); } } @@ -874,7 +921,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsDayCycle::ptr_t day = LLSettingsDayCycle::buildFromLegacyPreset(name, data); + LLSettingsDay::ptr_t day = LLSettingsDay::buildFromLegacyPreset(name, data); LLEnvironment::instance().addDayCycle(day); } } -- cgit v1.2.3 From d7dd10b88bc3fda88f6528ecc5936e4889f019f3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 30 Nov 2017 11:32:22 -0800 Subject: Split for viewer/simhost sync LLSD with simhost. --- indra/newview/llenvironment.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 8b879710da..e8c9db045c 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -44,6 +44,8 @@ #include "llsdserialize.h" #include "lldiriterator.h" +#include "llsettingsvo.h" + #include //========================================================================= namespace @@ -82,15 +84,15 @@ LLEnvironment::LLEnvironment(): void LLEnvironment::initSingleton() { - LLSettingsSky::ptr_t p_default_sky = LLSettingsSky::buildDefaultSky(); + LLSettingsSky::ptr_t p_default_sky = LLSettingsVOSky::buildDefaultSky(); addSky(p_default_sky); mCurrentSky = p_default_sky; - LLSettingsWater::ptr_t p_default_water = LLSettingsWater::buildDefaultWater(); + LLSettingsWater::ptr_t p_default_water = LLSettingsVOWater::buildDefaultWater(); addWater(p_default_water); mCurrentWater = p_default_water; - LLSettingsDay::ptr_t p_default_day = LLSettingsDay::buildDefaultDayCycle(); + LLSettingsDay::ptr_t p_default_day = LLSettingsVODay::buildDefaultDayCycle(); addDayCycle(p_default_day); mCurrentDay.reset(); @@ -155,7 +157,7 @@ void LLEnvironment::onLegacyRegionSettings(LLSD data) if (data[1].isUndefined()) regionday = LLEnvironment::findDayCycleByName("Default"); else - regionday = LLSettingsDay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); + regionday = LLSettingsVODay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); setSkyFor(ENV_REGION, LLSettingsSky::ptr_t()); setWaterFor(ENV_REGION, LLSettingsWater::ptr_t()); @@ -826,7 +828,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsSky::ptr_t sky = LLSettingsSky::buildFromLegacyPreset(name, data); + LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data); LLEnvironment::instance().addSky(sky); } } @@ -845,7 +847,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsSky::ptr_t sky = LLSettingsSky::buildFromLegacyPreset(name, data); + LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data); LLEnvironment::instance().addSky(sky); } } @@ -864,7 +866,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsWater::ptr_t water = LLSettingsWater::buildFromLegacyPreset(name, data); + LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data); LLEnvironment::instance().addWater(water); } } @@ -883,7 +885,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsWater::ptr_t water = LLSettingsWater::buildFromLegacyPreset(name, data); + LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data); LLEnvironment::instance().addWater(water); } } @@ -902,7 +904,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsDay::ptr_t day = LLSettingsDay::buildFromLegacyPreset(name, data); + LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); LLEnvironment::instance().addDayCycle(day); } } @@ -921,7 +923,7 @@ void LLEnvironment::legacyLoadAllPresets() { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); - LLSettingsDay::ptr_t day = LLSettingsDay::buildFromLegacyPreset(name, data); + LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); LLEnvironment::instance().addDayCycle(day); } } -- cgit v1.2.3 From 8211f57205f0008d8ffb9bfcd465ca26d906e19c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 8 Jan 2018 15:10:25 -0800 Subject: MAINT-7699: Deliver new settings to viewer via cap --- indra/newview/llenvironment.cpp | 270 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 268 insertions(+), 2 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e8c9db045c..e14265d950 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -45,8 +45,11 @@ #include "lldiriterator.h" #include "llsettingsvo.h" +#include "llnotificationsutil.h" #include + +#define EXPORT_PRESETS 1 //========================================================================= namespace { @@ -75,7 +78,9 @@ LLEnvironment::LLEnvironment(): mDayCycleByName(), mDayCycleById(), mUserPrefs(), - mSelectedEnvironment(ENV_LOCAL) + mSelectedEnvironment(ENV_LOCAL), + mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), + mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET) { mSetSkys.resize(ENV_END); mSetWater.resize(ENV_END); @@ -146,7 +151,8 @@ void LLEnvironment::onRegionChange() void LLEnvironment::requestRegionEnvironment() { - LLEnvironmentRequest::initiate(); +// LLEnvironmentRequest::initiate(); + requestRegion(); } void LLEnvironment::onLegacyRegionSettings(LLSD data) @@ -182,6 +188,20 @@ bool LLEnvironment::getIsDayTime() const return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; } +void LLEnvironment::setDayLength(S64Seconds seconds) +{ + mDayLength = seconds; + if (mCurrentDay) + mCurrentDay->setDayLength(mDayLength); +} + +void LLEnvironment::setDayOffset(S64Seconds seconds) +{ + mDayOffset = seconds; + if (mCurrentDay) + mCurrentDay->setDayOffset(seconds); +} + //------------------------------------------------------------------------- void LLEnvironment::update(const LLViewerCamera * cam) { @@ -455,6 +475,8 @@ void LLEnvironment::selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seco } mCurrentDay = daycycle; + mCurrentDay->setDayLength(mDayLength); + mCurrentDay->setDayOffset(mDayOffset); daycycle->startDayCycle(); selectWater(daycycle->getCurrentWater(), transition); @@ -740,6 +762,238 @@ LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const return boost::static_pointer_cast((*it).second); } + +void LLEnvironment::applyEnvironment(LLSD environment) +{ + LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; + + S32 daylength(LLSettingsDay::DEFAULT_DAYLENGTH); + S32 dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); + + if (environment.has("day_length")) + daylength = environment["day_length"].asInteger(); + if (environment.has("day_offset")) + dayoffset = environment["day_cycle"].asInteger(); + + setDayLength(S64Seconds(daylength)); + setDayOffset(S64Seconds(dayoffset)); + + if (environment.has("day_cycle")) + { + LLSettingsDay::ptr_t pday = LLSettingsVODay::buildFromEnvironmentMessage(environment["day_cycle"]); + + if (pday) + selectDayCycle(pday); + } + + /*TODO: track_altitudes*/ +} + +//========================================================================= +void LLEnvironment::requestRegion() +{ + if (gAgent.getRegionCapability("ExtEnvironment").empty()) + { + LLEnvironmentRequest::initiate(); + return; + } + + requestParcel(LLUUID::null); +} + +void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +{ + if (gAgent.getRegionCapability("ExtEnvironment").empty()) + { + LLEnvironmentApply::initiateRequest( LLSettingsVODay::convertToLegacy(pday) ); + return; + } + + updateParcel(LLUUID::null, pday, day_length, day_offset); +} + +void LLEnvironment::resetRegion() +{ + resetParcel(LLUUID::null); +} + +void LLEnvironment::requestParcel(const LLUUID &parcel_id) +{ + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", + boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id)); + +} + +void LLEnvironment::updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +{ + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", + boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, pday, day_length, day_offset)); + +} + +void LLEnvironment::resetParcel(const LLUUID &parcel_id) +{ + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", + boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id)); + +} + +void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ResetEnvironment", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string url = gAgent.getRegionCapability("ExtEnvironment"); + if (url.empty()) + return; + + if (!parcel_id.isNull()) + url += "?parcelid=" + parcel_id.asString(); + + LLSD result = httpAdapter->getAndSuspend(httpRequest, url); + // results that come back may contain the new settings + + LLSD notify; + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("WindlightCaps") << "Couldn't retrieve Windlight settings for " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + + std::stringstream msg; + msg << status.toString() << " (Code " << status.toTerseString() << ")"; + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = msg.str(); + + } + else + { + LLSD environment = result["environment"]; + if (environment.isDefined()) + { + applyEnvironment(environment); + } + } + + if (!notify.isUndefined()) + { + LLNotificationsUtil::add("WLRegionApplyFail", notify); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + } +} + +void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ResetEnvironment", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string url = gAgent.getRegionCapability("ExtEnvironment"); + if (url.empty()) + return; + + LLSD body(LLSD::emptyMap()); + body["environment"] = LLSD::emptyMap(); + + if (day_length >= 0) + body["environment"]["day_length"] = day_length; + if (day_offset >= 0) + body["environment"]["day_offset"] = day_offset; + if (pday) + body["environment"]["day_cycle"] = pday->getSettings(); + + + if (!parcel_id.isNull()) + url += "?parcelid=" + parcel_id.asString(); + + LLSD result = httpAdapter->putAndSuspend(httpRequest, url, body); + // results that come back may contain the new settings + + LLSD notify; + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + + std::stringstream msg; + msg << status.toString() << " (Code " << status.toTerseString() << ")"; + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = msg.str(); + } + else + { + LLSD environment = result["environment"]; + if (environment.isDefined()) + { + applyEnvironment(environment); + } + } + + if (!notify.isUndefined()) + { + LLNotificationsUtil::add("WLRegionApplyFail", notify); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + } +} + +void LLEnvironment::coroResetEnvironment(LLUUID parcel_id) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ResetEnvironment", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string url = gAgent.getRegionCapability("ExtEnvironment"); + if (url.empty()) + return; + + if (!parcel_id.isNull()) + url += "?parcelid=" + parcel_id.asString(); + + LLSD result = httpAdapter->deleteAndSuspend(httpRequest, url); + // results that come back may contain the new settings + + LLSD notify; + + LLSD httpResults = result["http_result"]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + if (!status) + { + LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + + std::stringstream msg; + msg << status.toString() << " (Code " << status.toTerseString() << ")"; + notify = LLSD::emptyMap(); + notify["FAIL_REASON"] = msg.str(); + + } + else + { + LLSD environment = result["environment"]; + if (environment.isDefined()) + { + applyEnvironment(environment); + } + } + + if (!notify.isUndefined()) + { + LLNotificationsUtil::add("WLRegionApplyFail", notify); + //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); + } + +} + + //========================================================================= LLEnvironment::UserPrefs::UserPrefs(): mUseRegionSettings(true), @@ -906,6 +1160,18 @@ void LLEnvironment::legacyLoadAllPresets() LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); LLEnvironment::instance().addDayCycle(day); + +#ifdef EXPORT_PRESETS + std::string exportfile = LLURI::escape(name) + "(new).xml"; + std::string exportpath = gDirUtilp->add(getSysDir("new"), exportfile); + + LLSD settings = day->getSettings(); + + std::ofstream daycyclefile(exportpath); + LLPointer formatter = new LLSDXMLFormatter(); + formatter->format(settings, daycyclefile, LLSDFormatter::OPTIONS_PRETTY); + daycyclefile.close(); +#endif } } } -- cgit v1.2.3 From a0c228d84240a80437b63e0a2cd1cee24e8004a0 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 16 Jan 2018 11:03:26 -0800 Subject: MAINT-8052: Report if the returned environment is the default. --- indra/newview/llenvironment.cpp | 49 ++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e14265d950..b05c9ee871 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -41,6 +41,9 @@ #include "llviewershadermgr.h" +#include "llparcel.h" +#include "llviewerparcelmgr.h" + #include "llsdserialize.h" #include "lldiriterator.h" @@ -106,6 +109,7 @@ void LLEnvironment::initSingleton() requestRegionEnvironment(); gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::onRegionChange, this)); + gAgent.addParcelChangedCallback(boost::bind(&LLEnvironment::onParcelChange, this)); } LLEnvironment::~LLEnvironment() @@ -143,12 +147,24 @@ LLEnvironment::connection_t LLEnvironment::setDayCycleListChange(const LLEnviron return mDayCycleListChange.connect(cb); } - void LLEnvironment::onRegionChange() { requestRegionEnvironment(); } +void LLEnvironment::onParcelChange() +{ + LLUUID parcel_id; + LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + + if (parcel) + { + parcel_id = parcel->getID(); + } + + requestParcel(parcel_id); +} + void LLEnvironment::requestRegionEnvironment() { // LLEnvironmentRequest::initiate(); @@ -821,7 +837,8 @@ void LLEnvironment::requestParcel(const LLUUID &parcel_id) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", - boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id)); + boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, + boost::bind(&LLEnvironment::applyEnvironment, this, _1))); } @@ -829,7 +846,9 @@ void LLEnvironment::updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t & { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", - boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, pday, day_length, day_offset)); + boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, + pday, day_length, day_offset, + boost::bind(&LLEnvironment::applyEnvironment, this, _1))); } @@ -837,11 +856,11 @@ void LLEnvironment::resetParcel(const LLUUID &parcel_id) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", - boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id)); - + boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id, + boost::bind(&LLEnvironment::applyEnvironment, this, _1))); } -void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id) +void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -875,9 +894,9 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id) else { LLSD environment = result["environment"]; - if (environment.isDefined()) + if (environment.isDefined() && !apply.empty()) { - applyEnvironment(environment); + apply(environment); } } @@ -888,7 +907,7 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id) } } -void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset) +void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -932,9 +951,9 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t else { LLSD environment = result["environment"]; - if (environment.isDefined()) + if (environment.isDefined() && !apply.empty()) { - applyEnvironment(environment); + apply(environment); } } @@ -945,7 +964,7 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t } } -void LLEnvironment::coroResetEnvironment(LLUUID parcel_id) +void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -979,10 +998,10 @@ void LLEnvironment::coroResetEnvironment(LLUUID parcel_id) else { LLSD environment = result["environment"]; - if (environment.isDefined()) + if (environment.isDefined() && !apply.empty()) { - applyEnvironment(environment); - } + apply(environment); + } } if (!notify.isUndefined()) -- cgit v1.2.3 From 1b8c2b5ebbe0d42f147730bc9b6528fa8c6796ce Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 23 Jan 2018 08:54:34 -0800 Subject: MAINT-8052: Initial support for new EEP cap --- indra/newview/llenvironment.cpp | 205 ++++++++++++++++++++++++++++++---------- 1 file changed, 157 insertions(+), 48 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index b05c9ee871..3451b0efef 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -52,7 +52,7 @@ #include -#define EXPORT_PRESETS 1 +//define EXPORT_PRESETS 1 //========================================================================= namespace { @@ -154,12 +154,12 @@ void LLEnvironment::onRegionChange() void LLEnvironment::onParcelChange() { - LLUUID parcel_id; + S32 parcel_id(INVALID_PARCEL_ID); LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); if (parcel) { - parcel_id = parcel->getID(); + parcel_id = parcel->getLocalID(); } requestParcel(parcel_id); @@ -167,7 +167,6 @@ void LLEnvironment::onParcelChange() void LLEnvironment::requestRegionEnvironment() { -// LLEnvironmentRequest::initiate(); requestRegion(); } @@ -243,7 +242,6 @@ void LLEnvironment::update(const LLViewerCamera * cam) if (mCurrentWater) mCurrentWater->update(); - F32 camYaw = cam->getYaw(); stop_glerror(); @@ -485,7 +483,7 @@ void LLEnvironment::selectDayCycle(const std::string &name, F32Seconds transitio void LLEnvironment::selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seconds transition) { - if (!daycycle) + if (!daycycle || (daycycle == mCurrentDay)) { return; } @@ -779,30 +777,81 @@ LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const } -void LLEnvironment::applyEnvironment(LLSD environment) +void LLEnvironment::selectAgentEnvironment() { - LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; + S64Seconds day_length(LLSettingsDay::DEFAULT_DAYLENGTH); + S64Seconds day_offset(LLSettingsDay::DEFAULT_DAYOFFSET); + LLSettingsDay::ptr_t pday; - S32 daylength(LLSettingsDay::DEFAULT_DAYLENGTH); - S32 dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); + // TODO: First test if agent has local environment set. - if (environment.has("day_length")) - daylength = environment["day_length"].asInteger(); - if (environment.has("day_offset")) - dayoffset = environment["day_cycle"].asInteger(); + LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); + LLViewerRegion *pRegion = gAgent.getRegion(); - setDayLength(S64Seconds(daylength)); - setDayOffset(S64Seconds(dayoffset)); + if (!parcel || parcel->getUsesDefaultDayCycle() || !parcel->getParcelDayCycle()) + { + day_length = pRegion->getDayLength(); + day_offset = pRegion->getDayOffset(); + pday = pRegion->getRegionDayCycle(); + } + else + { + day_length = parcel->getDayLength(); + day_offset = parcel->getDayOffset(); + pday = parcel->getParcelDayCycle(); + } - if (environment.has("day_cycle")) + if (getDayLength() != day_length) + setDayLength(day_length); + + if (getDayOffset() != day_offset) + setDayOffset(day_offset); + + if (pday) + selectDayCycle(pday); + +} + +void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo) +{ + LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; + + if (parcel_id == INVALID_PARCEL_ID) { - LLSettingsDay::ptr_t pday = LLSettingsVODay::buildFromEnvironmentMessage(environment["day_cycle"]); + LLViewerRegion *pRegion = gAgent.getRegion(); + + if (pRegion) + { + pRegion->setDayLength(envinfo->mDayLength); + pRegion->setDayOffset(envinfo->mDayOffset); + pRegion->setIsDefaultDayCycle(envinfo->mIsDefault); + pRegion->setRegionDayCycle(LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData)); + + /*TODO: track_altitudes*/ + } + } + else + { + LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); + + if (parcel->getLocalID() == parcel_id) + { + parcel->setDayLength(envinfo->mDayLength); + parcel->setDayOffset(envinfo->mDayOffset); + parcel->setUsesDefaultDayCycle(envinfo->mIsDefault); + + LLSettingsDay::ptr_t pday; + if (!envinfo->mIsDefault) + { + pday = LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData); + } + parcel->setParcelDayCycle(pday); - if (pday) - selectDayCycle(pday); + // select parcel day + } } - /*TODO: track_altitudes*/ + selectAgentEnvironment(); } //========================================================================= @@ -814,7 +863,7 @@ void LLEnvironment::requestRegion() return; } - requestParcel(LLUUID::null); + requestParcel(INVALID_PARCEL_ID); } void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) @@ -825,42 +874,45 @@ void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 return; } - updateParcel(LLUUID::null, pday, day_length, day_offset); + updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset); } void LLEnvironment::resetRegion() { - resetParcel(LLUUID::null); + resetParcel(INVALID_PARCEL_ID); } -void LLEnvironment::requestParcel(const LLUUID &parcel_id) +void LLEnvironment::requestParcel(S32 parcel_id) { + environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2); + std::string coroname = LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", - boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, - boost::bind(&LLEnvironment::applyEnvironment, this, _1))); + boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, apply)); } -void LLEnvironment::updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { + environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2); + std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, - pday, day_length, day_offset, - boost::bind(&LLEnvironment::applyEnvironment, this, _1))); + pday, day_length, day_offset, apply)); } -void LLEnvironment::resetParcel(const LLUUID &parcel_id) +void LLEnvironment::resetParcel(S32 parcel_id) { + environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2); + std::string coroname = LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", - boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id, - boost::bind(&LLEnvironment::applyEnvironment, this, _1))); + boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id, apply)); } -void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_fn apply) +void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -871,8 +923,17 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_f if (url.empty()) return; - if (!parcel_id.isNull()) - url += "?parcelid=" + parcel_id.asString(); + LL_WARNS("LAPRAS") << "Requesting for parcel_id=" << parcel_id << LL_ENDL; + + if (parcel_id != INVALID_PARCEL_ID) + { + std::stringstream query; + + query << "?parcelid=" << parcel_id; + url += query.str(); + } + + LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL; LLSD result = httpAdapter->getAndSuspend(httpRequest, url); // results that come back may contain the new settings @@ -883,7 +944,7 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_f LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { - LL_WARNS("WindlightCaps") << "Couldn't retrieve Windlight settings for " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + LL_WARNS("WindlightCaps") << "Couldn't retrieve Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; std::stringstream msg; msg << status.toString() << " (Code " << status.toTerseString() << ")"; @@ -896,7 +957,8 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_f LLSD environment = result["environment"]; if (environment.isDefined() && !apply.empty()) { - apply(environment); + EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); + apply(parcel_id, envinfo); } } @@ -907,7 +969,7 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_f } } -void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, environment_apply_fn apply) +void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, LLEnvironment::environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -928,9 +990,17 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t if (pday) body["environment"]["day_cycle"] = pday->getSettings(); + LL_WARNS("LAPRAS") << "Body = " << body << LL_ENDL; - if (!parcel_id.isNull()) - url += "?parcelid=" + parcel_id.asString(); + if (parcel_id != INVALID_PARCEL_ID) + { + std::stringstream query; + + query << "?parcelid=" << parcel_id; + url += query.str(); + } + + LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL; LLSD result = httpAdapter->putAndSuspend(httpRequest, url, body); // results that come back may contain the new settings @@ -941,7 +1011,7 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { - LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; std::stringstream msg; msg << status.toString() << " (Code " << status.toTerseString() << ")"; @@ -953,7 +1023,8 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t LLSD environment = result["environment"]; if (environment.isDefined() && !apply.empty()) { - apply(environment); + EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); + apply(parcel_id, envinfo); } } @@ -964,7 +1035,7 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t } } -void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn apply) +void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -975,8 +1046,15 @@ void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn if (url.empty()) return; - if (!parcel_id.isNull()) - url += "?parcelid=" + parcel_id.asString(); + if (parcel_id != INVALID_PARCEL_ID) + { + std::stringstream query; + + query << "?parcelid=" << parcel_id; + url += query.str(); + } + + LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL; LLSD result = httpAdapter->deleteAndSuspend(httpRequest, url); // results that come back may contain the new settings @@ -987,7 +1065,7 @@ void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { - LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL; + LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; std::stringstream msg; msg << status.toString() << " (Code " << status.toTerseString() << ")"; @@ -1000,7 +1078,8 @@ void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn LLSD environment = result["environment"]; if (environment.isDefined() && !apply.empty()) { - apply(environment); + EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); + apply(parcel_id, envinfo); } } @@ -1050,6 +1129,36 @@ void LLEnvironment::UserPrefs::store() } } +LLEnvironment::EnvironmentInfo::EnvironmentInfo(): + mParcelId(), + mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), + mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET), + mDaycycleData(), + mAltitudes(), + mIsDefault(false) +{ +} + +LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LLSD environment) +{ + ptr_t pinfo = boost::make_shared(); + + if (environment.has("parcel_id")) + pinfo->mParcelId = environment["parcel_id"].asUUID(); + if (environment.has("day_length")) + pinfo->mDayLength = S64Seconds(environment["day_length"].asInteger()); + if (environment.has("day_offset")) + pinfo->mDayOffset = S64Seconds(environment["day_offset"].asInteger()); + if (environment.has("day_cycle")) + pinfo->mDaycycleData = environment["day_cycle"]; + if (environment.has("is_default")) + pinfo->mIsDefault = environment["is_default"].asBoolean(); + if (environment.has("track_altitudes")) + pinfo->mAltitudes = environment["track_altitudes"]; + + return pinfo; +} + //========================================================================= // Transitional Code. // static -- cgit v1.2.3 From b4af7fe9d03b7a8a9999dcfec3ad85304faf5268 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 24 Jan 2018 17:30:56 -0800 Subject: Settins failure fix. --- indra/newview/llenvironment.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3451b0efef..e64d71e228 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1009,14 +1009,12 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - if (!status) + if ((!status) || !result["success"].asBoolean()) { LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; - std::stringstream msg; - msg << status.toString() << " (Code " << status.toTerseString() << ")"; notify = LLSD::emptyMap(); - notify["FAIL_REASON"] = msg.str(); + notify["FAIL_REASON"] = result["message"].asString(); } else { @@ -1063,15 +1061,12 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn app LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - if (!status) + if ((!status) || !result["success"].asBoolean()) { - LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; + LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; - std::stringstream msg; - msg << status.toString() << " (Code " << status.toTerseString() << ")"; notify = LLSD::emptyMap(); - notify["FAIL_REASON"] = msg.str(); - + notify["FAIL_REASON"] = result["message"].asString(); } else { -- cgit v1.2.3 From fbd8a98300277bdbc1885c25eea290560fd8c6c1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 25 Jan 2018 17:21:25 -0800 Subject: Selects correct day cycle. Fix an error validating legacy daycycles. --- indra/newview/llenvironment.cpp | 83 +++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 32 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e64d71e228..25c7fb89db 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -50,6 +50,8 @@ #include "llsettingsvo.h" #include "llnotificationsutil.h" +#include "llregioninfomodel.h" + #include //define EXPORT_PRESETS 1 @@ -108,8 +110,12 @@ void LLEnvironment::initSingleton() legacyLoadAllPresets(); requestRegionEnvironment(); - gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::onRegionChange, this)); + + LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLEnvironment::onParcelChange, this)); gAgent.addParcelChangedCallback(boost::bind(&LLEnvironment::onParcelChange, this)); + + //TODO: This frequently results in one more request than we need. It isn't breaking, but should be nicer. + gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::requestRegionEnvironment, this)); } LLEnvironment::~LLEnvironment() @@ -147,11 +153,6 @@ LLEnvironment::connection_t LLEnvironment::setDayCycleListChange(const LLEnviron return mDayCycleListChange.connect(cb); } -void LLEnvironment::onRegionChange() -{ - requestRegionEnvironment(); -} - void LLEnvironment::onParcelChange() { S32 parcel_id(INVALID_PARCEL_ID); @@ -783,7 +784,9 @@ void LLEnvironment::selectAgentEnvironment() S64Seconds day_offset(LLSettingsDay::DEFAULT_DAYOFFSET); LLSettingsDay::ptr_t pday; - // TODO: First test if agent has local environment set. + // TODO: Test if editing environment has been set. + + // TODO: Test if agent has local environment set. LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); LLViewerRegion *pRegion = gAgent.getRegion(); @@ -809,25 +812,38 @@ void LLEnvironment::selectAgentEnvironment() if (pday) selectDayCycle(pday); - } void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo) { LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; - if (parcel_id == INVALID_PARCEL_ID) - { + LLSettingsDay::ptr_t pday = LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData); + + LL_WARNS("ENVIRONMENT") << "serverhash=" << envinfo->mDayHash << " viewerhash=" << pday->getHash() << LL_ENDL; + + if (envinfo->mParcelId == INVALID_PARCEL_ID) + { // the returned info applies to an entire region. LLViewerRegion *pRegion = gAgent.getRegion(); - if (pRegion) + pRegion->setDayLength(envinfo->mDayLength); + pRegion->setDayOffset(envinfo->mDayOffset); + pRegion->setIsDefaultDayCycle(envinfo->mIsDefault); + if (pRegion->getRegionDayCycleHash() != envinfo->mDayHash) { - pRegion->setDayLength(envinfo->mDayLength); - pRegion->setDayOffset(envinfo->mDayOffset); - pRegion->setIsDefaultDayCycle(envinfo->mIsDefault); - pRegion->setRegionDayCycle(LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData)); + pRegion->setRegionDayCycle(pday); + pRegion->setRegionDayCycleHash(envinfo->mDayHash); + } + + if (parcel_id != INVALID_PARCEL_ID) + { // We requested a parcel environment but got back the region's. If this is the parcel we are in + // clear it out. + LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); - /*TODO: track_altitudes*/ + if (parcel->getLocalID() == parcel_id) + { + parcel->clearParcelDayCycleInfo(); + } } } else @@ -839,18 +855,16 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI parcel->setDayLength(envinfo->mDayLength); parcel->setDayOffset(envinfo->mDayOffset); parcel->setUsesDefaultDayCycle(envinfo->mIsDefault); - - LLSettingsDay::ptr_t pday; - if (!envinfo->mIsDefault) + if (parcel->getParcelDayCycleHash() != envinfo->mDayHash) { - pday = LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData); + parcel->setParcelDayCycle(pday); + parcel->setParcelDayCycleHash(envinfo->mDayHash); } - parcel->setParcelDayCycle(pday); - // select parcel day } } - + + /*TODO: track_altitudes*/ selectAgentEnvironment(); } @@ -1000,8 +1014,6 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd url += query.str(); } - LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL; - LLSD result = httpAdapter->putAndSuspend(httpRequest, url, body); // results that come back may contain the new settings @@ -1009,6 +1021,7 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + LL_WARNS("LAPRAS") << "success=" << result["success"] << LL_ENDL; if ((!status) || !result["success"].asBoolean()) { LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; @@ -1052,8 +1065,6 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn app url += query.str(); } - LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL; - LLSD result = httpAdapter->deleteAndSuspend(httpRequest, url); // results that come back may contain the new settings @@ -1061,6 +1072,7 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn app LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + LL_WARNS("LAPRAS") << "success=" << result["success"] << LL_ENDL; if ((!status) || !result["success"].asBoolean()) { LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; @@ -1125,12 +1137,15 @@ void LLEnvironment::UserPrefs::store() } LLEnvironment::EnvironmentInfo::EnvironmentInfo(): - mParcelId(), - mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), - mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET), + mParcelId(INVALID_PARCEL_ID), + mRegionId(), + mDayLength(0), + mDayOffset(0), + mDayHash(0), mDaycycleData(), mAltitudes(), - mIsDefault(false) + mIsDefault(false), + mIsRegion(false) { } @@ -1139,11 +1154,15 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL ptr_t pinfo = boost::make_shared(); if (environment.has("parcel_id")) - pinfo->mParcelId = environment["parcel_id"].asUUID(); + pinfo->mParcelId = environment["parcel_id"].asInteger(); + if (environment.has("region_id")) + pinfo->mRegionId = environment["region_id"].asUUID(); if (environment.has("day_length")) pinfo->mDayLength = S64Seconds(environment["day_length"].asInteger()); if (environment.has("day_offset")) pinfo->mDayOffset = S64Seconds(environment["day_offset"].asInteger()); + if (environment.has("day_hash")) + pinfo->mDayHash = environment["day_hash"].asInteger(); if (environment.has("day_cycle")) pinfo->mDaycycleData = environment["day_cycle"]; if (environment.has("is_default")) -- cgit v1.2.3 From 0bf50e2f8cfa5f3ccd6165ce935cf0fd9c174ced Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 30 Jan 2018 16:42:34 -0800 Subject: Cleanup on daycyle selection and stack. Move blenders into environment. (Transition bronken, instant only. Shaddows moved based on region, not parcel) --- indra/newview/llenvironment.cpp | 845 ++++++++++++++++++++++++---------------- 1 file changed, 509 insertions(+), 336 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 25c7fb89db..db8fd570c0 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -83,28 +83,26 @@ LLEnvironment::LLEnvironment(): mDayCycleByName(), mDayCycleById(), mUserPrefs(), - mSelectedEnvironment(ENV_LOCAL), - mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), - mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET) + mSelectedEnvironment(LLEnvironment::ENV_LOCAL) { - mSetSkys.resize(ENV_END); - mSetWater.resize(ENV_END); - mSetDays.resize(ENV_END); } void LLEnvironment::initSingleton() { LLSettingsSky::ptr_t p_default_sky = LLSettingsVOSky::buildDefaultSky(); addSky(p_default_sky); - mCurrentSky = p_default_sky; LLSettingsWater::ptr_t p_default_water = LLSettingsVOWater::buildDefaultWater(); addWater(p_default_water); - mCurrentWater = p_default_water; LLSettingsDay::ptr_t p_default_day = LLSettingsVODay::buildDefaultDayCycle(); addDayCycle(p_default_day); - mCurrentDay.reset(); + + mCurrentEnvironment = boost::make_shared(); + mCurrentEnvironment->setSky(p_default_sky); + mCurrentEnvironment->setWater(p_default_water); + + mEnvironments[ENV_DEFAULT] = mCurrentEnvironment; // LEGACY! legacyLoadAllPresets(); @@ -181,17 +179,16 @@ void LLEnvironment::onLegacyRegionSettings(LLSD data) else regionday = LLSettingsVODay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); - setSkyFor(ENV_REGION, LLSettingsSky::ptr_t()); - setWaterFor(ENV_REGION, LLSettingsWater::ptr_t()); - setDayFor(ENV_REGION, regionday); + clearEnvironment(ENV_PARCEL); + setEnvironment(ENV_REGION, regionday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); - applyChosenEnvironment(); + updateEnvironment(); } //------------------------------------------------------------------------- F32 LLEnvironment::getCamHeight() const { - return (mCurrentSky->getDomeOffset() * mCurrentSky->getDomeRadius()); + return (mCurrentEnvironment->getSky()->getDomeOffset() * mCurrentEnvironment->getSky()->getDomeRadius()); } F32 LLEnvironment::getWaterHeight() const @@ -201,21 +198,191 @@ F32 LLEnvironment::getWaterHeight() const bool LLEnvironment::getIsDayTime() const { - return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; + return mCurrentEnvironment->getSky()->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; +} + +//------------------------------------------------------------------------- +void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, F64Seconds transition) +{ + mSelectedEnvironment = env; + updateEnvironment(transition); +} + +bool LLEnvironment::hasEnvironment(LLEnvironment::EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env >= ENV_DEFAULT) || (!mEnvironments[env])) + { + return false; + } + + return true; +} + +LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnvironment::EnvSelection_t env, bool create /*= false*/) +{ + DayInstance::ptr_t environment = mEnvironments[env]; + if (!environment && create) + { + environment = boost::make_shared(); + mEnvironments[env] = environment; + } + + return environment; +} + + +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset) +{ + if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to change invalid environment selection." << LL_ENDL; + return; + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env, true); + + environment->clear(); + environment->setDay(pday, daylength, dayoffset); + environment->animate(); + /*TODO: readjust environment*/ +} + + +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironment::fixedEnvironment_t fixed) +{ + if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to change invalid environment selection." << LL_ENDL; + return; + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env, true); + + environment->clear(); + environment->setSky((fixed.first) ? fixed.first : mEnvironments[ENV_DEFAULT]->getSky()); + environment->setWater((fixed.second) ? fixed.second : mEnvironments[ENV_DEFAULT]->getWater()); + + /*TODO: readjust environment*/ +} + + +void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to change invalid environment selection." << LL_ENDL; + return; + } + + mEnvironments[env].reset(); + /*TODO: readjust environment*/ } -void LLEnvironment::setDayLength(S64Seconds seconds) +LLSettingsDay::ptr_t LLEnvironment::getEnvironmentDay(LLEnvironment::EnvSelection_t env) { - mDayLength = seconds; - if (mCurrentDay) - mCurrentDay->setDayLength(mDayLength); + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env); + + if (environment) + return environment->getDayCycle(); + + return LLSettingsDay::ptr_t(); +} + +S64Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; + return S64Seconds(0); + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env); + + if (environment) + return environment->getDayLength(); + + return S64Seconds(0); +} + +S64Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; + return S64Seconds(0); + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env); + if (environment) + return environment->getDayOffset(); + + return S64Seconds(0); +} + + +LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironment::EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; + return fixedEnvironment_t(); + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env); + + if (environment) + return fixedEnvironment_t(environment->getSky(), environment->getWater()); + + return fixedEnvironment_t(); +} + +LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance() +{ + for (S32 idx = mSelectedEnvironment; idx < ENV_DEFAULT; ++idx) + { + if (mEnvironments[idx]) + return mEnvironments[idx]; + } + + return mEnvironments[ENV_DEFAULT]; +} + + +void LLEnvironment::updateEnvironment(F64Seconds transition) +{ + DayInstance::ptr_t pinstance = getSelectedEnvironmentInstance(); + + if (mCurrentEnvironment != pinstance) + { + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + LLSettingsWater::ptr_t pwater = mCurrentEnvironment->getWater(); + + LLSettingsSky::ptr_t ptargetsky = psky->buildClone(); + LLSettingsWater::ptr_t ptargetwater = pwater->buildClone(); + + LLSettingsBlender::ptr_t skyblend = boost::make_shared(ptargetsky, psky, pinstance->getSky(), transition); + skyblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, true)); + LLSettingsBlender::ptr_t waterblend = boost::make_shared(ptargetwater, pwater, pinstance->getWater(), transition); + waterblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, false)); + + pinstance->setBlenders(skyblend, waterblend); + + mCurrentEnvironment = pinstance; + + mCurrentEnvironment->animate(); + } } -void LLEnvironment::setDayOffset(S64Seconds seconds) +void LLEnvironment::onTransitionDone(const LLSettingsBlender::ptr_t &blender, bool isSky) { - mDayOffset = seconds; - if (mCurrentDay) - mCurrentDay->setDayOffset(seconds); + /*TODO: Test for both sky and water*/ + mCurrentEnvironment->animate(); } //------------------------------------------------------------------------- @@ -227,21 +394,28 @@ void LLEnvironment::update(const LLViewerCamera * cam) F32Seconds delta(timer.getElapsedTimeAndResetF32()); - if (mBlenderSky) - mBlenderSky->update(delta); - if (mBlenderWater) - mBlenderWater->update(delta); + for (InstanceArray_t::iterator it = mEnvironments.begin(); it != mEnvironments.end(); ++it) + { + if (*it) + (*it)->update(delta); + } // update clouds, sun, and general updateCloudScroll(); - if (mCurrentDay) - mCurrentDay->update(); - - if (mCurrentSky) - mCurrentSky->update(); - if (mCurrentWater) - mCurrentWater->update(); +// if (mBlenderSky) +// mBlenderSky->update(delta); +// if (mBlenderWater) +// mBlenderWater->update(delta); +// +// +// if (mCurrentDay) +// mCurrentDay->update(); +// +// if (mCurrentEnvironment->getSky()) +// mCurrentEnvironment->getSky()->update(); +// if (mCurrentEnvironment->getWater()) +// mCurrentEnvironment->getWater()->update(); F32 camYaw = cam->getYaw(); @@ -277,10 +451,11 @@ 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; - mCloudScrollDelta += cloud_delta; - - + if (mCurrentEnvironment->getSky()) + { + LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentEnvironment->getSky()->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; + mCloudScrollDelta += cloud_delta; + } } @@ -352,11 +527,10 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) { - if (gPipeline.canUseWindLightShaders()) { - updateGLVariablesForSettings(shader, mCurrentSky); - updateGLVariablesForSettings(shader, mCurrentWater); + updateGLVariablesForSettings(shader, mCurrentEnvironment->getSky()); + updateGLVariablesForSettings(shader, mCurrentEnvironment->getWater()); } if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) @@ -374,237 +548,8 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) } shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, getSceneLightStrength()); - - -} -//-------------------------------------------------------------------------- -void LLEnvironment::selectSky(const std::string &name, F32Seconds transition) -{ - 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, transition); -} - -void LLEnvironment::selectSky(const LLSettingsSky::ptr_t &sky, F32Seconds transition) -{ - if (!sky) - { - mCurrentSky = mSelectedSky; - mBlenderSky.reset(); - return; - } - mSelectedSky = sky; - if (fabs(transition.value()) <= F_ALMOST_ZERO) - { - mBlenderSky.reset(); - mCurrentSky = sky; - mCurrentSky->setDirtyFlag(true); - mSelectedSky = sky; - } - else - { - LLSettingsSky::ptr_t skytarget = mCurrentSky->buildClone(); - - mBlenderSky = boost::make_shared( skytarget, mCurrentSky, sky, transition ); - mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::onSkyTransitionDone, this, _1)); - mCurrentSky = skytarget; - mSelectedSky = sky; - } -} - -void LLEnvironment::onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender) -{ - mCurrentSky = mSelectedSky; - mBlenderSky.reset(); -} - -void LLEnvironment::selectWater(const std::string &name, F32Seconds transition) -{ - 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, transition); -} - -void LLEnvironment::selectWater(const LLSettingsWater::ptr_t &water, F32Seconds transition) -{ - if (!water) - { - mCurrentWater = mSelectedWater; - mBlenderWater.reset(); - return; - } - mSelectedWater = water; - if (fabs(transition.value()) <= F_ALMOST_ZERO) - { - mBlenderWater.reset(); - mCurrentWater = water; - mCurrentWater->setDirtyFlag(true); - mSelectedWater = water; - } - else - { - LLSettingsWater::ptr_t watertarget = mCurrentWater->buildClone(); - - mBlenderWater = boost::make_shared(watertarget, mCurrentWater, water, transition); - mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::onWaterTransitionDone, this, _1)); - mCurrentWater = watertarget; - mSelectedWater = water; - } -} - -void LLEnvironment::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender) -{ - mCurrentWater = mSelectedWater; - mBlenderWater.reset(); -} - -void LLEnvironment::selectDayCycle(const std::string &name, F32Seconds transition) -{ - LLSettingsDay::ptr_t next_daycycle = findDayCycleByName(name); - - if (!next_daycycle) - { - LL_WARNS("ENVIRONMENT") << "Unable to select daycycle with unknown name '" << name << "'" << LL_ENDL; - return; - } - - selectDayCycle(next_daycycle, transition); -} - -void LLEnvironment::selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seconds transition) -{ - if (!daycycle || (daycycle == mCurrentDay)) - { - return; - } - - mCurrentDay = daycycle; - mCurrentDay->setDayLength(mDayLength); - mCurrentDay->setDayOffset(mDayOffset); - - daycycle->startDayCycle(); - selectWater(daycycle->getCurrentWater(), transition); - selectSky(daycycle->getCurrentSky(), transition); -} - - -void LLEnvironment::setSelectedEnvironment(EnvSelection_t env) -{ - if (env == mSelectedEnvironment) - { // No action to take - return; - } - - mSelectedEnvironment = env; - applyChosenEnvironment(); -} - -void LLEnvironment::applyChosenEnvironment() -{ - mSelectedSky.reset(); - mSelectedWater.reset(); - mSelectedDay.reset(); - - for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) - { - if (mSetDays[idx] && !mSelectedSky && !mSelectedWater) - selectDayCycle(mSetDays[idx]); - if (mSetSkys[idx] && !mSelectedSky) - selectSky(mSetSkys[idx]); - if (mSetWater[idx] && !mSelectedWater) - selectWater(mSetWater[idx]); - if (mSelectedSky && mSelectedWater) - return; - } - - if (!mSelectedSky) - selectSky("Default"); - if (!mSelectedWater) - selectWater("Default"); -} - -LLSettingsSky::ptr_t LLEnvironment::getChosenSky() const -{ - for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) - { - if (mSetSkys[idx]) - return mSetSkys[idx]; - } - - return LLSettingsSky::ptr_t(); -} - -LLSettingsWater::ptr_t LLEnvironment::getChosenWater() const -{ - for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) - { - if (mSetWater[idx]) - return mSetWater[idx]; - } - - return LLSettingsWater::ptr_t(); -} - -LLSettingsDay::ptr_t LLEnvironment::getChosenDay() const -{ - for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) - { - if (mSetDays[idx]) - return mSetDays[idx]; - } - - return LLSettingsDay::ptr_t(); -} - -void LLEnvironment::setSkyFor(EnvSelection_t env, const LLSettingsSky::ptr_t &sky) -{ - mSetSkys[env] = sky; -} - -LLSettingsSky::ptr_t LLEnvironment::getSkyFor(EnvSelection_t env) const -{ - return mSetSkys[env]; -} - -void LLEnvironment::setWaterFor(EnvSelection_t env, const LLSettingsWater::ptr_t &water) -{ - mSetWater[env] = water; -} - -LLSettingsWater::ptr_t LLEnvironment::getWaterFor(EnvSelection_t env) const -{ - return mSetWater[env]; -} - -void LLEnvironment::setDayFor(EnvSelection_t env, const LLSettingsDay::ptr_t &day) -{ - mSetDays[env] = day; -} - -LLSettingsDay::ptr_t LLEnvironment::getDayFor(EnvSelection_t env) const -{ - return mSetDays[env]; -} - -void LLEnvironment::clearUserSettings() -{ - mSetSkys[ENV_LOCAL].reset(); - mSetWater[ENV_LOCAL].reset(); - mSetDays[ENV_LOCAL].reset(); } - LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const { list_name_id_t list; @@ -778,42 +723,6 @@ LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const } -void LLEnvironment::selectAgentEnvironment() -{ - S64Seconds day_length(LLSettingsDay::DEFAULT_DAYLENGTH); - S64Seconds day_offset(LLSettingsDay::DEFAULT_DAYOFFSET); - LLSettingsDay::ptr_t pday; - - // TODO: Test if editing environment has been set. - - // TODO: Test if agent has local environment set. - - LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); - LLViewerRegion *pRegion = gAgent.getRegion(); - - if (!parcel || parcel->getUsesDefaultDayCycle() || !parcel->getParcelDayCycle()) - { - day_length = pRegion->getDayLength(); - day_offset = pRegion->getDayOffset(); - pday = pRegion->getRegionDayCycle(); - } - else - { - day_length = parcel->getDayLength(); - day_offset = parcel->getDayOffset(); - pday = parcel->getParcelDayCycle(); - } - - if (getDayLength() != day_length) - setDayLength(day_length); - - if (getDayOffset() != day_offset) - setDayOffset(day_offset); - - if (pday) - selectDayCycle(pday); -} - void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo) { LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; @@ -824,48 +733,65 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI if (envinfo->mParcelId == INVALID_PARCEL_ID) { // the returned info applies to an entire region. - LLViewerRegion *pRegion = gAgent.getRegion(); - - pRegion->setDayLength(envinfo->mDayLength); - pRegion->setDayOffset(envinfo->mDayOffset); - pRegion->setIsDefaultDayCycle(envinfo->mIsDefault); - if (pRegion->getRegionDayCycleHash() != envinfo->mDayHash) - { - pRegion->setRegionDayCycle(pday); - pRegion->setRegionDayCycleHash(envinfo->mDayHash); - } - + LL_WARNS("LAPRAS") << "Setting Region environment" << LL_ENDL; + setEnvironment(ENV_REGION, pday, envinfo->mDayLength, envinfo->mDayOffset); if (parcel_id != INVALID_PARCEL_ID) - { // We requested a parcel environment but got back the region's. If this is the parcel we are in - // clear it out. - LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); - - if (parcel->getLocalID() == parcel_id) - { - parcel->clearParcelDayCycleInfo(); - } + { + LL_WARNS("LAPRAS") << "Had requested parcel environment #" << parcel_id << " but got region." << LL_ENDL; + clearEnvironment(ENV_PARCEL); } +// LLViewerRegion *pRegion = gAgent.getRegion(); +// +// pRegion->setDayLength(envinfo->mDayLength); +// pRegion->setDayOffset(envinfo->mDayOffset); +// pRegion->setIsDefaultDayCycle(envinfo->mIsDefault); +// if (pRegion->getRegionDayCycleHash() != envinfo->mDayHash) +// { +// pRegion->setRegionDayCycle(pday); +// pRegion->setRegionDayCycleHash(envinfo->mDayHash); +// } +// +// if (parcel_id != INVALID_PARCEL_ID) +// { // We requested a parcel environment but got back the region's. If this is the parcel we are in +// // clear it out. +// LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); +// +// if (parcel->getLocalID() == parcel_id) +// { +// parcel->clearParcelDayCycleInfo(); +// } +// } } else { LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); - if (parcel->getLocalID() == parcel_id) + LL_WARNS("LAPRAS") << "Have parcel environment #" << envinfo->mParcelId << LL_ENDL; + if (parcel && (parcel->getLocalID() != parcel_id)) { - parcel->setDayLength(envinfo->mDayLength); - parcel->setDayOffset(envinfo->mDayOffset); - parcel->setUsesDefaultDayCycle(envinfo->mIsDefault); - if (parcel->getParcelDayCycleHash() != envinfo->mDayHash) - { - parcel->setParcelDayCycle(pday); - parcel->setParcelDayCycleHash(envinfo->mDayHash); - } - + LL_WARNS("ENVIRONMENT") << "Requested parcel #" << parcel_id << " agent is on " << parcel->getLocalID() << LL_ENDL; + return; } + + setEnvironment(ENV_PARCEL, pday, envinfo->mDayLength, envinfo->mDayOffset); +// LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); +// +// if (parcel->getLocalID() == parcel_id) +// { +// parcel->setDayLength(envinfo->mDayLength); +// parcel->setDayOffset(envinfo->mDayOffset); +// parcel->setUsesDefaultDayCycle(envinfo->mIsDefault); +// if (parcel->getParcelDayCycleHash() != envinfo->mDayHash) +// { +// parcel->setParcelDayCycle(pday); +// parcel->setParcelDayCycleHash(envinfo->mDayHash); +// } +// +// } } /*TODO: track_altitudes*/ - selectAgentEnvironment(); + updateEnvironment(); } //========================================================================= @@ -1337,3 +1263,250 @@ void LLEnvironment::legacyLoadAllPresets() } } } + +//========================================================================= +namespace +{ + inline F32 get_wrapping_distance(F32 begin, F32 end) + { + if (begin < end) + { + return end - begin; + } + else if (begin > end) + { + return 1.0 - (begin - end); + } + + return 0; + } + + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key) + { + if (collection.empty()) + return collection.end(); + + LLSettingsDay::CycleTrack_t::iterator it = collection.upper_bound(key); + + if (it == collection.end()) + { // wrap around + it = collection.begin(); + } + + return it; + } + + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key) + { + if (collection.empty()) + return collection.end(); + + LLSettingsDay::CycleTrack_t::iterator it = collection.lower_bound(key); + + if (it == collection.end()) + { // all keyframes are lower, take the last one. + --it; // we know the range is not empty + } + else if ((*it).first > key) + { // the keyframe we are interested in is smaller than the found. + if (it == collection.begin()) + it = collection.end(); + --it; + } + + return it; + } + + LLSettingsDay::TrackBound_t get_bounding_entries(LLSettingsDay::CycleTrack_t &track, F32 keyframe) + { + return LLSettingsDay::TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); + } + +} +//========================================================================= + + +LLEnvironment::DayInstance::DayInstance() : + mDayCycle(), + mSky(), + mWater(), + mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), + mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET), + mBlenderSky(), + mBlenderWater(), + mInitialized(false), + mType(TYPE_INVALID) +{ } + +void LLEnvironment::DayInstance::update(F64Seconds delta) +{ + if (!mInitialized) + initialize(); + + if (mBlenderSky) + mBlenderSky->update(delta); + if (mBlenderWater) + mBlenderWater->update(delta); + + if (mSky) + mSky->update(); + if (mWater) + mWater->update(); +} + +void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset) +{ + if (mType == TYPE_FIXED) + LL_WARNS("ENVIRONMENT") << "Fixed day instance changed to Cycled" << LL_ENDL; + mType = TYPE_CYCLED; + mInitialized = false; + + mDayCycle = pday; + mDayLength = daylength; + mDayOffset = dayoffset; + + mBlenderSky.reset(); + mBlenderWater.reset(); + + mSky = LLSettingsVOSky::buildDefaultSky(); + mWater = LLSettingsVOWater::buildDefaultWater(); + + animate(); +} + + +void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) +{ + if (mType == TYPE_CYCLED) + LL_WARNS("ENVIRONMENT") << "Cycled day instance changed to FIXED" << LL_ENDL; + mType = TYPE_FIXED; + mInitialized = false; + + mSky = psky; + mBlenderSky.reset(); +} + +void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) +{ + if (mType == TYPE_CYCLED) + LL_WARNS("ENVIRONMENT") << "Cycled day instance changed to FIXED" << LL_ENDL; + mType = TYPE_FIXED; + mInitialized = false; + + mWater = pwater; + mBlenderWater.reset(); +} + +void LLEnvironment::DayInstance::initialize() +{ + mInitialized = true; + + if (!mWater) + mWater = LLSettingsVOWater::buildDefaultWater(); + if (!mSky) + mSky = LLSettingsVOSky::buildDefaultSky(); +} + +void LLEnvironment::DayInstance::clear() +{ + mType = TYPE_INVALID; + mDayCycle.reset(); + mSky.reset(); + mWater.reset(); + mDayLength = LLSettingsDay::DEFAULT_DAYLENGTH; + mDayOffset = LLSettingsDay::DEFAULT_DAYOFFSET; + mBlenderSky.reset(); + mBlenderWater.reset(); +} + +void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &skyblend, const LLSettingsBlender::ptr_t &waterblend) +{ + mBlenderSky = skyblend; + mBlenderWater = waterblend; +} + +F64 LLEnvironment::DayInstance::secondsToKeyframe(S64Seconds seconds) +{ + F64 frame = static_cast(seconds.value() % mDayLength.value()) / static_cast(mDayLength.value()); + + return llclamp(frame, 0.0, 1.0); +} + +void LLEnvironment::DayInstance::animate() +{ + F64Seconds now(LLDate::now().secondsSinceEpoch()); + + now += mDayOffset; + + if (!mDayCycle) + return; + + LLSettingsDay::CycleTrack_t &wtrack = mDayCycle->getCycleTrack(0); + + if (wtrack.empty()) + { + mWater.reset(); + mBlenderWater.reset(); + } + else if (wtrack.size() == 1) + { + mWater = boost::static_pointer_cast((*(wtrack.begin())).second); + mBlenderWater.reset(); + } + else + { + LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, secondsToKeyframe(now)); + F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + + mWater = boost::static_pointer_cast((*bounds.first).second)->buildClone(); + mBlenderWater = boost::make_shared(mWater, + (*bounds.first).second, (*bounds.second).second, timespan); + mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::DayInstance::onTrackTransitionDone, this, 0, _1)); + } + + // Day track 1 only for the moment + // sky + LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(1); + + if (track.empty()) + { + mSky.reset(); + mBlenderSky.reset(); + } + else if (track.size() == 1) + { + mSky = boost::static_pointer_cast((*(track.begin())).second); + mBlenderSky.reset(); + } + else + { + LLSettingsDay::TrackBound_t bounds = get_bounding_entries(track, secondsToKeyframe(now)); + F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + + mSky = boost::static_pointer_cast((*bounds.first).second)->buildClone(); + mBlenderSky = boost::make_shared(mSky, + (*bounds.first).second, (*bounds.second).second, timespan); + mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::DayInstance::onTrackTransitionDone, this, 1, _1)); + } +} + +void LLEnvironment::DayInstance::onTrackTransitionDone(S32 trackno, const LLSettingsBlender::ptr_t &blender) +{ + LL_WARNS("LAPRAS") << "onTrackTransitionDone for " << trackno << LL_ENDL; + F64Seconds now(LLDate::now().secondsSinceEpoch()); + + now += mDayOffset; + + LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(trackno); + + LLSettingsDay::TrackBound_t bounds = get_bounding_entries(track, secondsToKeyframe(now)); + + F32 distance = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + F64Seconds timespan = mDayLength * distance; + + LL_WARNS("LAPRAS") << "New sky blender. now=" << now << + " start=" << (*bounds.first).first << " end=" << (*bounds.second).first << + " span=" << timespan << LL_ENDL; + + blender->reset((*bounds.first).second, (*bounds.second).second, timespan); +} -- cgit v1.2.3 From f07e5ee2a4907b9488a67a13db794c770878e648 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 5 Feb 2018 15:12:23 -0800 Subject: Transitions between skys. 1 --- indra/newview/llenvironment.cpp | 117 ++++++++++++++++++++++++++-------------- 1 file changed, 78 insertions(+), 39 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index db8fd570c0..cb1d85bed2 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -360,26 +360,33 @@ void LLEnvironment::updateEnvironment(F64Seconds transition) if (mCurrentEnvironment != pinstance) { - LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); - LLSettingsWater::ptr_t pwater = mCurrentEnvironment->getWater(); + DayInstance::ptr_t trans = boost::make_shared( + mCurrentEnvironment->getSky(), mCurrentEnvironment->getWater(), pinstance, transition); - LLSettingsSky::ptr_t ptargetsky = psky->buildClone(); - LLSettingsWater::ptr_t ptargetwater = pwater->buildClone(); - - LLSettingsBlender::ptr_t skyblend = boost::make_shared(ptargetsky, psky, pinstance->getSky(), transition); - skyblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, true)); - LLSettingsBlender::ptr_t waterblend = boost::make_shared(ptargetwater, pwater, pinstance->getWater(), transition); - waterblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, false)); + trans->animate(); - pinstance->setBlenders(skyblend, waterblend); - - mCurrentEnvironment = pinstance; - - mCurrentEnvironment->animate(); + mCurrentEnvironment = trans; +// +// LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); +// LLSettingsWater::ptr_t pwater = mCurrentEnvironment->getWater(); +// +// LLSettingsSky::ptr_t ptargetsky = psky->buildClone(); +// LLSettingsWater::ptr_t ptargetwater = pwater->buildClone(); +// +// LLSettingsBlender::ptr_t skyblend = boost::make_shared(ptargetsky, psky, pinstance->getSky(), transition); +// skyblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, true)); +// LLSettingsBlender::ptr_t waterblend = boost::make_shared(ptargetwater, pwater, pinstance->getWater(), transition); +// waterblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, false)); +// +// pinstance->setBlenders(skyblend, waterblend); +// +// mCurrentEnvironment = pinstance; +// +// mCurrentEnvironment->animate(); } } -void LLEnvironment::onTransitionDone(const LLSettingsBlender::ptr_t &blender, bool isSky) +void LLEnvironment::onTransitionDone(const LLSettingsBlender::ptr_t blender, bool isSky) { /*TODO: Test for both sky and water*/ mCurrentEnvironment->animate(); @@ -394,29 +401,16 @@ void LLEnvironment::update(const LLViewerCamera * cam) F32Seconds delta(timer.getElapsedTimeAndResetF32()); - for (InstanceArray_t::iterator it = mEnvironments.begin(); it != mEnvironments.end(); ++it) - { - if (*it) - (*it)->update(delta); - } +// for (InstanceArray_t::reverse_iterator it = mEnvironments.rbegin(); it != mEnvironments.rend(); ++it) +// { +// if (*it) +// (*it)->update(delta); +// } + mCurrentEnvironment->update(delta); // update clouds, sun, and general updateCloudScroll(); -// if (mBlenderSky) -// mBlenderSky->update(delta); -// if (mBlenderWater) -// mBlenderWater->update(delta); -// -// -// if (mCurrentDay) -// mCurrentDay->update(); -// -// if (mCurrentEnvironment->getSky()) -// mCurrentEnvironment->getSky()->update(); -// if (mCurrentEnvironment->getWater()) -// mCurrentEnvironment->getWater()->update(); - F32 camYaw = cam->getYaw(); stop_glerror(); @@ -1348,10 +1342,10 @@ void LLEnvironment::DayInstance::update(F64Seconds delta) if (mBlenderWater) mBlenderWater->update(delta); - if (mSky) - mSky->update(); - if (mWater) - mWater->update(); +// if (mSky) +// mSky->update(); +// if (mWater) +// mWater->update(); } void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset) @@ -1490,7 +1484,7 @@ void LLEnvironment::DayInstance::animate() } } -void LLEnvironment::DayInstance::onTrackTransitionDone(S32 trackno, const LLSettingsBlender::ptr_t &blender) +void LLEnvironment::DayInstance::onTrackTransitionDone(S32 trackno, const LLSettingsBlender::ptr_t blender) { LL_WARNS("LAPRAS") << "onTrackTransitionDone for " << trackno << LL_ENDL; F64Seconds now(LLDate::now().secondsSinceEpoch()); @@ -1510,3 +1504,48 @@ void LLEnvironment::DayInstance::onTrackTransitionDone(S32 trackno, const LLSett blender->reset((*bounds.first).second, (*bounds.second).second, timespan); } + +//------------------------------------------------------------------------- +LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart, + const LLSettingsWater::ptr_t &waterstart, LLEnvironment::DayInstance::ptr_t &end, S64Seconds time) : + DayInstance(), + mStartSky(skystart), + mStartWater(waterstart), + mNextInstance(end), + mTransitionTime(time) +{ + +} + +void LLEnvironment::DayTransition::update(F64Seconds delta) +{ + mNextInstance->update(delta); + DayInstance::update(delta); +} + +void LLEnvironment::DayTransition::animate() +{ + mNextInstance->animate(); + + mWater = mStartWater->buildClone(); + mBlenderWater = boost::make_shared(mWater, mStartWater, mNextInstance->getWater(), mTransitionTime); + mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::DayTransition::onTransitonDone, this, LLSettingsDay::TRACK_WATER, _1)); + + mSky = mStartSky->buildClone(); + mBlenderSky = boost::make_shared(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime); + mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::DayTransition::onTransitonDone, this, LLSettingsDay::TRACK_MAX, _1)); +} + + +void LLEnvironment::DayTransition::onTransitonDone(S32 trackno, const LLSettingsBlender::ptr_t blender) +{ + if (trackno == LLSettingsDay::TRACK_WATER) + mBlenderWater.reset(); + else + mBlenderSky.reset(); + + if (!mBlenderSky && !mBlenderWater) + { + LLEnvironment::instance().mCurrentEnvironment = mNextInstance; + } +} -- cgit v1.2.3 From 7838189843ff3b9c800e458b2452943edbc202ea Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 6 Feb 2018 17:27:56 -0800 Subject: boost->std & same level interp --- indra/newview/llenvironment.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index cb1d85bed2..cf5a68fdd2 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -98,7 +98,7 @@ void LLEnvironment::initSingleton() LLSettingsDay::ptr_t p_default_day = LLSettingsVODay::buildDefaultDayCycle(); addDayCycle(p_default_day); - mCurrentEnvironment = boost::make_shared(); + mCurrentEnvironment = std::make_shared(); mCurrentEnvironment->setSky(p_default_sky); mCurrentEnvironment->setWater(p_default_water); @@ -221,9 +221,10 @@ bool LLEnvironment::hasEnvironment(LLEnvironment::EnvSelection_t env) LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnvironment::EnvSelection_t env, bool create /*= false*/) { DayInstance::ptr_t environment = mEnvironments[env]; - if (!environment && create) +// if (!environment && create) + if (create) { - environment = boost::make_shared(); + environment = std::make_shared(); mEnvironments[env] = environment; } @@ -360,7 +361,7 @@ void LLEnvironment::updateEnvironment(F64Seconds transition) if (mCurrentEnvironment != pinstance) { - DayInstance::ptr_t trans = boost::make_shared( + DayInstance::ptr_t trans = std::make_shared( mCurrentEnvironment->getSky(), mCurrentEnvironment->getWater(), pinstance, transition); trans->animate(); @@ -373,9 +374,9 @@ void LLEnvironment::updateEnvironment(F64Seconds transition) // LLSettingsSky::ptr_t ptargetsky = psky->buildClone(); // LLSettingsWater::ptr_t ptargetwater = pwater->buildClone(); // -// LLSettingsBlender::ptr_t skyblend = boost::make_shared(ptargetsky, psky, pinstance->getSky(), transition); +// LLSettingsBlender::ptr_t skyblend = std::make_shared(ptargetsky, psky, pinstance->getSky(), transition); // skyblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, true)); -// LLSettingsBlender::ptr_t waterblend = boost::make_shared(ptargetwater, pwater, pinstance->getWater(), transition); +// LLSettingsBlender::ptr_t waterblend = std::make_shared(ptargetwater, pwater, pinstance->getWater(), transition); // waterblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, false)); // // pinstance->setBlenders(skyblend, waterblend); @@ -687,7 +688,7 @@ LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const return LLSettingsSky::ptr_t(); } - return boost::static_pointer_cast((*it).second); + return std::static_pointer_cast((*it).second); } LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const @@ -700,7 +701,7 @@ LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const return LLSettingsWater::ptr_t(); } - return boost::static_pointer_cast((*it).second); + return std::static_pointer_cast((*it).second); } LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const @@ -713,7 +714,7 @@ LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const return LLSettingsDay::ptr_t(); } - return boost::static_pointer_cast((*it).second); + return std::static_pointer_cast((*it).second); } @@ -1071,7 +1072,7 @@ LLEnvironment::EnvironmentInfo::EnvironmentInfo(): LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LLSD environment) { - ptr_t pinfo = boost::make_shared(); + ptr_t pinfo = std::make_shared(); if (environment.has("parcel_id")) pinfo->mParcelId = environment["parcel_id"].asInteger(); @@ -1444,7 +1445,7 @@ void LLEnvironment::DayInstance::animate() } else if (wtrack.size() == 1) { - mWater = boost::static_pointer_cast((*(wtrack.begin())).second); + mWater = std::static_pointer_cast((*(wtrack.begin())).second); mBlenderWater.reset(); } else @@ -1452,8 +1453,8 @@ void LLEnvironment::DayInstance::animate() LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, secondsToKeyframe(now)); F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); - mWater = boost::static_pointer_cast((*bounds.first).second)->buildClone(); - mBlenderWater = boost::make_shared(mWater, + mWater = std::static_pointer_cast((*bounds.first).second)->buildClone(); + mBlenderWater = std::make_shared(mWater, (*bounds.first).second, (*bounds.second).second, timespan); mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::DayInstance::onTrackTransitionDone, this, 0, _1)); } @@ -1469,7 +1470,7 @@ void LLEnvironment::DayInstance::animate() } else if (track.size() == 1) { - mSky = boost::static_pointer_cast((*(track.begin())).second); + mSky = std::static_pointer_cast((*(track.begin())).second); mBlenderSky.reset(); } else @@ -1477,8 +1478,8 @@ void LLEnvironment::DayInstance::animate() LLSettingsDay::TrackBound_t bounds = get_bounding_entries(track, secondsToKeyframe(now)); F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); - mSky = boost::static_pointer_cast((*bounds.first).second)->buildClone(); - mBlenderSky = boost::make_shared(mSky, + mSky = std::static_pointer_cast((*bounds.first).second)->buildClone(); + mBlenderSky = std::make_shared(mSky, (*bounds.first).second, (*bounds.second).second, timespan); mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::DayInstance::onTrackTransitionDone, this, 1, _1)); } @@ -1528,11 +1529,11 @@ void LLEnvironment::DayTransition::animate() mNextInstance->animate(); mWater = mStartWater->buildClone(); - mBlenderWater = boost::make_shared(mWater, mStartWater, mNextInstance->getWater(), mTransitionTime); + mBlenderWater = std::make_shared(mWater, mStartWater, mNextInstance->getWater(), mTransitionTime); mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::DayTransition::onTransitonDone, this, LLSettingsDay::TRACK_WATER, _1)); mSky = mStartSky->buildClone(); - mBlenderSky = boost::make_shared(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime); + mBlenderSky = std::make_shared(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime); mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::DayTransition::onTransitonDone, this, LLSettingsDay::TRACK_MAX, _1)); } -- cgit v1.2.3 From e9edd37cdb39639e1ab24e2e63d4f83432282c88 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 9 Feb 2018 10:10:13 -0800 Subject: Update a couple constructs --- indra/newview/llenvironment.cpp | 161 ++++++++++++---------------------------- 1 file changed, 49 insertions(+), 112 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index cf5a68fdd2..c67fcf880e 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -367,23 +367,6 @@ void LLEnvironment::updateEnvironment(F64Seconds transition) trans->animate(); mCurrentEnvironment = trans; -// -// LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); -// LLSettingsWater::ptr_t pwater = mCurrentEnvironment->getWater(); -// -// LLSettingsSky::ptr_t ptargetsky = psky->buildClone(); -// LLSettingsWater::ptr_t ptargetwater = pwater->buildClone(); -// -// LLSettingsBlender::ptr_t skyblend = std::make_shared(ptargetsky, psky, pinstance->getSky(), transition); -// skyblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, true)); -// LLSettingsBlender::ptr_t waterblend = std::make_shared(ptargetwater, pwater, pinstance->getWater(), transition); -// waterblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, false)); -// -// pinstance->setBlenders(skyblend, waterblend); -// -// mCurrentEnvironment = pinstance; -// -// mCurrentEnvironment->animate(); } } @@ -402,11 +385,6 @@ void LLEnvironment::update(const LLViewerCamera * cam) F32Seconds delta(timer.getElapsedTimeAndResetF32()); -// for (InstanceArray_t::reverse_iterator it = mEnvironments.rbegin(); it != mEnvironments.rend(); ++it) -// { -// if (*it) -// (*it)->update(delta); -// } mCurrentEnvironment->update(delta); // update clouds, sun, and general @@ -460,28 +438,28 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; LLSettingsBase::parammapping_t params = psetting->getParameterMap(); - for (LLSettingsBase::parammapping_t::iterator it = params.begin(); it != params.end(); ++it) + for (auto &it: params) { - if (!psetting->mSettings.has((*it).first)) + if (!psetting->mSettings.has(it.first)) continue; - LLSD value = psetting->mSettings[(*it).first]; + LLSD value = psetting->mSettings[it.first]; LLSD::Type setting_type = value.type(); stop_glerror(); switch (setting_type) { case LLSD::TypeInteger: - shader->uniform1i((*it).second, value.asInteger()); + shader->uniform1i(it.second, value.asInteger()); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; break; case LLSD::TypeReal: - shader->uniform1f((*it).second, value.asReal()); + shader->uniform1f(it.second, value.asReal()); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; break; case LLSD::TypeBoolean: - shader->uniform1i((*it).second, value.asBoolean() ? 1 : 0); + shader->uniform1i(it.second, value.asBoolean() ? 1 : 0); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; break; @@ -489,7 +467,7 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS { LLVector4 vect4(value); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; - shader->uniform4fv((*it).second, 1, vect4.mV); + shader->uniform4fv(it.second, 1, vect4.mV); break; } @@ -551,9 +529,9 @@ LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const list.reserve(mSkysByName.size()); - for (namedSettingMap_t::const_iterator it = mSkysByName.begin(); it != mSkysByName.end(); ++it) + for (auto &it: mSkysByName) { - list.push_back(std::vector::value_type((*it).second->getName(), (*it).second->getId())); + list.push_back(std::vector::value_type(it.second->getName(), it.second->getId())); } return list; @@ -565,9 +543,9 @@ LLEnvironment::list_name_id_t LLEnvironment::getWaterList() const list.reserve(mWaterByName.size()); - for (namedSettingMap_t::const_iterator it = mWaterByName.begin(); it != mWaterByName.end(); ++it) + for (auto &it : mWaterByName) { - list.push_back(std::vector::value_type((*it).second->getName(), (*it).second->getId())); + list.push_back(std::vector::value_type(it.second->getName(), it.second->getId())); } return list; @@ -579,9 +557,9 @@ LLEnvironment::list_name_id_t LLEnvironment::getDayCycleList() const list.reserve(mDayCycleByName.size()); - for (namedSettingMap_t::const_iterator it = mDayCycleByName.begin(); it != mDayCycleByName.end(); ++it) + for (auto &it: mDayCycleByName) { - list.push_back(std::vector::value_type((*it).second->getName(), (*it).second->getId())); + list.push_back(std::vector::value_type(it.second->getName(), it.second->getId())); } return list; @@ -593,8 +571,7 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) LL_WARNS("RIDER") << "Adding sky as '" << name << "'" << LL_ENDL; - std::pair result; - result = mSkysByName.insert(namedSettingMap_t::value_type(name, sky)); + auto result = mSkysByName.insert(namedSettingMap_t::value_type(name, sky)); // auto should be: std::pair if (!result.second) (*(result.first)).second = sky; @@ -603,7 +580,7 @@ void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) void LLEnvironment::removeSky(const std::string &name) { - namedSettingMap_t::iterator it = mSkysByName.find(name); + auto it = mSkysByName.find(name); if (it != mSkysByName.end()) mSkysByName.erase(it); mSkyListChange(); @@ -622,8 +599,7 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) LL_WARNS("RIDER") << "Adding water as '" << name << "'" << LL_ENDL; - std::pair result; - result = mWaterByName.insert(namedSettingMap_t::value_type(name, water)); + auto result = mWaterByName.insert(namedSettingMap_t::value_type(name, water)); if (!result.second) (*(result.first)).second = water; @@ -633,7 +609,7 @@ void LLEnvironment::addWater(const LLSettingsWater::ptr_t &water) void LLEnvironment::removeWater(const std::string &name) { - namedSettingMap_t::iterator it = mWaterByName.find(name); + auto it = mWaterByName.find(name); if (it != mWaterByName.end()) mWaterByName.erase(it); mWaterListChange(); @@ -652,8 +628,7 @@ void LLEnvironment::addDayCycle(const LLSettingsDay::ptr_t &daycycle) LL_WARNS("RIDER") << "Adding daycycle as '" << name << "'" << LL_ENDL; - std::pair result; - result = mDayCycleByName.insert(namedSettingMap_t::value_type(name, daycycle)); + auto result = mDayCycleByName.insert(namedSettingMap_t::value_type(name, daycycle)); if (!result.second) (*(result.first)).second = daycycle; @@ -664,7 +639,7 @@ void LLEnvironment::addDayCycle(const LLSettingsDay::ptr_t &daycycle) void LLEnvironment::removeDayCycle(const std::string &name) { - namedSettingMap_t::iterator it = mDayCycleByName.find(name); + auto it = mDayCycleByName.find(name); if (it != mDayCycleByName.end()) mDayCycleByName.erase(it); mDayCycleListChange(); @@ -680,7 +655,7 @@ void LLEnvironment::clearAllDayCycles() LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const { - namedSettingMap_t::const_iterator it = mSkysByName.find(name); + auto it = mSkysByName.find(name); if (it == mSkysByName.end()) { @@ -693,7 +668,7 @@ LLSettingsSky::ptr_t LLEnvironment::findSkyByName(std::string name) const LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const { - namedSettingMap_t::const_iterator it = mWaterByName.find(name); + auto it = mWaterByName.find(name); if (it == mWaterByName.end()) { @@ -706,7 +681,7 @@ LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const { - namedSettingMap_t::const_iterator it = mDayCycleByName.find(name); + auto it = mDayCycleByName.find(name); if (it == mDayCycleByName.end()) { @@ -735,27 +710,6 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI LL_WARNS("LAPRAS") << "Had requested parcel environment #" << parcel_id << " but got region." << LL_ENDL; clearEnvironment(ENV_PARCEL); } -// LLViewerRegion *pRegion = gAgent.getRegion(); -// -// pRegion->setDayLength(envinfo->mDayLength); -// pRegion->setDayOffset(envinfo->mDayOffset); -// pRegion->setIsDefaultDayCycle(envinfo->mIsDefault); -// if (pRegion->getRegionDayCycleHash() != envinfo->mDayHash) -// { -// pRegion->setRegionDayCycle(pday); -// pRegion->setRegionDayCycleHash(envinfo->mDayHash); -// } -// -// if (parcel_id != INVALID_PARCEL_ID) -// { // We requested a parcel environment but got back the region's. If this is the parcel we are in -// // clear it out. -// LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); -// -// if (parcel->getLocalID() == parcel_id) -// { -// parcel->clearParcelDayCycleInfo(); -// } -// } } else { @@ -769,20 +723,6 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI } setEnvironment(ENV_PARCEL, pday, envinfo->mDayLength, envinfo->mDayOffset); -// LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); -// -// if (parcel->getLocalID() == parcel_id) -// { -// parcel->setDayLength(envinfo->mDayLength); -// parcel->setDayOffset(envinfo->mDayOffset); -// parcel->setUsesDefaultDayCycle(envinfo->mIsDefault); -// if (parcel->getParcelDayCycleHash() != envinfo->mDayHash) -// { -// parcel->setParcelDayCycle(pday); -// parcel->setParcelDayCycleHash(envinfo->mDayHash); -// } -// -// } } /*TODO: track_altitudes*/ @@ -819,32 +759,27 @@ void LLEnvironment::resetRegion() void LLEnvironment::requestParcel(S32 parcel_id) { - environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2); - std::string coroname = LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", - boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, apply)); - + boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, + [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); })); } void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { - environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2); - std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, - pday, day_length, day_offset, apply)); - + pday, day_length, day_offset, + [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); })); } void LLEnvironment::resetParcel(S32 parcel_id) { - environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2); - std::string coroname = LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", - boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id, apply)); + boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id, + [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); })); } void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environment_apply_fn apply) @@ -890,7 +825,7 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ else { LLSD environment = result["environment"]; - if (environment.isDefined() && !apply.empty()) + if (environment.isDefined() && apply) { EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); apply(parcel_id, envinfo); @@ -953,7 +888,7 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd else { LLSD environment = result["environment"]; - if (environment.isDefined() && !apply.empty()) + if (environment.isDefined() && apply) { EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); apply(parcel_id, envinfo); @@ -1004,7 +939,7 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn app else { LLSD environment = result["environment"]; - if (environment.isDefined() && !apply.empty()) + if (environment.isDefined() && apply) { EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); apply(parcel_id, envinfo); @@ -1456,7 +1391,10 @@ void LLEnvironment::DayInstance::animate() mWater = std::static_pointer_cast((*bounds.first).second)->buildClone(); mBlenderWater = std::make_shared(mWater, (*bounds.first).second, (*bounds.second).second, timespan); - mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::DayInstance::onTrackTransitionDone, this, 0, _1)); + mBlenderWater->setOnFinished( + [this](LLSettingsBlender::ptr_t blender) { onTrackTransitionDone(0, blender); }); + + } // Day track 1 only for the moment @@ -1481,7 +1419,8 @@ void LLEnvironment::DayInstance::animate() mSky = std::static_pointer_cast((*bounds.first).second)->buildClone(); mBlenderSky = std::make_shared(mSky, (*bounds.first).second, (*bounds.second).second, timespan); - mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::DayInstance::onTrackTransitionDone, this, 1, _1)); + mBlenderSky->setOnFinished( + [this](LLSettingsBlender::ptr_t blender) { onTrackTransitionDone(1, blender); }); } } @@ -1530,23 +1469,21 @@ void LLEnvironment::DayTransition::animate() mWater = mStartWater->buildClone(); mBlenderWater = std::make_shared(mWater, mStartWater, mNextInstance->getWater(), mTransitionTime); - mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::DayTransition::onTransitonDone, this, LLSettingsDay::TRACK_WATER, _1)); + mBlenderWater->setOnFinished( + [this](LLSettingsBlender::ptr_t blender) { + mBlenderWater.reset(); + + if (!mBlenderSky && !mBlenderWater) + LLEnvironment::instance().mCurrentEnvironment = mNextInstance; + }); mSky = mStartSky->buildClone(); mBlenderSky = std::make_shared(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime); - mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::DayTransition::onTransitonDone, this, LLSettingsDay::TRACK_MAX, _1)); -} - - -void LLEnvironment::DayTransition::onTransitonDone(S32 trackno, const LLSettingsBlender::ptr_t blender) -{ - if (trackno == LLSettingsDay::TRACK_WATER) - mBlenderWater.reset(); - else + mBlenderSky->setOnFinished( + [this](LLSettingsBlender::ptr_t blender) { mBlenderSky.reset(); - if (!mBlenderSky && !mBlenderWater) - { - LLEnvironment::instance().mCurrentEnvironment = mNextInstance; - } + if (!mBlenderSky && !mBlenderWater) + LLEnvironment::instance().mCurrentEnvironment = mNextInstance; + }); } -- cgit v1.2.3 From 98862a53a77cd1ce9a2cae596a743669cc32a2af Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Sat, 3 Mar 2018 00:53:39 +0000 Subject: Fix 16F enum for compat w/ SL gl headers on Mac. Make density profile/layer parsing handle when LLSD heard you liked arrays so it put an array in your array. --- indra/newview/llenvironment.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index c67fcf880e..1936a67a18 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1157,7 +1157,15 @@ void LLEnvironment::legacyLoadAllPresets() std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); - LLEnvironment::instance().addDayCycle(day); + if (day->validate()) + { + LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; + LLEnvironment::instance().addDayCycle(day); + } + else + { + LL_WARNS() << "Day Cycle " << name << " was not valid. Ignoring." << LL_ENDL; + } #ifdef EXPORT_PRESETS std::string exportfile = LLURI::escape(name) + "(new).xml"; -- cgit v1.2.3 From 1687719a2523e1a6a9d8ebc8aeac52c530fa8fd0 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Tue, 6 Mar 2018 23:11:53 +0000 Subject: Undo changes to default Sky settings XML. Undo forced validation of objects built from legacy sky settings. --- indra/newview/llenvironment.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 1936a67a18..c5a1af8747 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1143,7 +1143,7 @@ void LLEnvironment::legacyLoadAllPresets() } } - // System water + // System Days { dir = getSysDir("days"); LLDirIterator dir_iter(dir, "*.xml"); @@ -1157,7 +1157,7 @@ void LLEnvironment::legacyLoadAllPresets() std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), true)); LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); - if (day->validate()) + /*if (day->validate()) { LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; LLEnvironment::instance().addDayCycle(day); @@ -1165,8 +1165,9 @@ void LLEnvironment::legacyLoadAllPresets() else { LL_WARNS() << "Day Cycle " << name << " was not valid. Ignoring." << LL_ENDL; - } - + }*/ + LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; + LLEnvironment::instance().addDayCycle(day); #ifdef EXPORT_PRESETS std::string exportfile = LLURI::escape(name) + "(new).xml"; std::string exportpath = gDirUtilp->add(getSysDir("new"), exportfile); @@ -1182,7 +1183,7 @@ void LLEnvironment::legacyLoadAllPresets() } } - // User water + // User Days { dir = getUserDir("days"); LLDirIterator dir_iter(dir, "*.xml"); -- cgit v1.2.3 From 057dda6afe59791f4a6fcf4c5ca8387b8aeda6a8 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Tue, 13 Mar 2018 17:21:10 +0100 Subject: Fix storing legacy haze parameters in inner map by fixing parameter update to not expect them at top level of LLSD for sky settings. --- indra/newview/llenvironment.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index c5a1af8747..b03367c4dd 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -440,12 +440,24 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS LLSettingsBase::parammapping_t params = psetting->getParameterMap(); for (auto &it: params) { - if (!psetting->mSettings.has(it.first)) + LLSD value; + + bool found_in_settings = psetting->mSettings.has(it.first); + bool found_in_legacy_settings = !found_in_settings && psetting->mSettings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE].has(it.first); + + if (!found_in_settings && !found_in_legacy_settings) continue; - LLSD value = psetting->mSettings[it.first]; - LLSD::Type setting_type = value.type(); + if (found_in_settings) + { + value = psetting->mSettings[it.first]; + } + else if (found_in_legacy_settings) + { + value = psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE][it.first]; + } + LLSD::Type setting_type = value.type(); stop_glerror(); switch (setting_type) { -- cgit v1.2.3 From 79e4a8c28ad29b028ddb907a6ea01f4ef71e822a Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Wed, 14 Mar 2018 00:11:19 +0100 Subject: Fix up atmospheric helpers and transport shader for adv atmo path. Basic hook-up of sky settings to llatmosphere model. Moved mie aniso to be a top-level setting instead of a per-mie-layer setting. --- indra/newview/llenvironment.cpp | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index b03367c4dd..a795628e8f 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -54,6 +54,8 @@ #include +#include "llatmosphere.h" + //define EXPORT_PRESETS 1 //========================================================================= namespace @@ -135,6 +137,55 @@ bool LLEnvironment::canEdit() const return true; } +void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settingsOut, const LLSettingsSky::ptr_t &psky) +{ + settingsOut.m_skyBottomRadius = psky->getSkyBottomRadius(); + settingsOut.m_skyTopRadius = psky->getSkyTopRadius(); + settingsOut.m_sunArcRadians = psky->getSunArcRadians(); + settingsOut.m_mieAnisotropy = psky->getMieAnisotropy(); + + LLSD rayleigh = psky->getRayleighConfigs(); + settingsOut.m_rayleighProfile.clear(); + for (LLSD::array_iterator itf = rayleigh.beginArray(); itf != rayleigh.endArray(); ++itf) + { + atmosphere::DensityProfileLayer layer; + LLSD& layerConfig = (*itf); + layer.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + layer.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + layer.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + layer.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + settingsOut.m_rayleighProfile.push_back(layer); + } + + LLSD mie = psky->getMieConfigs(); + settingsOut.m_mieProfile.clear(); + for (LLSD::array_iterator itf = mie.beginArray(); itf != mie.endArray(); ++itf) + { + atmosphere::DensityProfileLayer layer; + LLSD& layerConfig = (*itf); + layer.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + layer.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + layer.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + layer.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + settingsOut.m_mieProfile.push_back(layer); + } + + LLSD absorption = psky->getAbsorptionConfigs(); + settingsOut.m_absorptionProfile.clear(); + for (LLSD::array_iterator itf = absorption.beginArray(); itf != absorption.endArray(); ++itf) + { + atmosphere::DensityProfileLayer layer; + LLSD& layerConfig = (*itf); + layer.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + layer.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + layer.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + layer.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + settingsOut.m_absorptionProfile.push_back(layer); + } +} LLEnvironment::connection_t LLEnvironment::setSkyListChange(const LLEnvironment::change_signal_t::slot_type& cb) { @@ -1326,6 +1377,7 @@ void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, S64Sec } + void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) { if (mType == TYPE_CYCLED) @@ -1335,6 +1387,13 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) mSky = psky; mBlenderSky.reset(); + + if (gAtmosphere) + { + AtmosphericModelSettings settings; + LLEnvironment::getAtmosphericModelSettings(settings, psky); + gAtmosphere->configureAtmosphericModel(settings); + } } void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) -- cgit v1.2.3 From cf0e4f79f52b4fb24769aa6e355ec8c95c6d2afc Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 27 Apr 2018 17:12:13 -0700 Subject: Adding fixed water edit dialog. --- indra/newview/llenvironment.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index c5a1af8747..214ebb82b0 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -329,6 +329,30 @@ S64Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env) LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironment::EnvSelection_t env) { + if (env == ENV_CURRENT) + { + fixedEnvironment_t fixed; + for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) + { + if (fixed.first && fixed.second) + break; + + DayInstance::ptr_t environment = getEnvironmentInstance(static_cast(idx)); + if (environment) + { + if (!fixed.first) + fixed.first = environment->getSky(); + if (!fixed.second) + fixed.second = environment->getWater(); + } + } + + if (!fixed.first || !fixed.second) + LL_WARNS("ENVIRONMENT") << "Can not construct complete fixed environment. Missing Sky and/or Water." << LL_ENDL; + + return fixed; + } + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) { LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; -- cgit v1.2.3 From 438609699b838924becee89fa9d8ec83552f3236 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 30 Apr 2018 16:37:08 -0700 Subject: New water settings dialog. --- indra/newview/llenvironment.cpp | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 214ebb82b0..50f3f4f979 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -202,10 +202,10 @@ bool LLEnvironment::getIsDayTime() const } //------------------------------------------------------------------------- -void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, F64Seconds transition) +void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, F64Seconds transition, bool forced) { mSelectedEnvironment = env; - updateEnvironment(transition); + updateEnvironment(transition, forced); } bool LLEnvironment::hasEnvironment(LLEnvironment::EnvSelection_t env) @@ -337,6 +337,9 @@ LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironme if (fixed.first && fixed.second) break; + if (idx == ENV_EDIT) + continue; // skip the edit environment. + DayInstance::ptr_t environment = getEnvironmentInstance(static_cast(idx)); if (environment) { @@ -379,11 +382,11 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance( } -void LLEnvironment::updateEnvironment(F64Seconds transition) +void LLEnvironment::updateEnvironment(F64Seconds transition, bool forced) { DayInstance::ptr_t pinstance = getSelectedEnvironmentInstance(); - if (mCurrentEnvironment != pinstance) + if ((mCurrentEnvironment != pinstance) || forced) { DayInstance::ptr_t trans = std::make_shared( mCurrentEnvironment->getSky(), mCurrentEnvironment->getWater(), pinstance, transition); @@ -1067,6 +1070,30 @@ std::string LLEnvironment::getUserDir(const std::string &subdir) return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "windlight\\"+subdir, ""); } +LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename) +{ + LLSD data = legacyLoadPreset(filename); + if (!data) + return LLSettingsWater::ptr_t(); + + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data); + + return water; +} + +LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string filename) +{ + LLSD data = legacyLoadPreset(filename); + if (!data) + return LLSettingsSky::ptr_t(); + + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data); + + return sky; +} + LLSD LLEnvironment::legacyLoadPreset(const std::string& path) { llifstream xml_file; -- cgit v1.2.3 From 3e33fc9130cdd5dc63cc6cc7b9f0e38b6e552f12 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 3 May 2018 14:59:29 -0700 Subject: Inventory context menus and increment attrib for settings panels. --- indra/newview/llenvironment.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 50f3f4f979..ad4a1fca6a 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -135,6 +135,17 @@ bool LLEnvironment::canEdit() const return true; } +bool LLEnvironment::isExtendedEnvironmentEnabled() const +{ + return !gAgent.getRegionCapability("ExtEnvironment").empty(); +} + +bool LLEnvironment::isInventoryEnabled() const +{ + return (!gAgent.getRegionCapability("UpdateSettingsAgentInventory").empty() && + !gAgent.getRegionCapability("UpdateSettingsTaskInventory").empty()); +} + LLEnvironment::connection_t LLEnvironment::setSkyListChange(const LLEnvironment::change_signal_t::slot_type& cb) { @@ -759,7 +770,7 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI //========================================================================= void LLEnvironment::requestRegion() { - if (gAgent.getRegionCapability("ExtEnvironment").empty()) + if (!isExtendedEnvironmentEnabled()) { LLEnvironmentRequest::initiate(); return; @@ -770,7 +781,7 @@ void LLEnvironment::requestRegion() void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { - if (gAgent.getRegionCapability("ExtEnvironment").empty()) + if (!isExtendedEnvironmentEnabled()) { LLEnvironmentApply::initiateRequest( LLSettingsVODay::convertToLegacy(pday) ); return; -- cgit v1.2.3 From c238fa3ac5a3f93dcbf95e3cf7a7f8b576ab751c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 8 May 2018 16:57:14 -0700 Subject: Add save/update functionality hooks to fixed editor. --- indra/newview/llenvironment.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index ad4a1fca6a..98da6ea22f 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -277,6 +277,41 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm /*TODO: readjust environment*/ } +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsBase::ptr_t &settings) +{ + DayInstance::ptr_t environment = getEnvironmentInstance(env); + + if (settings->getSettingType() == "daycycle") + { + S64Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH); + S64Seconds dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); + if (environment) + { + daylength = environment->getDayLength(); + dayoffset = environment->getDayOffset(); + } + setEnvironment(env, std::static_pointer_cast(settings), daylength, dayoffset); + } + else if (settings->getSettingType() == "sky") + { + fixedEnvironment_t fixedenv(std::static_pointer_cast(settings), LLSettingsWater::ptr_t()); + if (environment) + { + fixedenv.second = environment->getWater(); + } + setEnvironment(env, fixedenv); + } + else if (settings->getSettingType() == "water") + { + fixedEnvironment_t fixedenv(LLSettingsSky::ptr_t(), std::static_pointer_cast(settings)); + if (environment) + { + fixedenv.first = environment->getSky(); + } + setEnvironment(env, fixedenv); + } +} + void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) { -- cgit v1.2.3 From 4975bd03c12673778616e1cca1811bf906bb42a6 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 16 May 2018 13:42:48 -0700 Subject: Splitting the blender up to support manual positioning as well as time. Phase1 --- indra/newview/llenvironment.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 98da6ea22f..f2d64f7e40 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1380,9 +1380,9 @@ void LLEnvironment::DayInstance::update(F64Seconds delta) initialize(); if (mBlenderSky) - mBlenderSky->update(delta); + mBlenderSky->update(delta.value()); if (mBlenderWater) - mBlenderWater->update(delta); + mBlenderWater->update(delta.value()); // if (mSky) // mSky->update(); @@ -1495,7 +1495,7 @@ void LLEnvironment::DayInstance::animate() F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); mWater = std::static_pointer_cast((*bounds.first).second)->buildClone(); - mBlenderWater = std::make_shared(mWater, + mBlenderWater = std::make_shared(mWater, (*bounds.first).second, (*bounds.second).second, timespan); mBlenderWater->setOnFinished( [this](LLSettingsBlender::ptr_t blender) { onTrackTransitionDone(0, blender); }); @@ -1523,7 +1523,7 @@ void LLEnvironment::DayInstance::animate() F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); mSky = std::static_pointer_cast((*bounds.first).second)->buildClone(); - mBlenderSky = std::make_shared(mSky, + mBlenderSky = std::make_shared(mSky, (*bounds.first).second, (*bounds.second).second, timespan); mBlenderSky->setOnFinished( [this](LLSettingsBlender::ptr_t blender) { onTrackTransitionDone(1, blender); }); @@ -1548,7 +1548,7 @@ void LLEnvironment::DayInstance::onTrackTransitionDone(S32 trackno, const LLSett " start=" << (*bounds.first).first << " end=" << (*bounds.second).first << " span=" << timespan << LL_ENDL; - blender->reset((*bounds.first).second, (*bounds.second).second, timespan); + blender->reset((*bounds.first).second, (*bounds.second).second, timespan.value()); } //------------------------------------------------------------------------- @@ -1574,7 +1574,7 @@ void LLEnvironment::DayTransition::animate() mNextInstance->animate(); mWater = mStartWater->buildClone(); - mBlenderWater = std::make_shared(mWater, mStartWater, mNextInstance->getWater(), mTransitionTime); + mBlenderWater = std::make_shared(mWater, mStartWater, mNextInstance->getWater(), mTransitionTime); mBlenderWater->setOnFinished( [this](LLSettingsBlender::ptr_t blender) { mBlenderWater.reset(); @@ -1584,7 +1584,7 @@ void LLEnvironment::DayTransition::animate() }); mSky = mStartSky->buildClone(); - mBlenderSky = std::make_shared(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime); + mBlenderSky = std::make_shared(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime); mBlenderSky->setOnFinished( [this](LLSettingsBlender::ptr_t blender) { mBlenderSky.reset(); -- cgit v1.2.3 From 430c5cd23558ba42c7da0e31845a3677e66f1fed Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 17 May 2018 16:16:33 -0700 Subject: Self contained looping track blender. Will blend over time across an entire track in a day cycle. --- indra/newview/llenvironment.cpp | 247 ++++++++++++++++++++++------------------ 1 file changed, 139 insertions(+), 108 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index f2d64f7e40..76192d1fe9 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -60,6 +60,125 @@ namespace { LLTrace::BlockTimerStatHandle FTM_ENVIRONMENT_UPDATE("Update Environment Tick"); LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); + + //--------------------------------------------------------------------- + inline F32 get_wrapping_distance(F32 begin, F32 end) + { + if (begin < end) + { + return end - begin; + } + else if (begin > end) + { + return 1.0 - (begin - end); + } + + return 0; + } + + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key) + { + if (collection.empty()) + return collection.end(); + + LLSettingsDay::CycleTrack_t::iterator it = collection.upper_bound(key); + + if (it == collection.end()) + { // wrap around + it = collection.begin(); + } + + return it; + } + + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key) + { + if (collection.empty()) + return collection.end(); + + LLSettingsDay::CycleTrack_t::iterator it = collection.lower_bound(key); + + if (it == collection.end()) + { // all keyframes are lower, take the last one. + --it; // we know the range is not empty + } + else if ((*it).first > key) + { // the keyframe we are interested in is smaller than the found. + if (it == collection.begin()) + it = collection.end(); + --it; + } + + return it; + } + + LLSettingsDay::TrackBound_t get_bounding_entries(LLSettingsDay::CycleTrack_t &track, F32 keyframe) + { + return LLSettingsDay::TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); + } + + //--------------------------------------------------------------------- + class LLTrackBlenderLoopingTime : public LLSettingsBlenderTimeDelta + { + public: + LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, F64Seconds cyclelength, F64Seconds cycleoffset) : + LLSettingsBlenderTimeDelta(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t(), F64Seconds(1.0)), + mDay(day), + mTrackNo(trackno), + mCycleLength(cyclelength), + mCycleOffset(cycleoffset) + { + LLSettingsDay::TrackBound_t initial = getBoundingEntries(getAdjustedNow()); + + mInitial = (*initial.first).second; + mFinal = (*initial.second).second; + mBlendSpan = getSpanTime(initial); + + setOnFinished([this](const LLSettingsBlender::ptr_t &){ onFinishedSpan(); }); + } + + protected: + LLSettingsDay::TrackBound_t getBoundingEntries(F64Seconds time) + { + LLSettingsDay::CycleTrack_t &wtrack = mDay->getCycleTrack(mTrackNo); + F64 position = convertTimeToPosition(time); + + LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, position); + return bounds; + } + + F64Seconds getAdjustedNow() const + { + F64Seconds now(LLDate::now().secondsSinceEpoch()); + + return (now + mCycleOffset); + } + + F64Seconds getSpanTime(const LLSettingsDay::TrackBound_t &bounds) const + { + return mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + } + + F64 convertTimeToPosition(F64Seconds time) + { + F64 position = static_cast(fmod(time.value(), mCycleLength.value())) / static_cast(mCycleLength.value()); + return llclamp(position, 0.0, 1.0); + } + + private: + LLSettingsDay::ptr_t mDay; + S32 mTrackNo; + F64Seconds mCycleLength; + F64Seconds mCycleOffset; + + void onFinishedSpan() + { + LLSettingsDay::TrackBound_t next = getBoundingEntries(getAdjustedNow()); + F64Seconds nextspan = getSpanTime(next); + reset((*next.first).second, (*next.second).second, nextspan.value()); + } + }; + } //========================================================================= @@ -443,12 +562,6 @@ void LLEnvironment::updateEnvironment(F64Seconds transition, bool forced) } } -void LLEnvironment::onTransitionDone(const LLSettingsBlender::ptr_t blender, bool isSky) -{ - /*TODO: Test for both sky and water*/ - mCurrentEnvironment->animate(); -} - //------------------------------------------------------------------------- void LLEnvironment::update(const LLViewerCamera * cam) { @@ -1301,67 +1414,6 @@ void LLEnvironment::legacyLoadAllPresets() } //========================================================================= -namespace -{ - inline F32 get_wrapping_distance(F32 begin, F32 end) - { - if (begin < end) - { - return end - begin; - } - else if (begin > end) - { - return 1.0 - (begin - end); - } - - return 0; - } - - LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key) - { - if (collection.empty()) - return collection.end(); - - LLSettingsDay::CycleTrack_t::iterator it = collection.upper_bound(key); - - if (it == collection.end()) - { // wrap around - it = collection.begin(); - } - - return it; - } - - LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key) - { - if (collection.empty()) - return collection.end(); - - LLSettingsDay::CycleTrack_t::iterator it = collection.lower_bound(key); - - if (it == collection.end()) - { // all keyframes are lower, take the last one. - --it; // we know the range is not empty - } - else if ((*it).first > key) - { // the keyframe we are interested in is smaller than the found. - if (it == collection.begin()) - it = collection.end(); - --it; - } - - return it; - } - - LLSettingsDay::TrackBound_t get_bounding_entries(LLSettingsDay::CycleTrack_t &track, F32 keyframe) - { - return LLSettingsDay::TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); - } - -} -//========================================================================= - - LLEnvironment::DayInstance::DayInstance() : mDayCycle(), mSky(), @@ -1371,7 +1423,8 @@ LLEnvironment::DayInstance::DayInstance() : mBlenderSky(), mBlenderWater(), mInitialized(false), - mType(TYPE_INVALID) + mType(TYPE_INVALID), + mSkyTrack(1) { } void LLEnvironment::DayInstance::update(F64Seconds delta) @@ -1453,8 +1506,21 @@ void LLEnvironment::DayInstance::clear() mDayOffset = LLSettingsDay::DEFAULT_DAYOFFSET; mBlenderSky.reset(); mBlenderWater.reset(); + mSkyTrack = 1; } +void LLEnvironment::DayInstance::setSkyTrack(S32 trackno) +{ + /*TODO*/ +// if (trackno != mSkyTrack) +// { +// mSkyTrack = trackno; +// +// // *TODO*: Pick the sky track based on the skytrack. +// } +} + + void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &skyblend, const LLSettingsBlender::ptr_t &waterblend) { mBlenderSky = skyblend; @@ -1491,21 +1557,13 @@ void LLEnvironment::DayInstance::animate() } else { - LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, secondsToKeyframe(now)); - F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); - - mWater = std::static_pointer_cast((*bounds.first).second)->buildClone(); - mBlenderWater = std::make_shared(mWater, - (*bounds.first).second, (*bounds.second).second, timespan); - mBlenderWater->setOnFinished( - [this](LLSettingsBlender::ptr_t blender) { onTrackTransitionDone(0, blender); }); - - + mWater = LLSettingsVOWater::buildDefaultWater(); + mBlenderWater = std::make_shared(mWater, mDayCycle, 0, mDayLength, mDayOffset); } // Day track 1 only for the moment // sky - LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(1); + LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(mSkyTrack); if (track.empty()) { @@ -1519,38 +1577,11 @@ void LLEnvironment::DayInstance::animate() } else { - LLSettingsDay::TrackBound_t bounds = get_bounding_entries(track, secondsToKeyframe(now)); - F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); - - mSky = std::static_pointer_cast((*bounds.first).second)->buildClone(); - mBlenderSky = std::make_shared(mSky, - (*bounds.first).second, (*bounds.second).second, timespan); - mBlenderSky->setOnFinished( - [this](LLSettingsBlender::ptr_t blender) { onTrackTransitionDone(1, blender); }); + mSky = LLSettingsVOSky::buildDefaultSky(); + mBlenderSky = std::make_shared(mSky, mDayCycle, mSkyTrack, mDayLength, mDayOffset); } } -void LLEnvironment::DayInstance::onTrackTransitionDone(S32 trackno, const LLSettingsBlender::ptr_t blender) -{ - LL_WARNS("LAPRAS") << "onTrackTransitionDone for " << trackno << LL_ENDL; - F64Seconds now(LLDate::now().secondsSinceEpoch()); - - now += mDayOffset; - - LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(trackno); - - LLSettingsDay::TrackBound_t bounds = get_bounding_entries(track, secondsToKeyframe(now)); - - F32 distance = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); - F64Seconds timespan = mDayLength * distance; - - LL_WARNS("LAPRAS") << "New sky blender. now=" << now << - " start=" << (*bounds.first).first << " end=" << (*bounds.second).first << - " span=" << timespan << LL_ENDL; - - blender->reset((*bounds.first).second, (*bounds.second).second, timespan.value()); -} - //------------------------------------------------------------------------- LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart, const LLSettingsWater::ptr_t &waterstart, LLEnvironment::DayInstance::ptr_t &end, S64Seconds time) : -- cgit v1.2.3 From 8082cb86682c008389cb8127f295e6566ec368e5 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Fri, 18 May 2018 23:14:56 +0100 Subject: Make nighttime elev constant _SIN, since it uses a sin value. Put that constant in sky settings and eliminate dups. Fix up logic around when to use heavenly bodies (fix broken moon in basic sky). Remove unnecessary clip to horizon. Put in temp code to ena/dis sun/moon based on LLEnvironment::getIsDaytime(). --- indra/newview/llenvironment.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index d878bd9abe..d37cbfc76d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -190,7 +190,6 @@ const F32Seconds LLEnvironment::TRANSITION_DEFAULT(5.0f); const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg -const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS); //------------------------------------------------------------------------- LLEnvironment::LLEnvironment(): @@ -380,7 +379,7 @@ F32 LLEnvironment::getWaterHeight() const bool LLEnvironment::getIsDayTime() const { - return mCurrentEnvironment->getSky()->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; + return mCurrentEnvironment->getSky()->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_SIN; } //------------------------------------------------------------------------- -- cgit v1.2.3 From ae5f24eb4d8a215cc26ef45ababc6ddec8f28edb Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Mon, 21 May 2018 19:10:32 +0100 Subject: Make rendering of sun / moon work with both in the sky (test visibility independently). --- indra/newview/llenvironment.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index d37cbfc76d..cc3a30d0b1 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -377,9 +377,16 @@ F32 LLEnvironment::getWaterHeight() const return gAgent.getRegion()->getWaterHeight(); } -bool LLEnvironment::getIsDayTime() const +bool LLEnvironment::getIsSunUp() const { - return mCurrentEnvironment->getSky()->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_SIN; + LLVector3 sunDir = mCurrentEnvironment->getSky()->getSunDirection(); + return sunDir.mV[2] > NIGHTTIME_ELEVATION_SIN; +} + +bool LLEnvironment::getIsMoonUp() const +{ + LLVector3 moonDir = mCurrentEnvironment->getSky()->getMoonDirection(); + return moonDir.mV[2] > NIGHTTIME_ELEVATION_SIN; } //------------------------------------------------------------------------- -- cgit v1.2.3 From 044b80e4e1a7b55f46e6f3b52c9cae6d9c6df3eb Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 22 May 2018 10:49:55 -0700 Subject: Manual blender for use in day editing dialog. --- indra/newview/llenvironment.cpp | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 76192d1fe9..cfea83c788 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -400,6 +400,18 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe { DayInstance::ptr_t environment = getEnvironmentInstance(env); + if (env == ENV_DEFAULT) + { + LL_WARNS("ENVIRONMENT") << "Attempt to set default environment. Not allowed." << LL_ENDL; + return; + } + + if (!settings) + { + clearEnvironment(env); + return; + } + if (settings->getSettingType() == "daycycle") { S64Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH); @@ -1624,3 +1636,68 @@ void LLEnvironment::DayTransition::animate() LLEnvironment::instance().mCurrentEnvironment = mNextInstance; }); } + +//========================================================================= +LLTrackBlenderLoopingManual::LLTrackBlenderLoopingManual(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno) : + LLSettingsBlender(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t()), + mDay(day), + mTrackNo(trackno), + mPosition(0.0) +{ + LLSettingsDay::TrackBound_t initial = getBoundingEntries(mPosition); + + if (initial.first != mEndMarker) + { // No frames in track + mInitial = (*initial.first).second; + mFinal = (*initial.second).second; + + LLSD initSettings = mInitial->getSettings(); + mTarget->replaceSettings(initSettings); + } +} + +F64 LLTrackBlenderLoopingManual::setPosition(F64 position) +{ + mPosition = llclamp(position, 0.0, 1.0); + + LLSettingsDay::TrackBound_t bounds = getBoundingEntries(mPosition); + + if (bounds.first == mEndMarker) + { // No frames in track. + return 0.0; + } + + mInitial = (*bounds.first).second; + mFinal = (*bounds.second).second; + + F64 spanLength = getSpanLength(bounds); + + F64 spanPos = ((mPosition < (*bounds.first).first) ? (mPosition + 1.0) : mPosition) - (*bounds.first).first; + + F64 blendf = fmod(spanPos, spanLength) / spanLength; + return LLSettingsBlender::setPosition(blendf); +} + +void LLTrackBlenderLoopingManual::switchTrack(S32 trackno, F64 position) +{ + mTrackNo = trackno; + + F64 useposition = (position < 0.0) ? mPosition : position; + + setPosition(useposition); +} + +LLSettingsDay::TrackBound_t LLTrackBlenderLoopingManual::getBoundingEntries(F64 position) +{ + LLSettingsDay::CycleTrack_t &wtrack = mDay->getCycleTrack(mTrackNo); + + mEndMarker = wtrack.end(); + + LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, position); + return bounds; +} + +F64 LLTrackBlenderLoopingManual::getSpanLength(const LLSettingsDay::TrackBound_t &bounds) const +{ + return get_wrapping_distance((*bounds.first).first, (*bounds.second).first); +} -- cgit v1.2.3 From 13536bb273b7413aa4461c8eeaf5a6a865f4234d Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Tue, 22 May 2018 21:42:54 +0100 Subject: Remove some obsolete sky funcs. Remove Matrix3/4 funcs using LLQuat 4-float init incorrectly (they are redundant to angle/axis versions anyway). Fix up tests referring to removed funcs above. --- indra/newview/llenvironment.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index cc3a30d0b1..1e14a0c5fb 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -379,14 +379,12 @@ F32 LLEnvironment::getWaterHeight() const bool LLEnvironment::getIsSunUp() const { - LLVector3 sunDir = mCurrentEnvironment->getSky()->getSunDirection(); - return sunDir.mV[2] > NIGHTTIME_ELEVATION_SIN; + return mCurrentEnvironment->getSky()->getIsSunUp(); } bool LLEnvironment::getIsMoonUp() const { - LLVector3 moonDir = mCurrentEnvironment->getSky()->getMoonDirection(); - return moonDir.mV[2] > NIGHTTIME_ELEVATION_SIN; + return mCurrentEnvironment->getSky()->getIsMoonUp(); } //------------------------------------------------------------------------- -- cgit v1.2.3 From b29aa01056a1ea08d1d29dd610f6a1cd0aadcd9b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 22 May 2018 16:54:04 -0700 Subject: Enable save/load/import for day edit. --- indra/newview/llenvironment.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index cfea83c788..9bc3f65c79 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1265,6 +1265,16 @@ LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string return sky; } +LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromLegacyPreset(const std::string filename) +{ + // for the moment just look it up from the preloaded. + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + + LLSettingsDay::ptr_t day = instance().findDayCycleByName(name); + return day; +} + + LLSD LLEnvironment::legacyLoadPreset(const std::string& path) { llifstream xml_file; -- cgit v1.2.3 From fa4ac065cb332c8c90fb59eeff0b983a1fd56691 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 24 May 2018 13:11:33 -0700 Subject: Enable sky changes with altitude. --- indra/newview/llenvironment.cpp | 126 +++++++++++++++++++++++++++++++--------- 1 file changed, 100 insertions(+), 26 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 9bc3f65c79..11347917c3 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -124,7 +124,7 @@ namespace LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, F64Seconds cyclelength, F64Seconds cycleoffset) : LLSettingsBlenderTimeDelta(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t(), F64Seconds(1.0)), mDay(day), - mTrackNo(trackno), + mTrackNo(0), mCycleLength(cyclelength), mCycleOffset(cycleoffset) { @@ -134,10 +134,57 @@ namespace mFinal = (*initial.second).second; mBlendSpan = getSpanTime(initial); + mTrackNo = selectTrackNumber(trackno); + setOnFinished([this](const LLSettingsBlender::ptr_t &){ onFinishedSpan(); }); } + + void switchTrack(S32 trackno, F64) override + { + S32 use_trackno = selectTrackNumber(trackno); + + if (use_trackno == mTrackNo) + { // results in no change + return; + } + + mTrackTransitionStart = mTarget->buildDerivedClone(); + mTrackNo = use_trackno; + + F64Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE; + LLSettingsDay::TrackBound_t bounds = getBoundingEntries(now); + + LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); + F64 targetpos = convertTimeToPosition(now) - (*bounds.first).first; + F64 targetspan = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + + F64 blendf = calculateBlend(targetpos, targetspan); + pendsetting->blend((*bounds.second).second, blendf); + + reset(mTrackTransitionStart, pendsetting, LLEnvironment::TRANSITION_ALTITUDE.value()); + } + + protected: + S32 selectTrackNumber(S32 trackno) + { + if (trackno == 0) + { // We are dealing with the water track. There is only ever one. + return 0; + } + + for (S32 test = trackno; test == 0; --test) + { // Find the track below the requested one with data. + LLSettingsDay::CycleTrack_t &track = mDay->getCycleTrack(mTrackNo); + + if (!track.empty()) + return test; + } + + return 1; + } + LLSettingsDay::TrackBound_t getBoundingEntries(F64Seconds time) { LLSettingsDay::CycleTrack_t &wtrack = mDay->getCycleTrack(mTrackNo); @@ -170,6 +217,7 @@ namespace S32 mTrackNo; F64Seconds mCycleLength; F64Seconds mCycleOffset; + LLSettingsBase::ptr_t mTrackTransitionStart; void onFinishedSpan() { @@ -186,6 +234,7 @@ const F32Seconds LLEnvironment::TRANSITION_INSTANT(0.0f); const F32Seconds LLEnvironment::TRANSITION_FAST(1.0f); const F32Seconds LLEnvironment::TRANSITION_DEFAULT(5.0f); const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); +const F32Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS); @@ -202,7 +251,8 @@ LLEnvironment::LLEnvironment(): mDayCycleByName(), mDayCycleById(), mUserPrefs(), - mSelectedEnvironment(LLEnvironment::ENV_LOCAL) + mSelectedEnvironment(LLEnvironment::ENV_LOCAL), + mCurrentTrack(1) { } @@ -228,11 +278,13 @@ void LLEnvironment::initSingleton() requestRegionEnvironment(); - LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLEnvironment::onParcelChange, this)); - gAgent.addParcelChangedCallback(boost::bind(&LLEnvironment::onParcelChange, this)); + LLRegionInfoModel::instance().setUpdateCallback([this]() { onParcelChange(); }); + gAgent.addParcelChangedCallback([this]() { onParcelChange(); }); //TODO: This frequently results in one more request than we need. It isn't breaking, but should be nicer. - gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::requestRegionEnvironment, this)); + gAgent.addRegionChangedCallback([this]() { requestRegionEnvironment(); }); + + gAgent.whenPositionChanged([this](const LLVector3 &localpos, const LLVector3d &) { onAgentPositionHasChanged(localpos); }); } LLEnvironment::~LLEnvironment() @@ -374,6 +426,7 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe environment->clear(); environment->setDay(pday, daylength, dayoffset); + environment->setSkyTrack(mCurrentTrack); environment->animate(); /*TODO: readjust environment*/ } @@ -1435,6 +1488,29 @@ void LLEnvironment::legacyLoadAllPresets() } } +void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos) +{ + S32 trackno = calculateSkyTrackForAltitude(localpos.mV[VZ]); + if (trackno == mCurrentTrack) + return; + + LL_WARNS("LAPRAS") << "Wants to switch to track #" << trackno << LL_ENDL; + + mCurrentTrack = trackno; + for (S32 env = ENV_LOCAL; env < ENV_DEFAULT; ++env) + { + if (mEnvironments[env]) + mEnvironments[env]->setSkyTrack(mCurrentTrack); + } +} + +S32 LLEnvironment::calculateSkyTrackForAltitude(F64 altitude) +{ + //*LAPRAS* temp base on region's response. + return llmin((static_cast(altitude) / 100) + 1, (LLSettingsDay::TRACK_MAX - 1)); +} + + //========================================================================= LLEnvironment::DayInstance::DayInstance() : mDayCycle(), @@ -1533,13 +1609,11 @@ void LLEnvironment::DayInstance::clear() void LLEnvironment::DayInstance::setSkyTrack(S32 trackno) { - /*TODO*/ -// if (trackno != mSkyTrack) -// { -// mSkyTrack = trackno; -// -// // *TODO*: Pick the sky track based on the skytrack. -// } + mSkyTrack = trackno; + if (mBlenderSky) + { + mBlenderSky->switchTrack(trackno); + } } @@ -1572,35 +1646,35 @@ void LLEnvironment::DayInstance::animate() mWater.reset(); mBlenderWater.reset(); } - else if (wtrack.size() == 1) - { - mWater = std::static_pointer_cast((*(wtrack.begin())).second); - mBlenderWater.reset(); - } +// else if (wtrack.size() == 1) +// { +// mWater = std::static_pointer_cast((*(wtrack.begin())).second); +// mBlenderWater.reset(); +// } else { mWater = LLSettingsVOWater::buildDefaultWater(); mBlenderWater = std::make_shared(mWater, mDayCycle, 0, mDayLength, mDayOffset); } - // Day track 1 only for the moment - // sky - LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(mSkyTrack); + // sky, initalize to track 1 + LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(1); if (track.empty()) { mSky.reset(); mBlenderSky.reset(); } - else if (track.size() == 1) - { - mSky = std::static_pointer_cast((*(track.begin())).second); - mBlenderSky.reset(); - } +// else if (track.size() == 1) +// { +// mSky = std::static_pointer_cast((*(track.begin())).second); +// mBlenderSky.reset(); +// } else { mSky = LLSettingsVOSky::buildDefaultSky(); - mBlenderSky = std::make_shared(mSky, mDayCycle, mSkyTrack, mDayLength, mDayOffset); + mBlenderSky = std::make_shared(mSky, mDayCycle, 1, mDayLength, mDayOffset); + mBlenderSky->switchTrack(mSkyTrack); } } -- cgit v1.2.3 From acaf57100eade61262d73cf5b318c4545e921bd5 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 24 May 2018 17:09:01 -0700 Subject: switch track based on altitudes sent from region. --- indra/newview/llenvironment.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 11347917c3..e0cfbbf79e 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -961,6 +961,10 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI LL_WARNS("LAPRAS") << "Had requested parcel environment #" << parcel_id << " but got region." << LL_ENDL; clearEnvironment(ENV_PARCEL); } + + mTrackAltitudes = envinfo->mAltitudes; + + LL_WARNS("LAPRAS") << "Altitudes set to {" << mTrackAltitudes[0] << ", "<< mTrackAltitudes[1] << ", " << mTrackAltitudes[2] << ", " << mTrackAltitudes[3] << LL_ENDL; } else { @@ -1250,7 +1254,7 @@ LLEnvironment::EnvironmentInfo::EnvironmentInfo(): mDayOffset(0), mDayHash(0), mDaycycleData(), - mAltitudes(), + mAltitudes({ { 0.0, 0.0, 0.0, 0.0 } }), mIsDefault(false), mIsRegion(false) { @@ -1275,7 +1279,16 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL if (environment.has("is_default")) pinfo->mIsDefault = environment["is_default"].asBoolean(); if (environment.has("track_altitudes")) - pinfo->mAltitudes = environment["track_altitudes"]; + { + LL_WARNS("LAPRAS") << "track_altitudes=" << environment["track_altitudes"] << LL_ENDL; + + /*LAPRAS: TODO: Fix the simulator message. Shouldn't be 5, just 4*/ + int idx = 1; + for (F32 &altitude : pinfo->mAltitudes) + { + altitude = environment["track_altitudes"][idx++].asReal(); + } + } return pinfo; } @@ -1506,8 +1519,17 @@ void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos) S32 LLEnvironment::calculateSkyTrackForAltitude(F64 altitude) { - //*LAPRAS* temp base on region's response. - return llmin((static_cast(altitude) / 100) + 1, (LLSettingsDay::TRACK_MAX - 1)); +// //*LAPRAS* temp base on region's response. +// return llmin((static_cast(altitude) / 100) + 1, (LLSettingsDay::TRACK_MAX - 1)); + + auto it = std::find_if_not(mTrackAltitudes.begin(), mTrackAltitudes.end(), [altitude](F32 test) { return altitude > test; }); + + if (it == mTrackAltitudes.begin()) + return 1; + else if (it == mTrackAltitudes.end()) + return 4; + + return std::min(std::distance(mTrackAltitudes.begin(), it), 4LL); } -- cgit v1.2.3 From 9831087fb605d14cc7a9818b82b36a6c0d7ca8a1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 31 May 2018 10:36:10 -0700 Subject: Use llmin rather than std::min --- indra/newview/llenvironment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e0cfbbf79e..54275446e3 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1529,7 +1529,7 @@ S32 LLEnvironment::calculateSkyTrackForAltitude(F64 altitude) else if (it == mTrackAltitudes.end()) return 4; - return std::min(std::distance(mTrackAltitudes.begin(), it), 4LL); + return llmin(std::distance(mTrackAltitudes.begin(), it), 4LL); } -- cgit v1.2.3 From 460d944b082ae73bbad3cf1d72a47ffa88970fb9 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 31 May 2018 11:15:17 -0700 Subject: More with min --- indra/newview/llenvironment.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 54275446e3..21ecf7741b 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -28,6 +28,8 @@ #include "llenvironment.h" +#include + #include "llagent.h" #include "llviewercontrol.h" // for gSavedSettings #include "llviewerregion.h" @@ -1529,7 +1531,7 @@ S32 LLEnvironment::calculateSkyTrackForAltitude(F64 altitude) else if (it == mTrackAltitudes.end()) return 4; - return llmin(std::distance(mTrackAltitudes.begin(), it), 4LL); + return std::min(static_cast(std::distance(mTrackAltitudes.begin(), it)), 4); } -- cgit v1.2.3 From 64302d3000b69b31e72eb6a3bd8a981c80cb88de Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 1 Jun 2018 00:18:36 +0100 Subject: Modify use of sky settings, reduce complexity, and name funcs to indicate coord systems in use. Fix class2 softenLightF shader. --- indra/newview/llenvironment.cpp | 80 ++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 25 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index a6f0f2cb62..0177f88b6d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -56,6 +56,8 @@ #include "llatmosphere.h" +#pragma optimize("", off) + //define EXPORT_PRESETS 1 //========================================================================= namespace @@ -630,6 +632,52 @@ void LLEnvironment::updateEnvironment(F64Seconds transition, bool forced) } } +LLVector3 LLEnvironment::getLightDirection() const +{ + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + if (!psky) + { + return LLVector3(0, 0, 1); + } + return psky->getLightDirection(); +} + +LLVector4 LLEnvironment::toCFR(const LLVector3 vec) const +{ + LLVector4 vec_cfr(vec.mV[1], vec.mV[0], vec.mV[2], 0.0f); + return vec_cfr; +} + +LLVector4 LLEnvironment::toLightNorm(const LLVector3 vec) const +{ + LLVector4 vec_ogl(vec.mV[1], vec.mV[2], vec.mV[0], 0.0f); + return vec_ogl; +} + +LLVector4 LLEnvironment::getLightDirectionCFR() const +{ + LLVector3 light_direction = getLightDirection(); + LLVector4 light_direction_cfr = toCFR(light_direction); + return light_direction_cfr; +} + +LLVector4 LLEnvironment::getClampedLightNorm() const +{ + LLVector3 light_direction = getLightDirection(); + if (light_direction.mV[2] < -0.1f) + { + light_direction.mV[2] = -0.1f; + } + return toLightNorm(light_direction); +} + +LLVector4 LLEnvironment::getRotatedLightNorm() const +{ + LLVector3 light_direction = getLightDirection(); + light_direction *= LLQuaternion(-mLastCamYaw, LLVector3(0.f, 1.f, 0.f)); + return toLightNorm(light_direction); +} + //------------------------------------------------------------------------- void LLEnvironment::update(const LLViewerCamera * cam) { @@ -644,18 +692,14 @@ void LLEnvironment::update(const LLViewerCamera * cam) // update clouds, sun, and general updateCloudScroll(); - F32 camYaw = cam->getYaw(); + // cache this for use in rotating the rotated light vec for shader param updates later... + mLastCamYaw = cam->getYaw() + SUN_DELTA_YAW; stop_glerror(); // *TODO: potential optimization - this block may only need to be // executed some of the time. For example for water shaders only. { - LLVector3 lightNorm3( getLightDirection() ); - - lightNorm3 *= LLQuaternion(-(camYaw + SUN_DELTA_YAW), LLVector3(0.f, 1.f, 0.f)); - mRotatedLight = 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) @@ -767,26 +811,10 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) { if (gPipeline.canUseWindLightShaders()) - { - updateGLVariablesForSettings(shader, mCurrentEnvironment->getSky()); + { updateGLVariablesForSettings(shader, mCurrentEnvironment->getWater()); - } - - if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) - { - stop_glerror(); - shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, mRotatedLight.mV); - shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); - stop_glerror(); - } - else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) - { - stop_glerror(); - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, getClampedLightDirection().mV); - stop_glerror(); - } - - shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, getSceneLightStrength()); + updateGLVariablesForSettings(shader, mCurrentEnvironment->getSky()); + } } LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const @@ -1552,6 +1580,7 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) mInitialized = false; mSky = psky; + mSky->update(); mBlenderSky.reset(); if (gAtmosphere) @@ -1570,6 +1599,7 @@ void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) mInitialized = false; mWater = pwater; + mWater->update(); mBlenderWater.reset(); } -- cgit v1.2.3 From 8dd85013865cc5b426234cd71b605d7208bcfe01 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 1 Jun 2018 15:50:25 +0100 Subject: Fix mis-merge of LLSettingsBase and remove optimize pragmas. --- indra/newview/llenvironment.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e9c27a7794..2650f69a2f 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -58,8 +58,6 @@ #include "llatmosphere.h" -#pragma optimize("", off) - //define EXPORT_PRESETS 1 //========================================================================= namespace -- cgit v1.2.3 From 8cfdc07e790a557e881fadaa1b6258e5b16751f4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 1 Jun 2018 23:32:30 +0100 Subject: Code cleanup and move to using typedefs of S64Seconds/F64Seconds for ease in sync w/ sim side which has not llunits types. --- indra/newview/llenvironment.cpp | 60 ++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 2650f69a2f..b7aff6bca9 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -125,8 +125,8 @@ namespace class LLTrackBlenderLoopingTime : public LLSettingsBlenderTimeDelta { public: - LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, F64Seconds cyclelength, F64Seconds cycleoffset) : - LLSettingsBlenderTimeDelta(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t(), F64Seconds(1.0)), + LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, LLSettingsBase::Seconds cyclelength, LLSettingsBase::Seconds cycleoffset) : + LLSettingsBlenderTimeDelta(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t(), LLSettingsBase::Seconds(1.0)), mDay(day), mTrackNo(0), mCycleLength(cyclelength), @@ -156,7 +156,7 @@ namespace mTrackTransitionStart = mTarget->buildDerivedClone(); mTrackNo = use_trackno; - F64Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE; + LLSettingsBase::Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE; LLSettingsDay::TrackBound_t bounds = getBoundingEntries(now); LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); @@ -189,7 +189,7 @@ namespace return 1; } - LLSettingsDay::TrackBound_t getBoundingEntries(F64Seconds time) + LLSettingsDay::TrackBound_t getBoundingEntries(LLSettingsBase::Seconds time) { LLSettingsDay::CycleTrack_t &wtrack = mDay->getCycleTrack(mTrackNo); F64 position = convertTimeToPosition(time); @@ -198,19 +198,19 @@ namespace return bounds; } - F64Seconds getAdjustedNow() const + LLSettingsBase::Seconds getAdjustedNow() const { - F64Seconds now(LLDate::now().secondsSinceEpoch()); + LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); return (now + mCycleOffset); } - F64Seconds getSpanTime(const LLSettingsDay::TrackBound_t &bounds) const + LLSettingsBase::Seconds getSpanTime(const LLSettingsDay::TrackBound_t &bounds) const { return mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); } - F64 convertTimeToPosition(F64Seconds time) + F64 convertTimeToPosition(LLSettingsBase::Seconds time) { F64 position = static_cast(fmod(time.value(), mCycleLength.value())) / static_cast(mCycleLength.value()); return llclamp(position, 0.0, 1.0); @@ -219,14 +219,14 @@ namespace private: LLSettingsDay::ptr_t mDay; S32 mTrackNo; - F64Seconds mCycleLength; - F64Seconds mCycleOffset; + LLSettingsBase::Seconds mCycleLength; + LLSettingsBase::Seconds mCycleOffset; LLSettingsBase::ptr_t mTrackTransitionStart; void onFinishedSpan() { LLSettingsDay::TrackBound_t next = getBoundingEntries(getAdjustedNow()); - F64Seconds nextspan = getSpanTime(next); + LLSettingsBase::Seconds nextspan = getSpanTime(next); reset((*next.first).second, (*next.second).second, nextspan.value()); } }; @@ -442,7 +442,7 @@ bool LLEnvironment::getIsMoonUp() const } //------------------------------------------------------------------------- -void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, F64Seconds transition, bool forced) +void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, LLSettingsBase::Seconds transition, bool forced) { mSelectedEnvironment = env; updateEnvironment(transition, forced); @@ -472,7 +472,7 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnviro } -void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset) +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) { if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) { @@ -525,8 +525,8 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe if (settings->getSettingType() == "daycycle") { - S64Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH); - S64Seconds dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); + LLSettingsDay::Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH); + LLSettingsDay::Seconds dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); if (environment) { daylength = environment->getDayLength(); @@ -583,12 +583,12 @@ LLSettingsDay::ptr_t LLEnvironment::getEnvironmentDay(LLEnvironment::EnvSelectio return LLSettingsDay::ptr_t(); } -S64Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env) +LLSettingsDay::Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env) { if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) { LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; - return S64Seconds(0); + return LLSettingsDay::Seconds(0); } DayInstance::ptr_t environment = getEnvironmentInstance(env); @@ -596,22 +596,22 @@ S64Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env) if (environment) return environment->getDayLength(); - return S64Seconds(0); + return LLSettingsDay::Seconds(0); } -S64Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env) +LLSettingsDay::Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env) { if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) { LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; - return S64Seconds(0); + return LLSettingsDay::Seconds(0); } DayInstance::ptr_t environment = getEnvironmentInstance(env); if (environment) return environment->getDayOffset(); - return S64Seconds(0); + return LLSettingsDay::Seconds(0); } @@ -670,7 +670,7 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance( } -void LLEnvironment::updateEnvironment(F64Seconds transition, bool forced) +void LLEnvironment::updateEnvironment(LLSettingsBase::Seconds transition, bool forced) { DayInstance::ptr_t pinstance = getSelectedEnvironmentInstance(); @@ -1365,9 +1365,9 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL if (environment.has("region_id")) pinfo->mRegionId = environment["region_id"].asUUID(); if (environment.has("day_length")) - pinfo->mDayLength = S64Seconds(environment["day_length"].asInteger()); + pinfo->mDayLength = LLSettingsDay::Seconds(environment["day_length"].asInteger()); if (environment.has("day_offset")) - pinfo->mDayOffset = S64Seconds(environment["day_offset"].asInteger()); + pinfo->mDayOffset = LLSettingsDay::Seconds(environment["day_offset"].asInteger()); if (environment.has("day_hash")) pinfo->mDayHash = environment["day_hash"].asInteger(); if (environment.has("day_cycle")) @@ -1643,7 +1643,7 @@ LLEnvironment::DayInstance::DayInstance() : mSkyTrack(1) { } -void LLEnvironment::DayInstance::update(F64Seconds delta) +void LLEnvironment::DayInstance::update(LLSettingsBase::Seconds delta) { if (!mInitialized) initialize(); @@ -1659,7 +1659,7 @@ void LLEnvironment::DayInstance::update(F64Seconds delta) // mWater->update(); } -void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset) +void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) { if (mType == TYPE_FIXED) LL_WARNS("ENVIRONMENT") << "Fixed day instance changed to Cycled" << LL_ENDL; @@ -1750,7 +1750,7 @@ void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &sky mBlenderWater = waterblend; } -F64 LLEnvironment::DayInstance::secondsToKeyframe(S64Seconds seconds) +F64 LLEnvironment::DayInstance::secondsToKeyframe(LLSettingsDay::Seconds seconds) { F64 frame = static_cast(seconds.value() % mDayLength.value()) / static_cast(mDayLength.value()); @@ -1759,7 +1759,7 @@ F64 LLEnvironment::DayInstance::secondsToKeyframe(S64Seconds seconds) void LLEnvironment::DayInstance::animate() { - F64Seconds now(LLDate::now().secondsSinceEpoch()); + LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); now += mDayOffset; @@ -1807,7 +1807,7 @@ void LLEnvironment::DayInstance::animate() //------------------------------------------------------------------------- LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart, - const LLSettingsWater::ptr_t &waterstart, LLEnvironment::DayInstance::ptr_t &end, S64Seconds time) : + const LLSettingsWater::ptr_t &waterstart, LLEnvironment::DayInstance::ptr_t &end, LLSettingsDay::Seconds time) : DayInstance(), mStartSky(skystart), mStartWater(waterstart), @@ -1817,7 +1817,7 @@ LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart } -void LLEnvironment::DayTransition::update(F64Seconds delta) +void LLEnvironment::DayTransition::update(LLSettingsBase::Seconds delta) { mNextInstance->update(delta); DayInstance::update(delta); -- cgit v1.2.3 From 2a613d7363c4e91a7258d4f0ea3971db1569e788 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 1 Jun 2018 16:24:36 -0700 Subject: Rework preset loading and context menu from inventory. --- indra/newview/llenvironment.cpp | 344 ++++++++++++++++++++-------------------- 1 file changed, 173 insertions(+), 171 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 21ecf7741b..228a396c0d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -238,6 +238,16 @@ const F32Seconds LLEnvironment::TRANSITION_DEFAULT(5.0f); const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F32Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); +//*TODO* Change these when available on Agni (these are Damballah asset IDs). +const LLUUID LLEnvironment::KNOWN_SKY_DEFAULT(LLSettingsSky::DEFAULT_ASSET_ID); +const LLUUID LLEnvironment::KNOWN_WATER_DEFAULT(LLSettingsWater::DEFAULT_ASSET_ID); +const LLUUID LLEnvironment::KNOWN_DAY_DEFAULT(LLSettingsDay::DEFAULT_ASSET_ID); + +const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("645d7475-19d6-d05c-6eb2-29eeacf76e06"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("68f5a7ec-2785-d9d8-be7c-cca93976759a"); +const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("06420773-757b-4b7c-a1f9-85fceb2f7bd4"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("c13658f3-91b8-d559-3a12-b11ce3940c4c"); + const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS); @@ -498,6 +508,25 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe } } +void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId) +{ + LLSettingsVOBase::getSettingsAsset(assetId, + [this, env](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onSetEnvAssetLoaded(env, asset_id, settings, status); }); + +} + +void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) +{ + if (!settings || status) + { + LLSD args; + args["DESC"] = asset_id.asString(); + LLNotificationsUtil::add("FailedToFindSettings", args); + return; + } + + setEnvironment(env, settings); +} void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) { @@ -1311,196 +1340,172 @@ std::string LLEnvironment::getUserDir(const std::string &subdir) LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename) { - LLSD data = legacyLoadPreset(filename); - if (!data) - return LLSettingsWater::ptr_t(); - std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); - LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data); + std::string path(gDirUtilp->getDirName(filename)); + LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPresetFile(name, path); return water; } LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string filename) { - LLSD data = legacyLoadPreset(filename); - if (!data) - return LLSettingsSky::ptr_t(); - std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); - LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data); + std::string path(gDirUtilp->getDirName(filename)); + LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPresetFile(name, path); return sky; + } LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromLegacyPreset(const std::string filename) { - // for the moment just look it up from the preloaded. std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + std::string path(gDirUtilp->getDirName(filename)); - LLSettingsDay::ptr_t day = instance().findDayCycleByName(name); + LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPresetFile(name, path); return day; } -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 = LLSettingsVOSky::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 = LLSettingsVOSky::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 = LLSettingsVOWater::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 = LLSettingsVOWater::buildFromLegacyPreset(name, data); - LLEnvironment::instance().addWater(water); - } - } - } - - // System Days - { - 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)); - - LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); - /*if (day->validate()) - { - LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; - LLEnvironment::instance().addDayCycle(day); - } - else - { - LL_WARNS() << "Day Cycle " << name << " was not valid. Ignoring." << LL_ENDL; - }*/ - LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; - LLEnvironment::instance().addDayCycle(day); -#ifdef EXPORT_PRESETS - std::string exportfile = LLURI::escape(name) + "(new).xml"; - std::string exportpath = gDirUtilp->add(getSysDir("new"), exportfile); - - LLSD settings = day->getSettings(); - - std::ofstream daycyclefile(exportpath); - LLPointer formatter = new LLSDXMLFormatter(); - formatter->format(settings, daycyclefile, LLSDFormatter::OPTIONS_PRETTY); - daycyclefile.close(); -#endif - } - } - } - - // User Days - { - 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)); - - LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); - LLEnvironment::instance().addDayCycle(day); - } - } - } +// 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 = LLSettingsVOSky::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 = LLSettingsVOSky::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 = LLSettingsVOWater::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 = LLSettingsVOWater::buildFromLegacyPreset(name, data); +// LLEnvironment::instance().addWater(water); +// } +// } +// } +// +// // System Days +// { +// 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)); +// +// LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); +// /*if (day->validate()) +// { +// LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; +// LLEnvironment::instance().addDayCycle(day); +// } +// else +// { +// LL_WARNS() << "Day Cycle " << name << " was not valid. Ignoring." << LL_ENDL; +// }*/ +// LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; +// LLEnvironment::instance().addDayCycle(day); +// #ifdef EXPORT_PRESETS +// std::string exportfile = LLURI::escape(name) + "(new).xml"; +// std::string exportpath = gDirUtilp->add(getSysDir("new"), exportfile); +// +// LLSD settings = day->getSettings(); +// +// std::ofstream daycyclefile(exportpath); +// LLPointer formatter = new LLSDXMLFormatter(); +// formatter->format(settings, daycyclefile, LLSDFormatter::OPTIONS_PRETTY); +// daycyclefile.close(); +// #endif +// } +// } +// } +// +// // User Days +// { +// 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)); +// +// LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); +// LLEnvironment::instance().addDayCycle(day); +// } +// } +// } } void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos) @@ -1521,9 +1526,6 @@ void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos) S32 LLEnvironment::calculateSkyTrackForAltitude(F64 altitude) { -// //*LAPRAS* temp base on region's response. -// return llmin((static_cast(altitude) / 100) + 1, (LLSettingsDay::TRACK_MAX - 1)); - auto it = std::find_if_not(mTrackAltitudes.begin(), mTrackAltitudes.end(), [altitude](F32 test) { return altitude > test; }); if (it == mTrackAltitudes.begin()) -- cgit v1.2.3 From 7136956b90614bbd236be0e30231781c04346220 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sat, 2 Jun 2018 23:28:48 +0100 Subject: Use more typedefs to simplify sync between viewer and sim env settings code. --- indra/newview/llenvironment.cpp | 45 ++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3b0bc4cd55..3f6241fa0b 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -66,7 +66,7 @@ namespace LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); //--------------------------------------------------------------------- - inline F32 get_wrapping_distance(F32 begin, F32 end) + inline LLSettingsBase::TrackPosition get_wrapping_distance(LLSettingsBase::TrackPosition begin, LLSettingsBase::TrackPosition end) { if (begin < end) { @@ -74,13 +74,13 @@ namespace } else if (begin > end) { - return 1.0 - (begin - end); + return LLSettingsBase::TrackPosition(1.0) - (begin - end); } return 0; } - LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key) + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key) { if (collection.empty()) return collection.end(); @@ -95,7 +95,7 @@ namespace return it; } - LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key) + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key) { if (collection.empty()) return collection.end(); @@ -116,7 +116,7 @@ namespace return it; } - LLSettingsDay::TrackBound_t get_bounding_entries(LLSettingsDay::CycleTrack_t &track, F32 keyframe) + LLSettingsDay::TrackBound_t get_bounding_entries(LLSettingsDay::CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe) { return LLSettingsDay::TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); } @@ -144,7 +144,7 @@ namespace } - void switchTrack(S32 trackno, F64) override + void switchTrack(S32 trackno, const LLSettingsBase::BlendFactor&) override { S32 use_trackno = selectTrackNumber(trackno); @@ -159,17 +159,16 @@ namespace LLSettingsBase::Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE; LLSettingsDay::TrackBound_t bounds = getBoundingEntries(now); - LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); - F64 targetpos = convertTimeToPosition(now) - (*bounds.first).first; - F64 targetspan = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); + LLSettingsBase::TrackPosition targetpos = convertTimeToPosition(now) - (*bounds.first).first; + LLSettingsBase::TrackPosition targetspan = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); - F64 blendf = calculateBlend(targetpos, targetspan); + LLSettingsBase::BlendFactor blendf = calculateBlend(targetpos, targetspan); pendsetting->blend((*bounds.second).second, blendf); - reset(mTrackTransitionStart, pendsetting, LLEnvironment::TRANSITION_ALTITUDE.value()); + reset(mTrackTransitionStart, pendsetting, LLEnvironment::TRANSITION_ALTITUDE); } - protected: S32 selectTrackNumber(S32 trackno) { @@ -210,9 +209,9 @@ namespace return mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); } - F64 convertTimeToPosition(LLSettingsBase::Seconds time) + LLSettingsBase::TrackPosition convertTimeToPosition(const LLSettingsBase::Seconds& time) { - F64 position = static_cast(fmod(time.value(), mCycleLength.value())) / static_cast(mCycleLength.value()); + F64 position = fmod((F64)time, (F64)mCycleLength) / (F64)mCycleLength; return llclamp(position, 0.0, 1.0); } @@ -223,11 +222,11 @@ namespace LLSettingsBase::Seconds mCycleOffset; LLSettingsBase::ptr_t mTrackTransitionStart; - void onFinishedSpan() + void onFinishedSpan() { LLSettingsDay::TrackBound_t next = getBoundingEntries(getAdjustedNow()); LLSettingsBase::Seconds nextspan = getSpanTime(next); - reset((*next.first).second, (*next.second).second, nextspan.value()); + reset((*next.first).second, (*next.second).second, nextspan); } }; @@ -241,10 +240,6 @@ const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F32Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); //*TODO* Change these when available on Agni (these are Damballah asset IDs). -const LLUUID LLEnvironment::KNOWN_SKY_DEFAULT(LLSettingsSky::DEFAULT_ASSET_ID); -const LLUUID LLEnvironment::KNOWN_WATER_DEFAULT(LLSettingsWater::DEFAULT_ASSET_ID); -const LLUUID LLEnvironment::KNOWN_DAY_DEFAULT(LLSettingsDay::DEFAULT_ASSET_ID); - const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("645d7475-19d6-d05c-6eb2-29eeacf76e06"); const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("68f5a7ec-2785-d9d8-be7c-cca93976759a"); const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("06420773-757b-4b7c-a1f9-85fceb2f7bd4"); @@ -1741,7 +1736,7 @@ void LLEnvironment::DayInstance::setSkyTrack(S32 trackno) mSkyTrack = trackno; if (mBlenderSky) { - mBlenderSky->switchTrack(trackno); + mBlenderSky->switchTrack(trackno, 0.0); } } @@ -1803,7 +1798,7 @@ void LLEnvironment::DayInstance::animate() { mSky = LLSettingsVOSky::buildDefaultSky(); mBlenderSky = std::make_shared(mSky, mDayCycle, 1, mDayLength, mDayOffset); - mBlenderSky->switchTrack(mSkyTrack); + mBlenderSky->switchTrack(mSkyTrack, 0.0); } } @@ -1869,7 +1864,7 @@ LLTrackBlenderLoopingManual::LLTrackBlenderLoopingManual(const LLSettingsBase::p } } -F64 LLTrackBlenderLoopingManual::setPosition(F64 position) +LLSettingsBase::BlendFactor LLTrackBlenderLoopingManual::setPosition(const LLSettingsBase::TrackPosition& position) { mPosition = llclamp(position, 0.0, 1.0); @@ -1891,11 +1886,11 @@ F64 LLTrackBlenderLoopingManual::setPosition(F64 position) return LLSettingsBlender::setPosition(blendf); } -void LLTrackBlenderLoopingManual::switchTrack(S32 trackno, F64 position) +void LLTrackBlenderLoopingManual::switchTrack(S32 trackno, const LLSettingsBase::TrackPosition& position) { mTrackNo = trackno; - F64 useposition = (position < 0.0) ? mPosition : position; + LLSettingsBase::TrackPosition useposition = (position < 0.0) ? mPosition : position; setPosition(useposition); } -- cgit v1.2.3 From cd8f0da2d187df69a99a665ea11faaa4e13b7a12 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 4 Jun 2018 23:12:21 +0100 Subject: Fix use of new typedefs in inventory settings code in llenvironment. --- indra/newview/llenvironment.cpp | 50 +++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 29 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3f6241fa0b..cc9cd4fb86 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -121,6 +121,13 @@ namespace return LLSettingsDay::TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); } + // Find normalized track position of given time along full length of cycle + inline LLSettingsBase::TrackPosition convert_time_to_position(const LLSettingsBase::Seconds& time, const LLSettingsBase::Seconds& len) + { + LLSettingsBase::TrackPosition position = LLSettingsBase::TrackPosition(fmod((F64)time, (F64)len) / (F64)len); + return llclamp(position, 0.0f, 1.0f); + } + //--------------------------------------------------------------------- class LLTrackBlenderLoopingTime : public LLSettingsBlenderTimeDelta { @@ -143,8 +150,7 @@ namespace setOnFinished([this](const LLSettingsBlender::ptr_t &){ onFinishedSpan(); }); } - - void switchTrack(S32 trackno, const LLSettingsBase::BlendFactor&) override + void switchTrack(S32 trackno, const LLSettingsBase::TrackPosition&) override { S32 use_trackno = selectTrackNumber(trackno); @@ -160,7 +166,7 @@ namespace LLSettingsDay::TrackBound_t bounds = getBoundingEntries(now); LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); - LLSettingsBase::TrackPosition targetpos = convertTimeToPosition(now) - (*bounds.first).first; + LLSettingsBase::TrackPosition targetpos = convert_time_to_position(now, mCycleLength) - (*bounds.first).first; LLSettingsBase::TrackPosition targetspan = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); LLSettingsBase::BlendFactor blendf = calculateBlend(targetpos, targetspan); @@ -191,8 +197,7 @@ namespace LLSettingsDay::TrackBound_t getBoundingEntries(LLSettingsBase::Seconds time) { LLSettingsDay::CycleTrack_t &wtrack = mDay->getCycleTrack(mTrackNo); - F64 position = convertTimeToPosition(time); - + LLSettingsBase::TrackPosition position = convert_time_to_position(time, mCycleLength); LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, position); return bounds; } @@ -209,12 +214,6 @@ namespace return mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); } - LLSettingsBase::TrackPosition convertTimeToPosition(const LLSettingsBase::Seconds& time) - { - F64 position = fmod((F64)time, (F64)mCycleLength) / (F64)mCycleLength; - return llclamp(position, 0.0, 1.0); - } - private: LLSettingsDay::ptr_t mDay; S32 mTrackNo; @@ -764,7 +763,7 @@ void LLEnvironment::update(const LLViewerCamera * cam) F32Seconds delta(timer.getElapsedTimeAndResetF32()); - mCurrentEnvironment->update(delta); + mCurrentEnvironment->applyTimeDelta(delta); // update clouds, sun, and general updateCloudScroll(); @@ -1640,20 +1639,15 @@ LLEnvironment::DayInstance::DayInstance() : mSkyTrack(1) { } -void LLEnvironment::DayInstance::update(LLSettingsBase::Seconds delta) +void LLEnvironment::DayInstance::applyTimeDelta(const LLSettingsBase::Seconds& delta) { if (!mInitialized) initialize(); if (mBlenderSky) - mBlenderSky->update(delta.value()); + mBlenderSky->applyTimeDelta(delta); if (mBlenderWater) - mBlenderWater->update(delta.value()); - -// if (mSky) -// mSky->update(); -// if (mWater) -// mWater->update(); + mBlenderWater->applyTimeDelta(delta); } void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) @@ -1747,11 +1741,9 @@ void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &sky mBlenderWater = waterblend; } -F64 LLEnvironment::DayInstance::secondsToKeyframe(LLSettingsDay::Seconds seconds) +LLSettingsBase::TrackPosition LLEnvironment::DayInstance::secondsToKeyframe(LLSettingsDay::Seconds seconds) { - F64 frame = static_cast(seconds.value() % mDayLength.value()) / static_cast(mDayLength.value()); - - return llclamp(frame, 0.0, 1.0); + return convert_time_to_position(seconds, mDayLength); } void LLEnvironment::DayInstance::animate() @@ -1814,10 +1806,10 @@ LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart } -void LLEnvironment::DayTransition::update(LLSettingsBase::Seconds delta) +void LLEnvironment::DayTransition::applyTimeDelta(const LLSettingsBase::Seconds& delta) { - mNextInstance->update(delta); - DayInstance::update(delta); + mNextInstance->applyTimeDelta(delta); + DayInstance::applyTimeDelta(delta); } void LLEnvironment::DayTransition::animate() @@ -1866,7 +1858,7 @@ LLTrackBlenderLoopingManual::LLTrackBlenderLoopingManual(const LLSettingsBase::p LLSettingsBase::BlendFactor LLTrackBlenderLoopingManual::setPosition(const LLSettingsBase::TrackPosition& position) { - mPosition = llclamp(position, 0.0, 1.0); + mPosition = llclamp(position, 0.0f, 1.0f); LLSettingsDay::TrackBound_t bounds = getBoundingEntries(mPosition); @@ -1883,7 +1875,7 @@ LLSettingsBase::BlendFactor LLTrackBlenderLoopingManual::setPosition(const LLSet F64 spanPos = ((mPosition < (*bounds.first).first) ? (mPosition + 1.0) : mPosition) - (*bounds.first).first; F64 blendf = fmod(spanPos, spanLength) / spanLength; - return LLSettingsBlender::setPosition(blendf); + return LLSettingsBlender::setBlendFactor(blendf); } void LLTrackBlenderLoopingManual::switchTrack(S32 trackno, const LLSettingsBase::TrackPosition& position) -- cgit v1.2.3 From b06803225bff30e863ea18cae1d33f42a4fd937e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 4 Jun 2018 16:50:13 -0700 Subject: Reconnect apply to region and parcel reconnected to interface. --- indra/newview/llenvironment.cpp | 146 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 145 insertions(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 228a396c0d..21c38302d1 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -318,6 +318,27 @@ bool LLEnvironment::canEdit() const return true; } +bool LLEnvironment::canAgentUpdateParcelEnvironment(bool useselected) const +{ + if (!LLEnvironment::instance().isExtendedEnvironmentEnabled()) + return false; + // *TODO* + //LLParcel* parcel = (useselected) ? LLViewerParcelMgr::instance().getParcelSelection() : LLViewerParcelMgr::instance().getAgentParcel(); + LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + if (parcel) + { + return parcel->allowTerraformBy(gAgent.getID()); + } + + return false; +} + +bool LLEnvironment::canAgentUpdateRegionEnvironment() const +{ + return gAgent.getRegion()->canManageEstate(); +} + + bool LLEnvironment::isExtendedEnvironmentEnabled() const { return !gAgent.getRegionCapability("ExtEnvironment").empty(); @@ -1011,7 +1032,6 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI setEnvironment(ENV_PARCEL, pday, envinfo->mDayLength, envinfo->mDayOffset); } - /*TODO: track_altitudes*/ updateEnvironment(); } @@ -1038,6 +1058,29 @@ void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset); } +void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset) +{ + if (!isExtendedEnvironmentEnabled()) + { + LL_WARNS("ENVIRONMENT") << "attempt to apply asset id to region not supporting it." << LL_ENDL; + LLNotificationsUtil::add("NoEnvironmentSettings"); + return; + } + + updateParcel(INVALID_PARCEL_ID, asset_id, day_length, day_offset); +} + +void LLEnvironment::updateRegion(LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) +{ + updateParcel(INVALID_PARCEL_ID, psky, day_length, day_offset); +} + +void LLEnvironment::updateRegion(LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) +{ + updateParcel(INVALID_PARCEL_ID, pwater, day_length, day_offset); +} + + void LLEnvironment::resetRegion() { resetParcel(INVALID_PARCEL_ID); @@ -1051,6 +1094,52 @@ void LLEnvironment::requestParcel(S32 parcel_id) [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); })); } +void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset) +{ + LLSettingsVOBase::getSettingsAsset(asset_id, + [this, parcel_id, day_length, day_offset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onUpdateParcelAssetLoaded(asset_id, settings, status, parcel_id, day_length, day_offset); }); +} + +void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset) +{ + if (status) + { + LL_WARNS("ENVIRONMENT") << "Unable to get settings asset with id " << asset_id << "!" << LL_ENDL; + LLNotificationsUtil::add("FailedToLoadSettingsApply"); + return; + } + + LLSettingsDay::ptr_t pday; + + if (settings->getSettingType() == "daycycle") + pday = std::static_pointer_cast(settings); + else + { + pday = createDayCycleFromEnvironment( (parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, settings); + } + + if (!pday) + { + LL_WARNS("ENVIRONMENT") << "Unable to construct day around " << asset_id << "!" << LL_ENDL; + LLNotificationsUtil::add("FailedToBuildSettingsDay"); + return; + } + + updateParcel(parcel_id, pday, day_length, day_offset); +} + +void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) +{ + LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, psky); + updateParcel(parcel_id, pday, day_length, day_offset); +} + +void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) +{ + LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, pwater); + updateParcel(parcel_id, pday, day_length, day_offset); +} + void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { std::string coroname = @@ -1136,6 +1225,20 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd if (url.empty()) return; + if (day_length < 1) + { + day_length = getEnvironmentDayLength((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL).value(); + if ((day_length < 1) && (parcel_id != INVALID_PARCEL_ID)) + day_length = getEnvironmentDayLength(ENV_REGION).value(); + } + + if (day_offset < 1) + { + day_offset = getEnvironmentDayOffset((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL).value(); + if ((day_offset < 1) && (parcel_id != INVALID_PARCEL_ID)) + day_offset = getEnvironmentDayOffset(ENV_REGION).value(); + } + LLSD body(LLSD::emptyMap()); body["environment"] = LLSD::emptyMap(); @@ -1366,6 +1469,47 @@ LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromLegacyPreset(const std::st return day; } +LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromEnvironment(EnvSelection_t env, LLSettingsBase::ptr_t settings) +{ + std::string type(settings->getSettingType()); + + if (type == "daycycle") + return std::static_pointer_cast(settings); + + if ((env != ENV_PARCEL) && (env != ENV_REGION)) + { + LL_WARNS("ENVIRONMENT") << "May only create from parcel or region environment." << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + LLSettingsDay::ptr_t day = this->getEnvironmentDay(env); + if (!day && (env == ENV_PARCEL)) + { + day = this->getEnvironmentDay(ENV_REGION); + } + + if (!day) + { + LL_WARNS("ENVIRONMENT") << "Could not retrieve existing day settings." << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + day = day->buildClone(); + + if (type == "sky") + { + for (S32 idx = 1; idx < LLSettingsDay::TRACK_MAX; ++idx) + day->clearTrack(idx); + day->setSettingsAtKeyframe(settings, 0.0f, 1); + } + else if (type == "water") + { + day->clearTrack(LLSettingsDay::TRACK_WATER); + day->setSettingsAtKeyframe(settings, 0.0f, LLSettingsDay::TRACK_WATER); + } + + return day; +} void LLEnvironment::legacyLoadAllPresets() { -- cgit v1.2.3 From 610a793aa8fb9f918fc25eeab02b7415ac18b33b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 5 Jun 2018 11:19:22 -0700 Subject: EOL in llsetingssky.cpp and llrender.cpp. const on ptr_t & in llenvironment --- indra/newview/llenvironment.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 097b229587..02d79b2bae 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1134,7 +1134,7 @@ void LLEnvironment::requestRegion() requestParcel(INVALID_PARCEL_ID); } -void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { if (!isExtendedEnvironmentEnabled()) { @@ -1157,12 +1157,12 @@ void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day updateParcel(INVALID_PARCEL_ID, asset_id, day_length, day_offset); } -void LLEnvironment::updateRegion(LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) { updateParcel(INVALID_PARCEL_ID, psky, day_length, day_offset); } -void LLEnvironment::updateRegion(LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) { updateParcel(INVALID_PARCEL_ID, pwater, day_length, day_offset); } @@ -1215,19 +1215,19 @@ void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::p updateParcel(parcel_id, pday, day_length, day_offset); } -void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) { LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, psky); updateParcel(parcel_id, pday, day_length, day_offset); } -void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) { LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, pwater); updateParcel(parcel_id, pday, day_length, day_offset); } -void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", -- cgit v1.2.3 From caa5bd3cb9f22a42de9fc1f37bb98b17e2405b5b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 6 Jun 2018 19:48:12 +0100 Subject: Fix legacy haze validation returning warnings as errors. Add assert that calculated spans are > 0 to avoid div by 0 NaNs. Make span calc return 1.0 for case where begin == end. Fix order of ops in LLTrackBlenderLoopingTime ctor causing skies to be init'd with water instances. --- indra/newview/llenvironment.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 02d79b2bae..5b184d8c25 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -77,7 +77,7 @@ namespace return LLSettingsBase::TrackPosition(1.0) - (begin - end); } - return 0; + return 1.0f; } LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key) @@ -139,14 +139,15 @@ namespace mCycleLength(cyclelength), mCycleOffset(cycleoffset) { + // must happen prior to getBoundingEntries call... + mTrackNo = selectTrackNumber(trackno); + LLSettingsDay::TrackBound_t initial = getBoundingEntries(getAdjustedNow()); mInitial = (*initial.first).second; mFinal = (*initial.second).second; mBlendSpan = getSpanTime(initial); - mTrackNo = selectTrackNumber(trackno); - setOnFinished([this](const LLSettingsBlender::ptr_t &){ onFinishedSpan(); }); } @@ -211,7 +212,9 @@ namespace LLSettingsBase::Seconds getSpanTime(const LLSettingsDay::TrackBound_t &bounds) const { - return mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + LLSettingsBase::Seconds span = mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + llassert(span > 0.01f); + return span; } private: @@ -1905,11 +1908,6 @@ void LLEnvironment::DayInstance::animate() mWater.reset(); mBlenderWater.reset(); } -// else if (wtrack.size() == 1) -// { -// mWater = std::static_pointer_cast((*(wtrack.begin())).second); -// mBlenderWater.reset(); -// } else { mWater = LLSettingsVOWater::buildDefaultWater(); @@ -1924,11 +1922,6 @@ void LLEnvironment::DayInstance::animate() mSky.reset(); mBlenderSky.reset(); } -// else if (track.size() == 1) -// { -// mSky = std::static_pointer_cast((*(track.begin())).second); -// mBlenderSky.reset(); -// } else { mSky = LLSettingsVOSky::buildDefaultSky(); -- cgit v1.2.3 From 8365945f8af6e27e7180b40aae79f210f99bb7c8 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 8 Jun 2018 16:40:01 -0700 Subject: Settings inventory picker. --- indra/newview/llenvironment.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 5b184d8c25..ccb5294a2e 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -550,7 +550,7 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe return; } - if (settings->getSettingType() == "daycycle") + if (settings->getSettingsType() == "daycycle") { LLSettingsDay::Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH); LLSettingsDay::Seconds dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); @@ -561,7 +561,7 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe } setEnvironment(env, std::static_pointer_cast(settings), daylength, dayoffset); } - else if (settings->getSettingType() == "sky") + else if (settings->getSettingsType() == "sky") { fixedEnvironment_t fixedenv(std::static_pointer_cast(settings), LLSettingsWater::ptr_t()); if (environment) @@ -570,7 +570,7 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe } setEnvironment(env, fixedenv); } - else if (settings->getSettingType() == "water") + else if (settings->getSettingsType() == "water") { fixedEnvironment_t fixedenv(LLSettingsSky::ptr_t(), std::static_pointer_cast(settings)); if (environment) @@ -1201,7 +1201,7 @@ void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::p LLSettingsDay::ptr_t pday; - if (settings->getSettingType() == "daycycle") + if (settings->getSettingsType() == "daycycle") pday = std::static_pointer_cast(settings); else { @@ -1561,7 +1561,7 @@ LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromLegacyPreset(const std::st LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromEnvironment(EnvSelection_t env, LLSettingsBase::ptr_t settings) { - std::string type(settings->getSettingType()); + std::string type(settings->getSettingsType()); if (type == "daycycle") return std::static_pointer_cast(settings); -- cgit v1.2.3 From 97da85de0b1e0f8c2fc60c156c31b237b869230a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 11 Jun 2018 11:43:50 -0700 Subject: remove legacy environmental edit floater and some lingering transition functions. Change floater environment switch behavior. --- indra/newview/llenvironment.cpp | 357 +--------------------------------------- 1 file changed, 1 insertion(+), 356 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index ccb5294a2e..a5ee7d0737 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -254,12 +254,6 @@ LLEnvironment::LLEnvironment(): mSelectedSky(), mSelectedWater(), mSelectedDay(), - mSkysById(), - mSkysByName(), - mWaterByName(), - mWaterById(), - mDayCycleByName(), - mDayCycleById(), mUserPrefs(), mSelectedEnvironment(LLEnvironment::ENV_LOCAL), mCurrentTrack(1) @@ -269,13 +263,7 @@ LLEnvironment::LLEnvironment(): void LLEnvironment::initSingleton() { LLSettingsSky::ptr_t p_default_sky = LLSettingsVOSky::buildDefaultSky(); - addSky(p_default_sky); - LLSettingsWater::ptr_t p_default_water = LLSettingsVOWater::buildDefaultWater(); - addWater(p_default_water); - - LLSettingsDay::ptr_t p_default_day = LLSettingsVODay::buildDefaultDayCycle(); - addDayCycle(p_default_day); mCurrentEnvironment = std::make_shared(); mCurrentEnvironment->setSky(p_default_sky); @@ -283,9 +271,6 @@ void LLEnvironment::initSingleton() mEnvironments[ENV_DEFAULT] = mCurrentEnvironment; - // LEGACY! - legacyLoadAllPresets(); - requestRegionEnvironment(); LLRegionInfoModel::instance().setUpdateCallback([this]() { onParcelChange(); }); @@ -397,22 +382,6 @@ bool LLEnvironment::isInventoryEnabled() const !gAgent.getRegionCapability("UpdateSettingsTaskInventory").empty()); } - -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); -} - void LLEnvironment::onParcelChange() { S32 parcel_id(INVALID_PARCEL_ID); @@ -437,7 +406,7 @@ void LLEnvironment::onLegacyRegionSettings(LLSD data) LLSettingsDay::ptr_t regionday; if (data[1].isUndefined()) - regionday = LLEnvironment::findDayCycleByName("Default"); + regionday = LLSettingsVODay::buildDefaultDayCycle(); else regionday = LLSettingsVODay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); @@ -916,176 +885,6 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) } } -LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const -{ - list_name_id_t list; - - list.reserve(mSkysByName.size()); - - for (auto &it: mSkysByName) - { - 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 (auto &it : mWaterByName) - { - 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 (auto &it: mDayCycleByName) - { - list.push_back(std::vector::value_type(it.second->getName(), it.second->getId())); - } - - return list; -} - -void LLEnvironment::addSky(const LLSettingsSky::ptr_t &sky) -{ - std::string name = sky->getValue(LLSettingsSky::SETTING_NAME).asString(); - - LL_WARNS("RIDER") << "Adding sky as '" << name << "'" << LL_ENDL; - - auto result = mSkysByName.insert(namedSettingMap_t::value_type(name, sky)); // auto should be: std::pair - - if (!result.second) - (*(result.first)).second = sky; - mSkyListChange(); -} - -void LLEnvironment::removeSky(const std::string &name) -{ - auto it = mSkysByName.find(name); - if (it != mSkysByName.end()) - mSkysByName.erase(it); - mSkyListChange(); -} - -void LLEnvironment::clearAllSkys() -{ - mSkysByName.clear(); - mSkysById.clear(); - mSkyListChange(); -} - -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; - - auto result = mWaterByName.insert(namedSettingMap_t::value_type(name, water)); - - if (!result.second) - (*(result.first)).second = water; - mWaterListChange(); -} - - -void LLEnvironment::removeWater(const std::string &name) -{ - auto it = mWaterByName.find(name); - if (it != mWaterByName.end()) - mWaterByName.erase(it); - mWaterListChange(); -} - -void LLEnvironment::clearAllWater() -{ - mWaterByName.clear(); - mWaterById.clear(); - mWaterListChange(); -} - -void LLEnvironment::addDayCycle(const LLSettingsDay::ptr_t &daycycle) -{ - std::string name = daycycle->getValue(LLSettingsDay::SETTING_NAME).asString(); - - LL_WARNS("RIDER") << "Adding daycycle as '" << name << "'" << LL_ENDL; - - auto 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) -{ - auto 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 -{ - auto it = mSkysByName.find(name); - - if (it == mSkysByName.end()) - { - LL_WARNS("ENVIRONMENT") << "Unable to find sky with unknown name '" << name << "'" << LL_ENDL; - return LLSettingsSky::ptr_t(); - } - - return std::static_pointer_cast((*it).second); -} - -LLSettingsWater::ptr_t LLEnvironment::findWaterByName(std::string name) const -{ - auto it = mWaterByName.find(name); - - if (it == mWaterByName.end()) - { - LL_WARNS("ENVIRONMENT") << "Unable to find water with unknown name '" << name << "'" << LL_ENDL; - return LLSettingsWater::ptr_t(); - } - - return std::static_pointer_cast((*it).second); -} - -LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const -{ - auto it = mDayCycleByName.find(name); - - if (it == mDayCycleByName.end()) - { - LL_WARNS("ENVIRONMENT") << "Unable to find daycycle with unknown name '" << name << "'" << LL_ENDL; - return LLSettingsDay::ptr_t(); - } - - return std::static_pointer_cast((*it).second); -} - - void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo) { LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; @@ -1518,19 +1317,6 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL } //========================================================================= -// 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, ""); -} - LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename) { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); @@ -1601,147 +1387,6 @@ LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromEnvironment(EnvSelection_t return day; } -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 = LLSettingsVOSky::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 = LLSettingsVOSky::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 = LLSettingsVOWater::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 = LLSettingsVOWater::buildFromLegacyPreset(name, data); -// LLEnvironment::instance().addWater(water); -// } -// } -// } -// -// // System Days -// { -// 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)); -// -// LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); -// /*if (day->validate()) -// { -// LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; -// LLEnvironment::instance().addDayCycle(day); -// } -// else -// { -// LL_WARNS() << "Day Cycle " << name << " was not valid. Ignoring." << LL_ENDL; -// }*/ -// LL_INFOS() << "Adding Day Cycle " << name << "." << LL_ENDL; -// LLEnvironment::instance().addDayCycle(day); -// #ifdef EXPORT_PRESETS -// std::string exportfile = LLURI::escape(name) + "(new).xml"; -// std::string exportpath = gDirUtilp->add(getSysDir("new"), exportfile); -// -// LLSD settings = day->getSettings(); -// -// std::ofstream daycyclefile(exportpath); -// LLPointer formatter = new LLSDXMLFormatter(); -// formatter->format(settings, daycyclefile, LLSDFormatter::OPTIONS_PRETTY); -// daycyclefile.close(); -// #endif -// } -// } -// } -// -// // User Days -// { -// 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)); -// -// LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPreset(name, data); -// LLEnvironment::instance().addDayCycle(day); -// } -// } -// } -} - void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos) { S32 trackno = calculateSkyTrackForAltitude(localpos.mV[VZ]); -- cgit v1.2.3 From 67ab0084f87c40bf31d7fadded55cc9ea6299ca2 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 12 Jun 2018 18:42:07 +0100 Subject: Fix env panel forward action. Make env panel update environment when jumping frame to frame. Add separate funcs for sun/moon vectors in various coord systems. Make haze glow only pay attention to sun (i.e. fix sun glow when moon is near horizon in daytime). --- indra/newview/llenvironment.cpp | 66 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 6 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index a5ee7d0737..f0bec2fda1 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -700,6 +700,18 @@ void LLEnvironment::updateEnvironment(LLSettingsBase::Seconds transition, bool f } } +LLVector4 LLEnvironment::toCFR(const LLVector3 vec) const +{ + LLVector4 vec_cfr(vec.mV[1], vec.mV[0], vec.mV[2], 0.0f); + return vec_cfr; +} + +LLVector4 LLEnvironment::toLightNorm(const LLVector3 vec) const +{ + LLVector4 vec_ogl(vec.mV[1], vec.mV[2], vec.mV[0], 0.0f); + return vec_ogl; +} + LLVector3 LLEnvironment::getLightDirection() const { LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); @@ -710,16 +722,24 @@ LLVector3 LLEnvironment::getLightDirection() const return psky->getLightDirection(); } -LLVector4 LLEnvironment::toCFR(const LLVector3 vec) const +LLVector3 LLEnvironment::getSunDirection() const { - LLVector4 vec_cfr(vec.mV[1], vec.mV[0], vec.mV[2], 0.0f); - return vec_cfr; + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + if (!psky) + { + return LLVector3(0, 0, 1); + } + return psky->getSunDirection(); } -LLVector4 LLEnvironment::toLightNorm(const LLVector3 vec) const +LLVector3 LLEnvironment::getMoonDirection() const { - LLVector4 vec_ogl(vec.mV[1], vec.mV[2], vec.mV[0], 0.0f); - return vec_ogl; + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + if (!psky) + { + return LLVector3(0, 0, -1); + } + return psky->getMoonDirection(); } LLVector4 LLEnvironment::getLightDirectionCFR() const @@ -729,6 +749,20 @@ LLVector4 LLEnvironment::getLightDirectionCFR() const return light_direction_cfr; } +LLVector4 LLEnvironment::getSunDirectionCFR() const +{ + LLVector3 light_direction = getSunDirection(); + LLVector4 light_direction_cfr = toCFR(light_direction); + return light_direction_cfr; +} + +LLVector4 LLEnvironment::getMoonDirectionCFR() const +{ + LLVector3 light_direction = getMoonDirection(); + LLVector4 light_direction_cfr = toCFR(light_direction); + return light_direction_cfr; +} + LLVector4 LLEnvironment::getClampedLightNorm() const { LLVector3 light_direction = getLightDirection(); @@ -739,6 +773,26 @@ LLVector4 LLEnvironment::getClampedLightNorm() const return toLightNorm(light_direction); } +LLVector4 LLEnvironment::getClampedSunNorm() const +{ + LLVector3 light_direction = getSunDirection(); + if (light_direction.mV[2] < -0.1f) + { + light_direction.mV[2] = -0.1f; + } + return toLightNorm(light_direction); +} + +LLVector4 LLEnvironment::getClampedMoonNorm() const +{ + LLVector3 light_direction = getMoonDirection(); + if (light_direction.mV[2] < -0.1f) + { + light_direction.mV[2] = -0.1f; + } + return toLightNorm(light_direction); +} + LLVector4 LLEnvironment::getRotatedLightNorm() const { LLVector3 light_direction = getLightDirection(); -- cgit v1.2.3 From 2add1e7abdf536b32bfbfa4b353189782df8cb19 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 12 Jun 2018 12:39:59 -0700 Subject: Time threshold on timer based updates. Editor can replace frame with one from inventory. Extra check on adding a frame type. --- indra/newview/llenvironment.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index a5ee7d0737..632f16c7fa 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -65,6 +65,8 @@ namespace LLTrace::BlockTimerStatHandle FTM_ENVIRONMENT_UPDATE("Update Environment Tick"); LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); + LLSettingsBase::Seconds DEFAULT_UPDATE_THRESHOLD(10.0); + //--------------------------------------------------------------------- inline LLSettingsBase::TrackPosition get_wrapping_distance(LLSettingsBase::TrackPosition begin, LLSettingsBase::TrackPosition end) { @@ -132,13 +134,15 @@ namespace class LLTrackBlenderLoopingTime : public LLSettingsBlenderTimeDelta { public: - LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, LLSettingsBase::Seconds cyclelength, LLSettingsBase::Seconds cycleoffset) : + LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, + LLSettingsBase::Seconds cyclelength, LLSettingsBase::Seconds cycleoffset, LLSettingsBase::Seconds updateThreshold) : LLSettingsBlenderTimeDelta(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t(), LLSettingsBase::Seconds(1.0)), mDay(day), mTrackNo(0), mCycleLength(cyclelength), mCycleOffset(cycleoffset) { + setTimeDeltaThreshold(updateThreshold); // must happen prior to getBoundingEntries call... mTrackNo = selectTrackNumber(trackno); @@ -1556,10 +1560,11 @@ void LLEnvironment::DayInstance::animate() else { mWater = LLSettingsVOWater::buildDefaultWater(); - mBlenderWater = std::make_shared(mWater, mDayCycle, 0, mDayLength, mDayOffset); + mBlenderWater = std::make_shared(mWater, mDayCycle, 0, + mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); } - // sky, initalize to track 1 + // sky, initialize to track 1 LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(1); if (track.empty()) @@ -1570,7 +1575,8 @@ void LLEnvironment::DayInstance::animate() else { mSky = LLSettingsVOSky::buildDefaultSky(); - mBlenderSky = std::make_shared(mSky, mDayCycle, 1, mDayLength, mDayOffset); + mBlenderSky = std::make_shared(mSky, mDayCycle, 1, + mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); mBlenderSky->switchTrack(mSkyTrack, 0.0); } } -- cgit v1.2.3 From 1f9b8f59afceeb8201780b679659f64845dcd7c1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 19 Jun 2018 16:46:12 -0700 Subject: Don't recalculate lighting every frame. Fix altitude transitions. On track switch ignore time threshold on blender. --- indra/newview/llenvironment.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 938cf857ee..e3a030225d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -164,7 +164,7 @@ namespace return; } - mTrackTransitionStart = mTarget->buildDerivedClone(); + LLSettingsBase::ptr_t pstartsetting = mTarget->buildDerivedClone(); mTrackNo = use_trackno; LLSettingsBase::Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE; @@ -177,7 +177,11 @@ namespace LLSettingsBase::BlendFactor blendf = calculateBlend(targetpos, targetspan); pendsetting->blend((*bounds.second).second, blendf); - reset(mTrackTransitionStart, pendsetting, LLEnvironment::TRANSITION_ALTITUDE); +// pstartsetting->setValue(LLSettingsSky::SETTING_AMBIENT, LLColor3(0.0, 1.0, 0.0)); +// pendsetting->setValue(LLSettingsSky::SETTING_AMBIENT, LLColor3(1.0, 0.0, 0.0)); + + setIgnoreTimeDeltaThreshold(true); // for the next span ignore the time delta threshold. + reset(pstartsetting, pendsetting, LLEnvironment::TRANSITION_ALTITUDE); } protected: @@ -185,12 +189,12 @@ namespace { if (trackno == 0) { // We are dealing with the water track. There is only ever one. - return 0; + return trackno; } - for (S32 test = trackno; test == 0; --test) + for (S32 test = trackno; test != 0; --test) { // Find the track below the requested one with data. - LLSettingsDay::CycleTrack_t &track = mDay->getCycleTrack(mTrackNo); + LLSettingsDay::CycleTrack_t &track = mDay->getCycleTrack(test); if (!track.empty()) return test; @@ -226,7 +230,6 @@ namespace S32 mTrackNo; LLSettingsBase::Seconds mCycleLength; LLSettingsBase::Seconds mCycleOffset; - LLSettingsBase::ptr_t mTrackTransitionStart; void onFinishedSpan() { -- cgit v1.2.3 From d25f80181463d373c317835a219903bcdf9b91c8 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 25 Jun 2018 14:44:09 -0700 Subject: Fix cloud scroll adjustment in the editor, pause clouds method, set sun disk UUID to null. --- indra/newview/llenvironment.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e3a030225d..94605dc062 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -258,6 +258,8 @@ const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg //------------------------------------------------------------------------- LLEnvironment::LLEnvironment(): + mCloudScrollDelta(), + mCloudScrollPaused(false), mSelectedSky(), mSelectedWater(), mSelectedDay(), @@ -851,7 +853,7 @@ void LLEnvironment::updateCloudScroll() F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); - if (mCurrentEnvironment->getSky()) + if (mCurrentEnvironment->getSky() && !mCloudScrollPaused) { LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentEnvironment->getSky()->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; mCloudScrollDelta += cloud_delta; -- cgit v1.2.3 From 438d97714778ebb8728f0ac3808f0b8f98afc1fa Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 25 Jun 2018 16:02:51 -0700 Subject: Adding pause clouds to menu, and throttling expensive visual update on change. --- indra/newview/llenvironment.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 94605dc062..ee5eec59a3 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -66,6 +66,7 @@ namespace LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); LLSettingsBase::Seconds DEFAULT_UPDATE_THRESHOLD(10.0); + const LLSettingsBase::Seconds MINIMUM_SPANLENGTH(0.01f); //--------------------------------------------------------------------- inline LLSettingsBase::TrackPosition get_wrapping_distance(LLSettingsBase::TrackPosition begin, LLSettingsBase::TrackPosition end) @@ -221,7 +222,8 @@ namespace LLSettingsBase::Seconds getSpanTime(const LLSettingsDay::TrackBound_t &bounds) const { LLSettingsBase::Seconds span = mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); - llassert(span > 0.01f); + if (span < MINIMUM_SPANLENGTH) // for very short spans set a minimum length. + span = MINIMUM_SPANLENGTH; return span; } -- cgit v1.2.3 From 294793b9a983a0c26c0e82bd432d4cc311ecb1ba Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 10 Jul 2018 15:15:47 -0700 Subject: MAINT-8821: Tighten up floater. Allow apply from gear menu. --- indra/newview/llenvironment.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index ee5eec59a3..289d0c5388 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -366,9 +366,9 @@ bool LLEnvironment::canAgentUpdateParcelEnvironment(bool useselected) const { if (!LLEnvironment::instance().isExtendedEnvironmentEnabled()) return false; - // *TODO* - //LLParcel* parcel = (useselected) ? LLViewerParcelMgr::instance().getParcelSelection() : LLViewerParcelMgr::instance().getAgentParcel(); - LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + + LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); + if (parcel) { return parcel->allowTerraformBy(gAgent.getID()); -- cgit v1.2.3 From 939174416453a46a4a415f37ae642e5508c05787 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 16 Jul 2018 16:49:49 -0700 Subject: Add default and wellknown asset ids. --- indra/newview/llenvironment.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 289d0c5388..f4dedbc848 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -58,7 +58,6 @@ #include "llatmosphere.h" -//define EXPORT_PRESETS 1 //========================================================================= namespace { @@ -250,11 +249,10 @@ const F32Seconds LLEnvironment::TRANSITION_DEFAULT(5.0f); const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F32Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); -//*TODO* Change these when available on Agni (these are Damballah asset IDs). -const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("645d7475-19d6-d05c-6eb2-29eeacf76e06"); -const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("68f5a7ec-2785-d9d8-be7c-cca93976759a"); -const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("06420773-757b-4b7c-a1f9-85fceb2f7bd4"); -const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("c13658f3-91b8-d559-3a12-b11ce3940c4c"); +const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("4204c687-f9e4-4893-8c1b-46761c0d2021"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("07589e0e-8e2e-4864-8e58-07b516efd9c3"); +const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("8113ba47-3223-46ba-bae6-12c875091b32"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("90187088-d7f3-4656-8c27-8ba0e19e21e9"); const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg -- cgit v1.2.3 From b50d546d5ffb520228926ff1f4e6b03c69b3f857 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 3 Aug 2018 16:13:22 -0700 Subject: MAINT-7699: More robust cap protocol, better support for delete and support for individual tracks, support for setting environment by asset id in the cap MAINT-7703: Initial flags sent in message protocol for parcels --- indra/newview/llenvironment.cpp | 183 ++++++++++++++++++++++++---------------- 1 file changed, 112 insertions(+), 71 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index f4dedbc848..3bcdf345f1 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -61,6 +61,18 @@ //========================================================================= namespace { + const std::string KEY_ENVIRONMENT("environment"); + const std::string KEY_DAYASSET("day_asset"); + const std::string KEY_DAYCYCLE("day_cycle"); + const std::string KEY_DAYHASH("day_hash"); + const std::string KEY_DAYLENGTH("day_length"); + const std::string KEY_DAYOFFSET("day_offset"); + const std::string KEY_ISDEFAULT("is_default"); + const std::string KEY_PARCELID("parcel_id"); + const std::string KEY_REGIONID("region_id"); + const std::string KEY_TRACKALTS("track_altitudes"); + + //--------------------------------------------------------------------- LLTrace::BlockTimerStatHandle FTM_ENVIRONMENT_UPDATE("Update Environment Tick"); LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); @@ -254,6 +266,8 @@ const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("07589e0e-8e2e-4864-8e58-07b516efd9 const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("8113ba47-3223-46ba-bae6-12c875091b32"); const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("90187088-d7f3-4656-8c27-8ba0e19e21e9"); +const S32 LLEnvironment::NO_TRACK(-1); + const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg //------------------------------------------------------------------------- @@ -269,6 +283,7 @@ LLEnvironment::LLEnvironment(): { } +#pragma optimize ("", off) void LLEnvironment::initSingleton() { LLSettingsSky::ptr_t p_default_sky = LLSettingsVOSky::buildDefaultSky(); @@ -280,16 +295,17 @@ void LLEnvironment::initSingleton() mEnvironments[ENV_DEFAULT] = mCurrentEnvironment; - requestRegionEnvironment(); + requestRegion(); - LLRegionInfoModel::instance().setUpdateCallback([this]() { onParcelChange(); }); gAgent.addParcelChangedCallback([this]() { onParcelChange(); }); //TODO: This frequently results in one more request than we need. It isn't breaking, but should be nicer. - gAgent.addRegionChangedCallback([this]() { requestRegionEnvironment(); }); + LLRegionInfoModel::instance().setUpdateCallback([this]() { requestRegion(); }); + gAgent.addRegionChangedCallback([this]() { requestRegion(); }); gAgent.whenPositionChanged([this](const LLVector3 &localpos, const LLVector3d &) { onAgentPositionHasChanged(localpos); }); } +#pragma optimize ("", on) LLEnvironment::~LLEnvironment() { @@ -391,6 +407,7 @@ bool LLEnvironment::isInventoryEnabled() const !gAgent.getRegionCapability("UpdateSettingsTaskInventory").empty()); } +#pragma optimize ("", off) void LLEnvironment::onParcelChange() { S32 parcel_id(INVALID_PARCEL_ID); @@ -403,11 +420,7 @@ void LLEnvironment::onParcelChange() requestParcel(parcel_id); } - -void LLEnvironment::requestRegionEnvironment() -{ - requestRegion(); -} +#pragma optimize ("", on) void LLEnvironment::onLegacyRegionSettings(LLSD data) { @@ -950,22 +963,10 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo) { - LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; - - LLSettingsDay::ptr_t pday = LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData); - - LL_WARNS("ENVIRONMENT") << "serverhash=" << envinfo->mDayHash << " viewerhash=" << pday->getHash() << LL_ENDL; - if (envinfo->mParcelId == INVALID_PARCEL_ID) { // the returned info applies to an entire region. LL_WARNS("LAPRAS") << "Setting Region environment" << LL_ENDL; - setEnvironment(ENV_REGION, pday, envinfo->mDayLength, envinfo->mDayOffset); - if (parcel_id != INVALID_PARCEL_ID) - { - LL_WARNS("LAPRAS") << "Had requested parcel environment #" << parcel_id << " but got region." << LL_ENDL; - clearEnvironment(ENV_PARCEL); - } - + setEnvironment(ENV_REGION, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset); mTrackAltitudes = envinfo->mAltitudes; LL_WARNS("LAPRAS") << "Altitudes set to {" << mTrackAltitudes[0] << ", "<< mTrackAltitudes[1] << ", " << mTrackAltitudes[2] << ", " << mTrackAltitudes[3] << LL_ENDL; @@ -973,7 +974,6 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI else { LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); - LL_WARNS("LAPRAS") << "Have parcel environment #" << envinfo->mParcelId << LL_ENDL; if (parcel && (parcel->getLocalID() != parcel_id)) { @@ -981,23 +981,33 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI return; } - setEnvironment(ENV_PARCEL, pday, envinfo->mDayLength, envinfo->mDayOffset); + if (!envinfo->mDayCycle) + { + LL_WARNS("LAPRAS") << "Clearing environment on parcel #" << parcel_id << LL_ENDL; + clearEnvironment(ENV_PARCEL); + } + else + { + setEnvironment(ENV_PARCEL, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset); + } } updateEnvironment(); } //========================================================================= +#pragma optimize ("", off) void LLEnvironment::requestRegion() { if (!isExtendedEnvironmentEnabled()) - { + { /*TODO: When EEP is live on the entire grid, this can go away. */ LLEnvironmentRequest::initiate(); return; } requestParcel(INVALID_PARCEL_ID); } +#pragma optimize ("", on) void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { @@ -1048,8 +1058,14 @@ void LLEnvironment::requestParcel(S32 parcel_id) void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset) { - LLSettingsVOBase::getSettingsAsset(asset_id, - [this, parcel_id, day_length, day_offset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onUpdateParcelAssetLoaded(asset_id, settings, status, parcel_id, day_length, day_offset); }); + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", + [this, parcel_id, asset_id, day_length, day_offset]() { coroUpdateEnvironment(parcel_id, NO_TRACK, + LLSettingsDay::ptr_t(), asset_id, day_length, day_offset, environment_apply_fn()); }); +// [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }); }); + +// LLSettingsVOBase::getSettingsAsset(asset_id, +// [this, parcel_id, day_length, day_offset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onUpdateParcelAssetLoaded(asset_id, settings, status, parcel_id, day_length, day_offset); }); } void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset) @@ -1096,17 +1112,19 @@ void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", - boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, - pday, day_length, day_offset, - [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); })); + [this, parcel_id, pday, day_length, day_offset]() { coroUpdateEnvironment(parcel_id, NO_TRACK, + pday, LLUUID::null, day_length, day_offset, environment_apply_fn()); }); +// [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }); }); } + + void LLEnvironment::resetParcel(S32 parcel_id) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", - boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id, - [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); })); + [this, parcel_id]() { coroResetEnvironment(parcel_id, NO_TRACK, environment_apply_fn()); }); +// [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }); }); } void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environment_apply_fn apply) @@ -1151,7 +1169,7 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ } else { - LLSD environment = result["environment"]; + LLSD environment = result[KEY_ENVIRONMENT]; if (environment.isDefined() && apply) { EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); @@ -1166,7 +1184,7 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ } } -void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, LLEnvironment::environment_apply_fn apply) +void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, LLSettingsDay::ptr_t pday, LLUUID settings_asset, S32 day_length, S32 day_offset, LLEnvironment::environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1192,22 +1210,39 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd } LLSD body(LLSD::emptyMap()); - body["environment"] = LLSD::emptyMap(); + body[KEY_ENVIRONMENT] = LLSD::emptyMap(); - if (day_length >= 0) - body["environment"]["day_length"] = day_length; - if (day_offset >= 0) - body["environment"]["day_offset"] = day_offset; + if (track_no == NO_TRACK) + { // day length and offset are only applicable if we are addressing the entire day cycle. + if (day_length >= 0) + body[KEY_ENVIRONMENT][KEY_DAYLENGTH] = day_length; + if (day_offset >= 0) + body[KEY_ENVIRONMENT][KEY_DAYOFFSET] = day_offset; + } if (pday) - body["environment"]["day_cycle"] = pday->getSettings(); + body[KEY_ENVIRONMENT][KEY_DAYCYCLE] = pday->getSettings(); + else if (!settings_asset.isNull()) + body[KEY_ENVIRONMENT][KEY_DAYASSET] = settings_asset; + LL_WARNS("LAPRAS") << "Body = " << body << LL_ENDL; - if (parcel_id != INVALID_PARCEL_ID) + if ((parcel_id != INVALID_PARCEL_ID) || (track_no != NO_TRACK)) { std::stringstream query; + query << "?"; - query << "?parcelid=" << parcel_id; + if (parcel_id != INVALID_PARCEL_ID) + { + query << "parcelid=" << parcel_id; + + if (track_no != NO_TRACK) + query << "&"; + } + if (track_no != NO_TRACK) + { + query << "trackno=" << track_no; + } url += query.str(); } @@ -1228,7 +1263,7 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd } else { - LLSD environment = result["environment"]; + LLSD environment = result[KEY_ENVIRONMENT]; if (environment.isDefined() && apply) { EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); @@ -1243,7 +1278,7 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd } } -void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn apply) +void LLEnvironment::coroResetEnvironment(S32 parcel_id, S32 track_no, environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1254,11 +1289,22 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn app if (url.empty()) return; - if (parcel_id != INVALID_PARCEL_ID) + if ((parcel_id != INVALID_PARCEL_ID) || (track_no != NO_TRACK)) { std::stringstream query; + query << "?"; - query << "?parcelid=" << parcel_id; + if (parcel_id != INVALID_PARCEL_ID) + { + query << "parcelid=" << parcel_id; + + if (track_no != NO_TRACK) + query << "&"; + } + if (track_no != NO_TRACK) + { + query << "trackno=" << track_no; + } url += query.str(); } @@ -1279,7 +1325,7 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn app } else { - LLSD environment = result["environment"]; + LLSD environment = result[KEY_ENVIRONMENT]; if (environment.isDefined() && apply) { EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); @@ -1339,10 +1385,9 @@ LLEnvironment::EnvironmentInfo::EnvironmentInfo(): mDayLength(0), mDayOffset(0), mDayHash(0), - mDaycycleData(), + mDayCycle(), mAltitudes({ { 0.0, 0.0, 0.0, 0.0 } }), - mIsDefault(false), - mIsRegion(false) + mIsDefault(false) { } @@ -1350,32 +1395,28 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL { ptr_t pinfo = std::make_shared(); - if (environment.has("parcel_id")) - pinfo->mParcelId = environment["parcel_id"].asInteger(); - if (environment.has("region_id")) - pinfo->mRegionId = environment["region_id"].asUUID(); - if (environment.has("day_length")) - pinfo->mDayLength = LLSettingsDay::Seconds(environment["day_length"].asInteger()); - if (environment.has("day_offset")) - pinfo->mDayOffset = LLSettingsDay::Seconds(environment["day_offset"].asInteger()); - if (environment.has("day_hash")) - pinfo->mDayHash = environment["day_hash"].asInteger(); - if (environment.has("day_cycle")) - pinfo->mDaycycleData = environment["day_cycle"]; - if (environment.has("is_default")) - pinfo->mIsDefault = environment["is_default"].asBoolean(); - if (environment.has("track_altitudes")) - { - LL_WARNS("LAPRAS") << "track_altitudes=" << environment["track_altitudes"] << LL_ENDL; - - /*LAPRAS: TODO: Fix the simulator message. Shouldn't be 5, just 4*/ - int idx = 1; - for (F32 &altitude : pinfo->mAltitudes) + pinfo->mIsDefault = environment.has(KEY_ISDEFAULT) ? environment[KEY_ISDEFAULT].asBoolean() : true; + pinfo->mParcelId = environment.has(KEY_PARCELID) ? environment[KEY_PARCELID].asInteger() : INVALID_PARCEL_ID; + pinfo->mRegionId = environment.has(KEY_REGIONID) ? environment[KEY_REGIONID].asUUID() : LLUUID::null; + + if (environment.has(KEY_TRACKALTS)) + { + for (int idx = 0; idx < 3; idx++) { - altitude = environment["track_altitudes"][idx++].asReal(); + pinfo->mAltitudes[idx+1] = environment[KEY_TRACKALTS][idx].asReal(); } + pinfo->mAltitudes[0] = 0; + } + + if (environment.has(KEY_DAYCYCLE)) + { + pinfo->mDayCycle = LLSettingsVODay::buildFromEnvironmentMessage(environment[KEY_DAYCYCLE]); + pinfo->mDayLength = LLSettingsDay::Seconds(environment.has(KEY_DAYLENGTH) ? environment[KEY_DAYLENGTH].asInteger() : -1); + pinfo->mDayOffset = LLSettingsDay::Seconds(environment.has(KEY_DAYOFFSET) ? environment[KEY_DAYOFFSET].asInteger() : -1); + pinfo->mDayHash = environment.has(KEY_DAYHASH) ? environment[KEY_DAYHASH].asInteger() : 0; } + return pinfo; } -- cgit v1.2.3 From 7e8c849a155eb7de73a324cb3d7195502ff1f574 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 3 Aug 2018 16:57:04 -0700 Subject: Fix name change from clearTrack to clealCycleTrack --- indra/newview/llenvironment.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3bcdf345f1..b73b8cb278 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1479,12 +1479,12 @@ LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromEnvironment(EnvSelection_t if (type == "sky") { for (S32 idx = 1; idx < LLSettingsDay::TRACK_MAX; ++idx) - day->clearTrack(idx); + day->clearCycleTrack(idx); day->setSettingsAtKeyframe(settings, 0.0f, 1); } else if (type == "water") { - day->clearTrack(LLSettingsDay::TRACK_WATER); + day->clearCycleTrack(LLSettingsDay::TRACK_WATER); day->setSettingsAtKeyframe(settings, 0.0f, LLSettingsDay::TRACK_WATER); } -- cgit v1.2.3 From 76206db45e7966657ce757d74a9ebad991b61ff1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 3 Aug 2018 22:21:43 -0700 Subject: remove some pragmas that snuck in --- indra/newview/llenvironment.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index b73b8cb278..8f6a94962f 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -283,7 +283,6 @@ LLEnvironment::LLEnvironment(): { } -#pragma optimize ("", off) void LLEnvironment::initSingleton() { LLSettingsSky::ptr_t p_default_sky = LLSettingsVOSky::buildDefaultSky(); @@ -305,7 +304,6 @@ void LLEnvironment::initSingleton() gAgent.whenPositionChanged([this](const LLVector3 &localpos, const LLVector3d &) { onAgentPositionHasChanged(localpos); }); } -#pragma optimize ("", on) LLEnvironment::~LLEnvironment() { @@ -407,7 +405,6 @@ bool LLEnvironment::isInventoryEnabled() const !gAgent.getRegionCapability("UpdateSettingsTaskInventory").empty()); } -#pragma optimize ("", off) void LLEnvironment::onParcelChange() { S32 parcel_id(INVALID_PARCEL_ID); @@ -420,7 +417,6 @@ void LLEnvironment::onParcelChange() requestParcel(parcel_id); } -#pragma optimize ("", on) void LLEnvironment::onLegacyRegionSettings(LLSD data) { @@ -996,7 +992,6 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI } //========================================================================= -#pragma optimize ("", off) void LLEnvironment::requestRegion() { if (!isExtendedEnvironmentEnabled()) @@ -1007,7 +1002,6 @@ void LLEnvironment::requestRegion() requestParcel(INVALID_PARCEL_ID); } -#pragma optimize ("", on) void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { -- cgit v1.2.3 From 881ee670d92f13ac518a74e1bff81bf69e07ccfa Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Aug 2018 15:41:28 -0700 Subject: Fix for mac build MAINT-8870, MAINT-8871: When legacy windlight fails load the default day cycle asset and use that. --- indra/newview/llenvironment.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 8f6a94962f..b2bd20d809 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -423,13 +423,17 @@ void LLEnvironment::onLegacyRegionSettings(LLSD data) LLUUID regionId = data[0]["regionID"].asUUID(); LLSettingsDay::ptr_t regionday; - if (data[1].isUndefined()) - regionday = LLSettingsVODay::buildDefaultDayCycle(); - else + if (!data[1].isUndefined()) regionday = LLSettingsVODay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); clearEnvironment(ENV_PARCEL); - setEnvironment(ENV_REGION, regionday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); + if (!regionday) + { + LL_WARNS("ENVIRONMENT") << "Unable to create day from legacy. Using default day cycle." << LL_ENDL; + setEnvironment(LLEnvironment::ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); + } + else + setEnvironment(ENV_REGION, regionday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); updateEnvironment(); } @@ -570,12 +574,17 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId) { - LLSettingsVOBase::getSettingsAsset(assetId, - [this, env](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onSetEnvAssetLoaded(env, asset_id, settings, status); }); + setEnvironment(env, assetId, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); +} + +void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) +{ + LLSettingsVOBase::getSettingsAsset(assetId, + [this, env, daylength, dayoffset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onSetEnvAssetLoaded(env, asset_id, settings, daylength, dayoffset, status); }); } -void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) +void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset, S32 status) { if (!settings || status) { -- cgit v1.2.3 From eadf0b910174274e7c83fe37e417f576a7350edb Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 15 Aug 2018 13:35:53 -0700 Subject: MAINT-8990, MAINT-9002: First pass rework on environment panels, region/parcel --- indra/newview/llenvironment.cpp | 55 +++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 19 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index b2bd20d809..66063564c0 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -57,6 +57,8 @@ #include #include "llatmosphere.h" +#include "llagent.h" +#include "roles_constants.h" //========================================================================= namespace @@ -374,23 +376,33 @@ void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settin } } -bool LLEnvironment::canAgentUpdateParcelEnvironment(bool useselected) const +bool LLEnvironment::canAgentUpdateParcelEnvironment() const { - if (!LLEnvironment::instance().isExtendedEnvironmentEnabled()) + LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); + + return canAgentUpdateParcelEnvironment(parcel); +} + + +bool LLEnvironment::canAgentUpdateParcelEnvironment(LLParcel *parcel) const +{ + if (!parcel) return false; - LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); + if (!LLEnvironment::instance().isExtendedEnvironmentEnabled()) + return false; - if (parcel) - { - return parcel->allowTerraformBy(gAgent.getID()); - } + if (gAgent.isGodlike()) + return true; - return false; + return LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_OPTIONS); } bool LLEnvironment::canAgentUpdateRegionEnvironment() const { + if (gAgent.isGodlike()) + return true; + return gAgent.getRegion()->canManageEstate(); } @@ -595,6 +607,7 @@ void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLS } setEnvironment(env, settings); + updateEnvironment(); } void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) @@ -1001,7 +1014,7 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI } //========================================================================= -void LLEnvironment::requestRegion() +void LLEnvironment::requestRegion(environment_apply_fn cb) { if (!isExtendedEnvironmentEnabled()) { /*TODO: When EEP is live on the entire grid, this can go away. */ @@ -1009,7 +1022,7 @@ void LLEnvironment::requestRegion() return; } - requestParcel(INVALID_PARCEL_ID); + requestParcel(INVALID_PARCEL_ID, cb); } void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) @@ -1051,12 +1064,16 @@ void LLEnvironment::resetRegion() resetParcel(INVALID_PARCEL_ID); } -void LLEnvironment::requestParcel(S32 parcel_id) +void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) { + if (!cb) + { + cb = [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }; + } + std::string coroname = LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", - boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, - [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); })); + [this, parcel_id, cb]() { coroRequestEnvironment(parcel_id, cb); }); } void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset) @@ -1065,10 +1082,6 @@ void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_ LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", [this, parcel_id, asset_id, day_length, day_offset]() { coroUpdateEnvironment(parcel_id, NO_TRACK, LLSettingsDay::ptr_t(), asset_id, day_length, day_offset, environment_apply_fn()); }); -// [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }); }); - -// LLSettingsVOBase::getSettingsAsset(asset_id, -// [this, parcel_id, day_length, day_offset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onUpdateParcelAssetLoaded(asset_id, settings, status, parcel_id, day_length, day_offset); }); } void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset) @@ -1117,7 +1130,6 @@ void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", [this, parcel_id, pday, day_length, day_offset]() { coroUpdateEnvironment(parcel_id, NO_TRACK, pday, LLUUID::null, day_length, day_offset, environment_apply_fn()); }); -// [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }); }); } @@ -1127,7 +1139,6 @@ void LLEnvironment::resetParcel(S32 parcel_id) std::string coroname = LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", [this, parcel_id]() { coroResetEnvironment(parcel_id, NO_TRACK, environment_apply_fn()); }); -// [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }); }); } void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environment_apply_fn apply) @@ -1419,6 +1430,12 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL pinfo->mDayHash = environment.has(KEY_DAYHASH) ? environment[KEY_DAYHASH].asInteger() : 0; } + if (environment.has(KEY_DAYASSET)) + { + pinfo->mAssetId = environment[KEY_DAYASSET].asUUID(); + LL_WARNS("LAPRAS") << "Environment asset ID is " << pinfo->mAssetId << LL_ENDL; + LL_WARNS("LAPRAS") << "(day cycle claims " << pinfo->mDayCycle->getAssetId() << ")" << LL_ENDL; + } return pinfo; } -- cgit v1.2.3 From 68158f0340729d9f7e5a4b3e64bfc154a105ab6c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 16 Aug 2018 09:43:54 -0700 Subject: Pass call backs into parcel and region change methods. --- indra/newview/llenvironment.cpp | 44 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 66063564c0..98fe593aeb 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1025,7 +1025,7 @@ void LLEnvironment::requestRegion(environment_apply_fn cb) requestParcel(INVALID_PARCEL_ID, cb); } -void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, environment_apply_fn cb) { if (!isExtendedEnvironmentEnabled()) { @@ -1033,10 +1033,10 @@ void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_lengt return; } - updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset); + updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset, cb); } -void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset, environment_apply_fn cb) { if (!isExtendedEnvironmentEnabled()) { @@ -1045,23 +1045,23 @@ void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day return; } - updateParcel(INVALID_PARCEL_ID, asset_id, day_length, day_offset); + updateParcel(INVALID_PARCEL_ID, asset_id, day_length, day_offset, cb); } -void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, environment_apply_fn cb) { - updateParcel(INVALID_PARCEL_ID, psky, day_length, day_offset); + updateParcel(INVALID_PARCEL_ID, psky, day_length, day_offset, cb); } -void LLEnvironment::updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, environment_apply_fn cb) { - updateParcel(INVALID_PARCEL_ID, pwater, day_length, day_offset); + updateParcel(INVALID_PARCEL_ID, pwater, day_length, day_offset, cb); } -void LLEnvironment::resetRegion() +void LLEnvironment::resetRegion(environment_apply_fn cb) { - resetParcel(INVALID_PARCEL_ID); + resetParcel(INVALID_PARCEL_ID, cb); } void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) @@ -1076,12 +1076,12 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) [this, parcel_id, cb]() { coroRequestEnvironment(parcel_id, cb); }); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset, environment_apply_fn cb) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", - [this, parcel_id, asset_id, day_length, day_offset]() { coroUpdateEnvironment(parcel_id, NO_TRACK, - LLSettingsDay::ptr_t(), asset_id, day_length, day_offset, environment_apply_fn()); }); + [this, parcel_id, asset_id, day_length, day_offset, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, + LLSettingsDay::ptr_t(), asset_id, day_length, day_offset, cb); }); } void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset) @@ -1112,33 +1112,33 @@ void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::p updateParcel(parcel_id, pday, day_length, day_offset); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, environment_apply_fn cb) { LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, psky); - updateParcel(parcel_id, pday, day_length, day_offset); + updateParcel(parcel_id, pday, day_length, day_offset, cb); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, environment_apply_fn cb) { LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, pwater); - updateParcel(parcel_id, pday, day_length, day_offset); + updateParcel(parcel_id, pday, day_length, day_offset, cb); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, environment_apply_fn cb) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", - [this, parcel_id, pday, day_length, day_offset]() { coroUpdateEnvironment(parcel_id, NO_TRACK, - pday, LLUUID::null, day_length, day_offset, environment_apply_fn()); }); + [this, parcel_id, pday, day_length, day_offset, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, + pday, LLUUID::null, day_length, day_offset, cb); }); } -void LLEnvironment::resetParcel(S32 parcel_id) +void LLEnvironment::resetParcel(S32 parcel_id, environment_apply_fn cb) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", - [this, parcel_id]() { coroResetEnvironment(parcel_id, NO_TRACK, environment_apply_fn()); }); + [this, parcel_id, cb]() { coroResetEnvironment(parcel_id, NO_TRACK, cb); }); } void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environment_apply_fn apply) -- cgit v1.2.3 From 7f25bef9c4bd5bf277331040711f13eb69b9c6d1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 16 Aug 2018 16:27:53 -0700 Subject: MAINT-7703: Estate level switch turns of parcel environments. --- indra/newview/llenvironment.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 98fe593aeb..f33e5b864a 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -59,6 +59,7 @@ #include "llatmosphere.h" #include "llagent.h" #include "roles_constants.h" +#include "llestateinfomodel.h" //========================================================================= namespace @@ -395,6 +396,9 @@ bool LLEnvironment::canAgentUpdateParcelEnvironment(LLParcel *parcel) const if (gAgent.isGodlike()) return true; + if (!LLEstateInfoModel::instance().getAllowEnvironmentOverride()) + return false; + return LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_OPTIONS); } -- cgit v1.2.3 From 1716129fd23ff35e030808406af1a8f796dc4b01 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 17 Aug 2018 12:35:42 -0700 Subject: MAINT-8826, MAINT-8990, MAINT-9002, MAINT-7703: Rework for environment pannels in Region/Estate and Parcel. Enable/disable by permission. Edit the correct environment. Dirty flags for changes. Estate owner disallow switch. --- indra/newview/llenvironment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index f33e5b864a..60e5b81f15 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -396,7 +396,7 @@ bool LLEnvironment::canAgentUpdateParcelEnvironment(LLParcel *parcel) const if (gAgent.isGodlike()) return true; - if (!LLEstateInfoModel::instance().getAllowEnvironmentOverride()) + if (!parcel->getRegionAllowEnvironmentOverride()) return false; return LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_OPTIONS); -- cgit v1.2.3 From 1e3ee272ae811b862a529b6f3bbebb50a0c22580 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 17 Aug 2018 15:37:10 -0700 Subject: Add an apparent time of day. More OSX complaints. --- indra/newview/llenvironment.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 60e5b81f15..84e915a95d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -192,9 +192,6 @@ namespace LLSettingsBase::BlendFactor blendf = calculateBlend(targetpos, targetspan); pendsetting->blend((*bounds.second).second, blendf); -// pstartsetting->setValue(LLSettingsSky::SETTING_AMBIENT, LLColor3(0.0, 1.0, 0.0)); -// pendsetting->setValue(LLSettingsSky::SETTING_AMBIENT, LLColor3(1.0, 0.0, 0.0)); - setIgnoreTimeDeltaThreshold(true); // for the next span ignore the time delta threshold. reset(pstartsetting, pendsetting, LLEnvironment::TRANSITION_ALTITUDE); } -- cgit v1.2.3 From 8fc3956a5eeaa2dffabdcda60800d9c4d4e49c43 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 20 Aug 2018 14:59:02 -0700 Subject: Use the EnvironmentInfo structure to pass information back from legacy environment requests. --- indra/newview/llenvironment.cpp | 91 +++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 36 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 84e915a95d..4f7ffe0724 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -431,26 +431,6 @@ void LLEnvironment::onParcelChange() requestParcel(parcel_id); } -void LLEnvironment::onLegacyRegionSettings(LLSD data) -{ - LLUUID regionId = data[0]["regionID"].asUUID(); - - LLSettingsDay::ptr_t regionday; - if (!data[1].isUndefined()) - regionday = LLSettingsVODay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); - - clearEnvironment(ENV_PARCEL); - if (!regionday) - { - LL_WARNS("ENVIRONMENT") << "Unable to create day from legacy. Using default day cycle." << LL_ENDL; - setEnvironment(LLEnvironment::ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); - } - else - setEnvironment(ENV_REGION, regionday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); - - updateEnvironment(); -} - //------------------------------------------------------------------------- F32 LLEnvironment::getCamHeight() const { @@ -1017,23 +997,11 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI //========================================================================= void LLEnvironment::requestRegion(environment_apply_fn cb) { - if (!isExtendedEnvironmentEnabled()) - { /*TODO: When EEP is live on the entire grid, this can go away. */ - LLEnvironmentRequest::initiate(); - return; - } - requestParcel(INVALID_PARCEL_ID, cb); } void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, environment_apply_fn cb) { - if (!isExtendedEnvironmentEnabled()) - { - LLEnvironmentApply::initiateRequest( LLSettingsVODay::convertToLegacy(pday) ); - return; - } - updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset, cb); } @@ -1067,6 +1035,27 @@ void LLEnvironment::resetRegion(environment_apply_fn cb) void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) { + if (!isExtendedEnvironmentEnabled()) + { /*TODO: When EEP is live on the entire grid, this can go away. */ + if (!cb) + { + cb = [this](S32 pid, EnvironmentInfo::ptr_t envinfo) + { + if (envinfo->mDayCycle) recordEnvironment(pid, envinfo); + else + { + clearEnvironment(ENV_PARCEL); + setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); + updateEnvironment(); + } + }; + } + + if (parcel_id == INVALID_PARCEL_ID) + LLEnvironmentRequest::initiate(cb); + return; + } + if (!cb) { cb = [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }; @@ -1358,7 +1347,7 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, S32 track_no, environmen //========================================================================= -LLEnvironment::UserPrefs::UserPrefs(): +LLEnvironment::UserPrefs::UserPrefs() : mUseRegionSettings(true), mUseDayCycle(true), mPersistEnvironment(false), @@ -1402,7 +1391,8 @@ LLEnvironment::EnvironmentInfo::EnvironmentInfo(): mDayHash(0), mDayCycle(), mAltitudes({ { 0.0, 0.0, 0.0, 0.0 } }), - mIsDefault(false) + mIsDefault(false), + mIsLegacy(false) { } @@ -1413,6 +1403,7 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL pinfo->mIsDefault = environment.has(KEY_ISDEFAULT) ? environment[KEY_ISDEFAULT].asBoolean() : true; pinfo->mParcelId = environment.has(KEY_PARCELID) ? environment[KEY_PARCELID].asInteger() : INVALID_PARCEL_ID; pinfo->mRegionId = environment.has(KEY_REGIONID) ? environment[KEY_REGIONID].asUUID() : LLUUID::null; + pinfo->mIsLegacy = false; if (environment.has(KEY_TRACKALTS)) { @@ -1434,13 +1425,41 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL if (environment.has(KEY_DAYASSET)) { pinfo->mAssetId = environment[KEY_DAYASSET].asUUID(); - LL_WARNS("LAPRAS") << "Environment asset ID is " << pinfo->mAssetId << LL_ENDL; - LL_WARNS("LAPRAS") << "(day cycle claims " << pinfo->mDayCycle->getAssetId() << ")" << LL_ENDL; } return pinfo; } + +LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extractLegacy(LLSD legacy) +{ + if (!legacy.isArray() || !legacy[0].has("regionID")) + { + LL_WARNS("ENVIRONMENT") << "Invalid legacy settings for environment: " << legacy << LL_ENDL; + return ptr_t(); + } + + ptr_t pinfo = std::make_shared(); + + pinfo->mIsDefault = false; + pinfo->mParcelId = INVALID_PARCEL_ID; + pinfo->mRegionId = legacy[0]["regionID"].asUUID(); + pinfo->mIsLegacy = true; + + pinfo->mDayLength = LLSettingsDay::DEFAULT_DAYLENGTH; + pinfo->mDayOffset = LLSettingsDay::DEFAULT_DAYOFFSET; + pinfo->mDayCycle = LLSettingsVODay::buildFromLegacyMessage(pinfo->mRegionId, legacy[1], legacy[2], legacy[3]); + if (pinfo->mDayCycle) + pinfo->mDayHash = pinfo->mDayCycle->getHash(); + + pinfo->mAltitudes[0] = 0; + pinfo->mAltitudes[2] = 10001; + pinfo->mAltitudes[3] = 10002; + pinfo->mAltitudes[4] = 10003; + + return pinfo; +} + //========================================================================= LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename) { -- cgit v1.2.3 From b2b3c36bda988be4b433e9f97f13bc1c67722eb7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 20 Aug 2018 16:26:54 -0700 Subject: Didn't get a fix from last week, and divide by zeros are bad. --- indra/newview/llenvironment.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 4f7ffe0724..be0c763e25 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1421,6 +1421,11 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL pinfo->mDayOffset = LLSettingsDay::Seconds(environment.has(KEY_DAYOFFSET) ? environment[KEY_DAYOFFSET].asInteger() : -1); pinfo->mDayHash = environment.has(KEY_DAYHASH) ? environment[KEY_DAYHASH].asInteger() : 0; } + else + { + pinfo->mDayLength = LLEnvironment::instance().getEnvironmentDayLength(ENV_REGION); + pinfo->mDayOffset = LLEnvironment::instance().getEnvironmentDayOffset(ENV_REGION); + } if (environment.has(KEY_DAYASSET)) { -- cgit v1.2.3 From 477c66c890d5d87318705415315aaf9464bec2ff Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 21 Aug 2018 11:37:59 -0700 Subject: Lest couple nullptr checks and disable the controls on legacy regions. --- indra/newview/llenvironment.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index be0c763e25..8f703d0035 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1037,22 +1037,26 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) { if (!isExtendedEnvironmentEnabled()) { /*TODO: When EEP is live on the entire grid, this can go away. */ - if (!cb) + if (parcel_id == INVALID_PARCEL_ID) { - cb = [this](S32 pid, EnvironmentInfo::ptr_t envinfo) - { - if (envinfo->mDayCycle) recordEnvironment(pid, envinfo); - else + if (!cb) + { + cb = [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { - clearEnvironment(ENV_PARCEL); - setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); - updateEnvironment(); - } - }; - } + if (envinfo->mDayCycle) recordEnvironment(pid, envinfo); + else + { + clearEnvironment(ENV_PARCEL); + setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); + updateEnvironment(); + } + }; + } - if (parcel_id == INVALID_PARCEL_ID) LLEnvironmentRequest::initiate(cb); + } + else if (cb) + cb(parcel_id, EnvironmentInfo::ptr_t()); return; } -- cgit v1.2.3 From 100a58778b6f96513978369820fcf328dcb21226 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 30 Aug 2018 00:16:44 +0100 Subject: MAINT-8944 Fix missed mNextFooTextureId updates when jumping between keyframes by forcing mReplaced when sky is replaced. --- indra/newview/llenvironment.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 8f703d0035..6e19df0a94 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1622,7 +1622,10 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) mType = TYPE_FIXED; mInitialized = false; + bool different_sky = mSky != psky; + mSky = psky; + mSky->mReplaced |= different_sky; mSky->update(); mBlenderSky.reset(); -- cgit v1.2.3 From 3b10414c632e73d66d2840ddcd474a79fa120540 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 31 Aug 2018 11:47:18 -0700 Subject: Adding optional flags to settings objects. --- indra/newview/llenvironment.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 6e19df0a94..3a1aec6319 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -444,11 +444,15 @@ F32 LLEnvironment::getWaterHeight() const bool LLEnvironment::getIsSunUp() const { + if (!mCurrentEnvironment || !mCurrentEnvironment->getSky()) + return false; return mCurrentEnvironment->getSky()->getIsSunUp(); } bool LLEnvironment::getIsMoonUp() const { + if (!mCurrentEnvironment || !mCurrentEnvironment->getSky()) + return false; return mCurrentEnvironment->getSky()->getIsMoonUp(); } -- cgit v1.2.3 From 451ab80ca65a7ae75316442086f42b6553ea6bbe Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 6 Sep 2018 22:50:26 +0100 Subject: Fix tex format mismatch between what libatmosphere was generating and what we were claiming to use in rendering. First pass at sky shader using libatmosphere sky radiance lookup. Add atmo density controls to ext daycycle floater tabs. --- indra/newview/llenvironment.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3a1aec6319..e437003520 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1633,12 +1633,15 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) mSky->update(); mBlenderSky.reset(); +#if 0 if (gAtmosphere) { AtmosphericModelSettings settings; LLEnvironment::getAtmosphericModelSettings(settings, psky); gAtmosphere->configureAtmosphericModel(settings); } +#endif + } void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) -- cgit v1.2.3 From 4bd2b8b98ba1c562dfd65975a87ef5ee3db35633 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 7 Sep 2018 17:24:29 +0100 Subject: Fix createDensityProfileLayer dropping passed in values. Enable sky density panel to update advanced atmo precomputed textures. Take wild stab at appropriate ranges for density parameters in edit panel UI. Clean up debug-only code that isn't necessary anymore. Point autobuild at latest version of libatmosphere package. --- indra/newview/llenvironment.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e437003520..4b60ed4e68 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -358,6 +358,7 @@ void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settin layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); settingsOut.m_mieProfile.push_back(layer); } + settingsOut.m_mieAnisotropy = psky->getMieAnisotropy(); LLSD absorption = psky->getAbsorptionConfigs(); settingsOut.m_absorptionProfile.clear(); @@ -1633,15 +1634,12 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) mSky->update(); mBlenderSky.reset(); -#if 0 if (gAtmosphere) { AtmosphericModelSettings settings; LLEnvironment::getAtmosphericModelSettings(settings, psky); gAtmosphere->configureAtmosphericModel(settings); } -#endif - } void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) -- cgit v1.2.3 From 3988bc8d85e593926c16282d8bd5094060da654b Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 14 Sep 2018 18:27:31 +0300 Subject: SL-9653 EEP Blender abruptly jumps from correct value to initial --- indra/newview/llenvironment.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 4b60ed4e68..6981203e75 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1818,7 +1818,14 @@ LLSettingsBase::BlendFactor LLTrackBlenderLoopingManual::setPosition(const LLSet F64 spanPos = ((mPosition < (*bounds.first).first) ? (mPosition + 1.0) : mPosition) - (*bounds.first).first; - F64 blendf = fmod(spanPos, spanLength) / spanLength; + if (spanPos > spanLength) + { + // we are clamping position to 0-1 and spanLength is 1 + // so don't account for case of spanPos == spanLength + spanPos = fmod(spanPos, spanLength); + } + + F64 blendf = spanPos / spanLength; return LLSettingsBlender::setBlendFactor(blendf); } -- cgit v1.2.3 From 7c6ac0740dac946275ef3f904614688f4b73f850 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 14 Sep 2018 09:52:28 -0700 Subject: SL-1556: Correctly identify when the selected parcel is in another region and display a message about cross region environments. --- indra/newview/llenvironment.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 6981203e75..3b1990c850 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1166,18 +1166,18 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ LLSD result = httpAdapter->getAndSuspend(httpRequest, url); // results that come back may contain the new settings - LLSD notify; +// LLSD notify; LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { - LL_WARNS("WindlightCaps") << "Couldn't retrieve Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; + LL_WARNS("WindlightCaps") << "Couldn't retrieve environment settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; - std::stringstream msg; - msg << status.toString() << " (Code " << status.toTerseString() << ")"; - notify = LLSD::emptyMap(); - notify["FAIL_REASON"] = msg.str(); +// std::stringstream msg; +// msg << status.toString() << " (Code " << status.toTerseString() << ")"; +// notify = LLSD::emptyMap(); +// notify["FAIL_REASON"] = msg.str(); } else @@ -1190,11 +1190,11 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ } } - if (!notify.isUndefined()) - { - LLNotificationsUtil::add("WLRegionApplyFail", notify); - //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); - } +// if (!notify.isUndefined()) +// { +// LLNotificationsUtil::add("WLRegionApplyFail", notify); +// //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); +// } } void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, LLSettingsDay::ptr_t pday, LLUUID settings_asset, S32 day_length, S32 day_offset, LLEnvironment::environment_apply_fn apply) -- cgit v1.2.3 From e53d35f4e8c9e15eda75f960b253481e1447b2b1 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Tue, 18 Sep 2018 17:38:06 +0300 Subject: SL-1258 FIXED [EEP] Custom cloud, sun & moon textures don't update when you apply a Windlight sky locally. --- indra/newview/llenvironment.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3b1990c850..ec2577d053 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1768,6 +1768,8 @@ void LLEnvironment::DayTransition::animate() if (!mBlenderSky && !mBlenderWater) LLEnvironment::instance().mCurrentEnvironment = mNextInstance; + else + setWater(mNextInstance->getWater()); }); mSky = mStartSky->buildClone(); @@ -1778,6 +1780,8 @@ void LLEnvironment::DayTransition::animate() if (!mBlenderSky && !mBlenderWater) LLEnvironment::instance().mCurrentEnvironment = mNextInstance; + else + setSky(mNextInstance->getSky()); }); } -- cgit v1.2.3 From cae08e0096f75827851a8c9447e163ddb0132f2d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 19 Sep 2018 15:31:23 -0700 Subject: SL-9661: Trigger an event when the settings on a parcel or region are changed. Environment panel montiors this event and updates itself when it occurs. --- indra/newview/llenvironment.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index ec2577d053..3d8222a371 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -502,7 +502,9 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe environment->setDay(pday, daylength, dayoffset); environment->setSkyTrack(mCurrentTrack); environment->animate(); - /*TODO: readjust environment*/ + + if (!mSignalEnvChanged.empty()) + mSignalEnvChanged(env); } @@ -519,6 +521,8 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm environment->clear(); environment->setSky((fixed.first) ? fixed.first : mEnvironments[ENV_DEFAULT]->getSky()); environment->setWater((fixed.second) ? fixed.second : mEnvironments[ENV_DEFAULT]->getWater()); + if (!mSignalEnvChanged.empty()) + mSignalEnvChanged(env); /*TODO: readjust environment*/ } @@ -605,6 +609,10 @@ void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) } mEnvironments[env].reset(); + + if (!mSignalEnvChanged.empty()) + mSignalEnvChanged(env); + /*TODO: readjust environment*/ } -- cgit v1.2.3 From 1bd1a101092d890b42eec8c59b97b8f267502356 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 21 Sep 2018 18:33:07 +0300 Subject: SL-1061 EEP prevent invalid settings from getting into environment --- indra/newview/llenvironment.cpp | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3d8222a371..1b38fceef7 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -976,10 +976,28 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo) { if (envinfo->mParcelId == INVALID_PARCEL_ID) - { // the returned info applies to an entire region. - LL_WARNS("LAPRAS") << "Setting Region environment" << LL_ENDL; - setEnvironment(ENV_REGION, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset); - mTrackAltitudes = envinfo->mAltitudes; + { + // the returned info applies to an entire region. + if (!envinfo->mDayCycle) + { + clearEnvironment(ENV_PARCEL); + setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); + updateEnvironment(); + } + else if (envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_WATER) + || envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_GROUND_LEVEL)) + { + LL_WARNS("LAPRAS") << "Invalid day cycle for region" << LL_ENDL; + clearEnvironment(ENV_PARCEL); + setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); + updateEnvironment(); + } + else + { + LL_INFOS("LAPRAS") << "Setting Region environment" << LL_ENDL; + setEnvironment(ENV_REGION, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset); + mTrackAltitudes = envinfo->mAltitudes; + } LL_WARNS("LAPRAS") << "Altitudes set to {" << mTrackAltitudes[0] << ", "<< mTrackAltitudes[1] << ", " << mTrackAltitudes[2] << ", " << mTrackAltitudes[3] << LL_ENDL; } @@ -998,6 +1016,12 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI LL_WARNS("LAPRAS") << "Clearing environment on parcel #" << parcel_id << LL_ENDL; clearEnvironment(ENV_PARCEL); } + else if (envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_WATER) + || envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_GROUND_LEVEL)) + { + LL_WARNS("LAPRAS") << "Invalid day cycle for parcel #" << parcel_id << LL_ENDL; + clearEnvironment(ENV_PARCEL); + } else { setEnvironment(ENV_PARCEL, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset); @@ -1056,13 +1080,7 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) { cb = [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { - if (envinfo->mDayCycle) recordEnvironment(pid, envinfo); - else - { - clearEnvironment(ENV_PARCEL); - setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); - updateEnvironment(); - } + recordEnvironment(pid, envinfo); }; } -- cgit v1.2.3 From 70c18ba14b4ea831c109030b48096d7c1fd5e510 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 24 Sep 2018 14:55:21 -0700 Subject: SL-9736: 0.0 is no motion for cloud scroll. --- indra/newview/llenvironment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 1b38fceef7..5abb1b2e55 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -880,7 +880,7 @@ void LLEnvironment::updateCloudScroll() if (mCurrentEnvironment->getSky() && !mCloudScrollPaused) { - LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentEnvironment->getSky()->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; + LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentEnvironment->getSky()->getCloudScrollRate()) / 100.0; mCloudScrollDelta += cloud_delta; } -- cgit v1.2.3 From 50ec228b02026a4ddc3e108df6a8d7709c713d53 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Mon, 1 Oct 2018 16:45:19 +0300 Subject: SL-9660 EEP Remove residual code (LLFloaterEditDayCycle and LLEnvironment::UserPrefs) --- indra/newview/llenvironment.cpp | 46 ----------------------------------------- 1 file changed, 46 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 5abb1b2e55..994420a139 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -277,7 +277,6 @@ LLEnvironment::LLEnvironment(): mSelectedSky(), mSelectedWater(), mSelectedDay(), - mUserPrefs(), mSelectedEnvironment(LLEnvironment::ENV_LOCAL), mCurrentTrack(1) { @@ -309,16 +308,6 @@ LLEnvironment::~LLEnvironment() { } -void LLEnvironment::loadPreferences() -{ - mUserPrefs.load(); -} - -void LLEnvironment::updatePreferences() -{ - /*NOOP for now. TODO record prefs and store.*/ -} - bool LLEnvironment::canEdit() const { return true; @@ -1382,41 +1371,6 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, S32 track_no, environmen //========================================================================= -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()); - } -} LLEnvironment::EnvironmentInfo::EnvironmentInfo(): mParcelId(INVALID_PARCEL_ID), -- cgit v1.2.3 From 6e7d794b01673c138a50859c0e513732cb89fc8b Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 1 Oct 2018 16:10:19 -0700 Subject: MAINT-9738: Wire the altitude slider to the protocol and send new altitudes to simulator. --- indra/newview/llenvironment.cpp | 83 +++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 36 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 5abb1b2e55..d8bac46151 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1037,12 +1037,12 @@ void LLEnvironment::requestRegion(environment_apply_fn cb) requestParcel(INVALID_PARCEL_ID, cb); } -void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, environment_apply_fn cb) +void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { - updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset, cb); + updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset, altitudes, cb); } -void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset, environment_apply_fn cb) +void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { if (!isExtendedEnvironmentEnabled()) { @@ -1051,17 +1051,17 @@ void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day return; } - updateParcel(INVALID_PARCEL_ID, asset_id, day_length, day_offset, cb); + updateParcel(INVALID_PARCEL_ID, asset_id, day_length, day_offset, altitudes, cb); } -void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, environment_apply_fn cb) +void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { - updateParcel(INVALID_PARCEL_ID, psky, day_length, day_offset, cb); + updateParcel(INVALID_PARCEL_ID, psky, day_length, day_offset, altitudes, cb); } -void LLEnvironment::updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, environment_apply_fn cb) +void LLEnvironment::updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { - updateParcel(INVALID_PARCEL_ID, pwater, day_length, day_offset, cb); + updateParcel(INVALID_PARCEL_ID, pwater, day_length, day_offset, altitudes, cb); } @@ -1101,15 +1101,15 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) [this, parcel_id, cb]() { coroRequestEnvironment(parcel_id, cb); }); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset, environment_apply_fn cb) +void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", - [this, parcel_id, asset_id, day_length, day_offset, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, - LLSettingsDay::ptr_t(), asset_id, day_length, day_offset, cb); }); + [this, parcel_id, asset_id, day_length, day_offset, altitudes, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, + LLSettingsDay::ptr_t(), asset_id, day_length, day_offset, altitudes, cb); }); } -void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset) +void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes) { if (status) { @@ -1134,27 +1134,27 @@ void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::p return; } - updateParcel(parcel_id, pday, day_length, day_offset); + updateParcel(parcel_id, pday, day_length, day_offset, altitudes); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, environment_apply_fn cb) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, psky); - updateParcel(parcel_id, pday, day_length, day_offset, cb); + updateParcel(parcel_id, pday, day_length, day_offset, altitudes, cb); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, environment_apply_fn cb) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, pwater); - updateParcel(parcel_id, pday, day_length, day_offset, cb); + updateParcel(parcel_id, pday, day_length, day_offset, altitudes, cb); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, environment_apply_fn cb) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", - [this, parcel_id, pday, day_length, day_offset, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, - pday, LLUUID::null, day_length, day_offset, cb); }); + [this, parcel_id, pday, day_length, day_offset, altitudes, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, + pday, LLUUID::null, day_length, day_offset, altitudes, cb); }); } @@ -1223,7 +1223,8 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ // } } -void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, LLSettingsDay::ptr_t pday, LLUUID settings_asset, S32 day_length, S32 day_offset, LLEnvironment::environment_apply_fn apply) +void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, LLSettingsDay::ptr_t pday, + LLUUID settings_asset, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, LLEnvironment::environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1234,30 +1235,40 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, LLSetting if (url.empty()) return; - if (day_length < 1) - { - day_length = getEnvironmentDayLength((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL).value(); - if ((day_length < 1) && (parcel_id != INVALID_PARCEL_ID)) - day_length = getEnvironmentDayLength(ENV_REGION).value(); - } - - if (day_offset < 1) - { - day_offset = getEnvironmentDayOffset((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL).value(); - if ((day_offset < 1) && (parcel_id != INVALID_PARCEL_ID)) - day_offset = getEnvironmentDayOffset(ENV_REGION).value(); - } +// if (day_length < 1) +// { +// day_length = getEnvironmentDayLength((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL).value(); +// if ((day_length < 1) && (parcel_id != INVALID_PARCEL_ID)) +// day_length = getEnvironmentDayLength(ENV_REGION).value(); +// } +// +// if (day_offset < 1) +// { +// day_offset = getEnvironmentDayOffset((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL).value(); +// if ((day_offset < 1) && (parcel_id != INVALID_PARCEL_ID)) +// day_offset = getEnvironmentDayOffset(ENV_REGION).value(); +// } LLSD body(LLSD::emptyMap()); body[KEY_ENVIRONMENT] = LLSD::emptyMap(); if (track_no == NO_TRACK) { // day length and offset are only applicable if we are addressing the entire day cycle. - if (day_length >= 0) + if (day_length > 0) body[KEY_ENVIRONMENT][KEY_DAYLENGTH] = day_length; - if (day_offset >= 0) + if (day_offset > 0) body[KEY_ENVIRONMENT][KEY_DAYOFFSET] = day_offset; + + if ((parcel_id == INVALID_PARCEL_ID) && (altitudes.size() == 3)) + { // only test for altitude changes if we are changing the region. + body[KEY_ENVIRONMENT][KEY_TRACKALTS] = LLSD::emptyArray(); + for (S32 i = 0; i < 3; ++i) + { + body[KEY_ENVIRONMENT][KEY_TRACKALTS][i] = altitudes[i]; + } + } } + if (pday) body[KEY_ENVIRONMENT][KEY_DAYCYCLE] = pday->getSettings(); else if (!settings_asset.isNull()) -- cgit v1.2.3 From 6cdcc7fe2edcb6c001f2dabf48c87e00d907a4db Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 17 Oct 2018 12:16:24 -0700 Subject: SL-9889: New reconverted default assets --- indra/newview/llenvironment.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 61b5e7f576..1bc35b44bb 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -261,10 +261,10 @@ const F32Seconds LLEnvironment::TRANSITION_DEFAULT(5.0f); const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F32Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); -const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("4204c687-f9e4-4893-8c1b-46761c0d2021"); -const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("07589e0e-8e2e-4864-8e58-07b516efd9c3"); -const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("8113ba47-3223-46ba-bae6-12c875091b32"); -const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("90187088-d7f3-4656-8c27-8ba0e19e21e9"); +const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("7e1489ce-fdc8-2971-c3a4-f1fe0cd70d20"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("9db06848-8b1f-501d-eeae-ecf487f40dd6"); +const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("95882e1b-7741-f082-d9d6-3a34ec644c66"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("d8e50d02-a15b-17a7-3425-523bc20f67b8"); const S32 LLEnvironment::NO_TRACK(-1); -- cgit v1.2.3 From 44cdf00bff2669004d0259637eddb6d461cc1a3b Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 17 Oct 2018 21:17:00 +0300 Subject: SL-1476 EEP parcel transition inconsistencies --- indra/newview/llenvironment.cpp | 48 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 1bc35b44bb..5e7e9937cd 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -888,9 +888,6 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS bool found_in_settings = psetting->mSettings.has(it.first); bool found_in_legacy_settings = !found_in_settings && psetting->mSettings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE].has(it.first); - if (!found_in_settings && !found_in_legacy_settings) - continue; - if (found_in_settings) { value = psetting->mSettings[it.first]; @@ -899,6 +896,51 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS { value = psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE][it.first]; } + else if (psetting->getSettingsType() == "sky") + { + // Legacy atmospherics is a special case, + // these values either have non zero defaults when they are not present + // in LLSD or need to be acounted for (reset) even if they are not present + // Todo: consider better options, for example make LLSettingsSky init these options + // Todo: we should reset shaders for all missing fields, not just these ones + LLSettingsSky::ptr_t skyp = std::static_pointer_cast(psetting); + if (it.first == LLSettingsSky::SETTING_BLUE_DENSITY) + { + value = skyp->getBlueDensity().getValue(); + } + else if (it.first == LLSettingsSky::SETTING_BLUE_HORIZON) + { + value = skyp->getBlueHorizon().getValue(); + } + else if (it.first == LLSettingsSky::SETTING_DENSITY_MULTIPLIER) + { + value = skyp->getDensityMultiplier(); + } + else if (it.first == LLSettingsSky::SETTING_DISTANCE_MULTIPLIER) + { + value = skyp->getDistanceMultiplier(); + } + else if (it.first == LLSettingsSky::SETTING_HAZE_DENSITY) + { + value = skyp->getHazeDensity(); + } + else if (it.first == LLSettingsSky::SETTING_HAZE_HORIZON) + { + value = skyp->getHazeHorizon(); + } + else if (it.first == LLSettingsSky::SETTING_AMBIENT) + { + value = skyp->getAmbientColor().getValue(); + } + else + { + continue; + } + } + else + { + continue; + } LLSD::Type setting_type = value.type(); stop_glerror(); -- cgit v1.2.3 From 8740368b0bab2ff9c0bbdb31b0da240e9e927e22 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Tue, 23 Oct 2018 17:52:00 +0300 Subject: =?UTF-8?q?SL-9922=20FIXED=20[EEP]=20The=20Day=20environment=20set?= =?UTF-8?q?tings=20are=20changed=20when=20open=20the=20Water=20setting=20i?= =?UTF-8?q?n=20=E2=80=98Fixed=20Environment=E2=80=99=20editor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- indra/newview/llenvironment.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 5e7e9937cd..ae625630eb 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -507,9 +507,19 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm DayInstance::ptr_t environment = getEnvironmentInstance(env, true); + LLSettingsSky::ptr_t prev_sky = mEnvironments[ENV_DEFAULT]->getSky(); + LLSettingsWater::ptr_t prev_water = mEnvironments[ENV_DEFAULT]->getWater(); + if (mCurrentEnvironment && (ENV_EDIT == env)) + { + prev_sky = mCurrentEnvironment->getSky() ? mCurrentEnvironment->getSky() : prev_sky; + prev_water = mCurrentEnvironment->getWater() ? mCurrentEnvironment->getWater() : prev_water; + } + environment->clear(); - environment->setSky((fixed.first) ? fixed.first : mEnvironments[ENV_DEFAULT]->getSky()); - environment->setWater((fixed.second) ? fixed.second : mEnvironments[ENV_DEFAULT]->getWater()); + environment->setSky((fixed.first) ? fixed.first : prev_sky); + environment->setWater((fixed.second) ? fixed.second : prev_water); + + if (!mSignalEnvChanged.empty()) mSignalEnvChanged(env); -- cgit v1.2.3 From 659d14504f6ab4ad283efe4ecd950a4483e1498f Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 29 Oct 2018 18:18:20 +0200 Subject: SL-1476 EEP Better shader resets and transitions --- indra/newview/llenvironment.cpp | 65 +++++++---------------------------------- 1 file changed, 11 insertions(+), 54 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index ae625630eb..da558a0ba3 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -885,6 +885,7 @@ void LLEnvironment::updateCloudScroll() } +// static void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting) { LL_RECORD_BLOCK_TIME(FTM_SHADER_PARAM_UPDATE); @@ -894,62 +895,19 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS for (auto &it: params) { LLSD value; - - bool found_in_settings = psetting->mSettings.has(it.first); - bool found_in_legacy_settings = !found_in_settings && psetting->mSettings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE].has(it.first); - - if (found_in_settings) - { - value = psetting->mSettings[it.first]; - } - else if (found_in_legacy_settings) + // legacy first since it contains ambient color and we prioritize value from legacy, see getAmbientColor() + if (psetting->mSettings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE].has(it.first)) { value = psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE][it.first]; } - else if (psetting->getSettingsType() == "sky") + else if (psetting->mSettings.has(it.first)) { - // Legacy atmospherics is a special case, - // these values either have non zero defaults when they are not present - // in LLSD or need to be acounted for (reset) even if they are not present - // Todo: consider better options, for example make LLSettingsSky init these options - // Todo: we should reset shaders for all missing fields, not just these ones - LLSettingsSky::ptr_t skyp = std::static_pointer_cast(psetting); - if (it.first == LLSettingsSky::SETTING_BLUE_DENSITY) - { - value = skyp->getBlueDensity().getValue(); - } - else if (it.first == LLSettingsSky::SETTING_BLUE_HORIZON) - { - value = skyp->getBlueHorizon().getValue(); - } - else if (it.first == LLSettingsSky::SETTING_DENSITY_MULTIPLIER) - { - value = skyp->getDensityMultiplier(); - } - else if (it.first == LLSettingsSky::SETTING_DISTANCE_MULTIPLIER) - { - value = skyp->getDistanceMultiplier(); - } - else if (it.first == LLSettingsSky::SETTING_HAZE_DENSITY) - { - value = skyp->getHazeDensity(); - } - else if (it.first == LLSettingsSky::SETTING_HAZE_HORIZON) - { - value = skyp->getHazeHorizon(); - } - else if (it.first == LLSettingsSky::SETTING_AMBIENT) - { - value = skyp->getAmbientColor().getValue(); - } - else - { - continue; - } + value = psetting->mSettings[it.first]; } else { - continue; + // We need to reset shaders, use defaults + value = it.second.getDefaultValue(); } LLSD::Type setting_type = value.type(); @@ -957,16 +915,16 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS switch (setting_type) { case LLSD::TypeInteger: - shader->uniform1i(it.second, value.asInteger()); + shader->uniform1i(it.second.getShaderKey(), value.asInteger()); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; break; case LLSD::TypeReal: - shader->uniform1f(it.second, value.asReal()); + shader->uniform1f(it.second.getShaderKey(), value.asReal()); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; break; case LLSD::TypeBoolean: - shader->uniform1i(it.second, value.asBoolean() ? 1 : 0); + shader->uniform1i(it.second.getShaderKey(), value.asBoolean() ? 1 : 0); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; break; @@ -974,8 +932,7 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS { LLVector4 vect4(value); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; - shader->uniform4fv(it.second, 1, vect4.mV); - + shader->uniform4fv(it.second.getShaderKey(), 1, vect4.mV); break; } -- cgit v1.2.3 From 51772e6083d8af786704cee18f5eb3c9b3dfefda Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 2 Nov 2018 09:17:19 -0700 Subject: SL-9886: Viewer send and receive new day_name(s) information in the environment protocol for viewer specified names on individual tracks. --- indra/newview/llenvironment.cpp | 79 +++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 35 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index da558a0ba3..05bbfd70d6 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -69,6 +69,8 @@ namespace const std::string KEY_DAYCYCLE("day_cycle"); const std::string KEY_DAYHASH("day_hash"); const std::string KEY_DAYLENGTH("day_length"); + const std::string KEY_DAYNAME("day_name"); + const std::string KEY_DAYNAMES("day_names"); const std::string KEY_DAYOFFSET("day_offset"); const std::string KEY_ISDEFAULT("is_default"); const std::string KEY_PARCELID("parcel_id"); @@ -1040,7 +1042,7 @@ void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_lengt updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset, altitudes, cb); } -void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +void LLEnvironment::updateRegion(const LLUUID &asset_id, std::string display_name, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { if (!isExtendedEnvironmentEnabled()) { @@ -1049,7 +1051,7 @@ void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day return; } - updateParcel(INVALID_PARCEL_ID, asset_id, day_length, day_offset, altitudes, cb); + updateParcel(INVALID_PARCEL_ID, asset_id, display_name, day_length, day_offset, altitudes, cb); } void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) @@ -1099,12 +1101,12 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) [this, parcel_id, cb]() { coroRequestEnvironment(parcel_id, cb); }); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, std::string display_name, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { + UpdateInfo::ptr_t updates(std::make_shared(asset_id, display_name, day_length, day_offset, altitudes)); std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", - [this, parcel_id, asset_id, day_length, day_offset, altitudes, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, - LLSettingsDay::ptr_t(), asset_id, day_length, day_offset, altitudes, cb); }); + [this, parcel_id, updates, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, updates, cb); }); } void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes) @@ -1149,10 +1151,11 @@ void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pw void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { + UpdateInfo::ptr_t updates(std::make_shared(pday, day_length, day_offset, altitudes)); + std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", - [this, parcel_id, pday, day_length, day_offset, altitudes, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, - pday, LLUUID::null, day_length, day_offset, altitudes, cb); }); + [this, parcel_id, updates, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, updates, cb); }); } @@ -1221,8 +1224,7 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ // } } -void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, LLSettingsDay::ptr_t pday, - LLUUID settings_asset, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, LLEnvironment::environment_apply_fn apply) +void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, UpdateInfo::ptr_t updates, environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1233,45 +1235,34 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, LLSetting if (url.empty()) return; -// if (day_length < 1) -// { -// day_length = getEnvironmentDayLength((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL).value(); -// if ((day_length < 1) && (parcel_id != INVALID_PARCEL_ID)) -// day_length = getEnvironmentDayLength(ENV_REGION).value(); -// } -// -// if (day_offset < 1) -// { -// day_offset = getEnvironmentDayOffset((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL).value(); -// if ((day_offset < 1) && (parcel_id != INVALID_PARCEL_ID)) -// day_offset = getEnvironmentDayOffset(ENV_REGION).value(); -// } - LLSD body(LLSD::emptyMap()); body[KEY_ENVIRONMENT] = LLSD::emptyMap(); if (track_no == NO_TRACK) { // day length and offset are only applicable if we are addressing the entire day cycle. - if (day_length > 0) - body[KEY_ENVIRONMENT][KEY_DAYLENGTH] = day_length; - if (day_offset > 0) - body[KEY_ENVIRONMENT][KEY_DAYOFFSET] = day_offset; + if (updates->mDayLength > 0) + body[KEY_ENVIRONMENT][KEY_DAYLENGTH] = updates->mDayLength; + if (updates->mDayOffset > 0) + body[KEY_ENVIRONMENT][KEY_DAYOFFSET] = updates->mDayOffset; - if ((parcel_id == INVALID_PARCEL_ID) && (altitudes.size() == 3)) + if ((parcel_id == INVALID_PARCEL_ID) && (updates->mAltitudes.size() == 3)) { // only test for altitude changes if we are changing the region. body[KEY_ENVIRONMENT][KEY_TRACKALTS] = LLSD::emptyArray(); for (S32 i = 0; i < 3; ++i) { - body[KEY_ENVIRONMENT][KEY_TRACKALTS][i] = altitudes[i]; + body[KEY_ENVIRONMENT][KEY_TRACKALTS][i] = updates->mAltitudes[i]; } } } - if (pday) - body[KEY_ENVIRONMENT][KEY_DAYCYCLE] = pday->getSettings(); - else if (!settings_asset.isNull()) - body[KEY_ENVIRONMENT][KEY_DAYASSET] = settings_asset; - + if (updates->mDayp) + body[KEY_ENVIRONMENT][KEY_DAYCYCLE] = updates->mDayp->getSettings(); + else if (!updates->mSettingsAsset.isNull()) + { + body[KEY_ENVIRONMENT][KEY_DAYASSET] = updates->mSettingsAsset; + if (!updates->mDayName.empty()) + body[KEY_ENVIRONMENT][KEY_DAYNAME] = updates->mDayName; + } LL_WARNS("LAPRAS") << "Body = " << body << LL_ENDL; @@ -1401,7 +1392,9 @@ LLEnvironment::EnvironmentInfo::EnvironmentInfo(): mDayCycle(), mAltitudes({ { 0.0, 0.0, 0.0, 0.0 } }), mIsDefault(false), - mIsLegacy(false) + mIsLegacy(false), + mDayCycleName(), + mNameList() { } @@ -1441,6 +1434,22 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL pinfo->mAssetId = environment[KEY_DAYASSET].asUUID(); } + if (environment.has(KEY_DAYNAMES)) + { + LLSD daynames = environment[KEY_DAYNAMES]; + if (daynames.isArray()) + { + for (S32 index = 0; index < pinfo->mNameList.size(); ++index) + { + pinfo->mNameList[index] = daynames[index]; + } + } + else if (daynames.isString()) + { + pinfo->mDayCycleName = daynames.asString(); + } + } + return pinfo; } -- cgit v1.2.3 From 8d333a0176d56738154c75b1a24d694467647312 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 2 Nov 2018 14:32:42 -0700 Subject: OSX Pedantics --- indra/newview/llenvironment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 05bbfd70d6..6bc7b8bf25 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1441,7 +1441,7 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL { for (S32 index = 0; index < pinfo->mNameList.size(); ++index) { - pinfo->mNameList[index] = daynames[index]; + pinfo->mNameList[index] = daynames[index].asString(); } } else if (daynames.isString()) -- cgit v1.2.3 From bda785e8b1bef35ecd9d45a7092b0ab66c17d1f4 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 12 Nov 2018 20:11:00 +0200 Subject: SL-10033 [EEP] Use fast environment transition for teleports --- indra/newview/llenvironment.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 6bc7b8bf25..530dc79fe9 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -973,7 +973,7 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) } } -void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo) +void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo, LLSettingsBase::Seconds transition) { if (envinfo->mParcelId == INVALID_PARCEL_ID) { @@ -1027,8 +1027,8 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI setEnvironment(ENV_PARCEL, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset); } } - - updateEnvironment(); + + updateEnvironment(transition); } //========================================================================= @@ -1078,9 +1078,10 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) { if (!cb) { - cb = [this](S32 pid, EnvironmentInfo::ptr_t envinfo) + LLSettingsBase::Seconds transition = LLViewerParcelMgr::getInstance()->getTeleportInProgress() ? TRANSITION_FAST : TRANSITION_DEFAULT; + cb = [this, transition](S32 pid, EnvironmentInfo::ptr_t envinfo) { - recordEnvironment(pid, envinfo); + recordEnvironment(pid, envinfo, transition); }; } @@ -1093,7 +1094,8 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) if (!cb) { - cb = [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }; + LLSettingsBase::Seconds transition = LLViewerParcelMgr::getInstance()->getTeleportInProgress() ? TRANSITION_FAST : TRANSITION_DEFAULT; + cb = [this, transition](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo, transition); }; } std::string coroname = -- cgit v1.2.3 From 29130c5483146d4d27272ef12e986520778ca2c8 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 20 Nov 2018 10:59:38 -0800 Subject: SL-10093: Client code to support experiences changing an environment. Handle generic messages with "commands" to be executed. --- indra/newview/llenvironment.cpp | 178 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 171 insertions(+), 7 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 530dc79fe9..580d0e785a 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -61,6 +61,10 @@ #include "roles_constants.h" #include "llestateinfomodel.h" +#include "lldispatcher.h" +#include "llviewergenericmessage.h" +#include "llexperiencelog.h" + //========================================================================= namespace { @@ -77,6 +81,21 @@ namespace const std::string KEY_REGIONID("region_id"); const std::string KEY_TRACKALTS("track_altitudes"); + const std::string MESSAGE_PUSHENVIRONMENT("PushExpEnvironment"); + + const std::string ACTION_CLEARENVIRONMENT("ClearEnvironment"); + const std::string ACTION_PUSHFULLENVIRONMENT("PushFullEnvironment"); + const std::string ACTION_PUSHPARTIALENVIRONMENT("PushPartialEnvironment"); + + const std::string KEY_ASSETID("asset_id"); + const std::string KEY_TRANSITIONTIME("transition_time"); + const std::string KEY_ACTION("action"); + const std::string KEY_ACTIONDATA("action_data"); + const std::string KEY_EXPERIENCEID("public_id"); + const std::string KEY_OBJECTNAME("ObjectName"); // some of these do not conform to the '_' format. + const std::string KEY_PARCELNAME("ParcelName"); // But changing these would also alter the Experience Log requirements. + const std::string KEY_COUNT("Count"); + //--------------------------------------------------------------------- LLTrace::BlockTimerStatHandle FTM_ENVIRONMENT_UPDATE("Update Environment Tick"); LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); @@ -254,6 +273,47 @@ namespace } }; + + class LLEnvironmentPushDispatchHandler : public LLDispatchHandler + { + public: + virtual bool operator()(const LLDispatcher *, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override + { + LLSD message; + + sparam_t::const_iterator it = strings.begin(); + + if (it != strings.end()) + { + const std::string& llsdRaw = *it++; + std::istringstream llsdData(llsdRaw); + if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length())) + { + LL_WARNS() << "LLExperienceLogDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL; + } + } + message[KEY_EXPERIENCEID] = invoice; + + // Object Name + if (it != strings.end()) + { + message[KEY_OBJECTNAME] = *it++; + } + + // parcel Name + if (it != strings.end()) + { + message[KEY_PARCELNAME] = *it++; + } + message[KEY_COUNT] = 1; + + LLEnvironment::instance().handleEnvironmentPush(message); + return true; + } + }; + + LLEnvironmentPushDispatchHandler environment_push_dispatch_handler; + } //========================================================================= @@ -301,9 +361,15 @@ void LLEnvironment::initSingleton() //TODO: This frequently results in one more request than we need. It isn't breaking, but should be nicer. LLRegionInfoModel::instance().setUpdateCallback([this]() { requestRegion(); }); - gAgent.addRegionChangedCallback([this]() { requestRegion(); }); + gAgent.addRegionChangedCallback([this]() { onRegionChange(); }); gAgent.whenPositionChanged([this](const LLVector3 &localpos, const LLVector3d &) { onAgentPositionHasChanged(localpos); }); + + if (!gGenericDispatcher.isHandlerPresent(MESSAGE_PUSHENVIRONMENT)) + { + gGenericDispatcher.addHandler(MESSAGE_PUSHENVIRONMENT, &environment_push_dispatch_handler); + } + } LLEnvironment::~LLEnvironment() @@ -410,6 +476,12 @@ bool LLEnvironment::isInventoryEnabled() const !gAgent.getRegionCapability("UpdateSettingsTaskInventory").empty()); } +void LLEnvironment::onRegionChange() +{ + clearEnvironment(ENV_PUSH); + requestRegion(); +} + void LLEnvironment::onParcelChange() { S32 parcel_id(INVALID_PARCEL_ID); @@ -584,10 +656,13 @@ void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId) void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) { LLSettingsVOBase::getSettingsAsset(assetId, - [this, env, daylength, dayoffset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onSetEnvAssetLoaded(env, asset_id, settings, daylength, dayoffset, status); }); + [this, env, daylength, dayoffset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) + { + onSetEnvAssetLoaded(env, asset_id, settings, daylength, dayoffset, TRANSITION_DEFAULT, status); + }); } -void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset, S32 status) +void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset, LLSettingsBase::Seconds transition, S32 status) { if (!settings || status) { @@ -598,7 +673,7 @@ void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLS } setEnvironment(env, settings); - updateEnvironment(); + updateEnvironment(transition); } void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) @@ -719,7 +794,6 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance( return mEnvironments[ENV_DEFAULT]; } - void LLEnvironment::updateEnvironment(LLSettingsBase::Seconds transition, bool forced) { DayInstance::ptr_t pinstance = getSelectedEnvironmentInstance(); @@ -1562,8 +1636,6 @@ void LLEnvironment::onAgentPositionHasChanged(const LLVector3 &localpos) if (trackno == mCurrentTrack) return; - LL_WARNS("LAPRAS") << "Wants to switch to track #" << trackno << LL_ENDL; - mCurrentTrack = trackno; for (S32 env = ENV_LOCAL; env < ENV_DEFAULT; ++env) { @@ -1584,6 +1656,98 @@ S32 LLEnvironment::calculateSkyTrackForAltitude(F64 altitude) return std::min(static_cast(std::distance(mTrackAltitudes.begin(), it)), 4); } +//------------------------------------------------------------------------- +void LLEnvironment::handleEnvironmentPush(LLSD &message) +{ + // Log the experience message + LLExperienceLog::instance().handleExperienceMessage(message); + + std::string action = message[KEY_ACTION].asString(); + LLUUID experience_id = message[KEY_EXPERIENCEID].asUUID(); + LLSD action_data = message[KEY_ACTIONDATA]; + F32 transition_time = action_data[KEY_TRANSITIONTIME].asReal(); + + //TODO: Check here that the viewer thinks the experience is still valid. + + + if (action == ACTION_CLEARENVIRONMENT) + { + handleEnvironmentPushClear(experience_id, action_data, transition_time); + } + else if (action == ACTION_PUSHFULLENVIRONMENT) + { + handleEnvironmentPushFull(experience_id, action_data, transition_time); + } + else if (action == ACTION_PUSHPARTIALENVIRONMENT) + { + handleEnvironmentPushPartial(experience_id, action_data, transition_time); + } + else + { + LL_WARNS("ENVIRONMENT", "GENERICMESSAGES") << "Unknown environment push action '" << action << "'" << LL_ENDL; + } +} + + +void LLEnvironment::handleEnvironmentPushClear(LLUUID experience_id, LLSD &message, F32 transition) +{ + clearExperienceEnvironment(experience_id, transition); +} + +void LLEnvironment::handleEnvironmentPushFull(LLUUID experience_id, LLSD &message, F32 transition) +{ + LLUUID asset_id(message[KEY_ASSETID].asUUID()); + + setExperienceEnvironment(experience_id, asset_id, LLSettingsBase::Seconds(transition)); +} + +void LLEnvironment::handleEnvironmentPushPartial(LLUUID experience_id, LLSD &message, F32 transition) +{ + +} + +void LLEnvironment::clearExperienceEnvironment(LLUUID experience_id, F32 transition_time) +{ + bool update_env(false); + + if (mPushEnvironmentExpId == experience_id) + { + mPushEnvironmentExpId.setNull(); + + if (hasEnvironment(ENV_PUSH)) + { + update_env |= true; + clearEnvironment(ENV_PUSH); + updateEnvironment(LLSettingsBase::Seconds(transition_time)); + } + + } + + // clear the override queue too. + // update |= true; + + + if (update_env) + updateEnvironment(LLSettingsBase::Seconds(transition_time)); +} + +void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLUUID asset_id, F32 transition_time) +{ + LLSettingsVOBase::getSettingsAsset(asset_id, + [this, experience_id, transition_time](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) + { + mPushEnvironmentExpId = experience_id; + onSetEnvAssetLoaded(ENV_PUSH, asset_id, settings, + LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET, + LLSettingsBase::Seconds(transition_time), status); + }); + + +} + +void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLSD data, F32 transition_time) +{ +} //========================================================================= LLEnvironment::DayInstance::DayInstance() : -- cgit v1.2.3 From d66012f85e885679738cf8c488fd8ff460319c85 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Fri, 30 Nov 2018 17:48:08 +0200 Subject: SL-9716 [EEP] "Use Shared Environment" does not enable when applying an environment to a parcel or region --- indra/newview/llenvironment.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 580d0e785a..3a030bb09d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1731,6 +1731,13 @@ void LLEnvironment::clearExperienceEnvironment(LLUUID experience_id, F32 transit updateEnvironment(LLSettingsBase::Seconds(transition_time)); } +void LLEnvironment::setSharedEnvironment() +{ + clearEnvironment(LLEnvironment::ENV_LOCAL); + setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + updateEnvironment(); +} + void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLUUID asset_id, F32 transition_time) { LLSettingsVOBase::getSettingsAsset(asset_id, -- cgit v1.2.3 From 76071d4fe8f2b88e33d0393fe00dc2ce88f71935 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 5 Dec 2018 22:13:49 +0200 Subject: SL-10091 EEP Filter out dupplicate refreshes and callbacks --- indra/newview/llenvironment.cpp | 61 +++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 17 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3a030bb09d..20021fb075 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -76,6 +76,7 @@ namespace const std::string KEY_DAYNAME("day_name"); const std::string KEY_DAYNAMES("day_names"); const std::string KEY_DAYOFFSET("day_offset"); + const std::string KEY_ENVVERSION("env_version"); const std::string KEY_ISDEFAULT("is_default"); const std::string KEY_PARCELID("parcel_id"); const std::string KEY_REGIONID("region_id"); @@ -329,6 +330,8 @@ const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("95882e1b-7741-f082-d9d6-3a34ec644c const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("d8e50d02-a15b-17a7-3425-523bc20f67b8"); const S32 LLEnvironment::NO_TRACK(-1); +const S32 LLEnvironment::NO_VERSION(-3); // For viewer sided change, like ENV_LOCAL. -3 since -1 and -2 are taken by parcel initial server/viewer version +const S32 LLEnvironment::VERSION_CLEANUP(-4); // for cleanups const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg @@ -360,6 +363,7 @@ void LLEnvironment::initSingleton() gAgent.addParcelChangedCallback([this]() { onParcelChange(); }); //TODO: This frequently results in one more request than we need. It isn't breaking, but should be nicer. + // We need to know new env version to fix this, without it we can only do full re-request LLRegionInfoModel::instance().setUpdateCallback([this]() { requestRegion(); }); gAgent.addRegionChangedCallback([this]() { onRegionChange(); }); @@ -551,7 +555,7 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnviro } -void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset, S32 env_version) { if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) { @@ -567,11 +571,11 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe environment->animate(); if (!mSignalEnvChanged.empty()) - mSignalEnvChanged(env); + mSignalEnvChanged(env, env_version); } -void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironment::fixedEnvironment_t fixed) +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironment::fixedEnvironment_t fixed, S32 env_version) { if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) { @@ -595,12 +599,12 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm if (!mSignalEnvChanged.empty()) - mSignalEnvChanged(env); + mSignalEnvChanged(env, env_version); /*TODO: readjust environment*/ } -void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsBase::ptr_t &settings) +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsBase::ptr_t &settings, S32 env_version) { DayInstance::ptr_t environment = getEnvironmentInstance(env); @@ -647,22 +651,33 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe } } -void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId) +void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId, S32 env_version) { setEnvironment(env, assetId, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); } -void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) +void LLEnvironment::setEnvironment(EnvSelection_t env, + const LLUUID &assetId, + LLSettingsDay::Seconds daylength, + LLSettingsDay::Seconds dayoffset, + S32 env_version) { LLSettingsVOBase::getSettingsAsset(assetId, - [this, env, daylength, dayoffset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) + [this, env, daylength, dayoffset, env_version](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { - onSetEnvAssetLoaded(env, asset_id, settings, daylength, dayoffset, TRANSITION_DEFAULT, status); + onSetEnvAssetLoaded(env, asset_id, settings, daylength, dayoffset, TRANSITION_DEFAULT, status, env_version); }); } -void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset, LLSettingsBase::Seconds transition, S32 status) +void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, + LLUUID asset_id, + LLSettingsBase::ptr_t settings, + LLSettingsDay::Seconds daylength, + LLSettingsDay::Seconds dayoffset, + LLSettingsBase::Seconds transition, + S32 status, + S32 env_version) { if (!settings || status) { @@ -687,7 +702,7 @@ void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) mEnvironments[env].reset(); if (!mSignalEnvChanged.empty()) - mSignalEnvChanged(env); + mSignalEnvChanged(env, VERSION_CLEANUP); /*TODO: readjust environment*/ } @@ -1055,7 +1070,7 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI if (!envinfo->mDayCycle) { clearEnvironment(ENV_PARCEL); - setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); + setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET, envinfo->mEnvVersion); updateEnvironment(); } else if (envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_WATER) @@ -1063,13 +1078,13 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI { LL_WARNS("LAPRAS") << "Invalid day cycle for region" << LL_ENDL; clearEnvironment(ENV_PARCEL); - setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); + setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET, envinfo->mEnvVersion); updateEnvironment(); } else { LL_INFOS("LAPRAS") << "Setting Region environment" << LL_ENDL; - setEnvironment(ENV_REGION, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset); + setEnvironment(ENV_REGION, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset, envinfo->mEnvVersion); mTrackAltitudes = envinfo->mAltitudes; } @@ -1098,7 +1113,7 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI } else { - setEnvironment(ENV_PARCEL, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset); + setEnvironment(ENV_PARCEL, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset, envinfo->mEnvVersion); } } @@ -1470,7 +1485,8 @@ LLEnvironment::EnvironmentInfo::EnvironmentInfo(): mIsDefault(false), mIsLegacy(false), mDayCycleName(), - mNameList() + mNameList(), + mEnvVersion(INVALID_PARCEL_ENVIRONMENT_VERSION) { } @@ -1526,6 +1542,17 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL } } + if (environment.has(KEY_ENVVERSION)) + { + LLSD version = environment[KEY_ENVVERSION]; + pinfo->mEnvVersion = version.asInteger(); + } + else + { + // can be used for region, but versions should be same + pinfo->mEnvVersion = pinfo->mIsDefault ? UNSET_PARCEL_ENVIRONMENT_VERSION : INVALID_PARCEL_ENVIRONMENT_VERSION; + } + return pinfo; } @@ -1746,7 +1773,7 @@ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLUUID asset_ mPushEnvironmentExpId = experience_id; onSetEnvAssetLoaded(ENV_PUSH, asset_id, settings, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET, - LLSettingsBase::Seconds(transition_time), status); + LLSettingsBase::Seconds(transition_time), status, NO_VERSION); }); -- cgit v1.2.3 From d4fe87cca49162c978b4eacde880431977624874 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 7 Dec 2018 16:24:47 +0200 Subject: SL-10091 Prevent info floater from re-requesting data when not open --- indra/newview/llenvironment.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 20021fb075..d8095ad2ce 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -364,6 +364,7 @@ void LLEnvironment::initSingleton() //TODO: This frequently results in one more request than we need. It isn't breaking, but should be nicer. // We need to know new env version to fix this, without it we can only do full re-request + // Happens: on updates, on opening LLFloaterRegionInfo, on region crossing if info floater is open LLRegionInfoModel::instance().setUpdateCallback([this]() { requestRegion(); }); gAgent.addRegionChangedCallback([this]() { onRegionChange(); }); -- cgit v1.2.3 From 70ac8d9fa7049891ed1b65f68f112127dfb5f5f7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 12 Dec 2018 14:07:23 -0800 Subject: SL-10238: Viewer spport for push notifications from the simulator contaiting partial groups of settings. Blend these settings into the current environment. --- indra/newview/llenvironment.cpp | 336 +++++++++++++++++++++++++++++++++++----- 1 file changed, 293 insertions(+), 43 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3a030bb09d..fa3afa74ca 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -280,7 +280,6 @@ namespace virtual bool operator()(const LLDispatcher *, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override { LLSD message; - sparam_t::const_iterator it = strings.begin(); if (it != strings.end()) @@ -292,8 +291,8 @@ namespace LL_WARNS() << "LLExperienceLogDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL; } } - message[KEY_EXPERIENCEID] = invoice; + message[KEY_EXPERIENCEID] = invoice; // Object Name if (it != strings.end()) { @@ -349,7 +348,7 @@ void LLEnvironment::initSingleton() LLSettingsSky::ptr_t p_default_sky = LLSettingsVOSky::buildDefaultSky(); LLSettingsWater::ptr_t p_default_water = LLSettingsVOWater::buildDefaultWater(); - mCurrentEnvironment = std::make_shared(); + mCurrentEnvironment = std::make_shared(ENV_DEFAULT); mCurrentEnvironment->setSky(p_default_sky); mCurrentEnvironment->setWater(p_default_water); @@ -381,6 +380,43 @@ bool LLEnvironment::canEdit() const return true; } +LLSettingsSky::ptr_t LLEnvironment::getCurrentSky() const +{ + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + + if (!psky && mCurrentEnvironment->getEnvironmentSelection() >= ENV_EDIT) + { + for (int idx = 0; idx < ENV_END; ++idx) + { + if (mEnvironments[idx]->getSky()) + { + psky = mEnvironments[idx]->getSky(); + break; + } + } + } + return psky; +} + +LLSettingsWater::ptr_t LLEnvironment::getCurrentWater() const +{ + LLSettingsWater::ptr_t pwater = mCurrentEnvironment->getWater(); + + if (!pwater && mCurrentEnvironment->getEnvironmentSelection() >= ENV_EDIT) + { + for (int idx = 0; idx < ENV_END; ++idx) + { + if (mEnvironments[idx]->getWater()) + { + pwater = mEnvironments[idx]->getWater(); + break; + } + } + } + return pwater; +} + + void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settingsOut, const LLSettingsSky::ptr_t &psky) { settingsOut.m_skyBottomRadius = psky->getSkyBottomRadius(); @@ -478,7 +514,7 @@ bool LLEnvironment::isInventoryEnabled() const void LLEnvironment::onRegionChange() { - clearEnvironment(ENV_PUSH); + clearExperienceEnvironment(LLUUID::null, TRANSITION_DEFAULT); requestRegion(); } @@ -540,10 +576,16 @@ bool LLEnvironment::hasEnvironment(LLEnvironment::EnvSelection_t env) LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnvironment::EnvSelection_t env, bool create /*= false*/) { DayInstance::ptr_t environment = mEnvironments[env]; -// if (!environment && create) if (create) { - environment = std::make_shared(); + if (environment) + environment = environment->clone(); + else + { + environment = std::make_shared(env); + if (mMakeBackups && env > ENV_PUSH) + environment->setBackup(true); + } mEnvironments[env] = environment; } @@ -581,17 +623,27 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm DayInstance::ptr_t environment = getEnvironmentInstance(env, true); - LLSettingsSky::ptr_t prev_sky = mEnvironments[ENV_DEFAULT]->getSky(); - LLSettingsWater::ptr_t prev_water = mEnvironments[ENV_DEFAULT]->getWater(); - if (mCurrentEnvironment && (ENV_EDIT == env)) - { - prev_sky = mCurrentEnvironment->getSky() ? mCurrentEnvironment->getSky() : prev_sky; - prev_water = mCurrentEnvironment->getWater() ? mCurrentEnvironment->getWater() : prev_water; - } +// LLSettingsSky::ptr_t prev_sky = mEnvironments[ENV_DEFAULT]->getSky(); +// LLSettingsWater::ptr_t prev_water = mEnvironments[ENV_DEFAULT]->getWater(); +// if (mCurrentEnvironment && (ENV_EDIT == env)) +// { +// prev_sky = mCurrentEnvironment->getSky() ? mCurrentEnvironment->getSky() : prev_sky; +// prev_water = mCurrentEnvironment->getWater() ? mCurrentEnvironment->getWater() : prev_water; +// } - environment->clear(); - environment->setSky((fixed.first) ? fixed.first : prev_sky); - environment->setWater((fixed.second) ? fixed.second : prev_water); +// environment->clear(); +// environment->setSky((fixed.first) ? fixed.first : prev_sky); +// environment->setWater((fixed.second) ? fixed.second : prev_water); + if (fixed.first) + environment->setSky(fixed.first); + else if (!environment->getSky()) + environment->setSky(mCurrentEnvironment->getSky()); + + if (fixed.second) + environment->setWater(fixed.second); + else if (!environment->getWater()) + environment->setWater(mCurrentEnvironment->getWater()); + if (!mSignalEnvChanged.empty()) @@ -630,19 +682,19 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe else if (settings->getSettingsType() == "sky") { fixedEnvironment_t fixedenv(std::static_pointer_cast(settings), LLSettingsWater::ptr_t()); - if (environment) - { - fixedenv.second = environment->getWater(); - } +// if (environment) +// { +// fixedenv.second = environment->getWater(); +// } setEnvironment(env, fixedenv); } else if (settings->getSettingsType() == "water") { fixedEnvironment_t fixedenv(LLSettingsSky::ptr_t(), std::static_pointer_cast(settings)); - if (environment) - { - fixedenv.first = environment->getSky(); - } +// if (environment) +// { +// fixedenv.first = environment->getSky(); +// } setEnvironment(env, fixedenv); } } @@ -794,6 +846,17 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance( return mEnvironments[ENV_DEFAULT]; } +LLEnvironment::DayInstance::ptr_t LLEnvironment::getSharedEnvironmentInstance() +{ + for (S32 idx = ENV_PARCEL; idx < ENV_DEFAULT; ++idx) + { + if (mEnvironments[idx]) + return mEnvironments[idx]; + } + + return mEnvironments[ENV_DEFAULT]; +} + void LLEnvironment::updateEnvironment(LLSettingsBase::Seconds transition, bool forced) { DayInstance::ptr_t pinstance = getSelectedEnvironmentInstance(); @@ -920,6 +983,11 @@ void LLEnvironment::update(const LLViewerCamera * cam) mCurrentEnvironment->applyTimeDelta(delta); + if (mCurrentEnvironment->getEnvironmentSelection() != ENV_LOCAL) + { + applyInjectedSettings(mCurrentEnvironment, delta); + } + // update clouds, sun, and general updateCloudScroll(); @@ -1703,32 +1771,37 @@ void LLEnvironment::handleEnvironmentPushFull(LLUUID experience_id, LLSD &messag void LLEnvironment::handleEnvironmentPushPartial(LLUUID experience_id, LLSD &message, F32 transition) { + LLSD settings(message["settings"]); + + if (settings.isUndefined()) + return; + setExperienceEnvironment(experience_id, settings, LLSettingsBase::Seconds(transition)); } void LLEnvironment::clearExperienceEnvironment(LLUUID experience_id, F32 transition_time) { bool update_env(false); - if (mPushEnvironmentExpId == experience_id) + if (hasEnvironment(ENV_PUSH)) { - mPushEnvironmentExpId.setNull(); - - if (hasEnvironment(ENV_PUSH)) - { - update_env |= true; - clearEnvironment(ENV_PUSH); - updateEnvironment(LLSettingsBase::Seconds(transition_time)); - } - + update_env |= true; + clearEnvironment(ENV_PUSH); + updateEnvironment(LLSettingsBase::Seconds(transition_time)); } - // clear the override queue too. - // update |= true; + setInstanceBackup(false); + /*TODO blend these back out*/ + mSkyExperienceBlends.clear(); + mWaterExperienceBlends.clear(); + mCurrentEnvironment->getSky(); - if (update_env) - updateEnvironment(LLSettingsBase::Seconds(transition_time)); + injectSettings(experience_id, mSkyExperienceBlends, mSkyOverrides, LLSettingsBase::Seconds(transition_time), false); + injectSettings(experience_id, mWaterExperienceBlends, mWaterOverrides, LLSettingsBase::Seconds(transition_time), false); + + mSkyOverrides = LLSD::emptyMap(); + mWaterOverrides = LLSD::emptyMap(); } void LLEnvironment::setSharedEnvironment() @@ -1754,10 +1827,110 @@ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLUUID asset_ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLSD data, F32 transition_time) { + LLSD sky(data["sky"]); + LLSD water(data["water"]); + + if (sky.isUndefined() && water.isUndefined()) + { + clearExperienceEnvironment(experience_id, transition_time); + return; + } + + setInstanceBackup(true); + + if (!sky.isUndefined()) + injectSettings(experience_id, mSkyExperienceBlends, sky, LLSettingsBase::Seconds(transition_time), true); + if (!water.isUndefined()) + injectSettings(experience_id, mWaterExperienceBlends, water, LLSettingsBase::Seconds(transition_time), true); + +} + + +void LLEnvironment::setInstanceBackup(bool dobackup) +{ + mMakeBackups = dobackup; + for (S32 idx = ENV_PARCEL; idx < ENV_DEFAULT; ++idx) + { + if (mEnvironments[idx]) + mEnvironments[idx]->setBackup(dobackup); + } +} + +void LLEnvironment::injectSettings(LLUUID experience_id, exerienceBlendValues_t &blends, LLSD injections, LLSettingsBase::Seconds transition, bool blendin) +{ + for (LLSD::map_iterator it = injections.beginMap(); it != injections.endMap(); ++it) + { + blends.push_back(ExpBlendValue(transition, (*it).first, (*it).second, blendin, -1)); + } + + std::stable_sort(blends.begin(), blends.end(), [](const ExpBlendValue &a, const ExpBlendValue &b) { return a.mTimeRemaining < b.mTimeRemaining; }); +} + +void LLEnvironment::applyInjectedSettings(DayInstance::ptr_t environment, F32Seconds delta) +{ + if ((mSkyOverrides.size() > 0) || (mSkyExperienceBlends.size() > 0)) + { + LLSettingsSky::ptr_t psky = environment->getSky(); + applyInjectedValues(psky, mSkyOverrides); + blendInjectedValues(psky, mSkyExperienceBlends, mSkyOverrides, delta); + } + if ((mWaterOverrides.size() > 0) || (mWaterExperienceBlends.size() > 0)) + { + LLSettingsWater::ptr_t pwater = environment->getWater(); + applyInjectedValues(pwater, mWaterOverrides); + blendInjectedValues(pwater, mWaterExperienceBlends, mWaterOverrides, delta); + } +} + + +void LLEnvironment::applyInjectedValues(LLSettingsBase::ptr_t psetting, LLSD injection) +{ + for (LLSD::map_iterator it = injection.beginMap(); it != injection.endMap(); ++it) + { + psetting->setValue((*it).first, (*it).second); + } +} + +void LLEnvironment::blendInjectedValues(LLSettingsBase::ptr_t psetting, exerienceBlendValues_t &blends, LLSD &overrides, F32Seconds delta) +{ + LLSD settings = psetting->getSettings(); + LLSettingsBase::parammapping_t mappings = psetting->getParameterMap(); + LLSettingsBase::stringset_t slerps = psetting->getSlerpKeys(); + + if (blends.empty()) + return; + + for (auto &blend : blends) + { + blend.mTimeRemaining -= delta; + LLSettingsBase::BlendFactor mix = std::max(blend.mTimeRemaining / blend.mTransition, 0.0f); + if (blend.mBlendIn) + mix = 1.0 - mix; + mix = std::max(0.0, std::min(mix, 1.0)); + + if (blend.mValueInitial.isUndefined()) + blend.mValueInitial = psetting->getValue(blend.mKeyName); + LLSD newvalue = psetting->interpolateSDValue(blend.mKeyName, blend.mValueInitial, blend.mValue, mappings, mix, slerps); + + psetting->setValue(blend.mKeyName, newvalue); + } + + auto it = blends.begin(); + for (; it != blends.end(); ++it) + { + if ((*it).mTimeRemaining > F32Seconds(0.0f)) + break; + if ((*it).mBlendIn) + overrides[(*it).mKeyName] = (*it).mValue; + } + if (it != blends.begin()) + { + blends.erase(blends.begin(), it); + } } //========================================================================= -LLEnvironment::DayInstance::DayInstance() : +LLEnvironment::DayInstance::DayInstance(EnvSelection_t env) : mDayCycle(), mSky(), mWater(), @@ -1767,18 +1940,42 @@ LLEnvironment::DayInstance::DayInstance() : mBlenderWater(), mInitialized(false), mType(TYPE_INVALID), - mSkyTrack(1) + mSkyTrack(1), + mEnv(env), + mBackup(false) { } + +LLEnvironment::DayInstance::ptr_t LLEnvironment::DayInstance::clone() const +{ + ptr_t environment = std::make_shared(mEnv); + + environment->mDayCycle = mDayCycle; + environment->mSky = mSky; + environment->mWater = mWater; + environment->mDayLength = mDayLength; + environment->mDayOffset = mDayOffset; + environment->mBlenderSky = mBlenderSky; + environment->mBlenderWater = mBlenderWater; + environment->mInitialized = mInitialized; + environment->mType = mType; + environment->mSkyTrack = mSkyTrack; + + return environment; +} + void LLEnvironment::DayInstance::applyTimeDelta(const LLSettingsBase::Seconds& delta) { + bool changed(false); if (!mInitialized) initialize(); if (mBlenderSky) - mBlenderSky->applyTimeDelta(delta); + changed |= mBlenderSky->applyTimeDelta(delta); if (mBlenderWater) - mBlenderWater->applyTimeDelta(delta); + changed |= mBlenderWater->applyTimeDelta(delta); + if (mBackup && changed) + backup(); } void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) @@ -1815,6 +2012,8 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) mSky->mReplaced |= different_sky; mSky->update(); mBlenderSky.reset(); + if (mBackup) + backup(); if (gAtmosphere) { @@ -1834,6 +2033,8 @@ void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) mWater = pwater; mWater->update(); mBlenderWater.reset(); + if (mBackup) + backup(); } void LLEnvironment::DayInstance::initialize() @@ -1875,6 +2076,53 @@ void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &sky mBlenderWater = waterblend; } + +void LLEnvironment::DayInstance::setBackup(bool backupval) +{ + if (backupval == mBackup) + return; + + mBackup = backupval; + LLSettingsSky::ptr_t psky = getSky(); + if (mBackup) + { + backup(); + } + else + { + restore(); + mBackupSky = LLSD(); + mBackupWater = LLSD(); + } +} + +void LLEnvironment::DayInstance::backup() +{ + if (!mBackup) + return; + + if (mSky) + { + mBackupSky = mSky->cloneSettings(); + } + if (mWater) + { + mBackupWater = mWater->cloneSettings(); + } +} + +void LLEnvironment::DayInstance::restore() +{ + if (!mBackupSky.isUndefined() && mSky) + { + mSky->replaceSettings(mBackupSky); + } + if (!mBackupWater.isUndefined() && mWater) + { + mWater->replaceSettings(mBackupWater); + } +} + LLSettingsBase::TrackPosition LLEnvironment::DayInstance::secondsToKeyframe(LLSettingsDay::Seconds seconds) { return convert_time_to_position(seconds, mDayLength); @@ -1923,7 +2171,7 @@ void LLEnvironment::DayInstance::animate() //------------------------------------------------------------------------- LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart, const LLSettingsWater::ptr_t &waterstart, LLEnvironment::DayInstance::ptr_t &end, LLSettingsDay::Seconds time) : - DayInstance(), + DayInstance(ENV_NONE), mStartSky(skystart), mStartWater(waterstart), mNextInstance(end), @@ -2038,3 +2286,5 @@ F64 LLTrackBlenderLoopingManual::getSpanLength(const LLSettingsDay::TrackBound_t { return get_wrapping_distance((*bounds.first).first, (*bounds.second).first); } + +//========================================================================= -- cgit v1.2.3 From 634910f685057c50ae3233d9f71d4b21cf958749 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 14 Dec 2018 14:33:42 -0800 Subject: SL-10241: Group roll for changing environment. --- indra/newview/llenvironment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 27b4789dfd..a8a386edee 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -495,7 +495,7 @@ bool LLEnvironment::canAgentUpdateParcelEnvironment(LLParcel *parcel) const if (!parcel->getRegionAllowEnvironmentOverride()) return false; - return LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_OPTIONS); + return LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_ALLOW_ENVIRONMENT); } bool LLEnvironment::canAgentUpdateRegionEnvironment() const -- cgit v1.2.3 From 8227a0b270f6e7cc521adeb7b97ad2d5fb646973 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 21 Dec 2018 15:30:57 -0800 Subject: SL-10279: Rework the environment pannel. Still in progress. --- indra/newview/llenvironment.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index a8a386edee..3541eb40fa 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1600,6 +1600,7 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL LLSD daynames = environment[KEY_DAYNAMES]; if (daynames.isArray()) { + pinfo->mDayCycleName.clear(); for (S32 index = 0; index < pinfo->mNameList.size(); ++index) { pinfo->mNameList[index] = daynames[index].asString(); @@ -1607,9 +1608,19 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL } else if (daynames.isString()) { + for (std::string &name: pinfo->mNameList) + { + name.clear(); + } + pinfo->mDayCycleName = daynames.asString(); } } + else if (pinfo->mDayCycle) + { + pinfo->mDayCycleName = pinfo->mDayCycle->getName(); + } + if (environment.has(KEY_ENVVERSION)) { -- cgit v1.2.3 From 1871f03d12e7a8e388d188f87e612117bcda75c1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 7 Jan 2019 17:00:01 -0800 Subject: SL-10067, SL-9917: Updated UUIDs for sun and moon textures and to corrected known skies. --- indra/newview/llenvironment.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3541eb40fa..d925dd9d49 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -323,10 +323,10 @@ const F32Seconds LLEnvironment::TRANSITION_DEFAULT(5.0f); const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F32Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); -const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("7e1489ce-fdc8-2971-c3a4-f1fe0cd70d20"); -const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("9db06848-8b1f-501d-eeae-ecf487f40dd6"); -const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("95882e1b-7741-f082-d9d6-3a34ec644c66"); -const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("d8e50d02-a15b-17a7-3425-523bc20f67b8"); +const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("01e41537-ff51-2f1f-8ef7-17e4df760bfb"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("6c83e853-e7f8-cad7-8ee6-5f31c453721c"); +const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("084e26cd-a900-28e8-08d0-64a9de5c15e2"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("8a01b97a-cb20-c1ea-ac63-f7ea84ad0090"); const S32 LLEnvironment::NO_TRACK(-1); const S32 LLEnvironment::NO_VERSION(-3); // For viewer sided change, like ENV_LOCAL. -3 since -1 and -2 are taken by parcel initial server/viewer version -- cgit v1.2.3 From 00d8caa359a216620db46d49696bc79a95fe8dc2 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 10 Jan 2019 22:11:11 +0200 Subject: SL-10279 Finalize drag and drop support --- indra/newview/llenvironment.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index d925dd9d49..5acd508d5d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1200,7 +1200,7 @@ void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_lengt updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset, altitudes, cb); } -void LLEnvironment::updateRegion(const LLUUID &asset_id, std::string display_name, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +void LLEnvironment::updateRegion(const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { if (!isExtendedEnvironmentEnabled()) { @@ -1209,7 +1209,7 @@ void LLEnvironment::updateRegion(const LLUUID &asset_id, std::string display_nam return; } - updateParcel(INVALID_PARCEL_ID, asset_id, display_name, day_length, day_offset, altitudes, cb); + updateParcel(INVALID_PARCEL_ID, asset_id, display_name, track_num, day_length, day_offset, altitudes, cb); } void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) @@ -1261,12 +1261,12 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) [this, parcel_id, cb]() { coroRequestEnvironment(parcel_id, cb); }); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, std::string display_name, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { UpdateInfo::ptr_t updates(std::make_shared(asset_id, display_name, day_length, day_offset, altitudes)); std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", - [this, parcel_id, updates, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, updates, cb); }); + [this, parcel_id, track_num, updates, cb]() { coroUpdateEnvironment(parcel_id, track_num, updates, cb); }); } void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes) @@ -1309,13 +1309,18 @@ void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pw updateParcel(parcel_id, pday, day_length, day_offset, altitudes, cb); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 track_num, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { UpdateInfo::ptr_t updates(std::make_shared(pday, day_length, day_offset, altitudes)); std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", - [this, parcel_id, updates, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, updates, cb); }); + [this, parcel_id, track_num, updates, cb]() { coroUpdateEnvironment(parcel_id, track_num, updates, cb); }); +} + +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +{ + updateParcel(parcel_id, pday, NO_TRACK, day_length, day_offset, altitudes, cb); } -- cgit v1.2.3 From f42ac5b94e384c789de0b2c4e865b087589a940e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 22 Jan 2019 09:24:11 -0800 Subject: SL-10387: Move settings intjection to a setting object (and out of llEnvironment) --- indra/newview/llenvironment.cpp | 328 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 307 insertions(+), 21 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 5acd508d5d..415cdfac6a 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -97,6 +97,9 @@ namespace const std::string KEY_PARCELNAME("ParcelName"); // But changing these would also alter the Experience Log requirements. const std::string KEY_COUNT("Count"); + const std::string LISTENER_NAME("LLEnvironmentSingleton"); + const std::string PUMP_EXPERIENCE("experience_permission"); + //--------------------------------------------------------------------- LLTrace::BlockTimerStatHandle FTM_ENVIRONMENT_UPDATE("Update Environment Tick"); LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); @@ -274,7 +277,6 @@ namespace } }; - class LLEnvironmentPushDispatchHandler : public LLDispatchHandler { public: @@ -314,6 +316,187 @@ namespace LLEnvironmentPushDispatchHandler environment_push_dispatch_handler; + template + class LLSettingsInjected : public SETTINGT + { + public: + typedef std::shared_ptr > ptr_t; + + LLSettingsInjected(typename SETTINGT::ptr_t source) : + SETTINGT(), + mSource(source) + {} + + virtual ~LLSettingsInjected() {}; + + typename SETTINGT::ptr_t buildClone() const override; + + typename SETTINGT::ptr_t getSource() const { return mSource; } + void setSource(const typename SETTINGT::ptr_t &source) { mSource = source; setDirtyFlag(true); } + + void injectSetting(const std::string keyname, LLSD value, LLUUID experience_id, F32Seconds transition) + { + Injection::ptr_t injection = std::make_shared(transition, keyname, value, true, experience_id); + + mInjections.push_back(injection); + std::stable_sort(mInjections.begin(), mInjections.end(), [](const Injection::ptr_t &a, const Injection::ptr_t &b) { return a->mTimeRemaining < b->mTimeRemaining; }); + } + + void removeInjection(const std::string keyname, LLUUID experience) + { + auto it = mInjections.begin(); + while (it != mInjections.end()) + { + if (((*it)->mKeyName == keyname) && + (experience.isNull() || (experience == (*it)->mExperience))) + { + mInjections.erase(it++); + } + else + { + ++it; + } + } + + for (auto itexp = mOverrideExps.begin(); itexp != mOverrideExps.end();) + { + if (experience.isNull() || ((*itexp).second == experience)) + { + mOverrideValues.erase((*itexp).first); + mOverrideExps.erase(itexp++); + } + else + ++itexp; + } + } + + void injectExperienceValues(LLSD values, LLUUID experience_id, F32Seconds transition) + { + for (auto it = values.beginMap(); it != values.endMap(); ++it) + { + injectSetting((*it).first, (*it).second, experience_id, transition); + } + setDirtyFlag(true); + } + + protected: + struct Injection + { + struct Injection(F32Seconds transition, const std::string &keyname, LLSD value, bool blendin, LLUUID experince, S32 index = -1) : + mTransition(transition), + mTimeRemaining(transition), + mKeyName(keyname), + mValue(value), + mExperience(experince), + mIndex(index), + mBlendIn(blendin) + {} + + F32Seconds mTransition; + F32Seconds mTimeRemaining; + std::string mKeyName; + LLSD mValue; + LLUUID mExperience; + S32 mIndex; + bool mBlendIn; + + typedef std::shared_ptr ptr_t; + }; + + + virtual void updateSettings() override + { + static LLFrameTimer timer; + + /**TODO: Add texture code + */ + + F32Seconds delta(timer.getElapsedTimeAndResetF32()); + + if (mSource && mSource->isDirty()) + { + mSource->updateSettings(); + } + + mSettings = mSource->getSettings(); + + for (auto ito = mOverrideValues.beginMap(); ito != mOverrideValues.endMap(); ++ito) + { + mSettings[(*ito).first] = mOverrideValues[(*ito).first]; + } + + const stringset_t &slerps = getSlerpKeys(); + const stringset_t &skips = getSkipInterpolateKeys(); + + injections_t::iterator it; + for (it = mInjections.begin(); it != mInjections.end(); ++it) + { + std::string key_name = (*it)->mKeyName; + if (skips.find(key_name) != skips.end()) + continue; + LLSD value = mSettings[key_name]; + LLSD target = (*it)->mValue; + + (*it)->mTimeRemaining -= delta; + + BlendFactor mix = 1.0f - (((*it)->mTransition.value() - (*it)->mTimeRemaining.value()) / (*it)->mTransition.value()); + + if (mix >= 1.0) + { + if ((*it)->mBlendIn) + { + mOverrideValues[key_name] = target; + mOverrideExps[key_name] = (*it)->mExperience; + } + mSettings[key_name] = target; + } + else + { + mSettings[key_name] = interpolateSDValue(key_name, value, target, getParameterMap(), mix, slerps); + } + } + + it = mInjections.begin(); + it = std::find_if(mInjections.begin(), mInjections.end(), [](const Injection::ptr_t &a) { return a->mTimeRemaining > 0.0f; }); + + if (it != mInjections.begin()) + { + + mInjections.erase(mInjections.begin(), mInjections.end()); + } + + SETTINGT::updateSettings(); + + if (!mInjections.empty()) + setDirtyFlag(true); + } + + + private: + typedef std::map key_to_expid_t; + typedef std::deque injections_t; + + typename SETTINGT::ptr_t mSource; + injections_t mInjections; + LLSD mOverrideValues; + key_to_expid_t mOverrideExps; + }; + + template<> + LLSettingsSky::ptr_t LLSettingsInjected::buildClone() const + { + return LLSettingsVOSky::buildSky(getSettings()); + } + + template<> + LLSettingsWater::ptr_t LLSettingsInjected::buildClone() const + { + return LLSettingsVOWater::buildWater(getSettings()); + } + + + typedef LLSettingsInjected LLSettingsInjectedSky; + typedef LLSettingsInjected LLSettingsInjectedWater; } //========================================================================= @@ -374,6 +557,12 @@ void LLEnvironment::initSingleton() gGenericDispatcher.addHandler(MESSAGE_PUSHENVIRONMENT, &environment_push_dispatch_handler); } + LLEventPumps::instance().obtain(PUMP_EXPERIENCE).listen(LISTENER_NAME, [this](LLSD message) { listenExperiencePump(message); return false; }); +} + +void LLEnvironment::cleanupSingleton() +{ + LLEventPumps::instance().obtain(PUMP_EXPERIENCE).stopListening(LISTENER_NAME); } LLEnvironment::~LLEnvironment() @@ -808,12 +997,12 @@ LLSettingsDay::Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env } -LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironment::EnvSelection_t env) +LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironment::EnvSelection_t env, bool resolve) { - if (env == ENV_CURRENT) + if ((env == ENV_CURRENT) || resolve) { fixedEnvironment_t fixed; - for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) + for (S32 idx = ((resolve) ? env : mSelectedEnvironment); idx < ENV_END; ++idx) { if (fixed.first && fixed.second) break; @@ -1800,7 +1989,6 @@ void LLEnvironment::handleEnvironmentPush(LLSD &message) } } - void LLEnvironment::handleEnvironmentPushClear(LLUUID experience_id, LLSD &message, F32 transition) { clearExperienceEnvironment(experience_id, transition); @@ -1837,15 +2025,15 @@ void LLEnvironment::clearExperienceEnvironment(LLUUID experience_id, F32 transit setInstanceBackup(false); /*TODO blend these back out*/ - mSkyExperienceBlends.clear(); - mWaterExperienceBlends.clear(); - mCurrentEnvironment->getSky(); - - injectSettings(experience_id, mSkyExperienceBlends, mSkyOverrides, LLSettingsBase::Seconds(transition_time), false); - injectSettings(experience_id, mWaterExperienceBlends, mWaterOverrides, LLSettingsBase::Seconds(transition_time), false); - - mSkyOverrides = LLSD::emptyMap(); - mWaterOverrides = LLSD::emptyMap(); +// mSkyExperienceBlends.clear(); +// mWaterExperienceBlends.clear(); +// mCurrentEnvironment->getSky(); +// +// injectSettings(experience_id, mSkyExperienceBlends, mSkyOverrides, LLSettingsBase::Seconds(transition_time), false); +// injectSettings(experience_id, mWaterExperienceBlends, mWaterOverrides, LLSettingsBase::Seconds(transition_time), false); +// +// mSkyOverrides = LLSD::emptyMap(); +// mWaterOverrides = LLSD::emptyMap(); } void LLEnvironment::setSharedEnvironment() @@ -1860,8 +2048,10 @@ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLUUID asset_ LLSettingsVOBase::getSettingsAsset(asset_id, [this, experience_id, transition_time](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { - mPushEnvironmentExpId = experience_id; - onSetEnvAssetLoaded(ENV_PUSH, asset_id, settings, +// mPushEnvironmentExpId = experience_id; +// removeExperinceInjections(experience_id); + // individual settings will be overridden by the settings. No need to keep injections. + onSetEnvAssetLoaded(ENV_PUSH, asset_id, settings, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET, LLSettingsBase::Seconds(transition_time), status, NO_VERSION); }); @@ -1880,15 +2070,63 @@ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLSD data, F3 return; } - setInstanceBackup(true); + LLSettingsInjectedSky::ptr_t pinjectedsky; + LLSettingsInjectedWater::ptr_t pinjectedwater; + + fixedEnvironment_t pushenv = getEnvironmentFixed(ENV_PUSH, true); if (!sky.isUndefined()) - injectSettings(experience_id, mSkyExperienceBlends, sky, LLSettingsBase::Seconds(transition_time), true); + { + bool newsky(false); + + if (pushenv.first) + { + pinjectedsky = std::dynamic_pointer_cast(pushenv.first); + } + if (!pinjectedsky) + { + pinjectedsky = std::make_shared(pushenv.first); + newsky = true; + } + + pinjectedsky->injectExperienceValues(sky, experience_id, F32Seconds(transition_time)); + if (!newsky) + pinjectedsky.reset(); + } + if (!water.isUndefined()) - injectSettings(experience_id, mWaterExperienceBlends, water, LLSettingsBase::Seconds(transition_time), true); + { + bool newwater(false); + if (pushenv.second) + { + pinjectedwater = std::dynamic_pointer_cast(pushenv.second); + } + if (!pinjectedwater) + { + pinjectedwater = std::make_shared(pushenv.second); + newwater = true; + } + + pinjectedwater->injectExperienceValues(water, experience_id, F32Seconds(transition_time)); + if (!newwater) + pinjectedwater.reset(); + } + + if (pinjectedsky || pinjectedwater) + { + setEnvironment(ENV_PUSH, pinjectedsky, pinjectedwater); + updateEnvironment(TRANSITION_INSTANT); + } -} +// setInstanceBackup(true); +// +// if (!sky.isUndefined()) +// injectSettings(experience_id, mSkyExperienceBlends, sky, LLSettingsBase::Seconds(transition_time), true); +// if (!water.isUndefined()) +// injectSettings(experience_id, mWaterExperienceBlends, water, LLSettingsBase::Seconds(transition_time), true); + +} void LLEnvironment::setInstanceBackup(bool dobackup) { @@ -1905,6 +2143,8 @@ void LLEnvironment::injectSettings(LLUUID experience_id, exerienceBlendValues_t for (LLSD::map_iterator it = injections.beginMap(); it != injections.endMap(); ++it) { blends.push_back(ExpBlendValue(transition, (*it).first, (*it).second, blendin, -1)); + if (blendin) + mExperienceOverrides[(*it).first] = experience_id; } std::stable_sort(blends.begin(), blends.end(), [](const ExpBlendValue &a, const ExpBlendValue &b) { return a.mTimeRemaining < b.mTimeRemaining; }); @@ -1926,7 +2166,6 @@ void LLEnvironment::applyInjectedSettings(DayInstance::ptr_t environment, F32Sec } } - void LLEnvironment::applyInjectedValues(LLSettingsBase::ptr_t psetting, LLSD injection) { for (LLSD::map_iterator it = injection.beginMap(); it != injection.endMap(); ++it) @@ -1973,6 +2212,53 @@ void LLEnvironment::blendInjectedValues(LLSettingsBase::ptr_t psetting, exerienc } } +void LLEnvironment::removeExperinceInjections(const LLUUID &experience_id) +{ + auto it = mExperienceOverrides.begin(); + while (it != mExperienceOverrides.end()) + { + if ((*it).second == experience_id) + { + std::string override_key((*it).first); + mExperienceOverrides.erase(it++); + + if (mSkyOverrides.has(override_key)) + mSkyOverrides.erase(override_key); + if (mWaterOverrides.has(override_key)) + mWaterOverrides.erase(override_key); + auto itBlend = std::find_if(mSkyExperienceBlends.begin(), mSkyExperienceBlends.end(), [override_key](const ExpBlendValue &a) { return a.mKeyName == override_key; }); + if (itBlend != mSkyExperienceBlends.end()) + mSkyExperienceBlends.erase(itBlend); + itBlend = std::find_if(mWaterExperienceBlends.begin(), mWaterExperienceBlends.end(), [override_key](const ExpBlendValue &a) { return a.mKeyName == override_key; }); + if (itBlend != mWaterExperienceBlends.end()) + mWaterExperienceBlends.erase(itBlend); + } + else + ++it; + } +} + +void LLEnvironment::removeExperinceSetting(const LLUUID &experience_id) +{ + clearExperienceEnvironment(experience_id, TRANSITION_INSTANT); +} + +void LLEnvironment::listenExperiencePump(const LLSD &message) +{ + LL_WARNS("LAPRAS") << "Have experience event: " << message << LL_ENDL; + + LLUUID experience_id = message["experience"]; + LLSD data = message[experience_id.asString()]; + std::string permission(data["permission"].asString()); + + if ((permission == "Forget") || (permission == "Block")) + { + removeExperinceSetting(experience_id); + } + + +} + //========================================================================= LLEnvironment::DayInstance::DayInstance(EnvSelection_t env) : mDayCycle(), -- cgit v1.2.3 From b465a5bf6f4f63026ff66bfee4671584c47c4119 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 22 Jan 2019 16:53:14 -0800 Subject: SL-10387: Inject individual settings. Still freezes parcel/region settings. --- indra/newview/llenvironment.cpp | 335 +++++++++++++++++++--------------------- 1 file changed, 158 insertions(+), 177 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 415cdfac6a..a9251629d4 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -174,8 +174,8 @@ namespace class LLTrackBlenderLoopingTime : public LLSettingsBlenderTimeDelta { public: - LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, - LLSettingsBase::Seconds cyclelength, LLSettingsBase::Seconds cycleoffset, LLSettingsBase::Seconds updateThreshold) : + LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, + LLSettingsBase::Seconds cyclelength, LLSettingsBase::Seconds cycleoffset, LLSettingsBase::Seconds updateThreshold) : LLSettingsBlenderTimeDelta(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t(), LLSettingsBase::Seconds(1.0)), mDay(day), mTrackNo(0), @@ -210,8 +210,8 @@ namespace LLSettingsBase::Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE; LLSettingsDay::TrackBound_t bounds = getBoundingEntries(now); - LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); - LLSettingsBase::TrackPosition targetpos = convert_time_to_position(now, mCycleLength) - (*bounds.first).first; + LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone(); + LLSettingsBase::TrackPosition targetpos = convert_time_to_position(now, mCycleLength) - (*bounds.first).first; LLSettingsBase::TrackPosition targetspan = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); LLSettingsBase::BlendFactor blendf = calculateBlend(targetpos, targetspan); @@ -329,17 +329,26 @@ namespace virtual ~LLSettingsInjected() {}; - typename SETTINGT::ptr_t buildClone() const override; +// typename SETTINGT::ptr_t buildClone() const override; - typename SETTINGT::ptr_t getSource() const { return mSource; } + typename SETTINGT::ptr_t getSource() const { return mSource; } void setSource(const typename SETTINGT::ptr_t &source) { mSource = source; setDirtyFlag(true); } void injectSetting(const std::string keyname, LLSD value, LLUUID experience_id, F32Seconds transition) { - Injection::ptr_t injection = std::make_shared(transition, keyname, value, true, experience_id); + if (transition > 0.1) + { + Injection::ptr_t injection = std::make_shared(transition, keyname, value, true, experience_id); - mInjections.push_back(injection); - std::stable_sort(mInjections.begin(), mInjections.end(), [](const Injection::ptr_t &a, const Injection::ptr_t &b) { return a->mTimeRemaining < b->mTimeRemaining; }); + mInjections.push_back(injection); + std::stable_sort(mInjections.begin(), mInjections.end(), [](const Injection::ptr_t &a, const Injection::ptr_t &b) { return a->mTimeRemaining < b->mTimeRemaining; }); + } + else + { + mOverrideValues[keyname] = value; + mOverrideExps[keyname] = experience_id; + setDirtyFlag(true); + } } void removeInjection(const std::string keyname, LLUUID experience) @@ -389,7 +398,8 @@ namespace mValue(value), mExperience(experince), mIndex(index), - mBlendIn(blendin) + mBlendIn(blendin), + mFirstTime(true) {} F32Seconds mTransition; @@ -399,20 +409,20 @@ namespace LLUUID mExperience; S32 mIndex; bool mBlendIn; + bool mFirstTime; typedef std::shared_ptr ptr_t; }; - virtual void updateSettings() override + virtual void updateSettings() override { static LLFrameTimer timer; - /**TODO: Add texture code - */ - F32Seconds delta(timer.getElapsedTimeAndResetF32()); + resetSpecial(); + if (mSource && mSource->isDirty()) { mSource->updateSettings(); @@ -422,37 +432,50 @@ namespace for (auto ito = mOverrideValues.beginMap(); ito != mOverrideValues.endMap(); ++ito) { - mSettings[(*ito).first] = mOverrideValues[(*ito).first]; + mSettings[(*ito).first] = (*ito).second; } const stringset_t &slerps = getSlerpKeys(); const stringset_t &skips = getSkipInterpolateKeys(); + const stringset_t &specials = getSpecialKeys(); injections_t::iterator it; for (it = mInjections.begin(); it != mInjections.end(); ++it) { std::string key_name = (*it)->mKeyName; - if (skips.find(key_name) != skips.end()) - continue; + LLSD value = mSettings[key_name]; LLSD target = (*it)->mValue; - (*it)->mTimeRemaining -= delta; + if ((*it)->mFirstTime) + (*it)->mFirstTime = false; + else + (*it)->mTimeRemaining -= delta; - BlendFactor mix = 1.0f - (((*it)->mTransition.value() - (*it)->mTimeRemaining.value()) / (*it)->mTransition.value()); + BlendFactor mix = 1.0f - ((*it)->mTimeRemaining.value() / (*it)->mTransition.value()); if (mix >= 1.0) { if ((*it)->mBlendIn) { + LL_WARNS("LAPRAS") << "Done blending '" << key_name << "' after " << (*it)->mTransition.value() - (*it)->mTimeRemaining.value() << " value now=" << target << LL_ENDL; mOverrideValues[key_name] = target; mOverrideExps[key_name] = (*it)->mExperience; + mSettings[key_name] = target; + } + else + { + mSettings.erase(key_name); } - mSettings[key_name] = target; } - else + else if (specials.find(key_name) != specials.end()) + { + updateSpecial(*it, mix); + } + else if (skips.find(key_name) == skips.end()) { mSettings[key_name] = interpolateSDValue(key_name, value, target, getParameterMap(), mix, slerps); +// LL_WARNS("LAPRAS") << "...blending '" << key_name << "' by " << mix << "% now=" << mSettings[key_name] << LL_ENDL; } } @@ -471,6 +494,9 @@ namespace setDirtyFlag(true); } + LLSettingsBase::stringset_t getSpecialKeys() const; + void resetSpecial(); + void updateSpecial(typename const Injection::ptr_t &injection, LLSettingsBase::BlendFactor mix); private: typedef std::map key_to_expid_t; @@ -482,21 +508,125 @@ namespace key_to_expid_t mOverrideExps; }; +// template<> +// LLSettingsSky::ptr_t LLSettingsInjected::buildClone() const +// { +// return LLSettingsVOSky::buildSky(getSettings()); +// } +// +// template<> +// LLSettingsWater::ptr_t LLSettingsInjected::buildClone() const +// { +// return LLSettingsVOWater::buildWater(getSettings()); +// } + + template<> + LLSettingsBase::stringset_t LLSettingsInjected::getSpecialKeys() const + { + static stringset_t specialSet; + + if (specialSet.empty()) + { + specialSet.insert(SETTING_BLOOM_TEXTUREID); + specialSet.insert(SETTING_RAINBOW_TEXTUREID); + specialSet.insert(SETTING_HALO_TEXTUREID); + specialSet.insert(SETTING_CLOUD_TEXTUREID); + specialSet.insert(SETTING_MOON_TEXTUREID); + specialSet.insert(SETTING_SUN_TEXTUREID); + } + return specialSet; + } + template<> - LLSettingsSky::ptr_t LLSettingsInjected::buildClone() const + LLSettingsBase::stringset_t LLSettingsInjected::getSpecialKeys() const { - return LLSettingsVOSky::buildSky(getSettings()); + static stringset_t specialSet; + + if (specialSet.empty()) + { + specialSet.insert(SETTING_TRANSPARENT_TEXTURE); + specialSet.insert(SETTING_NORMAL_MAP); + } + return specialSet; } template<> - LLSettingsWater::ptr_t LLSettingsInjected::buildClone() const + void LLSettingsInjected::resetSpecial() { - return LLSettingsVOWater::buildWater(getSettings()); + mNextSunTextureId.setNull(); + mNextMoonTextureId.setNull(); + mNextCloudTextureId.setNull(); + mNextBloomTextureId.setNull(); + mNextRainbowTextureId.setNull(); + mNextHaloTextureId.setNull(); + setBlendFactor(0.0f); } + template<> + void LLSettingsInjected::resetSpecial() + { + mNextNormalMapID.setNull(); + mNextTransparentTextureID.setNull(); + setBlendFactor(0.0f); + } + + template<> + void LLSettingsInjected::updateSpecial(const LLSettingsInjected::Injection::ptr_t &injection, LLSettingsBase::BlendFactor mix) + { + if (injection->mKeyName == SETTING_SUN_TEXTUREID) + { + mNextSunTextureId = injection->mValue.asUUID(); + } + else if (injection->mKeyName == SETTING_MOON_TEXTUREID) + { + mNextMoonTextureId = injection->mValue.asUUID(); + } + else if (injection->mKeyName == SETTING_CLOUD_TEXTUREID) + { + mNextCloudTextureId = injection->mValue.asUUID(); + } + else if (injection->mKeyName == SETTING_BLOOM_TEXTUREID) + { + mNextBloomTextureId = injection->mValue.asUUID(); + } + else if (injection->mKeyName == SETTING_RAINBOW_TEXTUREID) + { + mNextRainbowTextureId = injection->mValue.asUUID(); + } + else if (injection->mKeyName == SETTING_HALO_TEXTUREID) + { + mNextHaloTextureId = injection->mValue.asUUID(); + } + + // Unfortunately I don't have a per texture blend factor. We'll just pick the one that is furthest along. + if (getBlendFactor() < mix) + { + setBlendFactor(mix); + } + } + + template<> + void LLSettingsInjected::updateSpecial(const LLSettingsInjected::Injection::ptr_t &injection, LLSettingsBase::BlendFactor mix) + { + if (injection->mKeyName == SETTING_NORMAL_MAP) + { + mNextNormalMapID = injection->mValue.asUUID(); + } + else if (injection->mKeyName == SETTING_TRANSPARENT_TEXTURE) + { + mNextTransparentTextureID = injection->mValue.asUUID(); + } + + // Unfortunately I don't have a per texture blend factor. We'll just pick the one that is furthest along. + if (getBlendFactor() < mix) + { + setBlendFactor(mix); + } + + } - typedef LLSettingsInjected LLSettingsInjectedSky; - typedef LLSettingsInjected LLSettingsInjectedWater; + typedef LLSettingsInjected LLSettingsInjectedSky; + typedef LLSettingsInjected LLSettingsInjectedWater; } //========================================================================= @@ -777,8 +907,6 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnviro else { environment = std::make_shared(env); - if (mMakeBackups && env > ENV_PUSH) - environment->setBackup(true); } mEnvironments[env] = environment; } @@ -1188,11 +1316,6 @@ void LLEnvironment::update(const LLViewerCamera * cam) mCurrentEnvironment->applyTimeDelta(delta); - if (mCurrentEnvironment->getEnvironmentSelection() != ENV_LOCAL) - { - applyInjectedSettings(mCurrentEnvironment, delta); - } - // update clouds, sun, and general updateCloudScroll(); @@ -2013,27 +2136,12 @@ void LLEnvironment::handleEnvironmentPushPartial(LLUUID experience_id, LLSD &mes void LLEnvironment::clearExperienceEnvironment(LLUUID experience_id, F32 transition_time) { - bool update_env(false); - if (hasEnvironment(ENV_PUSH)) { - update_env |= true; clearEnvironment(ENV_PUSH); updateEnvironment(LLSettingsBase::Seconds(transition_time)); } - setInstanceBackup(false); - - /*TODO blend these back out*/ -// mSkyExperienceBlends.clear(); -// mWaterExperienceBlends.clear(); -// mCurrentEnvironment->getSky(); -// -// injectSettings(experience_id, mSkyExperienceBlends, mSkyOverrides, LLSettingsBase::Seconds(transition_time), false); -// injectSettings(experience_id, mWaterExperienceBlends, mWaterOverrides, LLSettingsBase::Seconds(transition_time), false); -// -// mSkyOverrides = LLSD::emptyMap(); -// mWaterOverrides = LLSD::emptyMap(); } void LLEnvironment::setSharedEnvironment() @@ -2048,8 +2156,6 @@ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLUUID asset_ LLSettingsVOBase::getSettingsAsset(asset_id, [this, experience_id, transition_time](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { -// mPushEnvironmentExpId = experience_id; -// removeExperinceInjections(experience_id); // individual settings will be overridden by the settings. No need to keep injections. onSetEnvAssetLoaded(ENV_PUSH, asset_id, settings, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET, @@ -2118,129 +2224,6 @@ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLSD data, F3 updateEnvironment(TRANSITION_INSTANT); } - -// setInstanceBackup(true); -// -// if (!sky.isUndefined()) -// injectSettings(experience_id, mSkyExperienceBlends, sky, LLSettingsBase::Seconds(transition_time), true); -// if (!water.isUndefined()) -// injectSettings(experience_id, mWaterExperienceBlends, water, LLSettingsBase::Seconds(transition_time), true); - -} - -void LLEnvironment::setInstanceBackup(bool dobackup) -{ - mMakeBackups = dobackup; - for (S32 idx = ENV_PARCEL; idx < ENV_DEFAULT; ++idx) - { - if (mEnvironments[idx]) - mEnvironments[idx]->setBackup(dobackup); - } -} - -void LLEnvironment::injectSettings(LLUUID experience_id, exerienceBlendValues_t &blends, LLSD injections, LLSettingsBase::Seconds transition, bool blendin) -{ - for (LLSD::map_iterator it = injections.beginMap(); it != injections.endMap(); ++it) - { - blends.push_back(ExpBlendValue(transition, (*it).first, (*it).second, blendin, -1)); - if (blendin) - mExperienceOverrides[(*it).first] = experience_id; - } - - std::stable_sort(blends.begin(), blends.end(), [](const ExpBlendValue &a, const ExpBlendValue &b) { return a.mTimeRemaining < b.mTimeRemaining; }); -} - -void LLEnvironment::applyInjectedSettings(DayInstance::ptr_t environment, F32Seconds delta) -{ - if ((mSkyOverrides.size() > 0) || (mSkyExperienceBlends.size() > 0)) - { - LLSettingsSky::ptr_t psky = environment->getSky(); - applyInjectedValues(psky, mSkyOverrides); - blendInjectedValues(psky, mSkyExperienceBlends, mSkyOverrides, delta); - } - if ((mWaterOverrides.size() > 0) || (mWaterExperienceBlends.size() > 0)) - { - LLSettingsWater::ptr_t pwater = environment->getWater(); - applyInjectedValues(pwater, mWaterOverrides); - blendInjectedValues(pwater, mWaterExperienceBlends, mWaterOverrides, delta); - } -} - -void LLEnvironment::applyInjectedValues(LLSettingsBase::ptr_t psetting, LLSD injection) -{ - for (LLSD::map_iterator it = injection.beginMap(); it != injection.endMap(); ++it) - { - psetting->setValue((*it).first, (*it).second); - } -} - -void LLEnvironment::blendInjectedValues(LLSettingsBase::ptr_t psetting, exerienceBlendValues_t &blends, LLSD &overrides, F32Seconds delta) -{ - LLSD settings = psetting->getSettings(); - LLSettingsBase::parammapping_t mappings = psetting->getParameterMap(); - LLSettingsBase::stringset_t slerps = psetting->getSlerpKeys(); - - if (blends.empty()) - return; - - for (auto &blend : blends) - { - blend.mTimeRemaining -= delta; - LLSettingsBase::BlendFactor mix = std::max(blend.mTimeRemaining / blend.mTransition, 0.0f); - if (blend.mBlendIn) - mix = 1.0 - mix; - mix = std::max(0.0, std::min(mix, 1.0)); - - if (blend.mValueInitial.isUndefined()) - blend.mValueInitial = psetting->getValue(blend.mKeyName); - LLSD newvalue = psetting->interpolateSDValue(blend.mKeyName, blend.mValueInitial, blend.mValue, mappings, mix, slerps); - - psetting->setValue(blend.mKeyName, newvalue); - } - - auto it = blends.begin(); - for (; it != blends.end(); ++it) - { - if ((*it).mTimeRemaining > F32Seconds(0.0f)) - break; - if ((*it).mBlendIn) - overrides[(*it).mKeyName] = (*it).mValue; - } - if (it != blends.begin()) - { - blends.erase(blends.begin(), it); - } -} - -void LLEnvironment::removeExperinceInjections(const LLUUID &experience_id) -{ - auto it = mExperienceOverrides.begin(); - while (it != mExperienceOverrides.end()) - { - if ((*it).second == experience_id) - { - std::string override_key((*it).first); - mExperienceOverrides.erase(it++); - - if (mSkyOverrides.has(override_key)) - mSkyOverrides.erase(override_key); - if (mWaterOverrides.has(override_key)) - mWaterOverrides.erase(override_key); - auto itBlend = std::find_if(mSkyExperienceBlends.begin(), mSkyExperienceBlends.end(), [override_key](const ExpBlendValue &a) { return a.mKeyName == override_key; }); - if (itBlend != mSkyExperienceBlends.end()) - mSkyExperienceBlends.erase(itBlend); - itBlend = std::find_if(mWaterExperienceBlends.begin(), mWaterExperienceBlends.end(), [override_key](const ExpBlendValue &a) { return a.mKeyName == override_key; }); - if (itBlend != mWaterExperienceBlends.end()) - mWaterExperienceBlends.erase(itBlend); - } - else - ++it; - } -} - -void LLEnvironment::removeExperinceSetting(const LLUUID &experience_id) -{ - clearExperienceEnvironment(experience_id, TRANSITION_INSTANT); } void LLEnvironment::listenExperiencePump(const LLSD &message) @@ -2253,10 +2236,8 @@ void LLEnvironment::listenExperiencePump(const LLSD &message) if ((permission == "Forget") || (permission == "Block")) { - removeExperinceSetting(experience_id); + clearExperienceEnvironment(experience_id, (permission == "Block") ? TRANSITION_INSTANT : TRANSITION_FAST); } - - } //========================================================================= -- cgit v1.2.3 From 5ac74412508b42d86b6dde0097751832c997a1d9 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 23 Jan 2019 09:13:06 -0800 Subject: Mac is a bit picky --- indra/newview/llenvironment.cpp | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index a9251629d4..56a4fd7129 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -379,7 +379,7 @@ namespace } } - void injectExperienceValues(LLSD values, LLUUID experience_id, F32Seconds transition) + void injectExperienceValues(LLSD values, LLUUID experience_id, typename LLSettingsBase::Seconds transition) { for (auto it = values.beginMap(); it != values.endMap(); ++it) { @@ -391,7 +391,7 @@ namespace protected: struct Injection { - struct Injection(F32Seconds transition, const std::string &keyname, LLSD value, bool blendin, LLUUID experince, S32 index = -1) : + struct Injection(typename LLSettingsBase::Seconds transition, const std::string &keyname, LLSD value, bool blendin, LLUUID experince, S32 index = -1) : mTransition(transition), mTimeRemaining(transition), mKeyName(keyname), @@ -402,14 +402,14 @@ namespace mFirstTime(true) {} - F32Seconds mTransition; - F32Seconds mTimeRemaining; - std::string mKeyName; - LLSD mValue; - LLUUID mExperience; - S32 mIndex; - bool mBlendIn; - bool mFirstTime; + typename LLSettingsBase::Seconds mTransition; + typename LLSettingsBase::Seconds mTimeRemaining; + std::string mKeyName; + LLSD mValue; + LLUUID mExperience; + S32 mIndex; + bool mBlendIn; + bool mFirstTime; typedef std::shared_ptr ptr_t; }; @@ -419,7 +419,7 @@ namespace { static LLFrameTimer timer; - F32Seconds delta(timer.getElapsedTimeAndResetF32()); + LLSettingsBase::Seconds delta(timer.getElapsedTimeAndResetF32()); resetSpecial(); @@ -508,18 +508,6 @@ namespace key_to_expid_t mOverrideExps; }; -// template<> -// LLSettingsSky::ptr_t LLSettingsInjected::buildClone() const -// { -// return LLSettingsVOSky::buildSky(getSettings()); -// } -// -// template<> -// LLSettingsWater::ptr_t LLSettingsInjected::buildClone() const -// { -// return LLSettingsVOWater::buildWater(getSettings()); -// } - template<> LLSettingsBase::stringset_t LLSettingsInjected::getSpecialKeys() const { -- cgit v1.2.3 From a5392bb8e822b3f75559275b3ccef7d4c55b0f9d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 23 Jan 2019 10:10:19 -0800 Subject: Found the issue. --- indra/newview/llenvironment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 56a4fd7129..d9870140ac 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -391,7 +391,7 @@ namespace protected: struct Injection { - struct Injection(typename LLSettingsBase::Seconds transition, const std::string &keyname, LLSD value, bool blendin, LLUUID experince, S32 index = -1) : + Injection(typename LLSettingsBase::Seconds transition, const std::string &keyname, LLSD value, bool blendin, LLUUID experince, S32 index = -1) : mTransition(transition), mTimeRemaining(transition), mKeyName(keyname), -- cgit v1.2.3 From f6b27a4a0cb27ac26411809905ecae0e5fdcccb2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 23 Jan 2019 10:54:46 -0800 Subject: More OSX pickyness. --- indra/newview/llenvironment.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index d9870140ac..31246d9a6c 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -428,23 +428,23 @@ namespace mSource->updateSettings(); } - mSettings = mSource->getSettings(); + this->mSettings = mSource->getSettings(); for (auto ito = mOverrideValues.beginMap(); ito != mOverrideValues.endMap(); ++ito) { - mSettings[(*ito).first] = (*ito).second; + this->mSettings[(*ito).first] = (*ito).second; } const stringset_t &slerps = getSlerpKeys(); const stringset_t &skips = getSkipInterpolateKeys(); const stringset_t &specials = getSpecialKeys(); - injections_t::iterator it; + typename injections_t::iterator it; for (it = mInjections.begin(); it != mInjections.end(); ++it) { std::string key_name = (*it)->mKeyName; - LLSD value = mSettings[key_name]; + LLSD value = this->mSettings[key_name]; LLSD target = (*it)->mValue; if ((*it)->mFirstTime) @@ -452,7 +452,7 @@ namespace else (*it)->mTimeRemaining -= delta; - BlendFactor mix = 1.0f - ((*it)->mTimeRemaining.value() / (*it)->mTransition.value()); + typename LLSettingsBase::BlendFactor mix = 1.0f - ((*it)->mTimeRemaining.value() / (*it)->mTransition.value()); if (mix >= 1.0) { @@ -461,11 +461,11 @@ namespace LL_WARNS("LAPRAS") << "Done blending '" << key_name << "' after " << (*it)->mTransition.value() - (*it)->mTimeRemaining.value() << " value now=" << target << LL_ENDL; mOverrideValues[key_name] = target; mOverrideExps[key_name] = (*it)->mExperience; - mSettings[key_name] = target; + this->mSettings[key_name] = target; } else { - mSettings.erase(key_name); + this->mSettings.erase(key_name); } } else if (specials.find(key_name) != specials.end()) @@ -474,7 +474,7 @@ namespace } else if (skips.find(key_name) == skips.end()) { - mSettings[key_name] = interpolateSDValue(key_name, value, target, getParameterMap(), mix, slerps); + this->mSettings[key_name] = interpolateSDValue(key_name, value, target, getParameterMap(), mix, slerps); // LL_WARNS("LAPRAS") << "...blending '" << key_name << "' by " << mix << "% now=" << mSettings[key_name] << LL_ENDL; } } -- cgit v1.2.3 From 618af868db91cd1a394541c4bc9afb52458202d7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 23 Jan 2019 11:45:07 -0800 Subject: More OSX template --- indra/newview/llenvironment.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 31246d9a6c..2f92ac8c72 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -331,23 +331,23 @@ namespace // typename SETTINGT::ptr_t buildClone() const override; - typename SETTINGT::ptr_t getSource() const { return mSource; } - void setSource(const typename SETTINGT::ptr_t &source) { mSource = source; setDirtyFlag(true); } + typename SETTINGT::ptr_t getSource() const { return this->mSource; } + void setSource(const typename SETTINGT::ptr_t &source) { this->mSource = source; this->setDirtyFlag(true); } void injectSetting(const std::string keyname, LLSD value, LLUUID experience_id, F32Seconds transition) { if (transition > 0.1) { - Injection::ptr_t injection = std::make_shared(transition, keyname, value, true, experience_id); + typename Injection::ptr_t injection = std::make_shared(transition, keyname, value, true, experience_id); mInjections.push_back(injection); - std::stable_sort(mInjections.begin(), mInjections.end(), [](const Injection::ptr_t &a, const Injection::ptr_t &b) { return a->mTimeRemaining < b->mTimeRemaining; }); + std::stable_sort(mInjections.begin(), mInjections.end(), [](const typename Injection::ptr_t &a, const typename Injection::ptr_t &b) { return a->mTimeRemaining < b->mTimeRemaining; }); } else { mOverrideValues[keyname] = value; mOverrideExps[keyname] = experience_id; - setDirtyFlag(true); + this->setDirtyFlag(true); } } @@ -419,7 +419,7 @@ namespace { static LLFrameTimer timer; - LLSettingsBase::Seconds delta(timer.getElapsedTimeAndResetF32()); + typename LLSettingsBase::Seconds delta(timer.getElapsedTimeAndResetF32()); resetSpecial(); @@ -435,9 +435,9 @@ namespace this->mSettings[(*ito).first] = (*ito).second; } - const stringset_t &slerps = getSlerpKeys(); - const stringset_t &skips = getSkipInterpolateKeys(); - const stringset_t &specials = getSpecialKeys(); + const LLSettingsBase::stringset_t &slerps = getSlerpKeys(); + const LLSettingsBase::stringset_t &skips = getSkipInterpolateKeys(); + const LLSettingsBase::stringset_t &specials = getSpecialKeys(); typename injections_t::iterator it; for (it = mInjections.begin(); it != mInjections.end(); ++it) @@ -480,7 +480,7 @@ namespace } it = mInjections.begin(); - it = std::find_if(mInjections.begin(), mInjections.end(), [](const Injection::ptr_t &a) { return a->mTimeRemaining > 0.0f; }); + it = std::find_if(mInjections.begin(), mInjections.end(), [](const typename Injection::ptr_t &a) { return a->mTimeRemaining > 0.0f; }); if (it != mInjections.begin()) { @@ -496,7 +496,7 @@ namespace LLSettingsBase::stringset_t getSpecialKeys() const; void resetSpecial(); - void updateSpecial(typename const Injection::ptr_t &injection, LLSettingsBase::BlendFactor mix); + void updateSpecial(const typename Injection::ptr_t &injection, typename LLSettingsBase::BlendFactor mix); private: typedef std::map key_to_expid_t; @@ -511,7 +511,7 @@ namespace template<> LLSettingsBase::stringset_t LLSettingsInjected::getSpecialKeys() const { - static stringset_t specialSet; + static LLSettingsBase::stringset_t specialSet; if (specialSet.empty()) { @@ -559,7 +559,7 @@ namespace } template<> - void LLSettingsInjected::updateSpecial(const LLSettingsInjected::Injection::ptr_t &injection, LLSettingsBase::BlendFactor mix) + void LLSettingsInjected::updateSpecial(const typename LLSettingsInjected::Injection::ptr_t &injection, typename LLSettingsBase::BlendFactor mix) { if (injection->mKeyName == SETTING_SUN_TEXTUREID) { @@ -594,7 +594,7 @@ namespace } template<> - void LLSettingsInjected::updateSpecial(const LLSettingsInjected::Injection::ptr_t &injection, LLSettingsBase::BlendFactor mix) + void LLSettingsInjected::updateSpecial(const typename LLSettingsInjected::Injection::ptr_t &injection, typename LLSettingsBase::BlendFactor mix) { if (injection->mKeyName == SETTING_NORMAL_MAP) { -- cgit v1.2.3 From a7570ae344cd4e2aeaf49b7770aa8a5e14d53863 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 23 Jan 2019 14:12:29 -0800 Subject: More specifics OSX compile. --- indra/newview/llenvironment.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 2f92ac8c72..26e025773a 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -435,9 +435,9 @@ namespace this->mSettings[(*ito).first] = (*ito).second; } - const LLSettingsBase::stringset_t &slerps = getSlerpKeys(); - const LLSettingsBase::stringset_t &skips = getSkipInterpolateKeys(); - const LLSettingsBase::stringset_t &specials = getSpecialKeys(); + const LLSettingsBase::stringset_t &slerps = this->getSlerpKeys(); + const LLSettingsBase::stringset_t &skips = this->getSkipInterpolateKeys(); + const LLSettingsBase::stringset_t &specials = this->getSpecialKeys(); typename injections_t::iterator it; for (it = mInjections.begin(); it != mInjections.end(); ++it) @@ -474,7 +474,7 @@ namespace } else if (skips.find(key_name) == skips.end()) { - this->mSettings[key_name] = interpolateSDValue(key_name, value, target, getParameterMap(), mix, slerps); + this->mSettings[key_name] = this->interpolateSDValue(key_name, value, target, this->getParameterMap(), mix, slerps); // LL_WARNS("LAPRAS") << "...blending '" << key_name << "' by " << mix << "% now=" << mSettings[key_name] << LL_ENDL; } } @@ -491,7 +491,7 @@ namespace SETTINGT::updateSettings(); if (!mInjections.empty()) - setDirtyFlag(true); + this->setDirtyFlag(true); } LLSettingsBase::stringset_t getSpecialKeys() const; -- cgit v1.2.3 From 211ad31dc236f868686339a9da19226b18724f20 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 23 Jan 2019 14:44:44 -0800 Subject: I hope this is the last one. --- indra/newview/llenvironment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 26e025773a..9ac8bccb74 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -385,7 +385,7 @@ namespace { injectSetting((*it).first, (*it).second, experience_id, transition); } - setDirtyFlag(true); + this->setDirtyFlag(true); } protected: -- cgit v1.2.3 From c7e02b0835cbb50777c677f618c4a957e69fabee Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 30 Jan 2019 14:36:46 -0800 Subject: SL-9925: Viewer now shows an error message if import from legacy windlight fails. --- indra/newview/llenvironment.cpp | 48 +++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 9ac8bccb74..a397f0f27a 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -615,6 +615,25 @@ namespace typedef LLSettingsInjected LLSettingsInjectedSky; typedef LLSettingsInjected LLSettingsInjectedWater; + +#if 0 + //===================================================================== + class DayInjection : public LLEnvironment::DayInstance + { + public: + typedef std::shared_ptr ptr_t; + + DayInjection(LLEnvironment::EnvSelection_t env) : + LLEnvironment::DayInstance(env) + { + } + + virtual ~DayInjection() { }; + + protected: + private: + }; +#endif } //========================================================================= @@ -1972,31 +1991,46 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extractLeg } //========================================================================= -LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename) +LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename, LLSD &messages) { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); std::string path(gDirUtilp->getDirName(filename)); - LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPresetFile(name, path); + LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPresetFile(name, path, messages); + + if (!water) + { + messages["NAME"] = name; + messages["FILE"] = filename; + } return water; } -LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string filename) +LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string filename, LLSD &messages) { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); std::string path(gDirUtilp->getDirName(filename)); - LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPresetFile(name, path); + LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPresetFile(name, path, messages); + if (!sky) + { + messages["NAME"] = name; + messages["FILE"] = filename; + } return sky; - } -LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromLegacyPreset(const std::string filename) +LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromLegacyPreset(const std::string filename, LLSD &messages) { std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); std::string path(gDirUtilp->getDirName(filename)); - LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPresetFile(name, path); + LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPresetFile(name, path, messages); + if (!day) + { + messages["NAME"] = name; + messages["FILE"] = filename; + } return day; } -- cgit v1.2.3 From fcf25b690f94aff846a846fd52eeb778e8507f25 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Fri, 1 Feb 2019 18:33:55 +0200 Subject: SL-10364 FIXED Parcel Sky Altitudes not set correct when opening About Land -> Environment for the first time upon region arrival --- indra/newview/llenvironment.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index a397f0f27a..bf8cf4b552 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -846,6 +846,17 @@ bool LLEnvironment::isInventoryEnabled() const void LLEnvironment::onRegionChange() { clearExperienceEnvironment(LLUUID::null, TRANSITION_DEFAULT); + + LLViewerRegion* cur_region = gAgent.getRegion(); + if (!cur_region) + { + return; + } + if (!cur_region->capabilitiesReceived()) + { + cur_region->setCapabilitiesReceivedCallback([](LLUUID region_id) { LLEnvironment::instance().requestRegion(); }); + return; + } requestRegion(); } -- cgit v1.2.3 From ce40f88ecb09c91061f7a18ad2b52dcaa3df7ca3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 5 Feb 2019 15:09:32 -0800 Subject: Better calculation of time remaining in span for track animator (from SL-10465) --- indra/newview/llenvironment.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index bf8cf4b552..fa583bdc9c 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -170,6 +170,20 @@ namespace return llclamp(position, 0.0f, 1.0f); } + inline LLSettingsBase::BlendFactor convert_time_to_blend_factor(const LLSettingsBase::Seconds& time, const LLSettingsBase::Seconds& len, LLSettingsDay::CycleTrack_t &track) + { + LLSettingsBase::TrackPosition position = convert_time_to_position(time, len); + LLSettingsDay::TrackBound_t bounds(get_bounding_entries(track, position)); + + LLSettingsBase::TrackPosition spanlength(get_wrapping_distance((*bounds.first).first, (*bounds.second).first)); + if (position < (*bounds.first).first) + position += 1.0; + + LLSettingsBase::TrackPosition start = position - (*bounds.first).first; + + return static_cast(start / spanlength); + } + //--------------------------------------------------------------------- class LLTrackBlenderLoopingTime : public LLSettingsBlenderTimeDelta { @@ -186,12 +200,14 @@ namespace // must happen prior to getBoundingEntries call... mTrackNo = selectTrackNumber(trackno); - LLSettingsDay::TrackBound_t initial = getBoundingEntries(getAdjustedNow()); + LLSettingsBase::Seconds now(getAdjustedNow()); + LLSettingsDay::TrackBound_t initial = getBoundingEntries(now); mInitial = (*initial.first).second; mFinal = (*initial.second).second; mBlendSpan = getSpanTime(initial); + initializeTarget(now); setOnFinished([this](const LLSettingsBlender::ptr_t &){ onFinishedSpan(); }); } @@ -248,6 +264,16 @@ namespace return bounds; } + void initializeTarget(LLSettingsBase::Seconds time) + { + LLSettingsBase::BlendFactor blendf(convert_time_to_blend_factor(time, mCycleLength, mDay->getCycleTrack(mTrackNo))); + + blendf = llclamp(blendf, 0.0, 0.999); + setTimeSpent(LLSettingsBase::Seconds(blendf * mBlendSpan)); + + setBlendFactor(blendf); + } + LLSettingsBase::Seconds getAdjustedNow() const { LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); -- cgit v1.2.3 From a9dd57c3517eb0ba1070f638d1eb6a4a56d4bfb7 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Thu, 7 Feb 2019 13:06:16 +0200 Subject: SL-10456 FIXED [EEP] Viewer continues to show last EEP environment after teleporting from EEP to non-EEP region --- indra/newview/llenvironment.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index fa583bdc9c..9179c545df 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1595,6 +1595,7 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) LLSettingsBase::Seconds transition = LLViewerParcelMgr::getInstance()->getTeleportInProgress() ? TRANSITION_FAST : TRANSITION_DEFAULT; cb = [this, transition](S32 pid, EnvironmentInfo::ptr_t envinfo) { + clearEnvironment(ENV_PARCEL); recordEnvironment(pid, envinfo, transition); }; } -- cgit v1.2.3 From 2a740309d01ca2ab80fd054ea8d8a79fb7ebbbe0 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 11 Feb 2019 16:50:15 -0800 Subject: SL-10406, SL-10464: Experience injections now have their own sub class of day instance (DayInjection) Montitors underlying environments and switches the sources as needed. --- indra/newview/llenvironment.cpp | 647 +++++++++++++++++++++++++++++----------- 1 file changed, 469 insertions(+), 178 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index fa583bdc9c..2dede1a667 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -350,15 +350,18 @@ namespace LLSettingsInjected(typename SETTINGT::ptr_t source) : SETTINGT(), - mSource(source) + mSource(source), + mLastSourceHash(0), + mLastHash(0) {} virtual ~LLSettingsInjected() {}; -// typename SETTINGT::ptr_t buildClone() const override; - typename SETTINGT::ptr_t getSource() const { return this->mSource; } - void setSource(const typename SETTINGT::ptr_t &source) { this->mSource = source; this->setDirtyFlag(true); } + void setSource(const typename SETTINGT::ptr_t &source) { this->mSource = source; this->setDirtyFlag(true); this->mLastSourceHash = 0; } + + virtual bool isDirty() const override { return SETTINGT::isDirty() || (this->mSource->isDirty()); } + virtual bool isVeryDirty() const override { return SETTINGT::isVeryDirty() || (this->mSource->isVeryDirty()); } void injectSetting(const std::string keyname, LLSD value, LLUUID experience_id, F32Seconds transition) { @@ -382,15 +385,13 @@ namespace auto it = mInjections.begin(); while (it != mInjections.end()) { - if (((*it)->mKeyName == keyname) && + if ((keyname.empty() || ((*it)->mKeyName == keyname)) && (experience.isNull() || (experience == (*it)->mExperience))) { mInjections.erase(it++); } else - { ++it; - } } for (auto itexp = mOverrideExps.begin(); itexp != mOverrideExps.end();) @@ -405,6 +406,11 @@ namespace } } + void removeInjections(LLUUID experience_id) + { + removeInjection(std::string(), experience_id); + } + void injectExperienceValues(LLSD values, LLUUID experience_id, typename LLSettingsBase::Seconds transition) { for (auto it = values.beginMap(); it != values.endMap(); ++it) @@ -414,47 +420,9 @@ namespace this->setDirtyFlag(true); } - protected: - struct Injection - { - Injection(typename LLSettingsBase::Seconds transition, const std::string &keyname, LLSD value, bool blendin, LLUUID experince, S32 index = -1) : - mTransition(transition), - mTimeRemaining(transition), - mKeyName(keyname), - mValue(value), - mExperience(experince), - mIndex(index), - mBlendIn(blendin), - mFirstTime(true) - {} - - typename LLSettingsBase::Seconds mTransition; - typename LLSettingsBase::Seconds mTimeRemaining; - std::string mKeyName; - LLSD mValue; - LLUUID mExperience; - S32 mIndex; - bool mBlendIn; - bool mFirstTime; - - typedef std::shared_ptr ptr_t; - }; - - - virtual void updateSettings() override + void applyInjections(LLSettingsBase::Seconds delta) { - static LLFrameTimer timer; - - typename LLSettingsBase::Seconds delta(timer.getElapsedTimeAndResetF32()); - - resetSpecial(); - - if (mSource && mSource->isDirty()) - { - mSource->updateSettings(); - } - - this->mSettings = mSource->getSettings(); + this->mSettings = this->mSource->getSettings(); for (auto ito = mOverrideValues.beginMap(); ito != mOverrideValues.endMap(); ++ito) { @@ -501,19 +469,75 @@ namespace else if (skips.find(key_name) == skips.end()) { this->mSettings[key_name] = this->interpolateSDValue(key_name, value, target, this->getParameterMap(), mix, slerps); -// LL_WARNS("LAPRAS") << "...blending '" << key_name << "' by " << mix << "% now=" << mSettings[key_name] << LL_ENDL; } } + size_t hash = this->getHash(); + + if (hash != mLastHash) + { + this->setDirtyFlag(true); + mLastHash = hash; + } + it = mInjections.begin(); it = std::find_if(mInjections.begin(), mInjections.end(), [](const typename Injection::ptr_t &a) { return a->mTimeRemaining > 0.0f; }); if (it != mInjections.begin()) { - mInjections.erase(mInjections.begin(), mInjections.end()); } + } + + protected: + struct Injection + { + Injection(typename LLSettingsBase::Seconds transition, const std::string &keyname, LLSD value, bool blendin, LLUUID experince, S32 index = -1) : + mTransition(transition), + mTimeRemaining(transition), + mKeyName(keyname), + mValue(value), + mExperience(experince), + mIndex(index), + mBlendIn(blendin), + mFirstTime(true) + {} + + typename LLSettingsBase::Seconds mTransition; + typename LLSettingsBase::Seconds mTimeRemaining; + std::string mKeyName; + LLSD mValue; + LLUUID mExperience; + S32 mIndex; + bool mBlendIn; + bool mFirstTime; + + typedef std::shared_ptr ptr_t; + }; + + + virtual void updateSettings() override + { + static LLFrameTimer timer; + + if (!this->mSource) + return; + + // clears the dirty flag on this object. Need to prevent triggering + // more calls into this updateSettings + LLSettingsBase::updateSettings(); + + resetSpecial(); + + if (this->mSource->isDirty()) + { + this->mSource->updateSettings(); + } + + typename LLSettingsBase::Seconds delta(timer.getElapsedTimeAndResetF32()); + + SETTINGT::updateSettings(); if (!mInjections.empty()) @@ -528,6 +552,8 @@ namespace typedef std::map key_to_expid_t; typedef std::deque injections_t; + size_t mLastSourceHash; + size_t mLastHash; typename SETTINGT::ptr_t mSource; injections_t mInjections; LLSD mOverrideValues; @@ -642,24 +668,76 @@ namespace typedef LLSettingsInjected LLSettingsInjectedSky; typedef LLSettingsInjected LLSettingsInjectedWater; -#if 0 //===================================================================== class DayInjection : public LLEnvironment::DayInstance { + friend class InjectedTransition; + public: typedef std::shared_ptr ptr_t; - DayInjection(LLEnvironment::EnvSelection_t env) : - LLEnvironment::DayInstance(env) - { - } + DayInjection(LLEnvironment::EnvSelection_t env); + virtual ~DayInjection(); - virtual ~DayInjection() { }; + virtual bool applyTimeDelta(const LLSettingsBase::Seconds& delta) override; - protected: + void setInjectedDay(const LLSettingsDay::ptr_t &pday, LLUUID experience_id, LLSettingsBase::Seconds transition); + void setInjectedSky(const LLSettingsSky::ptr_t &psky, LLUUID experience_id, LLSettingsBase::Seconds transition); + void setInjectedWater(const LLSettingsWater::ptr_t &pwater, LLUUID experience_id, LLSettingsBase::Seconds transition); + + void injectSkySettings(LLSD settings, LLUUID experience_id, LLSettingsBase::Seconds transition); + void injectWaterSettings(LLSD settings, LLUUID experience_id, LLSettingsBase::Seconds transition); + + void clearInjections(LLUUID experience_id); + +// virtual void setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) override; +// virtual void setSky(const LLSettingsSky::ptr_t &psky) override; +// virtual void setWater(const LLSettingsWater::ptr_t &pwater) override; + + virtual void animate() override; + + LLEnvironment::DayInstance::ptr_t getBaseDayInstance() const { return mBaseDayInstance; } + void setBaseDayInstance(const LLEnvironment::DayInstance::ptr_t &baseday); + + S32 experiencesActive() const { return mActiveExperiences.size(); } + + bool isOverriddenSky() const { return !mSkyExperience.isNull(); } + bool isOverriddenWater() const { return !mWaterExperience.isNull(); } private: + + void animateSkyChange(LLSettingsSky::ptr_t psky, LLSettingsBase::Seconds transition); + void animateWaterChange(LLSettingsWater::ptr_t pwater, LLSettingsBase::Seconds transition); + + void onEnvironmentChanged(LLEnvironment::EnvSelection_t env); + + void checkExperience(); + + LLEnvironment::DayInstance::ptr_t mBaseDayInstance; + + LLSettingsInjectedSky::ptr_t mInjectedSky; + LLSettingsInjectedWater::ptr_t mInjectedWater; + std::set mActiveExperiences; + LLUUID mDayExperience; + LLUUID mSkyExperience; + LLUUID mWaterExperience; + LLEnvironment::connection_t mEnvChangeConnection; }; -#endif + + class InjectedTransition : public LLEnvironment::DayTransition + { + public: + InjectedTransition(const DayInjection::ptr_t &injection, const LLSettingsSky::ptr_t &skystart, const LLSettingsWater::ptr_t &waterstart, DayInstance::ptr_t &end, LLSettingsDay::Seconds time): + LLEnvironment::DayTransition(skystart, waterstart, end, time), + mInjection(injection) + { } + virtual ~InjectedTransition() { }; + + virtual void animate() override; + + protected: + DayInjection::ptr_t mInjection; + }; + } //========================================================================= @@ -950,7 +1028,10 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnviro environment = environment->clone(); else { - environment = std::make_shared(env); + if (env == ENV_PUSH) + environment = std::make_shared(env); + else + environment = std::make_shared(env); } mEnvironments[env] = environment; } @@ -1048,19 +1129,11 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe else if (settings->getSettingsType() == "sky") { fixedEnvironment_t fixedenv(std::static_pointer_cast(settings), LLSettingsWater::ptr_t()); -// if (environment) -// { -// fixedenv.second = environment->getWater(); -// } setEnvironment(env, fixedenv); } else if (settings->getSettingsType() == "water") { fixedEnvironment_t fixedenv(LLSettingsSky::ptr_t(), std::static_pointer_cast(settings)); -// if (environment) -// { -// fixedenv.first = environment->getSky(); -// } setEnvironment(env, fixedenv); } } @@ -1240,12 +1313,19 @@ void LLEnvironment::updateEnvironment(LLSettingsBase::Seconds transition, bool f if ((mCurrentEnvironment != pinstance) || forced) { - DayInstance::ptr_t trans = std::make_shared( - mCurrentEnvironment->getSky(), mCurrentEnvironment->getWater(), pinstance, transition); - - trans->animate(); - - mCurrentEnvironment = trans; + if (transition != TRANSITION_INSTANT) + { + DayInstance::ptr_t trans = std::make_shared( + mCurrentEnvironment->getSky(), mCurrentEnvironment->getWater(), pinstance, transition); + + trans->animate(); + + mCurrentEnvironment = trans; + } + else + { + mCurrentEnvironment = pinstance; + } } } @@ -2215,15 +2295,53 @@ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLUUID asset_ LLSettingsVOBase::getSettingsAsset(asset_id, [this, experience_id, transition_time](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { - // individual settings will be overridden by the settings. No need to keep injections. - onSetEnvAssetLoaded(ENV_PUSH, asset_id, settings, - LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET, - LLSettingsBase::Seconds(transition_time), status, NO_VERSION); + onSetExperienceEnvAssetLoaded(experience_id, settings, transition_time, status); +// // individual settings will be overridden by the settings. No need to keep injections. +// onSetEnvAssetLoaded(ENV_PUSH, asset_id, settings, +// LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET, +// LLSettingsBase::Seconds(transition_time), status, NO_VERSION); }); } +void LLEnvironment::onSetExperienceEnvAssetLoaded(LLUUID experience_id, LLSettingsBase::ptr_t settings, F32 transition_time, S32 status) +{ + DayInjection::ptr_t environment = std::dynamic_pointer_cast(getEnvironmentInstance(ENV_PUSH)); + bool updateenvironment(false); + + if (!settings || status) + { + LLSD args; + args["DESC"] = experience_id.asString(); + LLNotificationsUtil::add("FailedToFindSettings", args); + return; + } + + if (!environment) + { + environment = std::dynamic_pointer_cast(getEnvironmentInstance(ENV_PUSH, true)); + updateenvironment = true; + } + + if (settings->getSettingsType() == "daycycle") + { + environment->setInjectedDay(std::static_pointer_cast(settings), experience_id, LLSettingsBase::Seconds(transition_time)); + } + else if (settings->getSettingsType() == "sky") + { + environment->setInjectedSky(std::static_pointer_cast(settings), experience_id, LLSettingsBase::Seconds(transition_time)); + } + else if (settings->getSettingsType() == "water") + { + environment->setInjectedWater(std::static_pointer_cast(settings), experience_id, LLSettingsBase::Seconds(transition_time)); + } + + if (updateenvironment) + updateEnvironment(TRANSITION_INSTANT, true); +} + + void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLSD data, F32 transition_time) { LLSD sky(data["sky"]); @@ -2235,53 +2353,27 @@ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLSD data, F3 return; } - LLSettingsInjectedSky::ptr_t pinjectedsky; - LLSettingsInjectedWater::ptr_t pinjectedwater; + DayInjection::ptr_t environment = std::dynamic_pointer_cast(getEnvironmentInstance(ENV_PUSH)); + bool updateenvironment(false); - fixedEnvironment_t pushenv = getEnvironmentFixed(ENV_PUSH, true); + if (!environment) + { + environment = std::dynamic_pointer_cast(getEnvironmentInstance(ENV_PUSH, true)); + updateenvironment = true; + } if (!sky.isUndefined()) { - bool newsky(false); - - if (pushenv.first) - { - pinjectedsky = std::dynamic_pointer_cast(pushenv.first); - } - if (!pinjectedsky) - { - pinjectedsky = std::make_shared(pushenv.first); - newsky = true; - } - - pinjectedsky->injectExperienceValues(sky, experience_id, F32Seconds(transition_time)); - if (!newsky) - pinjectedsky.reset(); + environment->injectSkySettings(sky, experience_id, LLSettingsBase::Seconds(transition_time)); } if (!water.isUndefined()) { - bool newwater(false); - if (pushenv.second) - { - pinjectedwater = std::dynamic_pointer_cast(pushenv.second); - } - if (!pinjectedwater) - { - pinjectedwater = std::make_shared(pushenv.second); - newwater = true; - } - - pinjectedwater->injectExperienceValues(water, experience_id, F32Seconds(transition_time)); - if (!newwater) - pinjectedwater.reset(); + environment->injectWaterSettings(sky, experience_id, LLSettingsBase::Seconds(transition_time)); } - if (pinjectedsky || pinjectedwater) - { - setEnvironment(ENV_PUSH, pinjectedsky, pinjectedwater); - updateEnvironment(TRANSITION_INSTANT); - } + if (updateenvironment) + updateEnvironment(TRANSITION_INSTANT, true); } @@ -2311,8 +2403,7 @@ LLEnvironment::DayInstance::DayInstance(EnvSelection_t env) : mInitialized(false), mType(TYPE_INVALID), mSkyTrack(1), - mEnv(env), - mBackup(false) + mEnv(env) { } @@ -2334,8 +2425,10 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::DayInstance::clone() const return environment; } -void LLEnvironment::DayInstance::applyTimeDelta(const LLSettingsBase::Seconds& delta) +bool LLEnvironment::DayInstance::applyTimeDelta(const LLSettingsBase::Seconds& delta) { + ptr_t keeper(shared_from_this()); // makes sure that this does not go away while it is being worked on. + bool changed(false); if (!mInitialized) initialize(); @@ -2344,14 +2437,11 @@ void LLEnvironment::DayInstance::applyTimeDelta(const LLSettingsBase::Seconds& d changed |= mBlenderSky->applyTimeDelta(delta); if (mBlenderWater) changed |= mBlenderWater->applyTimeDelta(delta); - if (mBackup && changed) - backup(); + return changed; } void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) { - if (mType == TYPE_FIXED) - LL_WARNS("ENVIRONMENT") << "Fixed day instance changed to Cycled" << LL_ENDL; mType = TYPE_CYCLED; mInitialized = false; @@ -2371,8 +2461,6 @@ void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSett void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) { - if (mType == TYPE_CYCLED) - LL_WARNS("ENVIRONMENT") << "Cycled day instance changed to FIXED" << LL_ENDL; mType = TYPE_FIXED; mInitialized = false; @@ -2382,8 +2470,6 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) mSky->mReplaced |= different_sky; mSky->update(); mBlenderSky.reset(); - if (mBackup) - backup(); if (gAtmosphere) { @@ -2395,16 +2481,12 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) { - if (mType == TYPE_CYCLED) - LL_WARNS("ENVIRONMENT") << "Cycled day instance changed to FIXED" << LL_ENDL; mType = TYPE_FIXED; mInitialized = false; mWater = pwater; mWater->update(); mBlenderWater.reset(); - if (mBackup) - backup(); } void LLEnvironment::DayInstance::initialize() @@ -2439,7 +2521,6 @@ void LLEnvironment::DayInstance::setSkyTrack(S32 trackno) } } - void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &skyblend, const LLSettingsBlender::ptr_t &waterblend) { mBlenderSky = skyblend; @@ -2447,52 +2528,6 @@ void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &sky } -void LLEnvironment::DayInstance::setBackup(bool backupval) -{ - if (backupval == mBackup) - return; - - mBackup = backupval; - LLSettingsSky::ptr_t psky = getSky(); - if (mBackup) - { - backup(); - } - else - { - restore(); - mBackupSky = LLSD(); - mBackupWater = LLSD(); - } -} - -void LLEnvironment::DayInstance::backup() -{ - if (!mBackup) - return; - - if (mSky) - { - mBackupSky = mSky->cloneSettings(); - } - if (mWater) - { - mBackupWater = mWater->cloneSettings(); - } -} - -void LLEnvironment::DayInstance::restore() -{ - if (!mBackupSky.isUndefined() && mSky) - { - mSky->replaceSettings(mBackupSky); - } - if (!mBackupWater.isUndefined() && mWater) - { - mWater->replaceSettings(mBackupWater); - } -} - LLSettingsBase::TrackPosition LLEnvironment::DayInstance::secondsToKeyframe(LLSettingsDay::Seconds seconds) { return convert_time_to_position(seconds, mDayLength); @@ -2550,10 +2585,13 @@ LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart } -void LLEnvironment::DayTransition::applyTimeDelta(const LLSettingsBase::Seconds& delta) +bool LLEnvironment::DayTransition::applyTimeDelta(const LLSettingsBase::Seconds& delta) { - mNextInstance->applyTimeDelta(delta); - DayInstance::applyTimeDelta(delta); + bool changed(false); + + changed = mNextInstance->applyTimeDelta(delta); + changed |= DayInstance::applyTimeDelta(delta); + return changed; } void LLEnvironment::DayTransition::animate() @@ -2658,3 +2696,256 @@ F64 LLTrackBlenderLoopingManual::getSpanLength(const LLSettingsDay::TrackBound_t } //========================================================================= +namespace +{ + DayInjection::DayInjection(LLEnvironment::EnvSelection_t env): + LLEnvironment::DayInstance(env), + mBaseDayInstance(), + mInjectedSky(), + mInjectedWater(), + mActiveExperiences(), + mDayExperience(), + mSkyExperience(), + mWaterExperience(), + mEnvChangeConnection() + { + mInjectedSky = std::make_shared(LLEnvironment::instance().getCurrentSky()); + mInjectedWater = std::make_shared(LLEnvironment::instance().getCurrentWater()); + mBaseDayInstance = LLEnvironment::instance().getSharedEnvironmentInstance(); + mSky = mInjectedSky; + mWater = mInjectedWater; + mEnvChangeConnection = LLEnvironment::instance().setEnvironmentChanged([this](LLEnvironment::EnvSelection_t env, S32) { onEnvironmentChanged(env); }); + } + + DayInjection::~DayInjection() + { + if (mEnvChangeConnection.connected()) + mEnvChangeConnection.disconnect(); + } + + + bool DayInjection::applyTimeDelta(const LLSettingsBase::Seconds& delta) + { + bool changed(false); + + if (mBaseDayInstance) + changed |= mBaseDayInstance->applyTimeDelta(delta); + mInjectedSky->applyInjections(delta); + mInjectedWater->applyInjections(delta); + changed |= LLEnvironment::DayInstance::applyTimeDelta(delta); + if (changed) + { + mInjectedSky->setDirtyFlag(true); + mInjectedWater->setDirtyFlag(true); + } + mInjectedSky->update(); + mInjectedWater->update(); + return changed; + } + + void DayInjection::setBaseDayInstance(const LLEnvironment::DayInstance::ptr_t &baseday) + { + mBaseDayInstance = baseday; + + if (mSkyExperience.isNull()) + mInjectedSky->setSource(mBaseDayInstance->getSky()); + if (mWaterExperience.isNull()) + mInjectedWater->setSource(mBaseDayInstance->getWater()); + } + + void DayInjection::setInjectedDay(const LLSettingsDay::ptr_t &pday, LLUUID experience_id, LLSettingsBase::Seconds transition) + { + mSkyExperience = experience_id; + mWaterExperience = experience_id; + mDayExperience = experience_id; + + mBaseDayInstance = mBaseDayInstance->clone(); + mBaseDayInstance->setEnvironmentSelection(LLEnvironment::ENV_NONE); + mBaseDayInstance->setDay(pday, mBaseDayInstance->getDayLength(), mBaseDayInstance->getDayOffset()); + animateSkyChange(mBaseDayInstance->getSky(), transition); + animateWaterChange(mBaseDayInstance->getWater(), transition); + + mActiveExperiences.insert(experience_id); + } + + void DayInjection::setInjectedSky(const LLSettingsSky::ptr_t &psky, LLUUID experience_id, LLSettingsBase::Seconds transition) + { + mSkyExperience = experience_id; + mActiveExperiences.insert(experience_id); + checkExperience(); + animateSkyChange(psky, transition); + } + + void DayInjection::setInjectedWater(const LLSettingsWater::ptr_t &pwater, LLUUID experience_id, LLSettingsBase::Seconds transition) + { + mWaterExperience = experience_id; + mActiveExperiences.insert(experience_id); + checkExperience(); + animateWaterChange(pwater, transition); + } + + void DayInjection::injectSkySettings(LLSD settings, LLUUID experience_id, LLSettingsBase::Seconds transition) + { + mInjectedSky->injectExperienceValues(settings, experience_id, transition); + } + + void DayInjection::injectWaterSettings(LLSD settings, LLUUID experience_id, LLSettingsBase::Seconds transition) + { + mInjectedWater->injectExperienceValues(settings, experience_id, transition); + } + + void DayInjection::clearInjections(LLUUID experience_id) + { + if (experience_id.isNull() || (experience_id == mSkyExperience)) + { + mSkyExperience.setNull(); + mInjectedSky->setSource(mBaseDayInstance->getSky()); + } + mInjectedSky->removeInjections(experience_id); + if (experience_id.isNull() || (experience_id == mWaterExperience)) + { + mWaterExperience.setNull(); + mInjectedWater->setSource(mBaseDayInstance->getWater()); + } + mInjectedWater->removeInjections(experience_id); + + if (experience_id.isNull()) + mActiveExperiences.clear(); + else + mActiveExperiences.erase(experience_id); + } + + void DayInjection::animateSkyChange(LLSettingsSky::ptr_t psky, LLSettingsBase::Seconds transition) + { + LLSettingsSky::ptr_t start_sky(mInjectedSky->getSource()->buildClone()); + LLSettingsSky::ptr_t target_sky(start_sky->buildClone()); + mInjectedSky->setSource(target_sky); + + mBlenderSky = std::make_shared(target_sky, start_sky, psky, transition); + mBlenderSky->setOnFinished( + [this, psky](LLSettingsBlender::ptr_t blender) { + mBlenderSky.reset(); + mInjectedSky->setSource(psky); + setSky(mInjectedSky); + }); + } + + void DayInjection::animateWaterChange(LLSettingsWater::ptr_t pwater, LLSettingsBase::Seconds transition) + { + LLSettingsWater::ptr_t start_Water(mInjectedWater->getSource()->buildClone()); + LLSettingsWater::ptr_t scratch_Water(start_Water->buildClone()); + mInjectedWater->setSource(scratch_Water); + + mBlenderWater = std::make_shared(scratch_Water, start_Water, pwater, transition); + mBlenderWater->setOnFinished( + [this, pwater](LLSettingsBlender::ptr_t blender) { + mBlenderWater.reset(); + mInjectedWater->setSource(pwater); + setWater(mInjectedWater); + }); + } + + void DayInjection::onEnvironmentChanged(LLEnvironment::EnvSelection_t env) + { + if (env >= LLEnvironment::ENV_PARCEL) + { + LLEnvironment::EnvSelection_t base_env(mBaseDayInstance->getEnvironmentSelection()); + LLEnvironment::DayInstance::ptr_t nextbase = LLEnvironment::instance().getSharedEnvironmentInstance(); + + if ((base_env == LLEnvironment::ENV_NONE) || (nextbase == mBaseDayInstance) || + (!mSkyExperience.isNull() && !mWaterExperience.isNull())) + { // base instance completely overridden, or not changed no transition will happen + return; + } + + LL_WARNS("PUSHENV") << "Underlying environment has changed (" << env << ")! Base env is type " << base_env << LL_ENDL; + + LLEnvironment::DayInstance::ptr_t trans = std::make_shared(std::static_pointer_cast(shared_from_this()), + mBaseDayInstance->getSky(), mBaseDayInstance->getWater(), nextbase, LLEnvironment::TRANSITION_DEFAULT); + + trans->animate(); + setBaseDayInstance(trans); + } + } + + void DayInjection::checkExperience() + { + if ((!mDayExperience.isNull()) && (mSkyExperience != mDayExperience) && (mWaterExperience != mDayExperience)) + { // There was a day experience but we've replaced it with a water and a sky experience. + mDayExperience.setNull(); + + // TODO test sky and water for injections before removing experience id + + mBaseDayInstance = LLEnvironment::instance().getSharedEnvironmentInstance(); + } + } + + void DayInjection::animate() + { + + } + + +// void DayInjection::setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) +// { +// +// } +// +// void DayInjection::setSky(const LLSettingsSky::ptr_t &psky) +// { +// +// } +// +// void DayInjection::setWater(const LLSettingsWater::ptr_t &pwater) +// { +// +// } + + void InjectedTransition::animate() + { + mNextInstance->animate(); + + if (!mInjection->isOverriddenSky()) + { + mSky = mStartSky->buildClone(); + mBlenderSky = std::make_shared(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime); + mBlenderSky->setOnFinished( + [this](LLSettingsBlender::ptr_t blender) { + mBlenderSky.reset(); + + if (!mBlenderSky && !mBlenderSky) + mInjection->setBaseDayInstance(mNextInstance); + else + mInjection->mInjectedSky->setSource(mNextInstance->getSky()); + }); + } + else + { + mSky = mInjection->getSky(); + mBlenderSky.reset(); + } + + if (!mInjection->isOverriddenWater()) + { + mWater = mStartWater->buildClone(); + mBlenderWater = std::make_shared(mWater, mStartWater, mNextInstance->getWater(), mTransitionTime); + mBlenderWater->setOnFinished( + [this](LLSettingsBlender::ptr_t blender) { + mBlenderWater.reset(); + + if (!mBlenderSky && !mBlenderWater) + mInjection->setBaseDayInstance(mNextInstance); +// else +// mInjection->mInjectedWater->setSource(mNextInstance->getWater()); + }); + } + else + { + mWater = mInjection->getWater(); + mBlenderWater.reset(); + } + + } + +} + -- cgit v1.2.3 From 5d9915243ba1a93934969e7e203a25c6f4c9f9d1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 12 Feb 2019 14:44:37 -0800 Subject: SL-10406, SL-10464: Remove experience injections and destroy push environment when finished. --- indra/newview/llenvironment.cpp | 233 ++++++++++++++++++++++++++++------------ 1 file changed, 164 insertions(+), 69 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 1018075409..25983e245b 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -380,7 +380,7 @@ namespace } } - void removeInjection(const std::string keyname, LLUUID experience) + void removeInjection(const std::string keyname, LLUUID experience, LLSettingsBase::Seconds transition) { auto it = mInjections.begin(); while (it != mInjections.end()) @@ -388,6 +388,11 @@ namespace if ((keyname.empty() || ((*it)->mKeyName == keyname)) && (experience.isNull() || (experience == (*it)->mExperience))) { + if (transition != LLEnvironment::TRANSITION_INSTANT) + { + typename Injection::ptr_t injection = std::make_shared(transition, keyname, (*it)->mLastValue, false, LLUUID::null); + mInjections.push_front(injection); // push them in at the front so we don't check them again. + } mInjections.erase(it++); } else @@ -398,17 +403,23 @@ namespace { if (experience.isNull() || ((*itexp).second == experience)) { + if (transition != LLEnvironment::TRANSITION_INSTANT) + { + typename Injection::ptr_t injection = std::make_shared(transition, (*itexp).first, mOverrideValues[(*itexp).first], false, LLUUID::null); + mInjections.push_front(injection); + } mOverrideValues.erase((*itexp).first); mOverrideExps.erase(itexp++); } else ++itexp; } + std::stable_sort(mInjections.begin(), mInjections.end(), [](const typename Injection::ptr_t &a, const typename Injection::ptr_t &b) { return a->mTimeRemaining < b->mTimeRemaining; }); } - void removeInjections(LLUUID experience_id) + void removeInjections(LLUUID experience_id, LLSettingsBase::Seconds transition) { - removeInjection(std::string(), experience_id); + removeInjection(std::string(), experience_id, transition); } void injectExperienceValues(LLSD values, LLUUID experience_id, typename LLSettingsBase::Seconds transition) @@ -452,7 +463,7 @@ namespace { if ((*it)->mBlendIn) { - LL_WARNS("LAPRAS") << "Done blending '" << key_name << "' after " << (*it)->mTransition.value() - (*it)->mTimeRemaining.value() << " value now=" << target << LL_ENDL; + //_WARNS("LAPRAS") << "Done blending '" << key_name << "' after " << (*it)->mTransition.value() - (*it)->mTimeRemaining.value() << " value now=" << target << LL_ENDL; mOverrideValues[key_name] = target; mOverrideExps[key_name] = (*it)->mExperience; this->mSettings[key_name] = target; @@ -468,7 +479,10 @@ namespace } else if (skips.find(key_name) == skips.end()) { - this->mSettings[key_name] = this->interpolateSDValue(key_name, value, target, this->getParameterMap(), mix, slerps); + if (!(*it)->mBlendIn) + mix = 1.0 - mix; + (*it)->mLastValue = this->interpolateSDValue(key_name, value, target, this->getParameterMap(), mix, slerps); + this->mSettings[key_name] = (*it)->mLastValue; } } @@ -490,6 +504,11 @@ namespace } + bool hasInjections() const + { + return (!mInjections.empty() || (mOverrideValues.size() > 0)); + } + protected: struct Injection { @@ -508,6 +527,7 @@ namespace typename LLSettingsBase::Seconds mTimeRemaining; std::string mKeyName; LLSD mValue; + LLSD mLastValue; LLUUID mExperience; S32 mIndex; bool mBlendIn; @@ -662,7 +682,6 @@ namespace { setBlendFactor(mix); } - } typedef LLSettingsInjected LLSettingsInjectedSky; @@ -688,30 +707,30 @@ namespace void injectSkySettings(LLSD settings, LLUUID experience_id, LLSettingsBase::Seconds transition); void injectWaterSettings(LLSD settings, LLUUID experience_id, LLSettingsBase::Seconds transition); - void clearInjections(LLUUID experience_id); - -// virtual void setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) override; -// virtual void setSky(const LLSettingsSky::ptr_t &psky) override; -// virtual void setWater(const LLSettingsWater::ptr_t &pwater) override; + void clearInjections(LLUUID experience_id, LLSettingsBase::Seconds transition_time); virtual void animate() override; LLEnvironment::DayInstance::ptr_t getBaseDayInstance() const { return mBaseDayInstance; } void setBaseDayInstance(const LLEnvironment::DayInstance::ptr_t &baseday); - S32 experiencesActive() const { return mActiveExperiences.size(); } + S32 countExperiencesActive() const { return mActiveExperiences.size(); } bool isOverriddenSky() const { return !mSkyExperience.isNull(); } bool isOverriddenWater() const { return !mWaterExperience.isNull(); } + + bool hasInjections() const; private: void animateSkyChange(LLSettingsSky::ptr_t psky, LLSettingsBase::Seconds transition); void animateWaterChange(LLSettingsWater::ptr_t pwater, LLSettingsBase::Seconds transition); void onEnvironmentChanged(LLEnvironment::EnvSelection_t env); + void onParcelChange(); void checkExperience(); + LLEnvironment::DayInstance::ptr_t mBaseDayInstance; LLSettingsInjectedSky::ptr_t mInjectedSky; @@ -721,6 +740,7 @@ namespace LLUUID mSkyExperience; LLUUID mWaterExperience; LLEnvironment::connection_t mEnvChangeConnection; + boost::signals2::connection mParcelChangeConnection; }; class InjectedTransition : public LLEnvironment::DayTransition @@ -949,6 +969,7 @@ bool LLEnvironment::isInventoryEnabled() const void LLEnvironment::onRegionChange() { + // TODO: Use test experiences rather than full clear. clearExperienceEnvironment(LLUUID::null, TRANSITION_DEFAULT); LLViewerRegion* cur_region = gAgent.getRegion(); @@ -1438,8 +1459,12 @@ void LLEnvironment::update(const LLViewerCamera * cam) F32Seconds delta(timer.getElapsedTimeAndResetF32()); - mCurrentEnvironment->applyTimeDelta(delta); + { + DayInstance::ptr_t keeper = mCurrentEnvironment; + // make sure the current environment does not go away until applyTimeDelta is done. + mCurrentEnvironment->applyTimeDelta(delta); + } // update clouds, sun, and general updateCloudScroll(); @@ -2254,7 +2279,7 @@ void LLEnvironment::handleEnvironmentPush(LLSD &message) void LLEnvironment::handleEnvironmentPushClear(LLUUID experience_id, LLSD &message, F32 transition) { - clearExperienceEnvironment(experience_id, transition); + clearExperienceEnvironment(experience_id, LLSettingsBase::Seconds(transition)); } void LLEnvironment::handleEnvironmentPushFull(LLUUID experience_id, LLSD &message, F32 transition) @@ -2274,12 +2299,14 @@ void LLEnvironment::handleEnvironmentPushPartial(LLUUID experience_id, LLSD &mes setExperienceEnvironment(experience_id, settings, LLSettingsBase::Seconds(transition)); } -void LLEnvironment::clearExperienceEnvironment(LLUUID experience_id, F32 transition_time) +void LLEnvironment::clearExperienceEnvironment(LLUUID experience_id, LLSettingsBase::Seconds transition_time) { - if (hasEnvironment(ENV_PUSH)) + DayInjection::ptr_t injection = std::dynamic_pointer_cast(getEnvironmentInstance(ENV_PUSH)); + if (injection) { - clearEnvironment(ENV_PUSH); - updateEnvironment(LLSettingsBase::Seconds(transition_time)); + injection->clearInjections(experience_id, transition_time); +// clearEnvironment(ENV_PUSH); +// updateEnvironment(transition_time); } } @@ -2297,10 +2324,6 @@ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLUUID asset_ [this, experience_id, transition_time](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onSetExperienceEnvAssetLoaded(experience_id, settings, transition_time, status); -// // individual settings will be overridden by the settings. No need to keep injections. -// onSetEnvAssetLoaded(ENV_PUSH, asset_id, settings, -// LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET, -// LLSettingsBase::Seconds(transition_time), status, NO_VERSION); }); @@ -2350,7 +2373,7 @@ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLSD data, F3 if (sky.isUndefined() && water.isUndefined()) { - clearExperienceEnvironment(experience_id, transition_time); + clearExperienceEnvironment(experience_id, LLSettingsBase::Seconds(transition_time)); return; } @@ -2708,20 +2731,25 @@ namespace mDayExperience(), mSkyExperience(), mWaterExperience(), - mEnvChangeConnection() + mEnvChangeConnection(), + mParcelChangeConnection() { mInjectedSky = std::make_shared(LLEnvironment::instance().getCurrentSky()); mInjectedWater = std::make_shared(LLEnvironment::instance().getCurrentWater()); mBaseDayInstance = LLEnvironment::instance().getSharedEnvironmentInstance(); mSky = mInjectedSky; mWater = mInjectedWater; + mEnvChangeConnection = LLEnvironment::instance().setEnvironmentChanged([this](LLEnvironment::EnvSelection_t env, S32) { onEnvironmentChanged(env); }); + mParcelChangeConnection = gAgent.addParcelChangedCallback([this]() { onParcelChange(); }); } DayInjection::~DayInjection() { if (mEnvChangeConnection.connected()) mEnvChangeConnection.disconnect(); + if (mParcelChangeConnection.connected()) + mParcelChangeConnection.disconnect(); } @@ -2741,6 +2769,13 @@ namespace } mInjectedSky->update(); mInjectedWater->update(); + + if (!hasInjections()) + { // There are no injections being managed. This should really go away. + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_PUSH); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); + } + return changed; } @@ -2754,6 +2789,13 @@ namespace mInjectedWater->setSource(mBaseDayInstance->getWater()); } + + bool DayInjection::hasInjections() const + { + return (!mSkyExperience.isNull() || !mWaterExperience.isNull() || !mDayExperience.isNull() || + mBlenderSky || mBlenderWater || mInjectedSky->hasInjections() || mInjectedWater->hasInjections()); + } + void DayInjection::setInjectedDay(const LLSettingsDay::ptr_t &pday, LLUUID experience_id, LLSettingsBase::Seconds transition) { mSkyExperience = experience_id; @@ -2795,55 +2837,107 @@ namespace mInjectedWater->injectExperienceValues(settings, experience_id, transition); } - void DayInjection::clearInjections(LLUUID experience_id) + void DayInjection::clearInjections(LLUUID experience_id, LLSettingsBase::Seconds transition_time) { - if (experience_id.isNull() || (experience_id == mSkyExperience)) - { + if ((experience_id.isNull() && !mDayExperience.isNull()) || (experience_id == mDayExperience)) + { + mDayExperience.setNull(); + if (mSkyExperience == experience_id) + mSkyExperience.setNull(); + if (mWaterExperience == experience_id) + mWaterExperience.setNull(); + + mBaseDayInstance = LLEnvironment::instance().getSharedEnvironmentInstance(); + + if (mSkyExperience.isNull()) + animateSkyChange(mBaseDayInstance->getSky(), transition_time); + if (mWaterExperience.isNull()) + animateWaterChange(mBaseDayInstance->getWater(), transition_time); + } + + if ((experience_id.isNull() && !mSkyExperience.isNull()) || (experience_id == mSkyExperience)) + { mSkyExperience.setNull(); - mInjectedSky->setSource(mBaseDayInstance->getSky()); + animateSkyChange(mBaseDayInstance->getSky(), transition_time); } - mInjectedSky->removeInjections(experience_id); - if (experience_id.isNull() || (experience_id == mWaterExperience)) + if ((experience_id.isNull() && !mWaterExperience.isNull()) || (experience_id == mWaterExperience)) { mWaterExperience.setNull(); - mInjectedWater->setSource(mBaseDayInstance->getWater()); + animateWaterChange(mBaseDayInstance->getWater(), transition_time); } - mInjectedWater->removeInjections(experience_id); + + mInjectedSky->removeInjections(experience_id, transition_time); + mInjectedWater->removeInjections(experience_id, transition_time); if (experience_id.isNull()) mActiveExperiences.clear(); else mActiveExperiences.erase(experience_id); + + if ((transition_time == LLEnvironment::TRANSITION_INSTANT) && (countExperiencesActive() == 0)) + { // Only do this if instant and there are no other experiences injecting values. + // (otherwise will be handled after transition) + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_PUSH); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); + } } void DayInjection::animateSkyChange(LLSettingsSky::ptr_t psky, LLSettingsBase::Seconds transition) { - LLSettingsSky::ptr_t start_sky(mInjectedSky->getSource()->buildClone()); - LLSettingsSky::ptr_t target_sky(start_sky->buildClone()); - mInjectedSky->setSource(target_sky); + if (transition == LLEnvironment::TRANSITION_INSTANT) + { + mBlenderSky.reset(); + mInjectedSky->setSource(psky); + } + else + { + LLSettingsSky::ptr_t start_sky(mInjectedSky->getSource()->buildClone()); + LLSettingsSky::ptr_t target_sky(start_sky->buildClone()); + mInjectedSky->setSource(target_sky); - mBlenderSky = std::make_shared(target_sky, start_sky, psky, transition); - mBlenderSky->setOnFinished( - [this, psky](LLSettingsBlender::ptr_t blender) { - mBlenderSky.reset(); - mInjectedSky->setSource(psky); - setSky(mInjectedSky); - }); + mBlenderSky = std::make_shared(target_sky, start_sky, psky, transition); + mBlenderSky->setOnFinished( + [this, psky](LLSettingsBlender::ptr_t blender) + { + mBlenderSky.reset(); + mInjectedSky->setSource(psky); + setSky(mInjectedSky); + if (!mBlenderWater && (countExperiencesActive() == 0)) + { + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_PUSH); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); + } + }); + } } void DayInjection::animateWaterChange(LLSettingsWater::ptr_t pwater, LLSettingsBase::Seconds transition) { - LLSettingsWater::ptr_t start_Water(mInjectedWater->getSource()->buildClone()); - LLSettingsWater::ptr_t scratch_Water(start_Water->buildClone()); - mInjectedWater->setSource(scratch_Water); - - mBlenderWater = std::make_shared(scratch_Water, start_Water, pwater, transition); - mBlenderWater->setOnFinished( - [this, pwater](LLSettingsBlender::ptr_t blender) { + if (transition == LLEnvironment::TRANSITION_INSTANT) + { mBlenderWater.reset(); mInjectedWater->setSource(pwater); - setWater(mInjectedWater); - }); + } + else + { + LLSettingsWater::ptr_t start_Water(mInjectedWater->getSource()->buildClone()); + LLSettingsWater::ptr_t scratch_Water(start_Water->buildClone()); + mInjectedWater->setSource(scratch_Water); + + mBlenderWater = std::make_shared(scratch_Water, start_Water, pwater, transition); + mBlenderWater->setOnFinished( + [this, pwater](LLSettingsBlender::ptr_t blender) + { + mBlenderWater.reset(); + mInjectedWater->setSource(pwater); + setWater(mInjectedWater); + if (!mBlenderSky && (countExperiencesActive() == 0)) + { + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_PUSH); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT); + } + }); + } } void DayInjection::onEnvironmentChanged(LLEnvironment::EnvSelection_t env) @@ -2869,6 +2963,23 @@ namespace } } + void DayInjection::onParcelChange() + { + S32 parcel_id(INVALID_PARCEL_ID); + LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + + if (!parcel) + return; + + parcel_id = parcel->getLocalID(); + + // TODO: + // 1) Get the parcel experiences, + // 2) check against injected experiences + // 3) if not allowed remove them. + + } + void DayInjection::checkExperience() { if ((!mDayExperience.isNull()) && (mSkyExperience != mDayExperience) && (mWaterExperience != mDayExperience)) @@ -2886,22 +2997,6 @@ namespace } - -// void DayInjection::setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) -// { -// -// } -// -// void DayInjection::setSky(const LLSettingsSky::ptr_t &psky) -// { -// -// } -// -// void DayInjection::setWater(const LLSettingsWater::ptr_t &pwater) -// { -// -// } - void InjectedTransition::animate() { mNextInstance->animate(); @@ -2936,8 +3031,8 @@ namespace if (!mBlenderSky && !mBlenderWater) mInjection->setBaseDayInstance(mNextInstance); -// else -// mInjection->mInjectedWater->setSource(mNextInstance->getWater()); + else + mInjection->mInjectedWater->setSource(mNextInstance->getWater()); }); } else -- cgit v1.2.3 From 98d6d1969be08f16a5d565b544f46c8a13fb4db5 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 13 Feb 2019 17:01:17 -0800 Subject: SL-10464: Request experience status on parcel change, strip if no longer allowed. --- indra/newview/llenvironment.cpp | 100 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 90 insertions(+), 10 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 25983e245b..425ce6363d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -694,6 +694,7 @@ namespace public: typedef std::shared_ptr ptr_t; + typedef std::weak_ptr wptr_t; DayInjection(LLEnvironment::EnvSelection_t env); virtual ~DayInjection(); @@ -720,7 +721,11 @@ namespace bool isOverriddenWater() const { return !mWaterExperience.isNull(); } bool hasInjections() const; + + void testExperiencesOnParcel(S32 parcel_id); private: + static void testExperiencesOnParcelCoro(wptr_t that, S32 parcel_id); + void animateSkyChange(LLSettingsSky::ptr_t psky, LLSettingsBase::Seconds transition); void animateWaterChange(LLSettingsWater::ptr_t pwater, LLSettingsBase::Seconds transition); @@ -2305,8 +2310,6 @@ void LLEnvironment::clearExperienceEnvironment(LLUUID experience_id, LLSettingsB if (injection) { injection->clearInjections(experience_id, transition_time); -// clearEnvironment(ENV_PUSH); -// updateEnvironment(transition_time); } } @@ -2796,6 +2799,14 @@ namespace mBlenderSky || mBlenderWater || mInjectedSky->hasInjections() || mInjectedWater->hasInjections()); } + + void DayInjection::testExperiencesOnParcel(S32 parcel_id) + { + LLCoros::instance().launch("DayInjection::testExperiencesOnParcel", + [this, parcel_id]() { DayInjection::testExperiencesOnParcelCoro(std::static_pointer_cast(this->shared_from_this()), parcel_id); }); + + } + void DayInjection::setInjectedDay(const LLSettingsDay::ptr_t &pday, LLUUID experience_id, LLSettingsBase::Seconds transition) { mSkyExperience = experience_id; @@ -2830,11 +2841,13 @@ namespace void DayInjection::injectSkySettings(LLSD settings, LLUUID experience_id, LLSettingsBase::Seconds transition) { mInjectedSky->injectExperienceValues(settings, experience_id, transition); + mActiveExperiences.insert(experience_id); } void DayInjection::injectWaterSettings(LLSD settings, LLUUID experience_id, LLSettingsBase::Seconds transition) { mInjectedWater->injectExperienceValues(settings, experience_id, transition); + mActiveExperiences.insert(experience_id); } void DayInjection::clearInjections(LLUUID experience_id, LLSettingsBase::Seconds transition_time) @@ -2882,6 +2895,80 @@ namespace } } + + void DayInjection::testExperiencesOnParcelCoro(wptr_t that, S32 parcel_id) + { + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("testExperiencesOnParcelCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + std::string url = gAgent.getRegionCapability("ExperienceQuery"); + + if (url.empty()) + { + LL_WARNS("ENVIRONMENT") << "No experience query cap." << LL_ENDL; + return; // no checking in this region. + } + + { + ptr_t thatlock(that); + std::stringstream fullurl; + + if (!thatlock) + return; + + fullurl << url << "?"; + fullurl << "parcelid=" << parcel_id; + + for (auto it = thatlock->mActiveExperiences.begin(); it != thatlock->mActiveExperiences.end(); ++it) + { + if (it != thatlock->mActiveExperiences.begin()) + fullurl << ","; + else + fullurl << "&experiences="; + fullurl << (*it).asString(); + } + url = fullurl.str(); + } + + LLSD result = httpAdapter->getAndSuspend(httpRequest, url); + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS() << "Unable to retrieve experience status for parcel." << LL_ENDL; + return; + } + + { + LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + if (!parcel) + return; + + if (parcel_id != parcel->getLocalID()) + { + // Agent no longer on queried parcel. + return; + } + } + + + LLSD experiences = result["experiences"]; + { + ptr_t thatlock(that); + if (!thatlock) + return; + + for (LLSD::map_iterator itr = experiences.beginMap(); itr != experiences.endMap(); ++itr) + { + if (!((*itr).second.asBoolean())) + thatlock->clearInjections(LLUUID((*itr).first), LLEnvironment::TRANSITION_FAST); + + } + } + } + void DayInjection::animateSkyChange(LLSettingsSky::ptr_t psky, LLSettingsBase::Seconds transition) { if (transition == LLEnvironment::TRANSITION_INSTANT) @@ -2973,11 +3060,7 @@ namespace parcel_id = parcel->getLocalID(); - // TODO: - // 1) Get the parcel experiences, - // 2) check against injected experiences - // 3) if not allowed remove them. - + testExperiencesOnParcel(parcel_id); } void DayInjection::checkExperience() @@ -2985,9 +3068,6 @@ namespace if ((!mDayExperience.isNull()) && (mSkyExperience != mDayExperience) && (mWaterExperience != mDayExperience)) { // There was a day experience but we've replaced it with a water and a sky experience. mDayExperience.setNull(); - - // TODO test sky and water for injections before removing experience id - mBaseDayInstance = LLEnvironment::instance().getSharedEnvironmentInstance(); } } -- cgit v1.2.3 From 2108d5ee38a955f140f40aa71705aa04e4487362 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 14 Feb 2019 16:19:39 -0800 Subject: SL-10464: A couple last fixes dealing with region crossings. Environment Experiences are still stripped when changing regions. Even if destination region participates in the experience. --- indra/newview/llenvironment.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 425ce6363d..4bf7a630a5 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -358,7 +358,14 @@ namespace virtual ~LLSettingsInjected() {}; typename SETTINGT::ptr_t getSource() const { return this->mSource; } - void setSource(const typename SETTINGT::ptr_t &source) { this->mSource = source; this->setDirtyFlag(true); this->mLastSourceHash = 0; } + void setSource(const typename SETTINGT::ptr_t &source) + { + if (source.get() == this) // do not set a source to itself. + return; + this->mSource = source; + this->setDirtyFlag(true); + this->mLastSourceHash = 0; + } virtual bool isDirty() const override { return SETTINGT::isDirty() || (this->mSource->isDirty()); } virtual bool isVeryDirty() const override { return SETTINGT::isVeryDirty() || (this->mSource->isVeryDirty()); } @@ -974,8 +981,11 @@ bool LLEnvironment::isInventoryEnabled() const void LLEnvironment::onRegionChange() { - // TODO: Use test experiences rather than full clear. +// if (gAgent.getRegionCapability("ExperienceQuery").empty()) +// { +// // for now environmental experiences do not survive region crossings clearExperienceEnvironment(LLUUID::null, TRANSITION_DEFAULT); +// } LLViewerRegion* cur_region = gAgent.getRegion(); if (!cur_region) @@ -2971,6 +2981,10 @@ namespace void DayInjection::animateSkyChange(LLSettingsSky::ptr_t psky, LLSettingsBase::Seconds transition) { + if (mInjectedSky.get() == psky.get()) + { // An attempt to animate to itself... don't do it. + return; + } if (transition == LLEnvironment::TRANSITION_INSTANT) { mBlenderSky.reset(); @@ -3000,6 +3014,10 @@ namespace void DayInjection::animateWaterChange(LLSettingsWater::ptr_t pwater, LLSettingsBase::Seconds transition) { + if (mInjectedWater.get() == pwater.get()) + { // An attempt to animate to itself. Bad idea. + return; + } if (transition == LLEnvironment::TRANSITION_INSTANT) { mBlenderWater.reset(); -- cgit v1.2.3 From 2401712d1073e85b4b9183d20c6e9274bc874f64 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 20 Feb 2019 15:20:30 -0800 Subject: SL-9660: Next pass cleanup. Removed and downgraded a number of logs. Removed refs to LAPAS. Better sync with legacy regions. --- indra/newview/llenvironment.cpp | 76 ++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 32 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 4bf7a630a5..f021c4a8c3 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -470,7 +470,6 @@ namespace { if ((*it)->mBlendIn) { - //_WARNS("LAPRAS") << "Done blending '" << key_name << "' after " << (*it)->mTransition.value() - (*it)->mTimeRemaining.value() << " value now=" << target << LL_ENDL; mOverrideValues[key_name] = target; mOverrideExps[key_name] = (*it)->mExperience; this->mSettings[key_name] = target; @@ -1621,39 +1620,38 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI else if (envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_WATER) || envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_GROUND_LEVEL)) { - LL_WARNS("LAPRAS") << "Invalid day cycle for region" << LL_ENDL; + LL_WARNS("ENVIRONMENT") << "Invalid day cycle for region" << LL_ENDL; clearEnvironment(ENV_PARCEL); setEnvironment(ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET, envinfo->mEnvVersion); updateEnvironment(); } else { - LL_INFOS("LAPRAS") << "Setting Region environment" << LL_ENDL; setEnvironment(ENV_REGION, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset, envinfo->mEnvVersion); mTrackAltitudes = envinfo->mAltitudes; } - LL_WARNS("LAPRAS") << "Altitudes set to {" << mTrackAltitudes[0] << ", "<< mTrackAltitudes[1] << ", " << mTrackAltitudes[2] << ", " << mTrackAltitudes[3] << LL_ENDL; + LL_DEBUGS("ENVIRONMENT") << "Altitudes set to {" << mTrackAltitudes[0] << ", "<< mTrackAltitudes[1] << ", " << mTrackAltitudes[2] << ", " << mTrackAltitudes[3] << LL_ENDL; } else { LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); - LL_WARNS("LAPRAS") << "Have parcel environment #" << envinfo->mParcelId << LL_ENDL; + LL_DEBUGS("ENVIRONMENT") << "Have parcel environment #" << envinfo->mParcelId << LL_ENDL; if (parcel && (parcel->getLocalID() != parcel_id)) { - LL_WARNS("ENVIRONMENT") << "Requested parcel #" << parcel_id << " agent is on " << parcel->getLocalID() << LL_ENDL; + LL_DEBUGS("ENVIRONMENT") << "Requested parcel #" << parcel_id << " agent is on " << parcel->getLocalID() << LL_ENDL; return; } if (!envinfo->mDayCycle) { - LL_WARNS("LAPRAS") << "Clearing environment on parcel #" << parcel_id << LL_ENDL; + LL_DEBUGS("ENVIRONMENT") << "Clearing environment on parcel #" << parcel_id << LL_ENDL; clearEnvironment(ENV_PARCEL); } else if (envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_WATER) || envinfo->mDayCycle->isTrackEmpty(LLSettingsDay::TRACK_GROUND_LEVEL)) { - LL_WARNS("LAPRAS") << "Invalid day cycle for parcel #" << parcel_id << LL_ENDL; + LL_WARNS("ENVIRONMENT") << "Invalid day cycle for parcel #" << parcel_id << LL_ENDL; clearEnvironment(ENV_PARCEL); } else @@ -1665,6 +1663,27 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI updateEnvironment(transition); } +void LLEnvironment::adjustRegionOffset(F32 adjust) +{ + if (isExtendedEnvironmentEnabled()) + { + LL_WARNS("ENVIRONMENT") << "Attempt to adjust region offset on EEP region. Legacy regions only." << LL_ENDL; + } + + if (mEnvironments[ENV_REGION]) + { + F32 day_length = mEnvironments[ENV_REGION]->getDayLength(); + F32 day_offset = mEnvironments[ENV_REGION]->getDayOffset(); + + F32 day_adjustment = adjust * day_length; + + day_offset += day_adjustment; + if (day_offset < 0.0f) + day_offset = day_length + day_offset; + mEnvironments[ENV_REGION]->setDayOffset(LLSettingsBase::Seconds(day_offset)); + } +} + //========================================================================= void LLEnvironment::requestRegion(environment_apply_fn cb) { @@ -1820,7 +1839,7 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ if (url.empty()) return; - LL_WARNS("LAPRAS") << "Requesting for parcel_id=" << parcel_id << LL_ENDL; + LL_DEBUGS("ENVIRONMENT") << "Requesting for parcel_id=" << parcel_id << LL_ENDL; if (parcel_id != INVALID_PARCEL_ID) { @@ -1830,24 +1849,14 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ url += query.str(); } - LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL; - LLSD result = httpAdapter->getAndSuspend(httpRequest, url); // results that come back may contain the new settings -// LLSD notify; - LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { - LL_WARNS("WindlightCaps") << "Couldn't retrieve environment settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; - -// std::stringstream msg; -// msg << status.toString() << " (Code " << status.toTerseString() << ")"; -// notify = LLSD::emptyMap(); -// notify["FAIL_REASON"] = msg.str(); - + LL_WARNS("ENVIRONMENT") << "Couldn't retrieve environment settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; } else { @@ -1859,11 +1868,6 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ } } -// if (!notify.isUndefined()) -// { -// LLNotificationsUtil::add("WLRegionApplyFail", notify); -// //LLEnvManagerNew::instance().onRegionSettingsApplyResponse(false); -// } } void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, UpdateInfo::ptr_t updates, environment_apply_fn apply) @@ -1906,7 +1910,7 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, UpdateInf body[KEY_ENVIRONMENT][KEY_DAYNAME] = updates->mDayName; } - LL_WARNS("LAPRAS") << "Body = " << body << LL_ENDL; + //_WARNS("ENVIRONMENT") << "Body = " << body << LL_ENDL; if ((parcel_id != INVALID_PARCEL_ID) || (track_no != NO_TRACK)) { @@ -1934,10 +1938,10 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, UpdateInf LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - LL_WARNS("LAPRAS") << "success=" << result["success"] << LL_ENDL; + if ((!status) || !result["success"].asBoolean()) { - LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; + LL_WARNS("ENVIRONMENT") << "Couldn't update Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; notify = LLSD::emptyMap(); notify["FAIL_REASON"] = result["message"].asString(); @@ -1996,10 +2000,10 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, S32 track_no, environmen LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - LL_WARNS("LAPRAS") << "success=" << result["success"] << LL_ENDL; + if ((!status) || !result["success"].asBoolean()) { - LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; + LL_WARNS("ENVIRONMENT") << "Couldn't reset Windlight settings in " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; notify = LLSD::emptyMap(); notify["FAIL_REASON"] = result["message"].asString(); @@ -2416,8 +2420,6 @@ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLSD data, F3 void LLEnvironment::listenExperiencePump(const LLSD &message) { - LL_WARNS("LAPRAS") << "Have experience event: " << message << LL_ENDL; - LLUUID experience_id = message["experience"]; LLSD data = message[experience_id.asString()]; std::string permission(data["permission"].asString()); @@ -2564,6 +2566,16 @@ void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &sky mBlenderWater = waterblend; } +LLSettingsBase::TrackPosition LLEnvironment::DayInstance::getProgress() const +{ + LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); + now += mDayOffset; + + if ((mDayLength <= 0) || !mDayCycle) + return -1.0f; // no actual day cycle. + + return convert_time_to_position(now, mDayLength); +} LLSettingsBase::TrackPosition LLEnvironment::DayInstance::secondsToKeyframe(LLSettingsDay::Seconds seconds) { -- cgit v1.2.3 From d8eff424a5fb340b828802351e2b7f6b63bfa30f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sat, 2 Mar 2019 07:17:46 -0800 Subject: SL-10664 --- indra/newview/llenvironment.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index f021c4a8c3..18777e53d1 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -882,6 +882,14 @@ LLSettingsWater::ptr_t LLEnvironment::getCurrentWater() const return pwater; } +void LayerConfigToDensityLayer(const LLSD& layerConfig, DensityLayer& layerOut) +{ + layerOut.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + layerOut.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + layerOut.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + layerOut.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + layerOut.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); +} void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settingsOut, const LLSettingsSky::ptr_t &psky) { @@ -894,13 +902,9 @@ void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settin settingsOut.m_rayleighProfile.clear(); for (LLSD::array_iterator itf = rayleigh.beginArray(); itf != rayleigh.endArray(); ++itf) { - atmosphere::DensityProfileLayer layer; + DensityLayer layer; LLSD& layerConfig = (*itf); - layer.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); - layer.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); - layer.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); - layer.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); - layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + LayerConfigToDensityLayer(layerConfig, layer); settingsOut.m_rayleighProfile.push_back(layer); } @@ -908,13 +912,9 @@ void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settin settingsOut.m_mieProfile.clear(); for (LLSD::array_iterator itf = mie.beginArray(); itf != mie.endArray(); ++itf) { - atmosphere::DensityProfileLayer layer; + DensityLayer layer; LLSD& layerConfig = (*itf); - layer.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); - layer.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); - layer.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); - layer.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); - layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + LayerConfigToDensityLayer(layerConfig, layer); settingsOut.m_mieProfile.push_back(layer); } settingsOut.m_mieAnisotropy = psky->getMieAnisotropy(); @@ -923,13 +923,9 @@ void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settin settingsOut.m_absorptionProfile.clear(); for (LLSD::array_iterator itf = absorption.beginArray(); itf != absorption.endArray(); ++itf) { - atmosphere::DensityProfileLayer layer; + DensityLayer layer; LLSD& layerConfig = (*itf); - layer.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); - layer.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); - layer.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); - layer.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); - layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + LayerConfigToDensityLayer(layerConfig, layer); settingsOut.m_absorptionProfile.push_back(layer); } } -- cgit v1.2.3 From 58582fb6212a3ccd8ff2f52a59a398b4041bba79 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 15 Mar 2019 14:44:52 +0200 Subject: SL-10672 Fixed Sun transitioned to image from previous keyframe --- indra/newview/llenvironment.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 18777e53d1..3defe68a0e 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -297,9 +297,18 @@ namespace void onFinishedSpan() { - LLSettingsDay::TrackBound_t next = getBoundingEntries(getAdjustedNow()); + LLSettingsBase::Seconds adjusted_now = getAdjustedNow(); + LLSettingsDay::TrackBound_t next = getBoundingEntries(adjusted_now); LLSettingsBase::Seconds nextspan = getSpanTime(next); + reset((*next.first).second, (*next.second).second, nextspan); + + // Recalculate (reinitialize) position. Because: + // - 'delta' from applyTimeDelta accumulates errors (probably should be fixed/changed to absolute time) + // - freezes and lag can result in reset being called too late, so we need to add missed time + // - occasional time corrections can happen + // - some transition switches can happen outside applyTimeDelta thus causing 'desync' from 'delta' (can be fixed by getting rid of delta) + initializeTarget(adjusted_now); } }; -- cgit v1.2.3 From e24237b6af504ff8faea02c8ab22344f2452364e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 3 Apr 2019 14:52:59 -0700 Subject: SL-10189, SL-10880: Mark the day instance so that it does not try to reanimate a day cycle when setting a fixed sky. Add new floater for setting the shared environment to local and allowing modifications. --- indra/newview/llenvironment.cpp | 89 ++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 37 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3defe68a0e..57e6ab7159 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -798,6 +798,11 @@ const S32 LLEnvironment::VERSION_CLEANUP(-4); // for cleanups const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg + +const U32 LLEnvironment::DayInstance::NO_ANIMATE_SKY(0x01); +const U32 LLEnvironment::DayInstance::NO_ANIMATE_WATER(0x02); + + //------------------------------------------------------------------------- LLEnvironment::LLEnvironment(): mCloudScrollDelta(), @@ -1110,28 +1115,28 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm DayInstance::ptr_t environment = getEnvironmentInstance(env, true); -// LLSettingsSky::ptr_t prev_sky = mEnvironments[ENV_DEFAULT]->getSky(); -// LLSettingsWater::ptr_t prev_water = mEnvironments[ENV_DEFAULT]->getWater(); -// if (mCurrentEnvironment && (ENV_EDIT == env)) -// { -// prev_sky = mCurrentEnvironment->getSky() ? mCurrentEnvironment->getSky() : prev_sky; -// prev_water = mCurrentEnvironment->getWater() ? mCurrentEnvironment->getWater() : prev_water; -// } -// environment->clear(); -// environment->setSky((fixed.first) ? fixed.first : prev_sky); -// environment->setWater((fixed.second) ? fixed.second : prev_water); if (fixed.first) + { environment->setSky(fixed.first); + environment->setFlags(DayInstance::NO_ANIMATE_SKY); + } else if (!environment->getSky()) + { environment->setSky(mCurrentEnvironment->getSky()); + environment->setFlags(DayInstance::NO_ANIMATE_SKY); + } if (fixed.second) + { environment->setWater(fixed.second); + environment->setFlags(DayInstance::NO_ANIMATE_WATER); + } else if (!environment->getWater()) + { environment->setWater(mCurrentEnvironment->getWater()); - - + environment->setFlags(DayInstance::NO_ANIMATE_WATER); + } if (!mSignalEnvChanged.empty()) mSignalEnvChanged(env, env_version); @@ -2447,7 +2452,8 @@ LLEnvironment::DayInstance::DayInstance(EnvSelection_t env) : mInitialized(false), mType(TYPE_INVALID), mSkyTrack(1), - mEnv(env) + mEnv(env), + mAnimateFlags(0) { } @@ -2465,6 +2471,7 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::DayInstance::clone() const environment->mInitialized = mInitialized; environment->mType = mType; environment->mSkyTrack = mSkyTrack; + environment->mAnimateFlags = mAnimateFlags; return environment; } @@ -2489,6 +2496,8 @@ void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSett mType = TYPE_CYCLED; mInitialized = false; + mAnimateFlags = 0; + mDayCycle = pday; mDayLength = daylength; mDayOffset = dayoffset; @@ -2596,34 +2605,40 @@ void LLEnvironment::DayInstance::animate() if (!mDayCycle) return; - LLSettingsDay::CycleTrack_t &wtrack = mDayCycle->getCycleTrack(0); - - if (wtrack.empty()) + if (!(mAnimateFlags & NO_ANIMATE_WATER)) { - mWater.reset(); - mBlenderWater.reset(); - } - else - { - mWater = LLSettingsVOWater::buildDefaultWater(); - mBlenderWater = std::make_shared(mWater, mDayCycle, 0, - mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); - } - - // sky, initialize to track 1 - LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(1); + LLSettingsDay::CycleTrack_t &wtrack = mDayCycle->getCycleTrack(0); - if (track.empty()) - { - mSky.reset(); - mBlenderSky.reset(); + if (wtrack.empty()) + { + mWater.reset(); + mBlenderWater.reset(); + } + else + { + mWater = LLSettingsVOWater::buildDefaultWater(); + mBlenderWater = std::make_shared(mWater, mDayCycle, 0, + mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); + } } - else + + if (!(mAnimateFlags & NO_ANIMATE_SKY)) { - mSky = LLSettingsVOSky::buildDefaultSky(); - mBlenderSky = std::make_shared(mSky, mDayCycle, 1, - mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); - mBlenderSky->switchTrack(mSkyTrack, 0.0); + // sky, initialize to track 1 + LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(1); + + if (track.empty()) + { + mSky.reset(); + mBlenderSky.reset(); + } + else + { + mSky = LLSettingsVOSky::buildDefaultSky(); + mBlenderSky = std::make_shared(mSky, mDayCycle, 1, + mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); + mBlenderSky->switchTrack(mSkyTrack, 0.0); + } } } -- cgit v1.2.3 From 6aa393f7f50ca30b65391f4ae230a3357092f3cd Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 24 May 2019 21:17:41 +0300 Subject: SL-11287 [EEP] Importing certain legacy windlights give upload error --- indra/newview/llenvironment.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 57e6ab7159..081b3a3d42 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -2165,7 +2165,7 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extractLeg //========================================================================= LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename, LLSD &messages) { - std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + std::string name(gDirUtilp->getBaseFileName(filename, true)); std::string path(gDirUtilp->getDirName(filename)); LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPresetFile(name, path, messages); @@ -2180,7 +2180,7 @@ LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::str LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string filename, LLSD &messages) { - std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + std::string name(gDirUtilp->getBaseFileName(filename, true)); std::string path(gDirUtilp->getDirName(filename)); LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPresetFile(name, path, messages); @@ -2194,7 +2194,7 @@ LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string LLSettingsDay::ptr_t LLEnvironment::createDayCycleFromLegacyPreset(const std::string filename, LLSD &messages) { - std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + std::string name(gDirUtilp->getBaseFileName(filename, true)); std::string path(gDirUtilp->getDirName(filename)); LLSettingsDay::ptr_t day = LLSettingsVODay::buildFromLegacyPresetFile(name, path, messages); -- cgit v1.2.3 From fdf0d49614b820ffa85d2aa9258e4592bc0e45f3 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Tue, 28 May 2019 18:06:08 +0300 Subject: SL-11279 [EEP] Automatically toggle the beacon checkboxes --- indra/newview/llenvironment.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 57e6ab7159..a67ba709b0 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -811,7 +811,10 @@ LLEnvironment::LLEnvironment(): mSelectedWater(), mSelectedDay(), mSelectedEnvironment(LLEnvironment::ENV_LOCAL), - mCurrentTrack(1) + mCurrentTrack(1), + mEditorCounter(0), + mShowSunBeacon(false), + mShowMoonBeacon(false) { } @@ -2692,6 +2695,25 @@ void LLEnvironment::DayTransition::animate() }); } +void LLEnvironment::saveBeaconsState() +{ + if (mEditorCounter == 0) + { + mShowSunBeacon = gSavedSettings.getBOOL("sunbeacon"); + mShowMoonBeacon = gSavedSettings.getBOOL("moonbeacon"); + } + ++mEditorCounter; +} +void LLEnvironment::revertBeaconsState() +{ + --mEditorCounter; + if (mEditorCounter == 0) + { + gSavedSettings.setBOOL("sunbeacon", mShowSunBeacon && gSavedSettings.getBOOL("sunbeacon")); + gSavedSettings.setBOOL("moonbeacon", mShowMoonBeacon && gSavedSettings.getBOOL("moonbeacon")); + } +} + //========================================================================= LLTrackBlenderLoopingManual::LLTrackBlenderLoopingManual(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno) : LLSettingsBlender(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t()), -- cgit v1.2.3 From 8ba159fed90fc221003e85c5d2d3b82ec30d81bf Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 27 Jun 2019 09:10:38 -0700 Subject: SL-11151, SL-11504 Remove update threshold logic causing hiccups and rework sky updates. Make deferred water do double transport again to match non-ALM rendering more closely. --- indra/newview/llenvironment.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3373c8c3a4..d20c05fe67 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -196,7 +196,6 @@ namespace mCycleLength(cyclelength), mCycleOffset(cycleoffset) { - setTimeDeltaThreshold(updateThreshold); // must happen prior to getBoundingEntries call... mTrackNo = selectTrackNumber(trackno); @@ -233,7 +232,6 @@ namespace LLSettingsBase::BlendFactor blendf = calculateBlend(targetpos, targetspan); pendsetting->blend((*bounds.second).second, blendf); - setIgnoreTimeDeltaThreshold(true); // for the next span ignore the time delta threshold. reset(pstartsetting, pendsetting, LLEnvironment::TRANSITION_ALTITUDE); } -- cgit v1.2.3 From b507d63566e8896af702dd10f5643dc29068a8a9 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2019 11:36:22 -0700 Subject: SL-11621 Remove all references to unused shader var global_gamma. Remove many unused decls for gamma from shaders. Make post-deferred gamma correction use display_gamma. Make setting display_gamma use the correct RenderDeferredDisplayGamma setting. --- indra/newview/llenvironment.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index d20c05fe67..daff4b7186 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1596,16 +1596,6 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS //_WARNS("RIDER") << "----------------------------------------------------------------" << LL_ENDL; psetting->applySpecial(shader); - - if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && !LLPipeline::sUnderWaterRender) - { - shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 2.2); - } - else - { - shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 1.0); - } - } void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) -- cgit v1.2.3 From 1f656735d339fc4d83da86efbb400af1361c27db Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 26 Aug 2019 11:43:45 -0700 Subject: SL-11705, SL-11706: New flags in llsettings base for tracking by simulator. --- indra/newview/llenvironment.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index daff4b7186..782077b9a2 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -81,6 +81,7 @@ namespace const std::string KEY_PARCELID("parcel_id"); const std::string KEY_REGIONID("region_id"); const std::string KEY_TRACKALTS("track_altitudes"); + const std::string KEY_FLAGS("flags"); const std::string MESSAGE_PUSHENVIRONMENT("PushExpEnvironment"); @@ -1696,7 +1697,7 @@ void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_lengt updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset, altitudes, cb); } -void LLEnvironment::updateRegion(const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +void LLEnvironment::updateRegion(const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, U32 flags, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { if (!isExtendedEnvironmentEnabled()) { @@ -1705,7 +1706,7 @@ void LLEnvironment::updateRegion(const LLUUID &asset_id, std::string display_nam return; } - updateParcel(INVALID_PARCEL_ID, asset_id, display_name, track_num, day_length, day_offset, altitudes, cb); + updateParcel(INVALID_PARCEL_ID, asset_id, display_name, track_num, day_length, day_offset, flags, altitudes, cb); } void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) @@ -1758,9 +1759,9 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) [this, parcel_id, cb]() { coroRequestEnvironment(parcel_id, cb); }); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) +void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, U32 flags, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { - UpdateInfo::ptr_t updates(std::make_shared(asset_id, display_name, day_length, day_offset, altitudes)); + UpdateInfo::ptr_t updates(std::make_shared(asset_id, display_name, day_length, day_offset, altitudes, flags)); std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", [this, parcel_id, track_num, updates, cb]() { coroUpdateEnvironment(parcel_id, track_num, updates, cb); }); @@ -1797,12 +1798,14 @@ void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::p void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, psky); + pday->setFlag(psky->getFlags()); updateParcel(parcel_id, pday, day_length, day_offset, altitudes, cb); } void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb) { LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, pwater); + pday->setFlag(pwater->getFlags()); updateParcel(parcel_id, pday, day_length, day_offset, altitudes, cb); } @@ -1911,6 +1914,7 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, UpdateInf body[KEY_ENVIRONMENT][KEY_DAYNAME] = updates->mDayName; } + body[KEY_ENVIRONMENT][KEY_FLAGS] = LLSD::Integer(updates->mFlags); //_WARNS("ENVIRONMENT") << "Body = " << body << LL_ENDL; if ((parcel_id != INVALID_PARCEL_ID) || (track_no != NO_TRACK)) -- cgit v1.2.3 From 79dcb0fba317388fd49d23461ab3c65adec2f77c Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 15 Jan 2020 17:03:33 +0200 Subject: SL-12208 [EEP] The Water Normal Map does not consistently render --- indra/newview/llenvironment.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 782077b9a2..8f778711ce 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -2532,7 +2532,9 @@ void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) mType = TYPE_FIXED; mInitialized = false; + bool different_water = mWater != pwater; mWater = pwater; + mWater->mReplaced |= different_water; mWater->update(); mBlenderWater.reset(); } -- cgit v1.2.3 From 44f0cadad8f51e33d6af49d7ef3b3e175bd5b8b2 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Thu, 27 Feb 2020 15:30:09 +0200 Subject: SL-12739 FIXED [EEP] Viewer is crashed after clicking the "Forget" button on the Experience Profile after the llSetAgentEnvironment was used --- indra/newview/llenvironment.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 8f778711ce..b8c5648cca 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -397,8 +397,8 @@ namespace void removeInjection(const std::string keyname, LLUUID experience, LLSettingsBase::Seconds transition) { - auto it = mInjections.begin(); - while (it != mInjections.end()) + injections_t injections_buf; + for (auto it = mInjections.begin(); it != mInjections.end(); it++) { if ((keyname.empty() || ((*it)->mKeyName == keyname)) && (experience.isNull() || (experience == (*it)->mExperience))) @@ -406,13 +406,16 @@ namespace if (transition != LLEnvironment::TRANSITION_INSTANT) { typename Injection::ptr_t injection = std::make_shared(transition, keyname, (*it)->mLastValue, false, LLUUID::null); - mInjections.push_front(injection); // push them in at the front so we don't check them again. + injections_buf.push_front(injection); } - mInjections.erase(it++); } else - ++it; + { + injections_buf.push_front(*it); + } } + mInjections.clear(); + mInjections = injections_buf; for (auto itexp = mOverrideExps.begin(); itexp != mOverrideExps.end();) { -- cgit v1.2.3 From a7849c6ec4fa31597121e7c8601fe427e222db0b Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 26 Mar 2020 18:09:09 +0200 Subject: Removed obsolete and misleading variable --- indra/newview/llenvironment.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index b8c5648cca..c6d878769d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -2448,7 +2448,6 @@ LLEnvironment::DayInstance::DayInstance(EnvSelection_t env) : mBlenderSky(), mBlenderWater(), mInitialized(false), - mType(TYPE_INVALID), mSkyTrack(1), mEnv(env), mAnimateFlags(0) @@ -2467,7 +2466,6 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::DayInstance::clone() const environment->mBlenderSky = mBlenderSky; environment->mBlenderWater = mBlenderWater; environment->mInitialized = mInitialized; - environment->mType = mType; environment->mSkyTrack = mSkyTrack; environment->mAnimateFlags = mAnimateFlags; @@ -2491,7 +2489,6 @@ bool LLEnvironment::DayInstance::applyTimeDelta(const LLSettingsBase::Seconds& d void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) { - mType = TYPE_CYCLED; mInitialized = false; mAnimateFlags = 0; @@ -2512,7 +2509,6 @@ void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSett void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) { - mType = TYPE_FIXED; mInitialized = false; bool different_sky = mSky != psky; @@ -2532,7 +2528,6 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) { - mType = TYPE_FIXED; mInitialized = false; bool different_water = mWater != pwater; @@ -2554,7 +2549,6 @@ void LLEnvironment::DayInstance::initialize() void LLEnvironment::DayInstance::clear() { - mType = TYPE_INVALID; mDayCycle.reset(); mSky.reset(); mWater.reset(); -- cgit v1.2.3 From 6620211bff5dca7df0667cf9220da1a9e7ce079c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 27 Mar 2020 00:13:33 +0200 Subject: SL-12911 Add Debug setting EnvironmentPersistAcrossLogin --- indra/newview/llenvironment.cpp | 204 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index c6d878769d..85fe2a7c95 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -101,6 +101,8 @@ namespace const std::string LISTENER_NAME("LLEnvironmentSingleton"); const std::string PUMP_EXPERIENCE("experience_permission"); + const std::string LOCAL_ENV_STORAGE_FILE("local_environment_data.bin"); + //--------------------------------------------------------------------- LLTrace::BlockTimerStatHandle FTM_ENVIRONMENT_UPDATE("Update Environment Tick"); LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); @@ -849,6 +851,8 @@ void LLEnvironment::initSingleton() } LLEventPumps::instance().obtain(PUMP_EXPERIENCE).listen(LISTENER_NAME, [this](LLSD message) { listenExperiencePump(message); return false; }); + + loadFromSettings(); } void LLEnvironment::cleanupSingleton() @@ -2686,6 +2690,206 @@ void LLEnvironment::DayTransition::animate() }); } +void LLEnvironment::saveToSettings() +{ + std::string user_dir = gDirUtilp->getLindenUserDir(); + if (user_dir.empty()) + { + // not logged in + return; + } + bool has_data = false; + + if (gSavedSettings.getBOOL("EnvironmentPersistAcrossLogin")) + { + DayInstance::ptr_t environment = getEnvironmentInstance(ENV_LOCAL); + if (environment) + { + // Environment is 'layered'. No data in ENV_LOCAL means we are using parcel/region + // Store local environment for next session + LLSD env_data; + + LLSettingsDay::ptr_t day = environment->getDayCycle(); + if (day) + { + const std::string name = day->getName(); + const LLUUID asset_id = day->getAssetId(); + if (asset_id.notNull()) + { + // just save the id + env_data["day_id"] = asset_id; + env_data["day_length"] = LLSD::Integer(environment->getDayLength()); + env_data["day_offset"] = LLSD::Integer(environment->getDayOffset()); + has_data = true; + } + else if (!name.empty() && name != LLSettingsBase::DEFAULT_SETTINGS_NAME) + { + // This setting was created locally and was not saved + // The only option is to save the whole thing + env_data["day_llsd"] = day->getSettings(); + env_data["day_length"] = LLSD::Integer(environment->getDayLength()); + env_data["day_offset"] = LLSD::Integer(environment->getDayOffset()); + has_data = true; + } + } + + LLSettingsSky::ptr_t sky = environment->getSky(); + if ((environment->getFlags() & DayInstance::NO_ANIMATE_SKY) && sky) + { + const std::string name = sky->getName(); + const LLUUID asset_id = sky->getAssetId(); + if (asset_id.notNull()) + { + // just save the id + env_data["sky_id"] = asset_id; + has_data = true; + } + else if (!name.empty() && name != LLSettingsBase::DEFAULT_SETTINGS_NAME) + { + // This setting was created locally and was not saved + // The only option is to save the whole thing + env_data["sky_llsd"] = sky->getSettings(); + has_data = true; + } + has_data = true; + } + + LLSettingsWater::ptr_t water = environment->getWater(); + if ((environment->getFlags() & DayInstance::NO_ANIMATE_WATER) && water) + { + const std::string name = water->getName(); + const LLUUID asset_id = water->getAssetId(); + if (asset_id.notNull()) + { + // just save the id + env_data["water_id"] = asset_id; + has_data = true; + } + else if (!name.empty() && name != LLSettingsBase::DEFAULT_SETTINGS_NAME) + { + // This setting was created locally and was not saved + // The only option is to save the whole thing + env_data["water_llsd"] = water->getSettings(); + has_data = true; + } + } + + std::string user_filepath = user_dir + gDirUtilp->getDirDelimiter() + LOCAL_ENV_STORAGE_FILE; + llofstream out(user_filepath.c_str(), std::ios_base::out | std::ios_base::binary); + if (out.good()) + { + LLSDSerialize::toBinary(env_data, out); + out.close(); + } + else + { + LL_WARNS("ENVIRONMENT") << "Unable to open " << user_filepath << " for output." << LL_ENDL; + } + } + } + + if (!has_data) + { + LLFile::remove(user_dir + gDirUtilp->getDirDelimiter() + LOCAL_ENV_STORAGE_FILE, ENOENT); + } +} + +bool LLEnvironment::loadFromSettings() +{ + if (!gSavedSettings.getBOOL("EnvironmentPersistAcrossLogin")) + { + return false; + } + + std::string user_path = gDirUtilp->getLindenUserDir(); + if (user_path.empty()) + { + LL_WARNS("ENVIRONMENT") << "Can't load previous environment, Environment was initialized before user logged in" << LL_ENDL; + return false; + } + std::string user_filepath(user_path + gDirUtilp->getDirDelimiter() + LOCAL_ENV_STORAGE_FILE); + if (!gDirUtilp->fileExists(user_filepath)) + { + // No previous environment + return false; + } + + LLSD env_data; + llifstream file(user_filepath.c_str(), std::ios_base::in | std::ios_base::binary); + if (file.is_open()) + { + LLSDSerialize::fromBinary(env_data, file, LLSDSerialize::SIZE_UNLIMITED); + if (env_data.isUndefined()) + { + LL_WARNS("ENVIRONMENT") << "error loading " << user_filepath << LL_ENDL; + return false; + } + else + { + LL_INFOS("ENVIRONMENT") << "Loaded previous session environment from: " << user_filepath << LL_ENDL; + } + file.close(); + } + else + { + LL_INFOS("ENVIRONMENT") << "Unable to open previous session environment file " << user_filepath << LL_ENDL; + } + + if (!env_data.isMap() || env_data.emptyMap()) + { + LL_DEBUGS("ENVIRONMENT") << "Empty map loaded from: " << user_filepath << LL_ENDL; + return false; + } + + bool valid = false; + + if (env_data.has("day_id")) + { + S32 length = env_data["day_length"].asInteger(); + S32 offset = env_data["day_offset"].asInteger(); + setEnvironment(ENV_LOCAL, env_data["day_id"].asUUID(), LLSettingsDay::Seconds(length), LLSettingsDay::Seconds(offset)); + valid = true; + } + else if (env_data.has("day_llsd")) + { + S32 length = env_data["day_length"].asInteger(); + S32 offset = env_data["day_offset"].asInteger(); + LLSettingsDay::ptr_t day = std::make_shared(env_data["day_llsd"]); + setEnvironment(ENV_LOCAL, day, LLSettingsDay::Seconds(length), LLSettingsDay::Seconds(offset)); + valid = true; + } + + if (env_data.has("sky_id")) + { + setEnvironment(ENV_LOCAL, env_data["sky_id"].asUUID()); + valid = true; + } + else if (env_data.has("sky_llsd")) + { + LLSettingsSky::ptr_t sky = std::make_shared(env_data["sky_llsd"]); + setEnvironment(ENV_LOCAL, sky); + valid = true; + } + + if (env_data.has("water_id")) + { + setEnvironment(ENV_LOCAL, env_data["water_id"].asUUID()); + valid = true; + } + else if (env_data.has("water_llsd")) + { + LLSettingsWater::ptr_t sky = std::make_shared(env_data["water_llsd"]); + setEnvironment(ENV_LOCAL, sky); + valid = true; + } + + if (valid) + { + updateEnvironment(TRANSITION_INSTANT, true); + } + return valid; +} + void LLEnvironment::saveBeaconsState() { if (mEditorCounter == 0) -- cgit v1.2.3 From 0524a1a86fd2a44b830e578291af09d2c2bee9f6 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Fri, 3 Apr 2020 11:49:17 -0600 Subject: SL-11368, fix missing water uniforms for low shader settings --- indra/newview/llenvironment.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 85fe2a7c95..1c551ed9a8 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1608,11 +1608,8 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) { - if (gPipeline.canUseWindLightShaders()) - { - updateGLVariablesForSettings(shader, mCurrentEnvironment->getWater()); - updateGLVariablesForSettings(shader, mCurrentEnvironment->getSky()); - } + updateGLVariablesForSettings(shader, mCurrentEnvironment->getWater()); + updateGLVariablesForSettings(shader, mCurrentEnvironment->getSky()); } void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo, LLSettingsBase::Seconds transition) -- cgit v1.2.3 From 483c459e2e013e3bf1c813c3bb5030d0c0631963 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 11 Apr 2020 00:23:08 +0300 Subject: SL-13029 Environment update was not applying properly --- indra/newview/llenvironment.cpp | 88 +++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 29 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 1c551ed9a8..7cd9503e4d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -2791,6 +2791,37 @@ void LLEnvironment::saveToSettings() } } +void LLEnvironment::loadSkyWaterFromSettings(const LLSD &env_data, bool &valid, bool &assets_present) +{ + if (env_data.has("sky_id")) + { + // causes asset loaded callback and an update + setEnvironment(ENV_LOCAL, env_data["sky_id"].asUUID()); + valid = true; + assets_present = true; + } + else if (env_data.has("sky_llsd")) + { + LLSettingsSky::ptr_t sky = std::make_shared(env_data["sky_llsd"]); + setEnvironment(ENV_LOCAL, sky); + valid = true; + } + + if (env_data.has("water_id")) + { + // causes asset loaded callback and an update + setEnvironment(ENV_LOCAL, env_data["water_id"].asUUID()); + valid = true; + assets_present = true; + } + else if (env_data.has("water_llsd")) + { + LLSettingsWater::ptr_t sky = std::make_shared(env_data["water_llsd"]); + setEnvironment(ENV_LOCAL, sky); + valid = true; + } +} + bool LLEnvironment::loadFromSettings() { if (!gSavedSettings.getBOOL("EnvironmentPersistAcrossLogin")) @@ -2839,13 +2870,32 @@ bool LLEnvironment::loadFromSettings() } bool valid = false; + bool has_assets = false; if (env_data.has("day_id")) { - S32 length = env_data["day_length"].asInteger(); - S32 offset = env_data["day_offset"].asInteger(); - setEnvironment(ENV_LOCAL, env_data["day_id"].asUUID(), LLSettingsDay::Seconds(length), LLSettingsDay::Seconds(offset)); - valid = true; + LLSettingsDay::Seconds length = LLSettingsDay::Seconds(env_data["day_length"].asInteger()); + LLSettingsDay::Seconds offset = LLSettingsDay::Seconds(env_data["day_offset"].asInteger()); + LLUUID assetId = env_data["day_id"].asUUID(); + + LLSettingsVOBase::getSettingsAsset(assetId, + [this, length, offset, env_data](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) + { + // Day should be always applied first, + // otherwise it will override sky or water that was set earlier + // so wait for asset to load before applying sky/water + onSetEnvAssetLoaded(ENV_LOCAL, asset_id, settings, length, offset, TRANSITION_DEFAULT, status, NO_VERSION); + bool valid = false, has_assets = false; + loadSkyWaterFromSettings(env_data, valid, has_assets); + if (!has_assets && valid) + { + // Settings were loaded from file without having an asset, needs update + // otherwise update will be done by asset callback + updateEnvironment(TRANSITION_DEFAULT, true); + } + }); + // bail early, everything have to be done at callback + return true; } else if (env_data.has("day_llsd")) { @@ -2856,33 +2906,13 @@ bool LLEnvironment::loadFromSettings() valid = true; } - if (env_data.has("sky_id")) - { - setEnvironment(ENV_LOCAL, env_data["sky_id"].asUUID()); - valid = true; - } - else if (env_data.has("sky_llsd")) - { - LLSettingsSky::ptr_t sky = std::make_shared(env_data["sky_llsd"]); - setEnvironment(ENV_LOCAL, sky); - valid = true; - } - - if (env_data.has("water_id")) - { - setEnvironment(ENV_LOCAL, env_data["water_id"].asUUID()); - valid = true; - } - else if (env_data.has("water_llsd")) - { - LLSettingsWater::ptr_t sky = std::make_shared(env_data["water_llsd"]); - setEnvironment(ENV_LOCAL, sky); - valid = true; - } + loadSkyWaterFromSettings(env_data, valid, has_assets); - if (valid) + if (valid && !has_assets) { - updateEnvironment(TRANSITION_INSTANT, true); + // Settings were loaded from file without having an asset, needs update + // otherwise update will be done by asset callback + updateEnvironment(TRANSITION_DEFAULT, true); } return valid; } -- cgit v1.2.3 From ee88ebf9e924882d0ac5baf0908fc9d6f437cfa2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 13 Apr 2020 16:48:25 +0300 Subject: SL-13029 Fixed load order --- indra/newview/llenvironment.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/llenvironment.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 7cd9503e4d..0e1c4f9434 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -851,8 +851,6 @@ void LLEnvironment::initSingleton() } LLEventPumps::instance().obtain(PUMP_EXPERIENCE).listen(LISTENER_NAME, [this](LLSD message) { listenExperiencePump(message); return false; }); - - loadFromSettings(); } void LLEnvironment::cleanupSingleton() -- cgit v1.2.3