diff options
author | Vadim ProductEngine <vsavchuk@productengine.com> | 2011-05-17 16:26:55 +0300 |
---|---|---|
committer | Vadim ProductEngine <vsavchuk@productengine.com> | 2011-05-17 16:26:55 +0300 |
commit | 348218e40f362d386a0175d4b010b639282764b2 (patch) | |
tree | 3dcb3d1d5dc8dadee923613cf2b88434f1ec4d75 /indra | |
parent | 3d0688da9461766d783383d68a990fcf8711228e (diff) |
STORM-1245 WIP Restored environment settings interpolation on region crossing.
Also got rid of duplicated region environment settings requests.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llagent.cpp | 24 | ||||
-rw-r--r-- | indra/newview/llenvmanager.cpp | 38 | ||||
-rw-r--r-- | indra/newview/llenvmanager.h | 10 | ||||
-rw-r--r-- | indra/newview/llwaterparammanager.cpp | 33 | ||||
-rw-r--r-- | indra/newview/llwaterparammanager.h | 2 | ||||
-rw-r--r-- | indra/newview/llwlhandlers.h | 3 | ||||
-rw-r--r-- | indra/newview/llwlparammanager.cpp | 9 | ||||
-rw-r--r-- | indra/newview/llwlparammanager.h | 2 |
8 files changed, 72 insertions, 49 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index bcc1953acc..fbe15505d8 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -596,6 +596,8 @@ void LLAgent::standUp() //----------------------------------------------------------------------------- void LLAgent::setRegion(LLViewerRegion *regionp) { + bool teleport = true; + llassert(regionp); if (mRegionp != regionp) { @@ -634,15 +636,7 @@ void LLAgent::setRegion(LLViewerRegion *regionp) } // Notify windlight managers - bool teleport = (gAgent.getTeleportState() != LLAgent::TELEPORT_NONE); - if (teleport) - { - LLEnvManagerNew::instance().onTeleport(); - } - else - { - LLEnvManagerNew::instance().onRegionCrossing(); - } + teleport = (gAgent.getTeleportState() != LLAgent::TELEPORT_NONE); } else { @@ -659,9 +653,6 @@ void LLAgent::setRegion(LLViewerRegion *regionp) // Update all of the regions. LLWorld::getInstance()->updateAgentOffset(mAgentOriginGlobal); - - // Notify windlight managers about login - LLEnvManagerNew::instance().onLogin(); } // Pass new region along to metrics components that care about this level of detail. @@ -687,7 +678,14 @@ void LLAgent::setRegion(LLViewerRegion *regionp) LLFloaterMove::sUpdateFlyingStatus(); - LLEnvManagerNew::instance().onTeleport(); + if (teleport) + { + LLEnvManagerNew::instance().onTeleport(); + } + else + { + LLEnvManagerNew::instance().onRegionCrossing(); + } } diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index 338a1e5f0a..5a04578e26 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -670,7 +670,7 @@ void LLEnvManagerNew::setUseRegionSettings(bool val) { mUserPrefs.setUseDefaults(val); saveUserPrefs(); - updateManagersFromPrefs(); + updateManagersFromPrefs(false); } void LLEnvManagerNew::setUseWaterPreset(const std::string& name) @@ -683,7 +683,7 @@ void LLEnvManagerNew::setUseWaterPreset(const std::string& name) mUserPrefs.setUseWaterPreset(name); saveUserPrefs(); - updateManagersFromPrefs(); + updateManagersFromPrefs(false); } void LLEnvManagerNew::setUseSkyPreset(const std::string& name) @@ -696,7 +696,7 @@ void LLEnvManagerNew::setUseSkyPreset(const std::string& name) mUserPrefs.setUseSkyPreset(name); saveUserPrefs(); - updateManagersFromPrefs(); + updateManagersFromPrefs(false); } void LLEnvManagerNew::setUseDayCycle(const std::string& name) @@ -709,7 +709,7 @@ void LLEnvManagerNew::setUseDayCycle(const std::string& name) mUserPrefs.setUseDayCycle(name); saveUserPrefs(); - updateManagersFromPrefs(); + updateManagersFromPrefs(true); } void LLEnvManagerNew::loadUserPrefs() @@ -749,12 +749,6 @@ void LLEnvManagerNew::onRegionCrossing() onRegionChange(true); } -void LLEnvManagerNew::onLogin() -{ - LL_DEBUGS("Windlight") << "Logged in" << LL_ENDL; - onRegionChange(false); -} - void LLEnvManagerNew::onTeleport() { LL_DEBUGS("Windlight") << "Teleported" << LL_ENDL; @@ -771,15 +765,13 @@ void LLEnvManagerNew::initSingleton() loadUserPrefs(); } -void LLEnvManagerNew::updateManagersFromPrefs() +void LLEnvManagerNew::updateManagersFromPrefs(bool interpolate) { - // *TODO: apply region settings if user preferences say to do so. - // Apply water settings. - LLWaterParamManager::instance().applyUserPrefs(); + LLWaterParamManager::instance().applyUserPrefs(interpolate); // Apply sky settings. - LLWLParamManager::instance().applyUserPrefs(); + LLWLParamManager::instance().applyUserPrefs(interpolate); } void LLEnvManagerNew::sendRegionSettingsRequest() @@ -790,6 +782,18 @@ void LLEnvManagerNew::sendRegionSettingsRequest() void LLEnvManagerNew::onRegionChange(bool interpolate) { + // Avoid duplicating region setting requests + // by checking whether the region is actually changing. + LLViewerRegion* regionp = gAgent.getRegion(); + LLUUID region_uuid = regionp ? regionp->getRegionID() : LLUUID::null; + if (region_uuid == mCurRegionUUID) + { + return; + } + + // Request environment settings of the new region. + LL_DEBUGS("Windlight") << "New viewer region: " << region_uuid << LL_ENDL; + mCurRegionUUID = region_uuid; mInterpNextChangeMessage = interpolate; sendRegionSettingsRequest(); } @@ -805,6 +809,8 @@ void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) // 2. If using server settings, update managers. if (getUseRegionSettings()) { - updateManagersFromPrefs(); + updateManagersFromPrefs(mInterpNextChangeMessage); } + + mInterpNextChangeMessage = false; } diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index da1db52074..b871ebc06f 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -278,7 +278,6 @@ public: void saveUserPrefs(); void dumpUserPrefs(); - void onLogin(); void onRegionCrossing(); void onTeleport(); void onRegionSettingsResponse(const LLSD& content); @@ -287,14 +286,15 @@ private: friend class LLSingleton<LLEnvManagerNew>; /*virtual*/ void initSingleton(); - void updateManagersFromPrefs(); + void updateManagersFromPrefs(bool interpolate); void sendRegionSettingsRequest(); void onRegionChange(bool interpolate); - LLEnvPrefs mUserPrefs; - LLEnvironmentSettings mCachedRegionPrefs; - bool mInterpNextChangeMessage; + LLEnvPrefs mUserPrefs; /// User environment preferences. + LLEnvironmentSettings mCachedRegionPrefs; /// Cached region environment settings. + bool mInterpNextChangeMessage; /// Interpolate env. settings on next region change. + LLUUID mCurRegionUUID; /// To avoid duplicated region env. settings requests. }; #endif // LL_LLENVMANAGER_H diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 715af09053..a11ae93847 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -256,21 +256,40 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) static LLFastTimer::DeclareTimer FTM_UPDATE_WATERPARAM("Update Water Params"); -void LLWaterParamManager::applyUserPrefs() +void LLWaterParamManager::applyUserPrefs(bool interpolate) { + LLSD target_water_params; + + // Determine new water settings based on user prefs. if (LLEnvManagerNew::instance().getUseRegionSettings()) { - // *TODO: interpolate? // *TODO: make sure whether region settings belong to the current region? LL_DEBUGS("Windlight") << "Applying region water" << LL_ENDL; - const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - LLWaterParamManager::getInstance()->mCurParams.setAll(region_settings.getWaterParams()); + target_water_params = LLEnvManagerNew::instance().getRegionSettings().getWaterParams(); } else { std::string water = LLEnvManagerNew::instance().getWaterPresetName(); - LL_DEBUGS("Windlight") << "Loading water preset [" << water << "]" << LL_ENDL; - loadPreset(water, true); + LL_DEBUGS("Windlight") << "Applying water preset [" << water << "]" << LL_ENDL; + LLWaterParamSet params; + getParamSet(water, params); + target_water_params = params.getAll(); + } + + // Apply them with or without interpolation. + if (target_water_params.isUndefined()) + { + llwarns << "Undefined target water params" << llendl; + return; + } + + if (interpolate) + { + LLWLParamManager::getInstance()->mAnimator.startInterpolation(target_water_params); + } + else + { + LLWaterParamManager::getInstance()->mCurParams.setAll(target_water_params); } } @@ -447,5 +466,5 @@ void LLWaterParamManager::initSingleton() { LL_DEBUGS("Windlight") << "Initializing water" << LL_ENDL; loadAllPresets(LLStringUtil::null); - applyUserPrefs(); + applyUserPrefs(false); } diff --git a/indra/newview/llwaterparammanager.h b/indra/newview/llwaterparammanager.h index 37c04448eb..5fadd8d66e 100644 --- a/indra/newview/llwaterparammanager.h +++ b/indra/newview/llwaterparammanager.h @@ -230,7 +230,7 @@ public: void propagateParameters(void); /// apply user water preferences - void applyUserPrefs(); + void applyUserPrefs(bool interpolate); /// update information for the shader void update(LLViewerCamera * cam); diff --git a/indra/newview/llwlhandlers.h b/indra/newview/llwlhandlers.h index 4929b4d27b..05b2244e8a 100644 --- a/indra/newview/llwlhandlers.h +++ b/indra/newview/llwlhandlers.h @@ -40,6 +40,7 @@ class LLEnvManager; class LLEnvironmentRequest { + LOG_CLASS(LLEnvironmentRequest); public: /// @return true if request was successfully sent static bool initiate(); @@ -51,6 +52,7 @@ private: class LLEnvironmentRequestResponder: public LLHTTPClient::Responder { + LOG_CLASS(LLEnvironmentRequestResponder); public: virtual void result(const LLSD& content); virtual void error(U32 status, const std::string& reason); @@ -66,6 +68,7 @@ private: class LLEnvironmentApplyResponder: public LLHTTPClient::Responder { + LOG_CLASS(LLEnvironmentApplyResponder); public: /* * Expecting reply from sim in form of: diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 4431b3f5c0..0913c4dec2 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -580,7 +580,7 @@ void LLWLParamManager::update(LLViewerCamera * cam) } } -void LLWLParamManager::applyUserPrefs() +void LLWLParamManager::applyUserPrefs(bool interpolate) { LL_DEBUGS("Windlight") << "Applying sky prefs" << LL_ENDL; clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); @@ -592,13 +592,10 @@ void LLWLParamManager::applyUserPrefs() const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - if (0) // *TODO: interpolate? - { - mAnimator.startInterpolation(region_settings.getWaterParams()); - } - addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap()); mDay.loadDayCycle(region_settings.getWLDayCycle(), LLEnvKey::SCOPE_REGION); + LL_DEBUGS("Windlight") << "Applying region time: " << region_settings.getDayTime() + << " = " << region_settings.getDayTime() * 24.0f << " h" << LL_ENDL; resetAnimator(region_settings.getDayTime(), true); } else // apply user-specified settings diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index a2327d35a8..8a852e043b 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -236,7 +236,7 @@ public: void update(LLViewerCamera * cam); /// apply specified params - void applyUserPrefs(); + void applyUserPrefs(bool interpolate); // get where the light is pointing inline LLVector4 getLightDir(void) const; |