diff options
author | Rider Linden <rider@lindenlab.com> | 2017-11-08 16:02:20 -0800 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2017-11-08 16:02:20 -0800 |
commit | fe846ec9942af5ad2ab6a4aad9e8561ba9bc1fba (patch) | |
tree | a664e1205eef8fb255d0bdd46486b8586e7e30b9 /indra | |
parent | 36c2992b01631150f7259c98df1cb46020757066 (diff) |
Day cycles and animated sky/water blending.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llenvironment.cpp | 214 | ||||
-rw-r--r-- | indra/newview/llenvironment.h | 58 | ||||
-rw-r--r-- | indra/newview/llenvmanager.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llfloatereditsky.cpp | 11 | ||||
-rw-r--r-- | indra/newview/llfloatereditwater.cpp | 7 | ||||
-rw-r--r-- | indra/newview/llfloaterenvironmentsettings.cpp | 17 | ||||
-rw-r--r-- | indra/newview/llsettingsbase.cpp | 25 | ||||
-rw-r--r-- | indra/newview/llsettingsbase.h | 71 | ||||
-rw-r--r-- | indra/newview/llsettingsdaycycle.cpp | 205 | ||||
-rw-r--r-- | indra/newview/llsettingsdaycycle.h | 69 | ||||
-rw-r--r-- | indra/newview/llsettingssky.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llsettingswater.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 18 | ||||
-rw-r--r-- | indra/newview/llwlhandlers.cpp | 7 |
14 files changed, 526 insertions, 182 deletions
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 <boost/make_shared.hpp> //========================================================================= 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<F32>(delta_t)* (mSelectedSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; + LLVector2 cloud_delta = static_cast<F32>(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<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::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<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::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<name_id_t>::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<name_id_t>::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<name_id_t>::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<NamedSettingMap_t::iterator, bool> result; - result = mSkysByName.insert(NamedSettingMap_t::value_type(name, sky)); + std::pair<namedSettingMap_t::iterator, bool> result; + result = mSkysByName.insert(namedSettingMap_t::value_type(name, sky)); if (!result.second) (*(result.first)).second = sky; @@ -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<NamedSettingMap_t::iterator, bool> result; - result = mWaterByName.insert(NamedSettingMap_t::value_type(name, water)); + std::pair<namedSettingMap_t::iterator, bool> 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<NamedSettingMap_t::iterator, bool> result; - result = mDayCycleByName.insert(NamedSettingMap_t::value_type(name, daycycle)); + std::pair<namedSettingMap_t::iterator, bool> 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) { diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index a3fc9eef66..7894d2ff6e 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -30,23 +30,29 @@ #include "llmemory.h" #include "llsd.h" +#include "llsettingsbase.h" #include "llsettingssky.h" #include "llsettingswater.h" #include "llsettingsdaycycle.h" +//------------------------------------------------------------------------- class LLViewerCamera; class LLGLSLShader; //------------------------------------------------------------------------- - - -//------------------------------------------------------------------------- class LLEnvironment : public LLSingleton<LLEnvironment> { LLSINGLETON(LLEnvironment); LOG_CLASS(LLEnvironment); public: + static const F32Seconds LLEnvironment::TRANSITION_INSTANT; + static const F32Seconds LLEnvironment::TRANSITION_FAST; + static const F32Seconds LLEnvironment::TRANSITION_DEFAULT; + static const F32Seconds LLEnvironment::TRANSITION_SLOW; + + typedef boost::signals2::connection connection_t; + class UserPrefs { friend class LLEnvironment; @@ -78,18 +84,18 @@ public: std::string mDayCycleName; }; - typedef std::pair<std::string, LLUUID> name_id_t; - typedef std::vector<name_id_t> list_name_id_t; - typedef boost::signals2::signal<void()> change_signal_t; - typedef boost::signals2::connection connection_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; + typedef boost::signals2::signal<void()> change_signal_t; virtual ~LLEnvironment(); void loadPreferences(); const UserPrefs & getPreferences() const { return mUserPrefs; } - LLSettingsSky::ptr_t getCurrentSky() const { return mSelectedSky; } - LLSettingsWater::ptr_t getCurrentWater() const { return mSelectedWater; } + LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentSky; } + LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentWater; } void update(const LLViewerCamera * cam); @@ -100,14 +106,14 @@ public: void addWater(const LLSettingsWater::ptr_t &sky); void addDayCycle(const LLSettingsDayCycle::ptr_t &day); - void selectSky(const std::string &name); - void selectSky(const LLSettingsSky::ptr_t &sky = LLSettingsSky::ptr_t()); + void selectSky(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT); + void selectSky(const LLSettingsSky::ptr_t &sky, F32Seconds transition = TRANSITION_DEFAULT); void applySky(const LLSettingsSky::ptr_t &sky = LLSettingsSky::ptr_t()); - void selectWater(const std::string &name); - void selectWater(const LLSettingsWater::ptr_t &water = LLSettingsWater::ptr_t()); + void selectWater(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT); + void selectWater(const LLSettingsWater::ptr_t &water, F32Seconds transition = TRANSITION_DEFAULT); void applyWater(const LLSettingsWater::ptr_t water = LLSettingsWater::ptr_t()); - void selectDayCycle(const std::string &name); - void selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle = LLSettingsDayCycle::ptr_t()); + void selectDayCycle(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT); + void selectDayCycle(const LLSettingsDayCycle::ptr_t &daycycle, F32Seconds transition = TRANSITION_DEFAULT); void applyDayCycle(const LLSettingsDayCycle::ptr_t &daycycle = LLSettingsDayCycle::ptr_t()); void clearAllSelected(); void applyAllSelected(); @@ -130,8 +136,8 @@ public: inline F32 getSceneLightStrength() const { return mSceneLightStrength; } inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; } - inline LLVector4 getLightDirection() const { return LLVector4(mSelectedSky->getLightDirection(), 0.0f); } - inline LLVector4 getClampedLightDirection() const { return LLVector4(mSelectedSky->getClampedLightDirection(), 0.0f); } + inline LLVector4 getLightDirection() const { return LLVector4(mCurrentSky->getLightDirection(), 0.0f); } + inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); } inline LLVector4 getRotatedLight() const { return mRotatedLight; } //------------------------------------------- @@ -139,6 +145,8 @@ public: connection_t setWaterListChange(const change_signal_t::slot_type& cb); connection_t setDayCycleListChange(const change_signal_t::slot_type& cb); + void onLegacyRegionSettings(LLSD data); + protected: virtual void initSingleton(); @@ -146,7 +154,6 @@ private: static const F32 SUN_DELTA_YAW; static const F32 NIGHTTIME_ELEVATION_COS; - typedef std::map<std::string, LLSettingsBase::ptr_t> NamedSettingMap_t; typedef std::map<LLUUID, LLSettingsBase::ptr_t> AssetSettingMap_t; LLVector2 mCloudScrollDelta; // cumulative cloud delta @@ -155,17 +162,20 @@ private: LLSettingsWater::ptr_t mSelectedWater; LLSettingsDayCycle::ptr_t mSelectedDayCycle; + LLSettingsBlender::ptr_t mBlenderSky; + LLSettingsBlender::ptr_t mBlenderWater; + LLSettingsSky::ptr_t mCurrentSky; LLSettingsWater::ptr_t mCurrentWater; LLSettingsDayCycle::ptr_t mCurrentDayCycle; - NamedSettingMap_t mSkysByName; + namedSettingMap_t mSkysByName; AssetSettingMap_t mSkysById; - NamedSettingMap_t mWaterByName; + namedSettingMap_t mWaterByName; AssetSettingMap_t mWaterById; - NamedSettingMap_t mDayCycleByName; + namedSettingMap_t mDayCycleByName; AssetSettingMap_t mDayCycleById; F32 mSceneLightStrength; @@ -177,6 +187,10 @@ private: change_signal_t mWaterListChange; change_signal_t mDayCycleListChange; + void onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender); + void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender); + + //void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky); void removeSky(const std::string &name); //void removeSky(const LLUUID &id); @@ -195,6 +209,8 @@ private: void updateCloudScroll(); + void onRegionChange(); + //========================================================================= void legacyLoadAllPresets(); LLSD legacyLoadPreset(const std::string& path); diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index fa1c3b983e..82f4cb8ed9 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -486,7 +486,7 @@ void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) mLastReceivedID = content[0]["messageID"].asUUID(); // Refresh cached region settings. - LL_DEBUGS("Windlight") << "Received region environment settings: " << content << LL_ENDL; + LL_WARNS("Windlight") << "Received region environment settings: " << content << LL_ENDL; F32 sun_hour = 0; // *TODO LLEnvironmentSettings new_settings(content[1], content[2], content[3], sun_hour); mCachedRegionPrefs = new_settings; diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 23744e5b07..715376cfa3 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -52,9 +52,12 @@ #include "llenvironment.h" #include "llenvadapters.h" -static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f; -static const F32 WL_BLUE_HORIZON_DENSITY_SCALE = 2.0f; -static const F32 WL_CLOUD_SLIDER_SCALE = 1.0f; +namespace +{ + const F32 WL_SUN_AMBIENT_SLIDER_SCALE(3.0f); + const F32 WL_BLUE_HORIZON_DENSITY_SCALE(2.0f); + const F32 WL_CLOUD_SLIDER_SCALE(1.0f); +} // static F32 sun_pos_to_time24(F32 sun_pos) // { @@ -647,7 +650,7 @@ void LLFloaterEditSky::onSkyPresetSelected() } psky = psky->buildClone(); - LLEnvironment::instance().selectSky(psky); + LLEnvironment::instance().selectSky(psky, LLEnvironment::TRANSITION_FAST); syncControls(); enableEditing(true); diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp index 2868a0609a..447ec56ce1 100644 --- a/indra/newview/llfloatereditwater.cpp +++ b/indra/newview/llfloatereditwater.cpp @@ -52,6 +52,11 @@ #include "v3colorutil.h" #undef max // Fixes a Windows compiler error +namespace +{ + const F32 SWITCH_TRANSITION(1.0); +} + LLFloaterEditWater::LLFloaterEditWater(const LLSD &key): LLFloater(key), @@ -428,7 +433,7 @@ void LLFloaterEditWater::onWaterPresetSelected() } pwater = pwater->buildClone(); - LLEnvironment::instance().selectWater(pwater); + LLEnvironment::instance().selectWater(pwater, LLEnvironment::TRANSITION_FAST); syncControls(); enableEditing(true); diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index e25c5cedbf..eaef017f08 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -1,25 +1,25 @@ -/** +/** * @file llfloaterenvironmentsettings.cpp * @brief LLFloaterEnvironmentSettings class definition * * $LicenseInfo:firstyear=2011&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$ */ @@ -35,6 +35,7 @@ #include "llenvironment.h" + LLFloaterEnvironmentSettings::LLFloaterEnvironmentSettings(const LLSD &key) : LLFloater(key) ,mRegionSettingsRadioGroup(NULL) @@ -197,13 +198,13 @@ void LLFloaterEnvironmentSettings::apply() { LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(sky_preset); if (psky) - LLEnvironment::instance().selectSky(psky); + LLEnvironment::instance().selectSky(psky, LLEnvironment::TRANSITION_FAST); } else { LLSettingsDayCycle::ptr_t pday = LLEnvironment::instance().findDayCycleByName(day_cycle); if (pday) - LLEnvironment::instance().selectDayCycle(pday); + LLEnvironment::instance().selectDayCycle(pday, LLEnvironment::TRANSITION_FAST); // LLEnvironment::instance().selectDayCycle(day_cycle); // env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL); @@ -211,7 +212,7 @@ void LLFloaterEnvironmentSettings::apply() LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(water_preset); if (pwater) - LLEnvironment::instance().selectWater(pwater); + LLEnvironment::instance().selectWater(pwater, LLEnvironment::TRANSITION_FAST); } } diff --git a/indra/newview/llsettingsbase.cpp b/indra/newview/llsettingsbase.cpp index a2e705d1fa..c538cbe320 100644 --- a/indra/newview/llsettingsbase.cpp +++ b/indra/newview/llsettingsbase.cpp @@ -43,6 +43,8 @@ namespace const std::string LLSettingsBase::SETTING_ID("id"); const std::string LLSettingsBase::SETTING_NAME("name"); +const F32Seconds LLSettingsBlender::DEFAULT_THRESHOLD(0.01); + //========================================================================= LLSettingsBase::LLSettingsBase(): mSettings(LLSD::emptyMap()), @@ -218,6 +220,7 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F // case LLSD::TypeBinary: // case LLSD::TypeDate: default: + /* TODO: If the UUID points to an image ID, blend the images. */ // atomic or unknown data types. Lerping between them does not make sense so switch at the break. newSettings[key_name] = (mix > BREAK_POINT) ? other_value : value; break; @@ -283,3 +286,25 @@ void LLSettingsBase::exportSettings(std::string name) const LL_WARNS("Presets") << "Cannot open for output preset file " << path_name << LL_ENDL; } } + + +//========================================================================= + +void LLSettingsBlender::update(F32Seconds timedelta) +{ + mTimeSpent += timedelta; + + if (mTimeSpent >= mSeconds) + { + LLSettingsBlender::ptr_t hold = shared_from_this(); // prevents this from deleting too soon + mOnFinished(shared_from_this()); + mOnFinished.disconnect_all_slots(); // prevent from firing more than once. + return; + } + + F32 blendf = fmod(mTimeSpent.value(), mSeconds.value()) / mSeconds.value(); + + mTarget->replaceSettings(mInitial->getSettings()); + mTarget->blend(mFinal, blendf); +} + diff --git a/indra/newview/llsettingsbase.h b/indra/newview/llsettingsbase.h index 205351c401..533c9288fe 100644 --- a/indra/newview/llsettingsbase.h +++ b/indra/newview/llsettingsbase.h @@ -31,6 +31,7 @@ #include <string> #include <map> #include <vector> +#include <boost/enable_shared_from_this.hpp> #include "llsd.h" #include "llsdutil.h" @@ -192,4 +193,74 @@ private: }; +class LLSettingsBlender : public boost::enable_shared_from_this<LLSettingsBlender> +{ +public: + typedef boost::shared_ptr<LLSettingsBlender> ptr_t; + typedef boost::signals2::signal<void(const ptr_t &)> finish_signal_t; + typedef boost::signals2::connection connection_t; + + static const F32Seconds DEFAULT_THRESHOLD; + + LLSettingsBlender(const LLSettingsBase::ptr_t &target, + const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F32Seconds seconds) : + mTarget(target), + mInitial(initsetting), + mFinal(endsetting), + mSeconds(seconds), + mOnFinished(), + mBlendThreshold(DEFAULT_THRESHOLD), + mLastUpdate(0.0f), + mTimeSpent(0.0f) + { + mTarget->replaceSettings(mInitial->getSettings()); + mTimeStart = F32Seconds(LLDate::now().secondsSinceEpoch()); + mLastUpdate = mTimeStart; + } + + ~LLSettingsBlender() {} + + connection_t setOnFinished(const finish_signal_t::slot_type &onfinished) + { + return mOnFinished.connect(onfinished); + } + + void setUpdateThreshold(F32Seconds threshold) + { + mBlendThreshold = threshold; + } + + F32Seconds getUpdateThreshold() const + { + return mBlendThreshold; + } + + LLSettingsBase::ptr_t getTarget() const + { + return mTarget; + } + + LLSettingsBase::ptr_t getInitial() const + { + return mInitial; + } + + LLSettingsBase::ptr_t getFinal() const + { + return mFinal; + } + + void update(F32Seconds time); +private: + LLSettingsBase::ptr_t mTarget; + LLSettingsBase::ptr_t mInitial; + LLSettingsBase::ptr_t mFinal; + F32Seconds mSeconds; + finish_signal_t mOnFinished; + F32Seconds mBlendThreshold; + F32Seconds mLastUpdate; + F32Seconds mTimeSpent; + F32Seconds mTimeStart; +}; + #endif diff --git a/indra/newview/llsettingsdaycycle.cpp b/indra/newview/llsettingsdaycycle.cpp index 2d97ea865f..f098acde02 100644 --- a/indra/newview/llsettingsdaycycle.cpp +++ b/indra/newview/llsettingsdaycycle.cpp @@ -116,10 +116,10 @@ const std::string LLSettingsDayCycle::SETTING_KEYKFRAME("key_keyframe"); const std::string LLSettingsDayCycle::SETTING_NAME("name"); const std::string LLSettingsDayCycle::SETTING_TRACKS("tracks"); -const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 300); // 5 mins +//const S64 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 300); // 5 mins -//const S32 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours -const S32 LLSettingsDayCycle::MAXIMUM_DAYLENGTH(604800); // 7 days +const S64 LLSettingsDayCycle::MINIMUM_DAYLENGTH( 14400); // 4 hours +const S64 LLSettingsDayCycle::MAXIMUM_DAYLENGTH(604800); // 7 days const S32 LLSettingsDayCycle::TRACK_WATER(0); // water track is 0 const S32 LLSettingsDayCycle::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water @@ -145,11 +145,11 @@ LLSD LLSettingsDayCycle::defaults() LLSD dfltsetting; dfltsetting[SETTING_NAME] = "_default_"; - dfltsetting[SETTING_DAYLENGTH] = MINIMUM_DAYLENGTH; + dfltsetting[SETTING_DAYLENGTH] = static_cast<S32>(MINIMUM_DAYLENGTH); dfltsetting[SETTING_TRACKS] = LLSDArray( LLSDArray(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_")) (LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_"))); - + return dfltsetting; } @@ -158,7 +158,7 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyPreset(const std::s LLSD newsettings(defaults()); newsettings[SETTING_NAME] = name; - newsettings[SETTING_DAYLENGTH] = MINIMUM_DAYLENGTH; + newsettings[SETTING_DAYLENGTH] = static_cast<S32>(MINIMUM_DAYLENGTH); LLSD watertrack = LLSDArray( LLSDMap ( SETTING_KEYKFRAME, LLSD::Real(0.0f) ) @@ -176,15 +176,54 @@ LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyPreset(const std::s newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack); LLSettingsDayCycle::ptr_t dayp = boost::make_shared<LLSettingsDayCycle>(newsettings); + dayp->parseFromLLSD(dayp->mSettings); return dayp; } +LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skydefs, LLSD waterdef) +{ + LLSettingsWater::ptr_t water = LLSettingsWater::buildFromLegacyPreset("Region", waterdef); + LLEnvironment::namedSettingMap_t skys; + + for (LLSD::map_iterator itm = skydefs.beginMap(); itm != skydefs.endMap(); ++itm) + { + std::string name = (*itm).first; + LLSettingsSky::ptr_t sky = LLSettingsSky::buildFromLegacyPreset(name, (*itm).second); + + skys[name] = sky; + LL_WARNS("WindlightCaps") << "created region sky '" << name << "'" << LL_ENDL; + } + + LLSettingsDayCycle::ptr_t day = buildFromLegacyPreset("Region (legacy)", daycycle); + + day->setWaterAtKeyframe(water, 0.0f); + + for (LLSD::array_iterator ita = daycycle.beginArray(); ita != daycycle.endArray(); ++ita) + { + F32 frame = (*ita)[0].asReal(); + std::string name = (*ita)[1].asString(); + + LLEnvironment::namedSettingMap_t::iterator it = skys.find(name); + + if (it == skys.end()) + continue; + day->setSkyAtKeyframe(boost::static_pointer_cast<LLSettingsSky>((*it).second), frame, 1); + + LL_WARNS("WindlightCaps") << "Added '" << name << "' to region day cycle at " << frame << LL_ENDL; + } + + day->mHasParsed = true; + + return day; +} + LLSettingsDayCycle::ptr_t LLSettingsDayCycle::buildDefaultDayCycle() { LLSD settings = LLSettingsDayCycle::defaults(); LLSettingsDayCycle::ptr_t dayp = boost::make_shared<LLSettingsDayCycle>(settings); + dayp->parseFromLLSD(dayp->mSettings); return dayp; } @@ -201,6 +240,7 @@ void LLSettingsDayCycle::parseFromLLSD(LLSD &data) for (LLSD::array_const_iterator it = curtrack.beginArray(); it != curtrack.endArray(); ++it) { F32 keyframe = (*it)[SETTING_KEYKFRAME].asReal(); + keyframe = llclamp(keyframe, 0.0f, 1.0f); LLSettingsBase::ptr_t setting; if ((*it).has(SETTING_KEYNAME)) @@ -238,25 +278,88 @@ void LLSettingsDayCycle::blend(const LLSettingsBase::ptr_t &other, F32 mix) } //========================================================================= -F32 LLSettingsDayCycle::secondsToKeyframe(S32 seconds) +F32 LLSettingsDayCycle::secondsToKeyframe(S64Seconds seconds) { - S32 daylength = getDayLength(); + S64Seconds daylength = getDayLength(); - return static_cast<F32>(seconds % daylength) / static_cast<F32>(daylength); + return llclamp(static_cast<F32>(seconds.value() % daylength.value()) / static_cast<F32>(daylength.value()), 0.0f, 1.0f); } -S32 LLSettingsDayCycle::keyframeToSeconds(F32 keyframe) +F64Seconds LLSettingsDayCycle::keyframeToSeconds(F32 keyframe) { - S32 daylength = getDayLength(); + S64Seconds daylength = getDayLength(); - return static_cast<S32>(keyframe * static_cast<F32>(daylength)); + return F64Seconds(static_cast<S32>(keyframe * static_cast<F32>(daylength.value()))); } //========================================================================= -void LLSettingsDayCycle::updateSettings() +void LLSettingsDayCycle::startDayCycle() { + F64Seconds now(LLDate::now().secondsSinceEpoch()); + if (!mHasParsed) parseFromLLSD(mSettings); + + // water + if (mDayTracks[0].empty()) + { + mBlendedWater.reset(); + mWaterBlender.reset(); + } + else if (mDayTracks[0].size() == 1) + { + mBlendedWater = boost::static_pointer_cast<LLSettingsWater>((*(mDayTracks[0].begin())).second); + mWaterBlender.reset(); + } + else + { + TrackBound_t bounds = getBoundingEntries(mDayTracks[0], now); + + F64Seconds timespan = F64Seconds( getDayLength() * get_wrapping_distance((*bounds.first).first, (*bounds.second).first)); + + mBlendedWater = LLSettingsWater::buildDefaultWater(); + mWaterBlender = boost::make_shared<LLSettingsBlender>(mBlendedWater, + (*bounds.first).second, (*bounds.second).second, timespan); + mWaterBlender->setOnFinished(boost::bind(&LLSettingsDayCycle::onWaterTransitionDone, this, _1)); + } + + // sky + if (mDayTracks[1].empty()) + { + mBlendedSky.reset(); + mSkyBlender.reset(); + } + else if (mDayTracks[1].size() == 1) + { + mBlendedSky = boost::static_pointer_cast<LLSettingsSky>( (*(mDayTracks[1].begin())).second); + mSkyBlender.reset(); + } + else + { + TrackBound_t bounds = getBoundingEntries(mDayTracks[1], now); + F64Seconds timespan = F64Seconds(getDayLength() * get_wrapping_distance((*bounds.first).first, (*bounds.second).first)); + + mBlendedSky = LLSettingsSky::buildDefaultSky(); + mSkyBlender = boost::make_shared<LLSettingsBlender>(mBlendedSky, + (*bounds.first).second, (*bounds.second).second, timespan); + mSkyBlender->setOnFinished(boost::bind(&LLSettingsDayCycle::onSkyTransitionDone, this, 1, _1)); + } +} + + +void LLSettingsDayCycle::updateSettings() +{ + static LLFrameTimer timer; + + + F64Seconds delta(timer.getElapsedTimeAndResetF32()); + + if (mSkyBlender) + mSkyBlender->update(delta); + if (mWaterBlender) + mWaterBlender->update(delta); + +#if 0 //F64Seconds time_now(LLWorld::instance().getSpaceTimeUSec()); F64Seconds time_now(LLDate::now().secondsSinceEpoch()); @@ -311,14 +414,15 @@ void LLSettingsDayCycle::updateSettings() // Always mark the day cycle as dirty.So that the blend check can be handled. setDirtyFlag(true); +#endif } //========================================================================= -void LLSettingsDayCycle::setDayLength(S32 seconds) +void LLSettingsDayCycle::setDayLength(S64Seconds seconds) { - seconds = llclamp(seconds, MINIMUM_DAYLENGTH, MAXIMUM_DAYLENGTH); + S32 val = llclamp(seconds.value(), MINIMUM_DAYLENGTH, MAXIMUM_DAYLENGTH); - setValue(SETTING_DAYLENGTH, seconds); + setValue(SETTING_DAYLENGTH, val); } LLSettingsDayCycle::KeyframeList_t LLSettingsDayCycle::getTrackKeyframes(S32 trackno) @@ -360,7 +464,7 @@ LLSettingsDayCycle::TimeList_t LLSettingsDayCycle::getTrackTimes(S32 trackno) return times; } -void LLSettingsDayCycle::setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 seconds) +void LLSettingsDayCycle::setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds) { F32 keyframe = secondsToKeyframe(seconds); setWaterAtKeyframe(water, keyframe); @@ -368,45 +472,68 @@ void LLSettingsDayCycle::setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 s void LLSettingsDayCycle::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe) { - mDayTracks[TRACK_WATER][keyframe] = water; + mDayTracks[TRACK_WATER][llclamp(keyframe, 0.0f, 1.0f)] = water; setDirtyFlag(true); } -void LLSettingsDayCycle::setSkyAtOnTrack(const LLSettingsSkyPtr_t &sky, S32 seconds, S32 track) +void LLSettingsDayCycle::setSkyAtTime(const LLSettingsSkyPtr_t &sky, S64Seconds seconds, S32 track) +{ + F32 keyframe = secondsToKeyframe(seconds); + setSkyAtKeyframe(sky, keyframe, track); +} + +void LLSettingsDayCycle::setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track) { if ((track < 1) || (track >= TRACK_MAX)) { LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL; return; } - F32 keyframe = secondsToKeyframe(seconds); - mDayTracks[track][keyframe] = sky; + mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = sky; setDirtyFlag(true); } -LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(CycleTrack_t &track, F32 keyframe) +LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(LLSettingsDayCycle::CycleTrack_t &track, F32 keyframe) { return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); } -// LLSettingsBase::ptr_t LLSettingsDayCycle::getBlendedEntry(CycleTrack_t &track, F32 keyframe) -// { -// TrackBound_t bounds = getBoundingEntries(track, keyframe); -// -// if (bounds.first == track.end()) -// return LLSettingsBase::ptr_t(); // Track is empty nothing to blend. -// -// if (bounds.first == bounds.second) -// { // Single entry. Nothing to blend -// return (*bounds.first).second; -// } -// -// F32 blendf = get_wrapping_distance((*bounds.first).first, keyframe) / get_wrapping_distance((*bounds.first).first, (*bounds.second).first); -// -// LLSettingsBase::ptr_t base = (*bounds.first).second; -// return base->blend((*bounds.second).second, blendf); -// } +LLSettingsDayCycle::TrackBound_t LLSettingsDayCycle::getBoundingEntries(LLSettingsDayCycle::CycleTrack_t &track, F64Seconds time) +{ + F32 frame = secondsToKeyframe(time); + + return getBoundingEntries(track, frame); +} //========================================================================= +void LLSettingsDayCycle::onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender) +{ + F64Seconds now(LLDate::now().secondsSinceEpoch()); + TrackBound_t bounds = getBoundingEntries(mDayTracks[track], now); + + F32 distance = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + F64Seconds timespan = F64Seconds(distance * getDayLength()); + + LL_WARNS("RIDER") << "New sky blender. now=" << now << + " start=" << (*bounds.first).first << " end=" << (*bounds.second).first << + " span=" << timespan << LL_ENDL; + + mSkyBlender = boost::make_shared<LLSettingsBlender>(mBlendedSky, + (*bounds.first).second, (*bounds.second).second, timespan); + mSkyBlender->setOnFinished(boost::bind(&LLSettingsDayCycle::onSkyTransitionDone, this, track, _1)); +} + +void LLSettingsDayCycle::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender) +{ + F64Seconds now(LLDate::now().secondsSinceEpoch()); + TrackBound_t bounds = getBoundingEntries(mDayTracks[0], now); + + F32 distance = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + F64Seconds timespan = F64Seconds(distance * getDayLength()); + + mWaterBlender = boost::make_shared<LLSettingsBlender>(mBlendedWater, + (*bounds.first).second, (*bounds.second).second, timespan); + mWaterBlender->setOnFinished(boost::bind(&LLSettingsDayCycle::onWaterTransitionDone, this, _1)); +} diff --git a/indra/newview/llsettingsdaycycle.h b/indra/newview/llsettingsdaycycle.h index f332b85dee..5132ebeea5 100644 --- a/indra/newview/llsettingsdaycycle.h +++ b/indra/newview/llsettingsdaycycle.h @@ -46,8 +46,8 @@ public: static const std::string SETTING_NAME; static const std::string SETTING_TRACKS; - static const S32 MINIMUM_DAYLENGTH; - static const S32 MAXIMUM_DAYLENGTH; + static const S64 MINIMUM_DAYLENGTH; + static const S64 MAXIMUM_DAYLENGTH; static const S32 TRACK_WATER; static const S32 TRACK_MAX; @@ -55,7 +55,7 @@ public: typedef std::map<F32, LLSettingsBase::ptr_t> CycleTrack_t; typedef std::vector<CycleTrack_t> CycleList_t; typedef boost::shared_ptr<LLSettingsDayCycle> ptr_t; - typedef std::vector<S32> TimeList_t; + typedef std::vector<S64Seconds> TimeList_t; typedef std::vector<F32> KeyframeList_t; typedef std::pair<CycleTrack_t::iterator, CycleTrack_t::iterator> TrackBound_t; @@ -64,6 +64,7 @@ public: virtual ~LLSettingsDayCycle() { }; static ptr_t buildFromLegacyPreset(const std::string &name, const LLSD &oldsettings); + static ptr_t buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skys, LLSD water); static ptr_t buildDefaultDayCycle(); ptr_t buildClone(); @@ -76,51 +77,65 @@ public: static LLSD defaults(); //--------------------------------------------------------------------- - S32 getDayLength() const + S64Seconds getDayLength() const { - return mSettings[SETTING_DAYLENGTH].asInteger(); + return S64Seconds(mSettings[SETTING_DAYLENGTH].asInteger()); } - void setDayLength(S32 seconds); + void setDayLength(S64Seconds seconds); - KeyframeList_t getTrackKeyframes(S32 track); - TimeList_t getTrackTimes(S32 track); + KeyframeList_t getTrackKeyframes(S32 track); + TimeList_t getTrackTimes(S32 track); - void setWaterAtTime(const LLSettingsWaterPtr_t &water, S32 seconds); - void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe); - LLSettingsSkyPtr_t getBlendedWaterAt(S32 seconds); + void setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds); + void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe); - void setSkyAtOnTrack(const LLSettingsSkyPtr_t &sky, S32 seconds, S32 track); - //--------------------------------------------------------------------- + void setSkyAtTime(const LLSettingsSkyPtr_t &sky, S64Seconds seconds, S32 track); + void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track); + //--------------------------------------------------------------------- + void startDayCycle(); + + LLSettingsSkyPtr_t getCurrentSky() const + { + return mBlendedSky; + } + + LLSettingsWaterPtr_t getCurrentWater() const + { + return mBlendedWater; + } protected: LLSettingsDayCycle(); - virtual void updateSettings(); + virtual void updateSettings(); - LLSettingsSkyPtr_t mBlendedSky; - LLSettingsWaterPtr_t mBlendedWater; +private: + LLSettingsBlender::ptr_t mSkyBlender; // convert to [] for altitudes + LLSettingsBlender::ptr_t mWaterBlender; - CycleList_t mDayTracks; + LLSettingsSkyPtr_t mBlendedSky; + LLSettingsWaterPtr_t mBlendedWater; - bool mHasParsed; + CycleList_t mDayTracks; - F32 secondsToKeyframe(S32 seconds); - S32 keyframeToSeconds(F32 keyframe); + bool mHasParsed; + F64Seconds mLastUpdateTime; - //LLSettingsBase::ptr_t getBlendedEntry(const CycleTrack_t &track, F32 keyframe); + F32 secondsToKeyframe(S64Seconds seconds); + F64Seconds keyframeToSeconds(F32 keyframe); - void parseFromLLSD(LLSD &data); -// CycleList_t & getTrackRef(S32 trackno); + void parseFromLLSD(LLSD &data); static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 keyframe); static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 keyframe); - static TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 keyframe); + TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 keyframe); + TrackBound_t getBoundingEntries(CycleTrack_t &track, F64Seconds time); + + void onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender); + void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender); - F32Seconds mLastUpdateTime; -private: - }; #endif diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index c420ebca1e..024277a228 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -358,7 +358,7 @@ LLSD LLSettingsSky::defaults() void LLSettingsSky::updateSettings() { LL_RECORD_BLOCK_TIME(FTM_UPDATE_SKYVALUES); - LL_INFOS("WINDLIGHT", "SKY", "EEP") << "WL Parameters are dirty. Reticulating Splines..." << LL_ENDL; + //LL_INFOS("WINDLIGHT", "SKY", "EEP") << "WL Parameters are dirty. Reticulating Splines..." << LL_ENDL; // base class clears dirty flag so as to not trigger recursive update LLSettingsBase::updateSettings(); diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp index 9a6dfc15fd..70688ee1ef 100644 --- a/indra/newview/llsettingswater.cpp +++ b/indra/newview/llsettingswater.cpp @@ -237,7 +237,7 @@ void LLSettingsWater::applySpecial(void *ptarget) void LLSettingsWater::updateSettings() { // LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERVALUES); - LL_INFOS("WINDLIGHT", "WATER", "EEP") << "Water Parameters are dirty. Reticulating Splines..." << LL_ENDL; +// LL_INFOS("WINDLIGHT", "WATER", "EEP") << "Water Parameters are dirty. Reticulating Splines..." << LL_ENDL; // base class clears dirty flag so as to not trigger recursive update LLSettingsBase::updateSettings(); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 5bbf5650ad..8ce0eaf7dd 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -53,7 +53,7 @@ #include "llconsole.h" #include "lldaycyclemanager.h" #include "lldebugview.h" -#include "llenvmanager.h" +#include "llenvironment.h" #include "llfacebookconnect.h" #include "llfilepicker.h" #include "llfirstuse.h" @@ -8394,19 +8394,19 @@ class LLWorldEnvSettings : public view_listener_t if (tod == "sunrise") { - LLEnvManagerNew::instance().setUseSkyPreset("Sunrise"); + LLEnvironment::instance().selectSky("Sunrise"); } else if (tod == "noon") { - LLEnvManagerNew::instance().setUseSkyPreset("Midday"); + LLEnvironment::instance().selectSky("Midday"); } else if (tod == "sunset") { - LLEnvManagerNew::instance().setUseSkyPreset("Sunset"); + LLEnvironment::instance().selectSky("Sunset"); } else if (tod == "midnight") { - LLEnvManagerNew::instance().setUseSkyPreset("Midnight"); + LLEnvironment::instance().selectSky("Midnight"); } else { @@ -8440,19 +8440,19 @@ class LLWorldEnableEnvSettings : public view_listener_t { if (tod == "sunrise") { - result = (LLEnvManagerNew::instance().getSkyPresetName() == "Sunrise"); + result = (LLEnvironment::instance().getCurrentSky()->getName() == "Sunrise"); } else if (tod == "noon") { - result = (LLEnvManagerNew::instance().getSkyPresetName() == "Midday"); + result = (LLEnvironment::instance().getCurrentSky()->getName() == "Midday"); } else if (tod == "sunset") { - result = (LLEnvManagerNew::instance().getSkyPresetName() == "Sunset"); + result = (LLEnvironment::instance().getCurrentSky()->getName() == "Sunset"); } else if (tod == "midnight") { - result = (LLEnvManagerNew::instance().getSkyPresetName() == "Midnight"); + result = (LLEnvironment::instance().getCurrentSky()->getName() == "Midnight"); } else if (tod == "region") { diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index ea65a0c6d9..c3543f051d 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -34,6 +34,8 @@ #include "llnotificationsutil.h" #include "llcorehttputil.h" +#include "llenvironment.h" + /**** * LLEnvironmentRequest ****/ @@ -114,7 +116,8 @@ void LLEnvironmentRequest::environmentRequestCoro(std::string url) if (!status) { LL_WARNS("WindlightCaps") << "Got an error, not using region windlight... " << LL_ENDL; - LLEnvManagerNew::getInstance()->onRegionSettingsResponse(LLSD()); + LLEnvironment::instance().onLegacyRegionSettings(LLSD()); + return; } result = result["content"]; @@ -134,7 +137,7 @@ void LLEnvironmentRequest::environmentRequestCoro(std::string url) return; } - LLEnvManagerNew::getInstance()->onRegionSettingsResponse(result); + LLEnvironment::instance().onLegacyRegionSettings(result); } |