diff options
-rw-r--r-- | indra/newview/llenvmanager.cpp | 26 | ||||
-rw-r--r-- | indra/newview/llenvmanager.h | 28 | ||||
-rw-r--r-- | indra/newview/llfloaterenvsettings.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 12 | ||||
-rw-r--r-- | indra/newview/llwaterparammanager.cpp | 17 | ||||
-rw-r--r-- | indra/newview/llwlanimator.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llwlanimator.h | 2 | ||||
-rw-r--r-- | indra/newview/llwlhandlers.cpp | 19 | ||||
-rw-r--r-- | indra/newview/llwlparammanager.cpp | 28 |
9 files changed, 84 insertions, 53 deletions
diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index 49bbf1a77c..338a1e5f0a 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -661,6 +661,11 @@ std::string LLEnvManagerNew::getDayCycleName() const return mUserPrefs.getDayCycleName(); } +const LLEnvironmentSettings& LLEnvManagerNew::getRegionSettings() const +{ + return mCachedRegionPrefs; +} + void LLEnvManagerNew::setUseRegionSettings(bool val) { mUserPrefs.setUseDefaults(val); @@ -728,6 +733,16 @@ void LLEnvManagerNew::saveUserPrefs() gSavedSettings.setBOOL("UseDayCycle", getUseDayCycle()); } +void LLEnvManagerNew::dumpUserPrefs() +{ + LL_DEBUGS("Windlight") << "WaterPresetName: " << gSavedSettings.getString("WaterPresetName") << LL_ENDL; + LL_DEBUGS("Windlight") << "SkyPresetName: " << gSavedSettings.getString("SkyPresetName") << LL_ENDL; + LL_DEBUGS("Windlight") << "DayCycleName: " << gSavedSettings.getString("DayCycleName") << LL_ENDL; + + LL_DEBUGS("Windlight") << "UseEnvironmentFromRegion: " << gSavedSettings.getBOOL("UseEnvironmentFromRegion") << LL_ENDL; + LL_DEBUGS("Windlight") << "UseDayCycle: " << gSavedSettings.getBOOL("UseDayCycle") << LL_ENDL; +} + void LLEnvManagerNew::onRegionCrossing() { LL_DEBUGS("Windlight") << "Crossed region" << LL_ENDL; @@ -769,6 +784,8 @@ void LLEnvManagerNew::updateManagersFromPrefs() void LLEnvManagerNew::sendRegionSettingsRequest() { + LLEnvironmentRequest::initiate(); + // *TODO: Indicate that current cached region settings have been invalidated? } void LLEnvManagerNew::onRegionChange(bool interpolate) @@ -777,13 +794,16 @@ void LLEnvManagerNew::onRegionChange(bool interpolate) sendRegionSettingsRequest(); } -void LLEnvManagerNew::onRegionSettingsResponse() +void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) { // 1. Refresh cached region settings. - // ... + LL_DEBUGS("Windlight") << "Caching region environment settings" << LL_ENDL; + F32 sun_hour = 0; // *TODO + LLEnvironmentSettings new_settings(content[1], content[2], content[3], sun_hour); + mCachedRegionPrefs = new_settings; // 2. If using server settings, update managers. - if (mUserPrefs.getUseDefaults()) + if (getUseRegionSettings()) { updateManagersFromPrefs(); } diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index 0fd2a7e87e..da1db52074 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -79,22 +79,22 @@ public: mDayTime = dayTime; } - LLSD& getWLDayCycle() + const LLSD& getWLDayCycle() const { return mWLDayCycle; } - LLSD& getWaterParams() + const LLSD& getWaterParams() const { return mWaterParams; } - LLSD& getSkyMap() + const LLSD& getSkyMap() const { return mSkyMap; } - F64 getDayTime() + F64 getDayTime() const { return mDayTime; } @@ -221,10 +221,9 @@ private: }; /** - * User or region preferences. + * User environment preferences. * - * Region defaults :- use SL defaults - * User defaults :- use region defaults + * defaults = use region settings */ class LLEnvPrefs { @@ -251,11 +250,6 @@ public: std::string mDayCycleName; }; -class LLRegionEnvPrefs : public LLEnvPrefs -{ - LLSD mDayCycle; -}; - /** * Setting: * 1. Use region settings. @@ -273,6 +267,7 @@ public: std::string getWaterPresetName() const; std::string getSkyPresetName() const; std::string getDayCycleName() const; + const LLEnvironmentSettings& getRegionSettings() const; void setUseRegionSettings(bool val); void setUseWaterPreset(const std::string& name); @@ -281,10 +276,12 @@ public: void loadUserPrefs(); void saveUserPrefs(); + void dumpUserPrefs(); void onLogin(); void onRegionCrossing(); void onTeleport(); + void onRegionSettingsResponse(const LLSD& content); private: friend class LLSingleton<LLEnvManagerNew>; @@ -294,11 +291,10 @@ private: void sendRegionSettingsRequest(); void onRegionChange(bool interpolate); - void onRegionSettingsResponse(); - LLEnvPrefs mUserPrefs; - LLRegionEnvPrefs mCachedRegionPrefs; - bool mInterpNextChangeMessage; + LLEnvPrefs mUserPrefs; + LLEnvironmentSettings mCachedRegionPrefs; + bool mInterpNextChangeMessage; }; #endif // LL_LLENVMANAGER_H diff --git a/indra/newview/llfloaterenvsettings.cpp b/indra/newview/llfloaterenvsettings.cpp index a2a6005b14..bb476e5d00 100644 --- a/indra/newview/llfloaterenvsettings.cpp +++ b/indra/newview/llfloaterenvsettings.cpp @@ -90,7 +90,8 @@ void LLFloaterEnvSettings::initCallbacks(void) childSetCommitCallback("EnvUseEstateTimeButton", &LLFloaterEnvSettings::onUseEstateTime, NULL); getChild<LLUICtrl>("EnvUseLocalTimeButton")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onUseLocalTime)); - getChild<LLUICtrl>("EnvUseEstateTimeButton")->setRightMouseDownCallback(boost::bind(&LLEnvManager::dumpScopes, &LLEnvManager::instance())); + getChild<LLUICtrl>("EnvUseLocalTimeButton")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, &LLEnvManagerNew::instance())); + getChild<LLUICtrl>("EnvUseEstateTimeButton")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, &LLEnvManagerNew::instance())); } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 4a0e9fa766..4acf9a1fad 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7605,7 +7605,7 @@ class LLWorldEnvSettings : public view_listener_t } else { - LLWLParamManager::getInstance()->mAnimator.activate(LLWLAnimator::TIME_LINDEN); + LLEnvManagerNew::instance().setUseDayCycle(LLEnvManagerNew::instance().getDayCycleName()); } return true; @@ -7621,8 +7621,7 @@ class LLWorldCheckEnvironment : public view_listener_t if (item == "use_region_settings") { // Check whether we're using region environment settings. - LLEnvKey::EScope cur_scope = LLEnvManager::getInstance()->getNormallyDisplayedScope(); - return cur_scope == LLEnvKey::SCOPE_REGION; + return LLEnvManagerNew::instance().getUseRegionSettings(); } return true; @@ -7637,11 +7636,8 @@ class LLWorldEnvironment : public view_listener_t if (item == "use_region_settings") { - // Toggle using region environment settings. - LLEnvManager* env_mgr = LLEnvManager::getInstance(); - LLEnvKey::EScope cur_scope = env_mgr->getNormallyDisplayedScope(); - LLEnvKey::EScope new_scope = (cur_scope == LLEnvKey::SCOPE_LOCAL ? LLEnvKey::SCOPE_REGION : LLEnvKey::SCOPE_LOCAL); - env_mgr->setNormallyDisplayedScope(new_scope); + bool cur_val = LLEnvManagerNew::instance().getUseRegionSettings(); + LLEnvManagerNew::instance().setUseRegionSettings(!cur_val); } return true; diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 587249856e..715af09053 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -258,9 +258,20 @@ static LLFastTimer::DeclareTimer FTM_UPDATE_WATERPARAM("Update Water Params"); void LLWaterParamManager::applyUserPrefs() { - std::string water = LLEnvManagerNew::instance().getWaterPresetName(); - LL_DEBUGS("Windlight") << "Loading water preset [" << water << "]" << LL_ENDL; - loadPreset(water, true); + 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()); + } + else + { + std::string water = LLEnvManagerNew::instance().getWaterPresetName(); + LL_DEBUGS("Windlight") << "Loading water preset [" << water << "]" << LL_ENDL; + loadPreset(water, true); + } } void LLWaterParamManager::update(LLViewerCamera * cam) diff --git a/indra/newview/llwlanimator.cpp b/indra/newview/llwlanimator.cpp index 3d51ad89ff..0a3fd3cfee 100644 --- a/indra/newview/llwlanimator.cpp +++ b/indra/newview/llwlanimator.cpp @@ -217,7 +217,7 @@ void LLWLAnimator::setTrack(std::map<F32, LLWLParamKey>& curTrack, mIsRunning = run; } -void LLWLAnimator::startInterpolation(LLSD& targetWater) +void LLWLAnimator::startInterpolation(const LLSD& targetWater) { mInterpBeginWL->setAll(LLWLParamManager::getInstance()->mCurParams.getAll()); mInterpBeginWater->setAll(LLWaterParamManager::getInstance()->mCurParams.getAll()); diff --git a/indra/newview/llwlanimator.h b/indra/newview/llwlanimator.h index 07c2fa2328..5223b45343 100644 --- a/indra/newview/llwlanimator.h +++ b/indra/newview/llwlanimator.h @@ -88,7 +88,7 @@ public: mTimeType = time; } - void startInterpolation(LLSD& targetWater); + void startInterpolation(const LLSD& targetWater); bool getIsRunning() { diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index de20051880..905b8d83a8 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -47,6 +47,12 @@ bool LLEnvironmentRequest::initiate() { LLViewerRegion* cur_region = gAgent.getRegion(); + if (!cur_region) + { + LL_WARNS("WindlightCaps") << "Viewer region not set yet, skipping env. settings request" << LL_ENDL; + return false; + } + if (!cur_region->capabilitiesReceived()) { LL_INFOS("WindlightCaps") << "Deferring windlight settings request until we've got region caps" << LL_ENDL; @@ -113,21 +119,12 @@ LLEnvironmentRequestResponder::LLEnvironmentRequestResponder() return; } -#if 0 - LLEnvManager::getInstance()->processIncomingMessage(unvalidated_content, LLEnvKey::SCOPE_REGION); -#else - LL_INFOS("WindlightCaps") << "Temprarily ignoring region settings" << LL_ENDL; -#endif + LLEnvManagerNew::getInstance()->onRegionSettingsResponse(unvalidated_content); } /*virtual*/ void LLEnvironmentRequestResponder::error(U32 status, const std::string& reason) { LL_INFOS("WindlightCaps") << "Got an error, not using region windlight..." << LL_ENDL; -#if 0 - // notify manager that region settings are undefined - LLEnvManager::getInstance()->processIncomingMessage(LLSD(), LLEnvKey::SCOPE_REGION); -#else - LL_INFOS("WindlightCaps") << "Temprarily ignoring region settings" << LL_ENDL; -#endif + LLEnvManagerNew::getInstance()->onRegionSettingsResponse(LLSD()); } diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 43f0cdae93..4431b3f5c0 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -583,23 +583,33 @@ void LLWLParamManager::update(LLViewerCamera * cam) void LLWLParamManager::applyUserPrefs() { LL_DEBUGS("Windlight") << "Applying sky prefs" << LL_ENDL; + clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); if (LLEnvManagerNew::instance().getUseRegionSettings()) // apply region-wide settings { - llwarns << "Using region settings has not been implemented" << llendl; + // *TODO: Support fixed sky from region. + LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; + + 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); + resetAnimator(region_settings.getDayTime(), true); } else // apply user-specified settings { - bool use_day_cycle = LLEnvManagerNew::instance().getUseDayCycle(); + // Load day cycle anyway so that we can switch to it from a fixed sky. + LL_DEBUGS("Windlight") << "Loading day cycle " << LLEnvManagerNew::instance().getDayCycleName() << LL_ENDL; + mDay.loadDayCycleFromFile(LLEnvManagerNew::instance().getDayCycleName() + ".xml"); - if (use_day_cycle) - { - LL_DEBUGS("Windlight") << "Loading day cycle " << LLEnvManagerNew::instance().getDayCycleName() << LL_ENDL; - mDay.loadDayCycleFromFile(LLEnvManagerNew::instance().getDayCycleName() + ".xml"); - } - else + bool use_day_cycle = LLEnvManagerNew::instance().getUseDayCycle(); + if (!use_day_cycle) // if we should use fixed sky { - // *HACK - sets cloud scrolling to what we want... fix this better in the future std::string sky = LLEnvManagerNew::instance().getSkyPresetName(); LL_DEBUGS("Windlight") << "Loading fixed sky " << sky << LL_ENDL; getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams); |