summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llenvironment.cpp845
-rw-r--r--indra/newview/llenvironment.h149
-rw-r--r--indra/newview/llfloatereditdaycycle.cpp3
-rw-r--r--indra/newview/llfloatereditextdaycycle.cpp10
-rw-r--r--indra/newview/llfloatereditsky.cpp10
-rw-r--r--indra/newview/llfloatereditwater.cpp10
-rw-r--r--indra/newview/llfloaterenvironmentsettings.cpp34
-rw-r--r--indra/newview/llfloaterland.cpp27
-rw-r--r--indra/newview/llfloaterregioninfo.cpp15
-rw-r--r--indra/newview/llviewermenu.cpp21
-rw-r--r--indra/newview/llviewerregion.cpp4
-rw-r--r--indra/newview/llviewerregion.h17
12 files changed, 675 insertions, 470 deletions
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<DayInstance>();
+ 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<DayInstance>();
+ 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<LLSettingsBlender>(ptargetsky, psky, pinstance->getSky(), transition);
+ skyblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, true));
+ LLSettingsBlender::ptr_t waterblend = boost::make_shared<LLSettingsBlender>(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<F32>(delta_t)* (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0;
- mCloudScrollDelta += cloud_delta;
-
-
+ if (mCurrentEnvironment->getSky())
+ {
+ LLVector2 cloud_delta = static_cast<F32>(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<LLSettingsBlender>( 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<LLSettingsBlender>(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<F64>(seconds.value() % mDayLength.value()) / static_cast<F64>(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<LLSettingsWater>((*(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<LLSettingsVOWater>((*bounds.first).second)->buildClone();
+ mBlenderWater = boost::make_shared<LLSettingsBlender>(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<LLSettingsSky>((*(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<LLSettingsVOSky>((*bounds.first).second)->buildClone();
+ mBlenderSky = boost::make_shared<LLSettingsBlender>(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);
+}
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
index 451bab5f9e..4230f76862 100644
--- a/indra/newview/llenvironment.h
+++ b/indra/newview/llenvironment.h
@@ -77,9 +77,11 @@ public:
enum EnvSelection_t
{
+ ENV_EDIT,
ENV_LOCAL,
ENV_PARCEL,
ENV_REGION,
+ ENV_DEFAULT,
ENV_END
};
@@ -116,6 +118,8 @@ public:
std::string mDayCycleName;
};
+ typedef std::pair<LLSettingsSky::ptr_t, LLSettingsWater::ptr_t> fixedEnvironment_t;
+
typedef std::map<std::string, LLSettingsBase::ptr_t> namedSettingMap_t;
typedef std::pair<std::string, LLUUID> name_id_t;
typedef std::vector<name_id_t> list_name_id_t;
@@ -130,56 +134,35 @@ public:
bool canEdit() const;
- LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentSky; }
- LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentWater; }
+ LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentEnvironment->getSky(); }
+ LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentEnvironment->getWater(); }
void update(const LLViewerCamera * cam);
void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting);
void updateShaderUniforms(LLGLSLShader *shader);
- void addSky(const LLSettingsSky::ptr_t &sky);
- void addWater(const LLSettingsWater::ptr_t &sky);
- void addDayCycle(const LLSettingsDay::ptr_t &day);
+ void setSelectedEnvironment(EnvSelection_t env, F64Seconds transition = TRANSITION_DEFAULT);
+ EnvSelection_t getSelectedEnvironment() const { return mSelectedEnvironment; }
- void selectSky(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT);
- void selectSky(const LLSettingsSky::ptr_t &sky, F32Seconds transition = TRANSITION_DEFAULT);
- void selectWater(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT);
- void selectWater(const LLSettingsWater::ptr_t &water, F32Seconds transition = TRANSITION_DEFAULT);
- void selectDayCycle(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT);
- void selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seconds transition = TRANSITION_DEFAULT);
+ bool hasEnvironment(EnvSelection_t env);
+ void setEnvironment(EnvSelection_t env, const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset);
+ void setEnvironment(EnvSelection_t env, fixedEnvironment_t fixed);
+ void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(fixed, LLSettingsWater::ptr_t())); }
+ void setEnvironment(EnvSelection_t env, const LLSettingsWater::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(LLSettingsSky::ptr_t(), fixed)); }
+ void clearEnvironment(EnvSelection_t env);
+ LLSettingsDay::ptr_t getEnvironmentDay(EnvSelection_t env);
+ S64Seconds getEnvironmentDayLength(EnvSelection_t env);
+ S64Seconds getEnvironmentDayOffset(EnvSelection_t env);
+ fixedEnvironment_t getEnvironmentFixed(EnvSelection_t env);
+ LLSettingsSky::ptr_t getEnvironmentFixedSky(EnvSelection_t env) { return getEnvironmentFixed(env).first; };
+ LLSettingsWater::ptr_t getEnvironmentFixedWater(EnvSelection_t env) { return getEnvironmentFixed(env).second; };
- void setUserSky(const LLSettingsSky::ptr_t &sky)
- {
- setSkyFor(ENV_LOCAL, sky);
- }
- void setUserWater(const LLSettingsWater::ptr_t &water)
- {
- setWaterFor(ENV_LOCAL, water);
- }
- void setUserDaycycle(const LLSettingsDay::ptr_t &day)
- {
- setDayFor(ENV_LOCAL, day);
- }
+ void updateEnvironment(F64Seconds transition = TRANSITION_DEFAULT);
- void setSelectedEnvironment(EnvSelection_t env);
- EnvSelection_t getSelectedEnvironment() const
- {
- return mSelectedEnvironment;
- }
- void applyChosenEnvironment();
- LLSettingsSky::ptr_t getChosenSky() const;
- LLSettingsWater::ptr_t getChosenWater() const;
- LLSettingsDay::ptr_t getChosenDay() const;
-
- void setSkyFor(EnvSelection_t env, const LLSettingsSky::ptr_t &sky);
- LLSettingsSky::ptr_t getSkyFor(EnvSelection_t env) const;
- void setWaterFor(EnvSelection_t env, const LLSettingsWater::ptr_t &water);
- LLSettingsWater::ptr_t getWaterFor(EnvSelection_t env) const;
- void setDayFor(EnvSelection_t env, const LLSettingsDay::ptr_t &day);
- LLSettingsDay::ptr_t getDayFor(EnvSelection_t env) const;
-
- void clearUserSettings();
+ void addSky(const LLSettingsSky::ptr_t &sky);
+ void addWater(const LLSettingsWater::ptr_t &sky);
+ void addDayCycle(const LLSettingsDay::ptr_t &day);
list_name_id_t getSkyList() const;
list_name_id_t getWaterList() const;
@@ -199,14 +182,10 @@ public:
inline F32 getSceneLightStrength() const { return mSceneLightStrength; }
inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; }
- inline LLVector4 getLightDirection() const { return LLVector4(mCurrentSky->getLightDirection(), 0.0f); }
- inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); }
+ inline LLVector4 getLightDirection() const { return ((mCurrentEnvironment->getSky()) ? LLVector4(mCurrentEnvironment->getSky()->getLightDirection(), 0.0f) : LLVector4()); }
+ inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentEnvironment->getSky()->getClampedLightDirection(), 0.0f); }
inline LLVector4 getRotatedLight() const { return mRotatedLight; }
- inline S64Seconds getDayLength() const { return mDayLength; }
- void setDayLength(S64Seconds seconds);
- inline S64Seconds getDayOffset() const { return mDayOffset; }
- void setDayOffset(S64Seconds seconds);
//-------------------------------------------
connection_t setSkyListChange(const change_signal_t::slot_type& cb);
connection_t setWaterListChange(const change_signal_t::slot_type& cb);
@@ -229,6 +208,62 @@ protected:
virtual void initSingleton();
private:
+ class DayInstance
+ {
+ public:
+ enum InstanceType_t
+ {
+ TYPE_INVALID,
+ TYPE_FIXED,
+ TYPE_CYCLED
+ };
+ typedef boost::shared_ptr<DayInstance> ptr_t;
+
+ DayInstance();
+
+ void update(F64Seconds);
+
+ void setDay(const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset);
+ void setSky(const LLSettingsSky::ptr_t &psky);
+ void setWater(const LLSettingsWater::ptr_t &pwater);
+
+ void initialize();
+ bool isInitialized();
+
+ void clear();
+
+ LLSettingsDay::ptr_t getDayCycle() const { return mDayCycle; }
+ LLSettingsSky::ptr_t getSky() const { return mSky; }
+ LLSettingsWater::ptr_t getWater() const { return mWater; }
+ S64Seconds getDayLength() const { return mDayLength; }
+ S64Seconds getDayOffset() const { return mDayOffset; }
+
+ void animate();
+
+ void setBlenders(const LLSettingsBlender::ptr_t &skyblend, const LLSettingsBlender::ptr_t &waterblend);
+
+ private:
+ LLSettingsDay::ptr_t mDayCycle;
+ LLSettingsSky::ptr_t mSky;
+ LLSettingsWater::ptr_t mWater;
+
+ InstanceType_t mType;
+ bool mInitialized;
+
+ S64Seconds mDayLength;
+ S64Seconds mDayOffset;
+
+ LLSettingsBlender::ptr_t mBlenderSky;
+ LLSettingsBlender::ptr_t mBlenderWater;
+
+
+ F64 secondsToKeyframe(S64Seconds seconds);
+
+ void onTrackTransitionDone(S32 trackno, const LLSettingsBlender::ptr_t &blender);
+ };
+ typedef std::array<DayInstance::ptr_t, ENV_END> InstanceArray_t;
+
+
static const F32 SUN_DELTA_YAW;
static const F32 NIGHTTIME_ELEVATION_COS;
@@ -236,6 +271,11 @@ private:
LLVector2 mCloudScrollDelta; // cumulative cloud delta
+ InstanceArray_t mEnvironments;
+
+ EnvSelection_t mSelectedEnvironment;
+ DayInstance::ptr_t mCurrentEnvironment;
+
LLSettingsSky::ptr_t mSelectedSky;
LLSettingsWater::ptr_t mSelectedWater;
LLSettingsDay::ptr_t mSelectedDay;
@@ -243,20 +283,12 @@ private:
LLSettingsBlender::ptr_t mBlenderSky;
LLSettingsBlender::ptr_t mBlenderWater;
- LLSettingsSky::ptr_t mCurrentSky;
- LLSettingsWater::ptr_t mCurrentWater;
LLSettingsDay::ptr_t mCurrentDay;
- EnvSelection_t mSelectedEnvironment;
-
typedef std::vector<LLSettingsSky::ptr_t> SkyList_t;
typedef std::vector<LLSettingsWater::ptr_t> WaterList_t;
typedef std::vector<LLSettingsDay::ptr_t> DayList_t;
- SkyList_t mSetSkys;
- WaterList_t mSetWater;
- DayList_t mSetDays;
-
namedSettingMap_t mSkysByName;
AssetSettingMap_t mSkysById;
@@ -275,11 +307,9 @@ private:
change_signal_t mWaterListChange;
change_signal_t mDayCycleListChange;
- S64Seconds mDayLength;
- S64Seconds mDayOffset;
+ DayInstance::ptr_t getEnvironmentInstance(EnvSelection_t env, bool create = false);
- void onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender);
- void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender);
+ DayInstance::ptr_t getSelectedEnvironmentInstance();
//void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky);
@@ -308,6 +338,7 @@ private:
void recordEnvironment(S32 parcel_id, EnvironmentInfo::ptr_t environment);
+ void onTransitionDone(const LLSettingsBlender::ptr_t &, bool isSky);
//=========================================================================
void legacyLoadAllPresets();
LLSD legacyLoadPreset(const std::string& path);
diff --git a/indra/newview/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp
index efeec72f6e..4ddedbf7df 100644
--- a/indra/newview/llfloatereditdaycycle.cpp
+++ b/indra/newview/llfloatereditdaycycle.cpp
@@ -114,7 +114,8 @@ void LLFloaterEditDayCycle::onClose(bool app_quitting)
{
if (!app_quitting) // there's no point to change environment if we're quitting
{
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
+ LLEnvironment::instance().updateEnvironment();
}
}
diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp
index 76c275e47c..0beb856456 100644
--- a/indra/newview/llfloatereditextdaycycle.cpp
+++ b/indra/newview/llfloatereditextdaycycle.cpp
@@ -98,7 +98,8 @@ void LLFloaterEditExtDayCycle::onClose(bool app_quitting)
if (!app_quitting) // there's no point to change environment if we're quitting
{
/* TODO: don't restore this environment. We may have gotten here from land or region. */
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
+ LLEnvironment::instance().updateEnvironment();
}
}
@@ -106,12 +107,13 @@ void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility)
{
if (new_visibility)
{
- LLEnvironment::instance().selectDayCycle(mEditDay, LLEnvironment::TRANSITION_FAST);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mEditDay, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT);
}
else
{
/* TODO: don't restore this environment. We may have gotten here from land or region. */
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
}
@@ -125,7 +127,7 @@ void LLFloaterEditExtDayCycle::onDayPresetChanged()
if (pday)
{
pday = pday->buildClone();
- LLEnvironment::instance().selectDayCycle(pday, LLEnvironment::TRANSITION_INSTANT);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, pday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET);
mEditDay = pday;
}
diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp
index ab9cb81db5..1574e73caa 100644
--- a/indra/newview/llfloatereditsky.cpp
+++ b/indra/newview/llfloatereditsky.cpp
@@ -125,7 +125,8 @@ void LLFloaterEditSky::onClose(bool app_quitting)
{
if (!app_quitting) // there's no point to change environment if we're quitting
{
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
}
@@ -644,7 +645,8 @@ void LLFloaterEditSky::onSkyPresetSelected()
}
psky = psky->buildClone();
- LLEnvironment::instance().selectSky(psky, LLEnvironment::TRANSITION_FAST);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, psky);
+ mEditSettings = psky;
syncControls();
enableEditing(true);
@@ -677,7 +679,7 @@ void LLFloaterEditSky::onSaveConfirmed()
if (mMakeDefaultCheckBox->getEnabled() && mMakeDefaultCheckBox->getValue())
{
LL_DEBUGS("Windlight") << name << " is now the new preferred sky preset" << LL_ENDL;
- LLEnvironment::instance().setUserSky(mEditSettings);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings);
}
closeFloater();
@@ -686,7 +688,7 @@ void LLFloaterEditSky::onSaveConfirmed()
void LLFloaterEditSky::onBtnSave()
{
LLEnvironment::instance().addSky(mEditSettings);
- LLEnvironment::instance().setUserSky(mEditSettings);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings);
closeFloater();
}
diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp
index 6b218d5008..4d8ffdef21 100644
--- a/indra/newview/llfloatereditwater.cpp
+++ b/indra/newview/llfloatereditwater.cpp
@@ -111,7 +111,8 @@ void LLFloaterEditWater::onClose(bool app_quitting)
{
if (!app_quitting) // there's no point to change environment if we're quitting
{
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
}
@@ -428,7 +429,8 @@ void LLFloaterEditWater::onWaterPresetSelected()
}
pwater = pwater->buildClone();
- LLEnvironment::instance().selectWater(pwater, LLEnvironment::TRANSITION_FAST);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, pwater);
+ mEditSettings = pwater;
syncControls();
enableEditing(true);
@@ -460,7 +462,7 @@ void LLFloaterEditWater::onSaveConfirmed()
if (mMakeDefaultCheckBox->getEnabled() && mMakeDefaultCheckBox->getValue())
{
LL_DEBUGS("Windlight") << name << " is now the new preferred water preset" << LL_ENDL;
- LLEnvironment::instance().setUserWater(mEditSettings);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings);
}
closeFloater();
@@ -469,7 +471,7 @@ void LLFloaterEditWater::onSaveConfirmed()
void LLFloaterEditWater::onBtnSave()
{
LLEnvironment::instance().addWater(mEditSettings);
- LLEnvironment::instance().setUserWater(mEditSettings);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings);
closeFloater();
}
diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp
index 9a41d434ee..b7bf6918fe 100644
--- a/indra/newview/llfloaterenvironmentsettings.cpp
+++ b/indra/newview/llfloaterenvironmentsettings.cpp
@@ -84,7 +84,7 @@ void LLFloaterEnvironmentSettings::onOpen(const LLSD& key)
void LLFloaterEnvironmentSettings::onClose(bool app_quitting)
{
if (!app_quitting)
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().updateEnvironment();
}
@@ -124,23 +124,24 @@ void LLFloaterEnvironmentSettings::onBtnOK()
{
bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0;
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
if (use_region_settings)
{
- LLEnvironment::instance().clearUserSettings();
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_PARCEL);
}
else
{
- LLEnvironment::instance().clearUserSettings();
-
bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0;
if (!use_fixed_sky)
{
+
std::string day_cycle = mDayCyclePresetCombo->getValue().asString();
LLSettingsDay::ptr_t day = LLEnvironment::instance().findDayCycleByName(day_cycle);
if (day)
{
- LLEnvironment::instance().setDayFor(LLEnvironment::ENV_LOCAL, day);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, day, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET);
}
}
else
@@ -151,9 +152,9 @@ void LLFloaterEnvironmentSettings::onBtnOK()
LLSettingsSky::ptr_t sky = LLEnvironment::instance().findSkyByName(sky_preset);
LLSettingsWater::ptr_t water = LLEnvironment::instance().findWaterByName(water_preset);
- LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, sky);
- LLEnvironment::instance().setWaterFor(LLEnvironment::ENV_LOCAL, water);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::fixedEnvironment_t(sky, water));
}
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
#if 0
@@ -183,11 +184,12 @@ void LLFloaterEnvironmentSettings::onBtnCancel()
void LLFloaterEnvironmentSettings::refresh()
{
- LLSettingsDay::ptr_t day = LLEnvironment::instance().getChosenDay();
- LLSettingsSky::ptr_t sky = LLEnvironment::instance().getChosenSky();
- LLSettingsWater::ptr_t water = LLEnvironment::instance().getChosenWater();
+ LLEnvironment::fixedEnvironment_t fixed = LLEnvironment::instance().getEnvironmentFixed(LLEnvironment::ENV_EDIT);
+
+ LLSettingsDay::ptr_t day = LLEnvironment::instance().getEnvironmentDay(LLEnvironment::ENV_EDIT);
+ LLSettingsSky::ptr_t sky = fixed.first;
+ LLSettingsWater::ptr_t water = fixed.second;
-
bool use_region_settings = true;
bool use_fixed_sky = !day;
@@ -239,18 +241,18 @@ void LLFloaterEnvironmentSettings::apply()
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(sky_preset);
if (psky)
- LLEnvironment::instance().selectSky(psky, LLEnvironment::TRANSITION_FAST);
- }
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
+ }
else
{
LLSettingsDay::ptr_t pday = LLEnvironment::instance().findDayCycleByName(day_cycle);
if (pday)
- LLEnvironment::instance().selectDayCycle(pday, LLEnvironment::TRANSITION_FAST);
- }
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, pday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET);
+ }
LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(water_preset);
if (pwater)
- LLEnvironment::instance().selectWater(pwater, LLEnvironment::TRANSITION_FAST);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, pwater);
}
}
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index 18bf4a47b3..39dada1984 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -3283,8 +3283,19 @@ void LLPanelLandEnvironment::refresh()
F64Hours daylength;
F64Hours dayoffset;
- daylength = parcel->getDayLength();
- dayoffset = parcel->getDayOffset();
+ LLEnvironment::EnvSelection_t env = LLEnvironment::ENV_PARCEL;
+
+ if (!LLEnvironment::instance().hasEnvironment(env))
+ env = LLEnvironment::ENV_REGION;
+
+ daylength = LLEnvironment::instance().getEnvironmentDayLength(env);
+ dayoffset = LLEnvironment::instance().getEnvironmentDayOffset(env);
+
+ LLSettingsDay::ptr_t pday = LLEnvironment::instance().getEnvironmentDay(env);
+
+ mEditingDayCycle = pday->buildClone();
+
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mEditingDayCycle, daylength, dayoffset);
if (dayoffset.value() > 12.0)
dayoffset = dayoffset - F32Hours(24.0f);
@@ -3292,19 +3303,11 @@ void LLPanelLandEnvironment::refresh()
mDayLengthSlider->setValue(daylength.value());
mDayOffsetSlider->setValue(dayoffset.value());
- mRegionSettingsRadioGroup->setSelectedIndex(parcel->getUsesDefaultDayCycle() ? 0 : 1);
+ //mRegionSettingsRadioGroup->setSelectedIndex(parcel->getUsesDefaultDayCycle() ? 0 : 1);
+ mRegionSettingsRadioGroup->setSelectedIndex(1);
setControlsEnabled(owner_or_god);
- if (!parcel->getUsesDefaultDayCycle())
- mEditingDayCycle = parcel->getParcelDayCycle()->buildClone();
- else
- {
- LLViewerRegion* regionp = LLViewerParcelMgr::getInstance()->getSelectionRegion();
- if (regionp)
- mEditingDayCycle = regionp->getRegionDayCycle()->buildClone();
- }
-
}
void LLPanelLandEnvironment::doApply()
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index bf965afbe1..272ac8a1bb 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -3395,22 +3395,25 @@ bool LLPanelRegionEnvironment::refreshFromRegion(LLViewerRegion* region)
F64Hours daylength;
F64Hours dayoffset;
- daylength = region->getDayLength();
- dayoffset = region->getDayOffset();
+ daylength = LLEnvironment::instance().getEnvironmentDayLength(LLEnvironment::ENV_REGION);
+ dayoffset = LLEnvironment::instance().getEnvironmentDayOffset(LLEnvironment::ENV_REGION);
if (dayoffset.value() > 12.0)
- dayoffset = dayoffset - F32Hours(24.0f);
+ dayoffset = dayoffset - F64Hours(24.0f);
mDayLengthSlider->setValue(daylength.value());
mDayOffsetSlider->setValue(dayoffset.value());
- mRegionSettingsRadioGroup->setSelectedIndex(region->getIsDefaultDayCycle() ? 0 : 1);
+ //mRegionSettingsRadioGroup->setSelectedIndex(region->getIsDefaultDayCycle() ? 0 : 1);
+ mRegionSettingsRadioGroup->setSelectedIndex(1);
setControlsEnabled(owner_or_god_or_manager);
mLastRegion = region;
- if (region->getRegionDayCycle())
- mEditingDayCycle = region->getRegionDayCycle()->buildClone();
+ LLSettingsDay::ptr_t pday = LLEnvironment::instance().getEnvironmentDay(LLEnvironment::ENV_REGION);
+
+ if (pday)
+ mEditingDayCycle = pday->buildClone();
return true;
}
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 647489666f..456c080f8a 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -8392,29 +8392,34 @@ class LLWorldEnvSettings : public view_listener_t
if (tod == "sunrise")
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Sunrise");
- LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else if (tod == "noon")
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Midday");
- LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else if (tod == "sunset")
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Sunset");
- LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else if (tod == "midnight")
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Midnight");
- LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else
{
- LLEnvironment::instance().clearUserSettings();
- }
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
+ }
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().updateEnvironment();
return true;
}
};
@@ -8426,7 +8431,7 @@ class LLWorldEnableEnvSettings : public view_listener_t
bool result = false;
std::string tod = userdata.asString();
- LLSettingsSky::ptr_t sky = LLEnvironment::instance().getSkyFor(LLEnvironment::ENV_LOCAL);
+ LLSettingsSky::ptr_t sky = LLEnvironment::instance().getEnvironmentFixedSky(LLEnvironment::ENV_LOCAL);
if (!sky)
{
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 1dda516ca4..b272595d79 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -535,9 +535,7 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
mInvisibilityCheckHistory(-1),
mPaused(FALSE),
mRegionCacheHitCount(0),
- mRegionCacheMissCount(0),
- mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH),
- mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET)
+ mRegionCacheMissCount(0)
{
mWidth = region_width_meters;
mImpl->mOriginGlobal = from_region_handle(handle);
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 71d4d85ade..1628c3620a 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -390,17 +390,6 @@ public:
static BOOL isNewObjectCreationThrottleDisabled() { return sNewObjectCreationThrottle < 0; }
- S64Seconds getDayLength() const { return mDayLength; }
- void setDayLength(S64SecondsImplicit seconds) { mDayLength = seconds; }
- S64Seconds getDayOffset() const { return mDayOffset; }
- void setDayOffset(S64SecondsImplicit seconds) { mDayOffset = seconds; }
- bool getIsDefaultDayCycle() const { return mIsDefaultDayCycle; }
- void setIsDefaultDayCycle(bool isdefault) { mIsDefaultDayCycle = isdefault; }
- LLSettingsDay::ptr_t getRegionDayCycle() const { return mDayCycle; }
- void setRegionDayCycle(const LLSettingsDay::ptr_t &pday) { mDayCycle = pday; }
- size_t getRegionDayCycleHash() const { return mDayCycleHash; }
- void setRegionDayCycleHash(size_t hash) { mDayCycleHash = hash; }
-
private:
void addToVOCacheTree(LLVOCacheEntry* entry);
LLViewerObject* addNewObject(LLVOCacheEntry* entry);
@@ -540,12 +529,6 @@ private:
typedef std::map<U32, std::vector<U32> > orphan_list_t;
orphan_list_t mOrphanMap;
- S64Seconds mDayLength;
- S64Seconds mDayOffset;
- bool mIsDefaultDayCycle;
- LLSettingsDay::ptr_t mDayCycle;
- size_t mDayCycleHash;
-
class CacheMissItem
{
public: