From a0c228d84240a80437b63e0a2cd1cee24e8004a0 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 16 Jan 2018 11:03:26 -0800 Subject: MAINT-8052: Report if the returned environment is the default. --- indra/llinventory/llparcel.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llinventory/llparcel.cpp') diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp index 0908613c10..f53ef5e0ff 100644 --- a/indra/llinventory/llparcel.cpp +++ b/indra/llinventory/llparcel.cpp @@ -231,6 +231,11 @@ void LLParcel::init(const LLUUID &owner_id, setAllowGroupAVSounds(TRUE); setAllowAnyAVSounds(TRUE); setHaveNewParcelLimitData(FALSE); + + mDayLength = S64Seconds(LLSettingsDay::DEFAULT_DAYLENGTH); + mDayOffset = S64Seconds(LLSettingsDay::DEFAULT_DAYOFFSET); + mIsDefaultDayCycle = true; + mDayCycle.reset(); } void LLParcel::overrideOwner(const LLUUID& owner_id, BOOL is_group_owned) -- cgit v1.3 From fbd8a98300277bdbc1885c25eea290560fd8c6c1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 25 Jan 2018 17:21:25 -0800 Subject: Selects correct day cycle. Fix an error validating legacy daycycles. --- indra/llinventory/llparcel.cpp | 10 ++++ indra/llinventory/llparcel.h | 20 +++++--- indra/llinventory/llsettingsdaycycle.cpp | 3 +- indra/newview/llenvironment.cpp | 83 ++++++++++++++++++++------------ indra/newview/llenvironment.h | 7 ++- indra/newview/llsettingsvo.cpp | 6 ++- indra/newview/llviewerregion.h | 19 +++++--- 7 files changed, 94 insertions(+), 54 deletions(-) (limited to 'indra/llinventory/llparcel.cpp') diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp index f53ef5e0ff..411c35ed6b 100644 --- a/indra/llinventory/llparcel.cpp +++ b/indra/llinventory/llparcel.cpp @@ -236,6 +236,7 @@ void LLParcel::init(const LLUUID &owner_id, mDayOffset = S64Seconds(LLSettingsDay::DEFAULT_DAYOFFSET); mIsDefaultDayCycle = true; mDayCycle.reset(); + mDayCycleHash = 0; } void LLParcel::overrideOwner(const LLUUID& owner_id, BOOL is_group_owned) @@ -1272,3 +1273,12 @@ U32 LLParcel::countExperienceKeyType( U32 type ) boost::end(mExperienceKeys | boost::adaptors::map_values), std::bind2nd(std::equal_to(), type)); } + +void LLParcel::clearParcelDayCycleInfo() +{ + mDayLength = S64Seconds(LLSettingsDay::DEFAULT_DAYLENGTH); + mDayOffset = S64Seconds(LLSettingsDay::DEFAULT_DAYOFFSET); + mIsDefaultDayCycle = true; + mDayCycle.reset(); + mDayCycleHash = 0; +} diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index 7b4647cc5f..6bbd5a949d 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -591,14 +591,17 @@ public: BOOL getPreviouslyGroupOwned() const { return mPreviouslyGroupOwned; } BOOL getSellWithObjects() const { return (mParcelFlags & PF_SELL_PARCEL_OBJECTS) ? TRUE : FALSE; } - S64Seconds getDayLength() const { return mDayLength; } - void setDayLength(S64SecondsImplicit seconds) { mDayLength = seconds; } - S64Seconds getDayOffset() const { return mDayOffset; } - void setDayOffset(S64SecondsImplicit seconds) { mDayOffset = seconds; } - bool getUsesDefaultDayCycle() const { return mIsDefaultDayCycle; } - void setUsesDefaultDayCycle(bool isdefault) { mIsDefaultDayCycle = isdefault; } - LLSettingsDay::ptr_t getParcelDayCycle() const { return mDayCycle; } - void setParcelDayCycle(const LLSettingsDay::ptr_t &pday) { mDayCycle = pday; } + S64Seconds getDayLength() const { return mDayLength; } + void setDayLength(S64SecondsImplicit seconds) { mDayLength = seconds; } + S64Seconds getDayOffset() const { return mDayOffset; } + void setDayOffset(S64SecondsImplicit seconds) { mDayOffset = seconds; } + bool getUsesDefaultDayCycle() const { return mIsDefaultDayCycle; } + void setUsesDefaultDayCycle(bool isdefault) { mIsDefaultDayCycle = isdefault; } + LLSettingsDay::ptr_t getParcelDayCycle() const { return mDayCycle; } + void setParcelDayCycle(const LLSettingsDay::ptr_t &pday) { mDayCycle = pday; } + size_t getParcelDayCycleHash() const { return mDayCycleHash; } + void setParcelDayCycleHash(size_t hash) { mDayCycleHash = hash; } + void clearParcelDayCycleInfo(); protected: LLUUID mID; @@ -678,6 +681,7 @@ protected: S64Seconds mDayOffset; bool mIsDefaultDayCycle; LLSettingsDay::ptr_t mDayCycle; + size_t mDayCycleHash; public: // HACK, make private diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index c7d5c35c60..1b992ff313 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -376,12 +376,12 @@ namespace LLSD frame = (*itf).second; std::string ftype = frame[LLSettingsBase::SETTING_TYPE]; + LL_WARNS("LAPRAS") << "Validating frame: " << frame << LL_ENDL; if (ftype == "sky") { LLSettingsSky::validation_list_t valid_sky = LLSettingsSky::validationList(); LLSD res_sky = LLSettingsSky::settingValidation(frame, valid_sky); LL_WARNS("SETTINGS") << "'" << (*itf).first << "' res=" << res_sky << LL_ENDL; - //_WARNS("SETTINGS") << "success=" << res_sky["success"].asBoolean() << "(" << res_sky["success"].asInteger() << ") res=" << res_sky << LL_ENDL; if (res_sky["success"].asInteger() == 0) { @@ -396,7 +396,6 @@ namespace LLSettingsWater::validation_list_t valid_h2o = LLSettingsWater::validationList(); LLSD res_h2o = LLSettingsWater::settingValidation(frame, valid_h2o); LL_WARNS("SETTINGS") << "'" << (*itf).first << "' res=" << res_h2o << LL_ENDL; - //_WARNS("SETTINGS") << "success=" << res_h2o["success"].asBoolean() << LL_ENDL; if (res_h2o["success"].asInteger() == 0) { LL_WARNS("SETTINGS") << "Water setting named '" << (*itf).first << "' validation failed!: " << res_h2o << LL_ENDL; diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e64d71e228..25c7fb89db 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -50,6 +50,8 @@ #include "llsettingsvo.h" #include "llnotificationsutil.h" +#include "llregioninfomodel.h" + #include //define EXPORT_PRESETS 1 @@ -108,8 +110,12 @@ void LLEnvironment::initSingleton() legacyLoadAllPresets(); requestRegionEnvironment(); - gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::onRegionChange, this)); + + LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLEnvironment::onParcelChange, this)); gAgent.addParcelChangedCallback(boost::bind(&LLEnvironment::onParcelChange, this)); + + //TODO: This frequently results in one more request than we need. It isn't breaking, but should be nicer. + gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::requestRegionEnvironment, this)); } LLEnvironment::~LLEnvironment() @@ -147,11 +153,6 @@ LLEnvironment::connection_t LLEnvironment::setDayCycleListChange(const LLEnviron return mDayCycleListChange.connect(cb); } -void LLEnvironment::onRegionChange() -{ - requestRegionEnvironment(); -} - void LLEnvironment::onParcelChange() { S32 parcel_id(INVALID_PARCEL_ID); @@ -783,7 +784,9 @@ void LLEnvironment::selectAgentEnvironment() S64Seconds day_offset(LLSettingsDay::DEFAULT_DAYOFFSET); LLSettingsDay::ptr_t pday; - // TODO: First test if agent has local environment set. + // TODO: Test if editing environment has been set. + + // TODO: Test if agent has local environment set. LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); LLViewerRegion *pRegion = gAgent.getRegion(); @@ -809,25 +812,38 @@ void LLEnvironment::selectAgentEnvironment() if (pday) selectDayCycle(pday); - } void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo) { LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; - if (parcel_id == INVALID_PARCEL_ID) - { + LLSettingsDay::ptr_t pday = LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData); + + LL_WARNS("ENVIRONMENT") << "serverhash=" << envinfo->mDayHash << " viewerhash=" << pday->getHash() << LL_ENDL; + + if (envinfo->mParcelId == INVALID_PARCEL_ID) + { // the returned info applies to an entire region. LLViewerRegion *pRegion = gAgent.getRegion(); - if (pRegion) + pRegion->setDayLength(envinfo->mDayLength); + pRegion->setDayOffset(envinfo->mDayOffset); + pRegion->setIsDefaultDayCycle(envinfo->mIsDefault); + if (pRegion->getRegionDayCycleHash() != envinfo->mDayHash) { - pRegion->setDayLength(envinfo->mDayLength); - pRegion->setDayOffset(envinfo->mDayOffset); - pRegion->setIsDefaultDayCycle(envinfo->mIsDefault); - pRegion->setRegionDayCycle(LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData)); + pRegion->setRegionDayCycle(pday); + pRegion->setRegionDayCycleHash(envinfo->mDayHash); + } + + if (parcel_id != INVALID_PARCEL_ID) + { // We requested a parcel environment but got back the region's. If this is the parcel we are in + // clear it out. + LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); - /*TODO: track_altitudes*/ + if (parcel->getLocalID() == parcel_id) + { + parcel->clearParcelDayCycleInfo(); + } } } else @@ -839,18 +855,16 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI parcel->setDayLength(envinfo->mDayLength); parcel->setDayOffset(envinfo->mDayOffset); parcel->setUsesDefaultDayCycle(envinfo->mIsDefault); - - LLSettingsDay::ptr_t pday; - if (!envinfo->mIsDefault) + if (parcel->getParcelDayCycleHash() != envinfo->mDayHash) { - pday = LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData); + parcel->setParcelDayCycle(pday); + parcel->setParcelDayCycleHash(envinfo->mDayHash); } - parcel->setParcelDayCycle(pday); - // select parcel day } } - + + /*TODO: track_altitudes*/ selectAgentEnvironment(); } @@ -1000,8 +1014,6 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd url += query.str(); } - LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL; - LLSD result = httpAdapter->putAndSuspend(httpRequest, url, body); // results that come back may contain the new settings @@ -1009,6 +1021,7 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + LL_WARNS("LAPRAS") << "success=" << result["success"] << LL_ENDL; if ((!status) || !result["success"].asBoolean()) { LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; @@ -1052,8 +1065,6 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn app url += query.str(); } - LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL; - LLSD result = httpAdapter->deleteAndSuspend(httpRequest, url); // results that come back may contain the new settings @@ -1061,6 +1072,7 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn app LLSD httpResults = result["http_result"]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + LL_WARNS("LAPRAS") << "success=" << result["success"] << LL_ENDL; if ((!status) || !result["success"].asBoolean()) { LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL; @@ -1125,12 +1137,15 @@ void LLEnvironment::UserPrefs::store() } LLEnvironment::EnvironmentInfo::EnvironmentInfo(): - mParcelId(), - mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), - mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET), + mParcelId(INVALID_PARCEL_ID), + mRegionId(), + mDayLength(0), + mDayOffset(0), + mDayHash(0), mDaycycleData(), mAltitudes(), - mIsDefault(false) + mIsDefault(false), + mIsRegion(false) { } @@ -1139,11 +1154,15 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL ptr_t pinfo = boost::make_shared(); if (environment.has("parcel_id")) - pinfo->mParcelId = environment["parcel_id"].asUUID(); + pinfo->mParcelId = environment["parcel_id"].asInteger(); + if (environment.has("region_id")) + pinfo->mRegionId = environment["region_id"].asUUID(); if (environment.has("day_length")) pinfo->mDayLength = S64Seconds(environment["day_length"].asInteger()); if (environment.has("day_offset")) pinfo->mDayOffset = S64Seconds(environment["day_offset"].asInteger()); + if (environment.has("day_hash")) + pinfo->mDayHash = environment["day_hash"].asInteger(); if (environment.has("day_cycle")) pinfo->mDaycycleData = environment["day_cycle"]; if (environment.has("is_default")) diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index f5bd9be870..451bab5f9e 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -60,12 +60,16 @@ public: typedef boost::shared_ptr ptr_t; - LLUUID mParcelId; + S32 mParcelId; + LLUUID mRegionId; S64Seconds mDayLength; S64Seconds mDayOffset; + size_t mDayHash; LLSD mDaycycleData; LLSD mAltitudes; bool mIsDefault; + bool mIsRegion; + static ptr_t extract(LLSD); @@ -296,7 +300,6 @@ private: void updateCloudScroll(); - void onRegionChange(); void onParcelChange(); void coroRequestEnvironment(S32 parcel_id, environment_apply_fn apply); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 8ba6b2354a..eadc035b3b 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -515,7 +515,9 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io ( SETTING_TRACKS, LLSDArray(watertrack)(skytrack)) ( SETTING_FRAMES, frames ); - LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LL_WARNS("LAPRAS") << "newsettings=" << newsettings << LL_ENDL; + + LLSettingsSky::validation_list_t validations = LLSettingsDay::validationList(); LLSD results = LLSettingsDay::settingValidation(newsettings, validations); if (!results["success"].asBoolean()) { @@ -527,7 +529,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io if (dayp) { - dayp->setInitialized(); + dayp->initialize(); } return dayp; } diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index fef78e29a9..71d4d85ade 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -390,14 +390,16 @@ 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; } + 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); @@ -542,6 +544,7 @@ private: S64Seconds mDayOffset; bool mIsDefaultDayCycle; LLSettingsDay::ptr_t mDayCycle; + size_t mDayCycleHash; class CacheMissItem { -- cgit v1.3 From 0bf50e2f8cfa5f3ccd6165ce935cf0fd9c174ced Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 30 Jan 2018 16:42:34 -0800 Subject: Cleanup on daycyle selection and stack. Move blenders into environment. (Transition bronken, instant only. Shaddows moved based on region, not parcel) --- indra/llinventory/llparcel.cpp | 15 - indra/llinventory/llparcel.h | 16 - indra/llinventory/llsettingsbase.cpp | 2 +- indra/llinventory/llsettingsbase.h | 17 +- indra/llinventory/llsettingsdaycycle.cpp | 160 +---- indra/llinventory/llsettingsdaycycle.h | 50 +- indra/llinventory/llsettingssky.cpp | 2 +- indra/newview/llenvironment.cpp | 845 +++++++++++++++---------- indra/newview/llenvironment.h | 149 +++-- indra/newview/llfloatereditdaycycle.cpp | 3 +- indra/newview/llfloatereditextdaycycle.cpp | 10 +- indra/newview/llfloatereditsky.cpp | 10 +- indra/newview/llfloatereditwater.cpp | 10 +- indra/newview/llfloaterenvironmentsettings.cpp | 34 +- indra/newview/llfloaterland.cpp | 27 +- indra/newview/llfloaterregioninfo.cpp | 15 +- indra/newview/llviewermenu.cpp | 21 +- indra/newview/llviewerregion.cpp | 4 +- indra/newview/llviewerregion.h | 17 - 19 files changed, 696 insertions(+), 711 deletions(-) (limited to 'indra/llinventory/llparcel.cpp') diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp index 411c35ed6b..0908613c10 100644 --- a/indra/llinventory/llparcel.cpp +++ b/indra/llinventory/llparcel.cpp @@ -231,12 +231,6 @@ void LLParcel::init(const LLUUID &owner_id, setAllowGroupAVSounds(TRUE); setAllowAnyAVSounds(TRUE); setHaveNewParcelLimitData(FALSE); - - mDayLength = S64Seconds(LLSettingsDay::DEFAULT_DAYLENGTH); - mDayOffset = S64Seconds(LLSettingsDay::DEFAULT_DAYOFFSET); - mIsDefaultDayCycle = true; - mDayCycle.reset(); - mDayCycleHash = 0; } void LLParcel::overrideOwner(const LLUUID& owner_id, BOOL is_group_owned) @@ -1273,12 +1267,3 @@ U32 LLParcel::countExperienceKeyType( U32 type ) boost::end(mExperienceKeys | boost::adaptors::map_values), std::bind2nd(std::equal_to(), type)); } - -void LLParcel::clearParcelDayCycleInfo() -{ - mDayLength = S64Seconds(LLSettingsDay::DEFAULT_DAYLENGTH); - mDayOffset = S64Seconds(LLSettingsDay::DEFAULT_DAYOFFSET); - mIsDefaultDayCycle = true; - mDayCycle.reset(); - mDayCycleHash = 0; -} diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index 6bbd5a949d..6ef389d246 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -590,18 +590,6 @@ public: LLUUID getPreviousOwnerID() const { return mPreviousOwnerID; } BOOL getPreviouslyGroupOwned() const { return mPreviouslyGroupOwned; } BOOL getSellWithObjects() const { return (mParcelFlags & PF_SELL_PARCEL_OBJECTS) ? TRUE : FALSE; } - - S64Seconds getDayLength() const { return mDayLength; } - void setDayLength(S64SecondsImplicit seconds) { mDayLength = seconds; } - S64Seconds getDayOffset() const { return mDayOffset; } - void setDayOffset(S64SecondsImplicit seconds) { mDayOffset = seconds; } - bool getUsesDefaultDayCycle() const { return mIsDefaultDayCycle; } - void setUsesDefaultDayCycle(bool isdefault) { mIsDefaultDayCycle = isdefault; } - LLSettingsDay::ptr_t getParcelDayCycle() const { return mDayCycle; } - void setParcelDayCycle(const LLSettingsDay::ptr_t &pday) { mDayCycle = pday; } - size_t getParcelDayCycleHash() const { return mDayCycleHash; } - void setParcelDayCycleHash(size_t hash) { mDayCycleHash = hash; } - void clearParcelDayCycleInfo(); protected: LLUUID mID; @@ -677,11 +665,7 @@ protected: BOOL mAllowGroupAVSounds; BOOL mAllowAnyAVSounds; - S64Seconds mDayLength; - S64Seconds mDayOffset; bool mIsDefaultDayCycle; - LLSettingsDay::ptr_t mDayCycle; - size_t mDayCycleHash; public: // HACK, make private diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index a35504e0e6..ffeae8677f 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -592,12 +592,12 @@ void LLSettingsBlender::update(F64Seconds timedelta) { 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; } F64 blendf = fmod(mTimeSpent.value(), mSeconds.value()) / mSeconds.value(); + //_WARNS("LAPRAS") << "blending at " << (blendf * 100.0f) << "%" << LL_ENDL; mTarget->replaceSettings(mInitial->getSettings()); mTarget->blend(mFinal, blendf); } diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index fa5fb7a763..f5146b1c27 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -253,7 +253,6 @@ public: mFinal(endsetting), mSeconds(seconds), mOnFinished(), - mBlendThreshold(DEFAULT_THRESHOLD), mLastUpdate(0.0f), mTimeSpent(0.0f) { @@ -264,11 +263,11 @@ public: ~LLSettingsBlender() {} - void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 seconds ) + void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64Seconds seconds ) { mInitial = initsetting; mFinal = endsetting; - mSeconds.value(seconds); + mSeconds = seconds; mTarget->replaceSettings(mInitial->getSettings()); mTimeStart.value(LLDate::now().secondsSinceEpoch()); mLastUpdate = mTimeStart; @@ -280,16 +279,6 @@ public: return mOnFinished.connect(onfinished); } - void setUpdateThreshold(F64Seconds threshold) - { - mBlendThreshold = threshold; - } - - F64Seconds getUpdateThreshold() const - { - return mBlendThreshold; - } - LLSettingsBase::ptr_t getTarget() const { return mTarget; @@ -306,13 +295,13 @@ public: } void update(F64Seconds time); + private: LLSettingsBase::ptr_t mTarget; LLSettingsBase::ptr_t mInitial; LLSettingsBase::ptr_t mFinal; F64Seconds mSeconds; finish_signal_t mOnFinished; - F64Seconds mBlendThreshold; F64Seconds mLastUpdate; F64Seconds mTimeSpent; F64Seconds mTimeStart; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 1b992ff313..9b0a6c1127 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -96,7 +96,6 @@ namespace } //========================================================================= -const std::string LLSettingsDay::SETTING_DAYLENGTH("day_length"); const std::string LLSettingsDay::SETTING_KEYID("key_id"); const std::string LLSettingsDay::SETTING_KEYNAME("key_name"); const std::string LLSettingsDay::SETTING_KEYKFRAME("key_keyframe"); @@ -104,13 +103,13 @@ const std::string LLSettingsDay::SETTING_KEYHASH("key_hash"); const std::string LLSettingsDay::SETTING_TRACKS("tracks"); const std::string LLSettingsDay::SETTING_FRAMES("frames"); -const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 300); // 5 mins -const S64 LLSettingsDay::DEFAULT_DAYLENGTH( 14400); // 4 hours -const S64 LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days +const S64Seconds LLSettingsDay::MINIMUM_DAYLENGTH(300); // 5 mins +const S64Seconds LLSettingsDay::DEFAULT_DAYLENGTH(14400); // 4 hours +const S64Seconds LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days -const S32 LLSettingsDay::MINIMUM_DAYOFFSET( 0); -const S32 LLSettingsDay::DEFAULT_DAYOFFSET(57600); // +16 hours == -8 hours (SLT time offset) -const S32 LLSettingsDay::MAXIMUM_DAYOFFSET(86400); // 24 hours +const S64Seconds LLSettingsDay::MINIMUM_DAYOFFSET(0); +const S64Seconds LLSettingsDay::DEFAULT_DAYOFFSET(57600); // +16 hours == -8 hours (SLT time offset) +const S64Seconds LLSettingsDay::MAXIMUM_DAYOFFSET(86400); // 24 hours const S32 LLSettingsDay::TRACK_WATER(0); // water track is 0 const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water @@ -119,18 +118,14 @@ const S32 LLSettingsDay::FRAME_MAX(56); //========================================================================= LLSettingsDay::LLSettingsDay(const LLSD &data) : LLSettingsBase(data), - mInitialized(false), - mDayLength(DEFAULT_DAYLENGTH), - mDayOffset(DEFAULT_DAYOFFSET) + mInitialized(false) { mDayTracks.resize(TRACK_MAX); } LLSettingsDay::LLSettingsDay() : LLSettingsBase(), - mInitialized(false), - mDayLength(DEFAULT_DAYLENGTH), - mDayOffset(DEFAULT_DAYOFFSET) + mInitialized(false) { mDayTracks.resize(TRACK_MAX); } @@ -287,7 +282,6 @@ LLSD LLSettingsDay::defaults() LLSD dfltsetting; dfltsetting[SETTING_NAME] = "_default_"; - dfltsetting[SETTING_DAYLENGTH] = static_cast(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_"))); @@ -376,12 +370,10 @@ namespace LLSD frame = (*itf).second; std::string ftype = frame[LLSettingsBase::SETTING_TYPE]; - LL_WARNS("LAPRAS") << "Validating frame: " << frame << LL_ENDL; if (ftype == "sky") { LLSettingsSky::validation_list_t valid_sky = LLSettingsSky::validationList(); LLSD res_sky = LLSettingsSky::settingValidation(frame, valid_sky); - LL_WARNS("SETTINGS") << "'" << (*itf).first << "' res=" << res_sky << LL_ENDL; if (res_sky["success"].asInteger() == 0) { @@ -395,7 +387,6 @@ namespace { LLSettingsWater::validation_list_t valid_h2o = LLSettingsWater::validationList(); LLSD res_h2o = LLSettingsWater::settingValidation(frame, valid_h2o); - LL_WARNS("SETTINGS") << "'" << (*itf).first << "' res=" << res_h2o << LL_ENDL; if (res_h2o["success"].asInteger() == 0) { LL_WARNS("SETTINGS") << "Water setting named '" << (*itf).first << "' validation failed!: " << res_h2o << LL_ENDL; @@ -456,23 +447,6 @@ LLSettingsDay::CycleTrack_t &LLSettingsDay::getCycleTrack(S32 track) return mDayTracks[track]; } -//========================================================================= -F32 LLSettingsDay::secondsToKeyframe(S64Seconds seconds) -{ - S64Seconds daylength = getDayLength(); - S64Seconds dayoffset = getDayOffset(); - - return llclamp(static_cast((seconds.value() + dayoffset.value()) % daylength.value()) / static_cast(daylength.value()), 0.0f, 1.0f); -} - -F64Seconds LLSettingsDay::keyframeToSeconds(F32 keyframe) -{ - S64Seconds daylength = getDayLength(); - S64Seconds dayoffset = getDayOffset(); - - return F64Seconds(static_cast(keyframe * static_cast(daylength.value())) - dayoffset.value()); -} - //========================================================================= void LLSettingsDay::startDayCycle() { @@ -484,63 +458,11 @@ void LLSettingsDay::startDayCycle() return; } - // water - if (mDayTracks[0].empty()) - { - mBlendedWater.reset(); - mWaterBlender.reset(); - } - else if (mDayTracks[0].size() == 1) - { - mBlendedWater = boost::static_pointer_cast((*(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 = getDefaultWater(); - mWaterBlender = boost::make_shared(mBlendedWater, - (*bounds.first).second, (*bounds.second).second, timespan); - mWaterBlender->setOnFinished(boost::bind(&LLSettingsDay::onWaterTransitionDone, this, _1)); - } - - // sky - if (mDayTracks[1].empty()) - { - mBlendedSky.reset(); - mSkyBlender.reset(); - } - else if (mDayTracks[1].size() == 1) - { - mBlendedSky = boost::static_pointer_cast( (*(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 = getDefaultSky(); - mSkyBlender = boost::make_shared(mBlendedSky, - (*bounds.first).second, (*bounds.second).second, timespan); - mSkyBlender->setOnFinished(boost::bind(&LLSettingsDay::onSkyTransitionDone, this, 1, _1)); - } } void LLSettingsDay::updateSettings() { - static LLFrameTimer timer; - - F64Seconds delta(timer.getElapsedTimeAndResetF32()); - - if (mSkyBlender) - mSkyBlender->update(delta); - if (mWaterBlender) - mWaterBlender->update(delta); } //========================================================================= @@ -565,30 +487,6 @@ LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno) return keyframes; } -LLSettingsDay::TimeList_t LLSettingsDay::getTrackTimes(S32 trackno) -{ - KeyframeList_t keyframes = getTrackKeyframes(trackno); - - if (keyframes.empty()) - return TimeList_t(); - - TimeList_t times; - - times.reserve(keyframes.size()); - for (KeyframeList_t::iterator it = keyframes.begin(); it != keyframes.end(); ++it) - { - times.push_back(keyframeToSeconds(*it)); - } - - return times; -} - -void LLSettingsDay::setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds) -{ - F32 keyframe = secondsToKeyframe(seconds); - setWaterAtKeyframe(water, keyframe); -} - void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe) { mDayTracks[TRACK_WATER][llclamp(keyframe, 0.0f, 1.0f)] = water; @@ -596,12 +494,6 @@ void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 ke } -void LLSettingsDay::setSkyAtTime(const LLSettingsSkyPtr_t &sky, S64Seconds seconds, S32 track) -{ - F32 keyframe = secondsToKeyframe(seconds); - setSkyAtKeyframe(sky, keyframe, track); -} - void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track) { if ((track < 1) || (track >= TRACK_MAX)) @@ -619,40 +511,4 @@ LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::Cyc return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); } -LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F64Seconds time) -{ - F32 frame = secondsToKeyframe(time); - - return getBoundingEntries(track, frame); -} - //========================================================================= -void LLSettingsDay::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_DEBUGS("DAYCYCLE") << "New sky blender. now=" << now << - " start=" << (*bounds.first).first << " end=" << (*bounds.second).first << - " span=" << timespan << LL_ENDL; - - mSkyBlender = boost::make_shared(mBlendedSky, - (*bounds.first).second, (*bounds.second).second, timespan); - mSkyBlender->setOnFinished(boost::bind(&LLSettingsDay::onSkyTransitionDone, this, track, _1)); -} - -void LLSettingsDay::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(mBlendedWater, - (*bounds.first).second, (*bounds.second).second, timespan); - mWaterBlender->setOnFinished(boost::bind(&LLSettingsDay::onWaterTransitionDone, this, _1)); -} diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 4a7bc02871..8a1634d674 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -39,7 +39,6 @@ typedef boost::shared_ptr LLSettingsSkyPtr_t; class LLSettingsDay : public LLSettingsBase { public: - static const std::string SETTING_DAYLENGTH; static const std::string SETTING_KEYID; static const std::string SETTING_KEYNAME; static const std::string SETTING_KEYKFRAME; @@ -47,13 +46,13 @@ public: static const std::string SETTING_TRACKS; static const std::string SETTING_FRAMES; - static const S64 MINIMUM_DAYLENGTH; - static const S64 DEFAULT_DAYLENGTH; - static const S64 MAXIMUM_DAYLENGTH; + static const S64Seconds MINIMUM_DAYLENGTH; + static const S64Seconds DEFAULT_DAYLENGTH; + static const S64Seconds MAXIMUM_DAYLENGTH; - static const S32 MINIMUM_DAYOFFSET; - static const S32 DEFAULT_DAYOFFSET; - static const S32 MAXIMUM_DAYOFFSET; + static const S64Seconds MINIMUM_DAYOFFSET; + static const S64Seconds DEFAULT_DAYOFFSET; + static const S64Seconds MAXIMUM_DAYOFFSET; static const S32 TRACK_WATER; static const S32 TRACK_MAX; @@ -62,7 +61,6 @@ public: typedef std::map CycleTrack_t; typedef std::vector CycleList_t; typedef boost::shared_ptr ptr_t; - typedef std::vector TimeList_t; typedef std::vector KeyframeList_t; typedef std::pair TrackBound_t; @@ -86,26 +84,12 @@ public: //--------------------------------------------------------------------- KeyframeList_t getTrackKeyframes(S32 track); - TimeList_t getTrackTimes(S32 track); - void setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds); void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe); - - 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; - } - virtual LLSettingsSkyPtr_t getDefaultSky() const = 0; virtual LLSettingsWaterPtr_t getDefaultWater() const = 0; @@ -121,11 +105,6 @@ public: virtual validation_list_t getValidationList() const; static validation_list_t validationList(); - S64Seconds getDayLength() const { return mDayLength; } - void setDayLength(S64Seconds val ) { mDayLength = val; } - S64Seconds getDayOffset() const { return mDayOffset; } - void setDayOffset(S64Seconds val) { mDayOffset = val; } - protected: LLSettingsDay(); @@ -134,32 +113,19 @@ protected: bool mInitialized; private: - LLSettingsBlender::ptr_t mSkyBlender; // convert to [] for altitudes - LLSettingsBlender::ptr_t mWaterBlender; - - LLSettingsSkyPtr_t mBlendedSky; - LLSettingsWaterPtr_t mBlendedWater; - CycleList_t mDayTracks; F64Seconds mLastUpdateTime; - S64Seconds mDayLength; - S64Seconds mDayOffset; - - F32 secondsToKeyframe(S64Seconds seconds); - F64Seconds keyframeToSeconds(F32 keyframe); - void parseFromLLSD(LLSD &data); static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 keyframe); static CycleTrack_t::iterator getEntryAtOrAfter(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); +// void onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender); +// void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender); }; diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index c02d99fb67..32b292e384 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -265,7 +265,7 @@ LLSD LLSettingsSky::defaults() dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 0.0).getValue(); dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue(); - dfltsetting[SETTING_BLOOM_TEXTUREID] = LLUUID::null; + dfltsetting[SETTING_BLOOM_TEXTUREID] = IMG_BLOOM1; dfltsetting[SETTING_CLOUD_TEXTUREID] = LLUUID::null; dfltsetting[SETTING_MOON_TEXTUREID] = IMG_MOON; // gMoonTextureID; // These two are returned by the login... wow! dfltsetting[SETTING_SUN_TEXUTUREID] = IMG_SUN; // gSunTextureID; diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 25c7fb89db..db8fd570c0 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -83,28 +83,26 @@ LLEnvironment::LLEnvironment(): mDayCycleByName(), mDayCycleById(), mUserPrefs(), - mSelectedEnvironment(ENV_LOCAL), - mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), - mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET) + mSelectedEnvironment(LLEnvironment::ENV_LOCAL) { - mSetSkys.resize(ENV_END); - mSetWater.resize(ENV_END); - mSetDays.resize(ENV_END); } void LLEnvironment::initSingleton() { LLSettingsSky::ptr_t p_default_sky = LLSettingsVOSky::buildDefaultSky(); addSky(p_default_sky); - mCurrentSky = p_default_sky; LLSettingsWater::ptr_t p_default_water = LLSettingsVOWater::buildDefaultWater(); addWater(p_default_water); - mCurrentWater = p_default_water; LLSettingsDay::ptr_t p_default_day = LLSettingsVODay::buildDefaultDayCycle(); addDayCycle(p_default_day); - mCurrentDay.reset(); + + mCurrentEnvironment = boost::make_shared(); + mCurrentEnvironment->setSky(p_default_sky); + mCurrentEnvironment->setWater(p_default_water); + + mEnvironments[ENV_DEFAULT] = mCurrentEnvironment; // LEGACY! legacyLoadAllPresets(); @@ -181,17 +179,16 @@ void LLEnvironment::onLegacyRegionSettings(LLSD data) else regionday = LLSettingsVODay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); - setSkyFor(ENV_REGION, LLSettingsSky::ptr_t()); - setWaterFor(ENV_REGION, LLSettingsWater::ptr_t()); - setDayFor(ENV_REGION, regionday); + clearEnvironment(ENV_PARCEL); + setEnvironment(ENV_REGION, regionday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); - applyChosenEnvironment(); + updateEnvironment(); } //------------------------------------------------------------------------- F32 LLEnvironment::getCamHeight() const { - return (mCurrentSky->getDomeOffset() * mCurrentSky->getDomeRadius()); + return (mCurrentEnvironment->getSky()->getDomeOffset() * mCurrentEnvironment->getSky()->getDomeRadius()); } F32 LLEnvironment::getWaterHeight() const @@ -201,21 +198,191 @@ F32 LLEnvironment::getWaterHeight() const bool LLEnvironment::getIsDayTime() const { - return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; + return mCurrentEnvironment->getSky()->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; +} + +//------------------------------------------------------------------------- +void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, F64Seconds transition) +{ + mSelectedEnvironment = env; + updateEnvironment(transition); +} + +bool LLEnvironment::hasEnvironment(LLEnvironment::EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env >= ENV_DEFAULT) || (!mEnvironments[env])) + { + return false; + } + + return true; +} + +LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnvironment::EnvSelection_t env, bool create /*= false*/) +{ + DayInstance::ptr_t environment = mEnvironments[env]; + if (!environment && create) + { + environment = boost::make_shared(); + mEnvironments[env] = environment; + } + + return environment; +} + + +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset) +{ + if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to change invalid environment selection." << LL_ENDL; + return; + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env, true); + + environment->clear(); + environment->setDay(pday, daylength, dayoffset); + environment->animate(); + /*TODO: readjust environment*/ +} + + +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironment::fixedEnvironment_t fixed) +{ + if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to change invalid environment selection." << LL_ENDL; + return; + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env, true); + + environment->clear(); + environment->setSky((fixed.first) ? fixed.first : mEnvironments[ENV_DEFAULT]->getSky()); + environment->setWater((fixed.second) ? fixed.second : mEnvironments[ENV_DEFAULT]->getWater()); + + /*TODO: readjust environment*/ +} + + +void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env >= ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to change invalid environment selection." << LL_ENDL; + return; + } + + mEnvironments[env].reset(); + /*TODO: readjust environment*/ } -void LLEnvironment::setDayLength(S64Seconds seconds) +LLSettingsDay::ptr_t LLEnvironment::getEnvironmentDay(LLEnvironment::EnvSelection_t env) { - mDayLength = seconds; - if (mCurrentDay) - mCurrentDay->setDayLength(mDayLength); + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; + return LLSettingsDay::ptr_t(); + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env); + + if (environment) + return environment->getDayCycle(); + + return LLSettingsDay::ptr_t(); +} + +S64Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; + return S64Seconds(0); + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env); + + if (environment) + return environment->getDayLength(); + + return S64Seconds(0); +} + +S64Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; + return S64Seconds(0); + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env); + if (environment) + return environment->getDayOffset(); + + return S64Seconds(0); +} + + +LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironment::EnvSelection_t env) +{ + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) + { + LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; + return fixedEnvironment_t(); + } + + DayInstance::ptr_t environment = getEnvironmentInstance(env); + + if (environment) + return fixedEnvironment_t(environment->getSky(), environment->getWater()); + + return fixedEnvironment_t(); +} + +LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance() +{ + for (S32 idx = mSelectedEnvironment; idx < ENV_DEFAULT; ++idx) + { + if (mEnvironments[idx]) + return mEnvironments[idx]; + } + + return mEnvironments[ENV_DEFAULT]; +} + + +void LLEnvironment::updateEnvironment(F64Seconds transition) +{ + DayInstance::ptr_t pinstance = getSelectedEnvironmentInstance(); + + if (mCurrentEnvironment != pinstance) + { + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + LLSettingsWater::ptr_t pwater = mCurrentEnvironment->getWater(); + + LLSettingsSky::ptr_t ptargetsky = psky->buildClone(); + LLSettingsWater::ptr_t ptargetwater = pwater->buildClone(); + + LLSettingsBlender::ptr_t skyblend = boost::make_shared(ptargetsky, psky, pinstance->getSky(), transition); + skyblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, true)); + LLSettingsBlender::ptr_t waterblend = boost::make_shared(ptargetwater, pwater, pinstance->getWater(), transition); + waterblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, false)); + + pinstance->setBlenders(skyblend, waterblend); + + mCurrentEnvironment = pinstance; + + mCurrentEnvironment->animate(); + } } -void LLEnvironment::setDayOffset(S64Seconds seconds) +void LLEnvironment::onTransitionDone(const LLSettingsBlender::ptr_t &blender, bool isSky) { - mDayOffset = seconds; - if (mCurrentDay) - mCurrentDay->setDayOffset(seconds); + /*TODO: Test for both sky and water*/ + mCurrentEnvironment->animate(); } //------------------------------------------------------------------------- @@ -227,21 +394,28 @@ void LLEnvironment::update(const LLViewerCamera * cam) F32Seconds delta(timer.getElapsedTimeAndResetF32()); - if (mBlenderSky) - mBlenderSky->update(delta); - if (mBlenderWater) - mBlenderWater->update(delta); + for (InstanceArray_t::iterator it = mEnvironments.begin(); it != mEnvironments.end(); ++it) + { + if (*it) + (*it)->update(delta); + } // update clouds, sun, and general updateCloudScroll(); - if (mCurrentDay) - mCurrentDay->update(); - - if (mCurrentSky) - mCurrentSky->update(); - if (mCurrentWater) - mCurrentWater->update(); +// if (mBlenderSky) +// mBlenderSky->update(delta); +// if (mBlenderWater) +// mBlenderWater->update(delta); +// +// +// if (mCurrentDay) +// mCurrentDay->update(); +// +// if (mCurrentEnvironment->getSky()) +// mCurrentEnvironment->getSky()->update(); +// if (mCurrentEnvironment->getWater()) +// mCurrentEnvironment->getWater()->update(); F32 camYaw = cam->getYaw(); @@ -277,10 +451,11 @@ void LLEnvironment::updateCloudScroll() F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); - LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; - mCloudScrollDelta += cloud_delta; - - + if (mCurrentEnvironment->getSky()) + { + LLVector2 cloud_delta = static_cast(delta_t)* (mCurrentEnvironment->getSky()->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0; + mCloudScrollDelta += cloud_delta; + } } @@ -352,11 +527,10 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) { - if (gPipeline.canUseWindLightShaders()) { - updateGLVariablesForSettings(shader, mCurrentSky); - updateGLVariablesForSettings(shader, mCurrentWater); + updateGLVariablesForSettings(shader, mCurrentEnvironment->getSky()); + updateGLVariablesForSettings(shader, mCurrentEnvironment->getWater()); } if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) @@ -374,237 +548,8 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) } shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, getSceneLightStrength()); - - -} -//-------------------------------------------------------------------------- -void LLEnvironment::selectSky(const std::string &name, F32Seconds transition) -{ - LLSettingsSky::ptr_t next_sky = findSkyByName(name); - if (!next_sky) - { - LL_WARNS("ENVIRONMENT") << "Unable to select sky with unknown name '" << name << "'" << LL_ENDL; - return; - } - - selectSky(next_sky, transition); -} - -void LLEnvironment::selectSky(const LLSettingsSky::ptr_t &sky, F32Seconds transition) -{ - if (!sky) - { - mCurrentSky = mSelectedSky; - mBlenderSky.reset(); - return; - } - mSelectedSky = sky; - if (fabs(transition.value()) <= F_ALMOST_ZERO) - { - mBlenderSky.reset(); - mCurrentSky = sky; - mCurrentSky->setDirtyFlag(true); - mSelectedSky = sky; - } - else - { - LLSettingsSky::ptr_t skytarget = mCurrentSky->buildClone(); - - mBlenderSky = boost::make_shared( skytarget, mCurrentSky, sky, transition ); - mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::onSkyTransitionDone, this, _1)); - mCurrentSky = skytarget; - mSelectedSky = sky; - } -} - -void LLEnvironment::onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender) -{ - mCurrentSky = mSelectedSky; - mBlenderSky.reset(); -} - -void LLEnvironment::selectWater(const std::string &name, F32Seconds transition) -{ - LLSettingsWater::ptr_t next_water = findWaterByName(name); - - if (!next_water) - { - LL_WARNS("ENVIRONMENT") << "Unable to select water with unknown name '" << name << "'" << LL_ENDL; - return; - } - - selectWater(next_water, transition); -} - -void LLEnvironment::selectWater(const LLSettingsWater::ptr_t &water, F32Seconds transition) -{ - if (!water) - { - mCurrentWater = mSelectedWater; - mBlenderWater.reset(); - return; - } - mSelectedWater = water; - if (fabs(transition.value()) <= F_ALMOST_ZERO) - { - mBlenderWater.reset(); - mCurrentWater = water; - mCurrentWater->setDirtyFlag(true); - mSelectedWater = water; - } - else - { - LLSettingsWater::ptr_t watertarget = mCurrentWater->buildClone(); - - mBlenderWater = boost::make_shared(watertarget, mCurrentWater, water, transition); - mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::onWaterTransitionDone, this, _1)); - mCurrentWater = watertarget; - mSelectedWater = water; - } -} - -void LLEnvironment::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender) -{ - mCurrentWater = mSelectedWater; - mBlenderWater.reset(); -} - -void LLEnvironment::selectDayCycle(const std::string &name, F32Seconds transition) -{ - LLSettingsDay::ptr_t next_daycycle = findDayCycleByName(name); - - if (!next_daycycle) - { - LL_WARNS("ENVIRONMENT") << "Unable to select daycycle with unknown name '" << name << "'" << LL_ENDL; - return; - } - - selectDayCycle(next_daycycle, transition); -} - -void LLEnvironment::selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seconds transition) -{ - if (!daycycle || (daycycle == mCurrentDay)) - { - return; - } - - mCurrentDay = daycycle; - mCurrentDay->setDayLength(mDayLength); - mCurrentDay->setDayOffset(mDayOffset); - - daycycle->startDayCycle(); - selectWater(daycycle->getCurrentWater(), transition); - selectSky(daycycle->getCurrentSky(), transition); -} - - -void LLEnvironment::setSelectedEnvironment(EnvSelection_t env) -{ - if (env == mSelectedEnvironment) - { // No action to take - return; - } - - mSelectedEnvironment = env; - applyChosenEnvironment(); -} - -void LLEnvironment::applyChosenEnvironment() -{ - mSelectedSky.reset(); - mSelectedWater.reset(); - mSelectedDay.reset(); - - for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) - { - if (mSetDays[idx] && !mSelectedSky && !mSelectedWater) - selectDayCycle(mSetDays[idx]); - if (mSetSkys[idx] && !mSelectedSky) - selectSky(mSetSkys[idx]); - if (mSetWater[idx] && !mSelectedWater) - selectWater(mSetWater[idx]); - if (mSelectedSky && mSelectedWater) - return; - } - - if (!mSelectedSky) - selectSky("Default"); - if (!mSelectedWater) - selectWater("Default"); -} - -LLSettingsSky::ptr_t LLEnvironment::getChosenSky() const -{ - for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) - { - if (mSetSkys[idx]) - return mSetSkys[idx]; - } - - return LLSettingsSky::ptr_t(); -} - -LLSettingsWater::ptr_t LLEnvironment::getChosenWater() const -{ - for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) - { - if (mSetWater[idx]) - return mSetWater[idx]; - } - - return LLSettingsWater::ptr_t(); -} - -LLSettingsDay::ptr_t LLEnvironment::getChosenDay() const -{ - for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) - { - if (mSetDays[idx]) - return mSetDays[idx]; - } - - return LLSettingsDay::ptr_t(); -} - -void LLEnvironment::setSkyFor(EnvSelection_t env, const LLSettingsSky::ptr_t &sky) -{ - mSetSkys[env] = sky; -} - -LLSettingsSky::ptr_t LLEnvironment::getSkyFor(EnvSelection_t env) const -{ - return mSetSkys[env]; -} - -void LLEnvironment::setWaterFor(EnvSelection_t env, const LLSettingsWater::ptr_t &water) -{ - mSetWater[env] = water; -} - -LLSettingsWater::ptr_t LLEnvironment::getWaterFor(EnvSelection_t env) const -{ - return mSetWater[env]; -} - -void LLEnvironment::setDayFor(EnvSelection_t env, const LLSettingsDay::ptr_t &day) -{ - mSetDays[env] = day; -} - -LLSettingsDay::ptr_t LLEnvironment::getDayFor(EnvSelection_t env) const -{ - return mSetDays[env]; -} - -void LLEnvironment::clearUserSettings() -{ - mSetSkys[ENV_LOCAL].reset(); - mSetWater[ENV_LOCAL].reset(); - mSetDays[ENV_LOCAL].reset(); } - LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const { list_name_id_t list; @@ -778,42 +723,6 @@ LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const } -void LLEnvironment::selectAgentEnvironment() -{ - S64Seconds day_length(LLSettingsDay::DEFAULT_DAYLENGTH); - S64Seconds day_offset(LLSettingsDay::DEFAULT_DAYOFFSET); - LLSettingsDay::ptr_t pday; - - // TODO: Test if editing environment has been set. - - // TODO: Test if agent has local environment set. - - LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); - LLViewerRegion *pRegion = gAgent.getRegion(); - - if (!parcel || parcel->getUsesDefaultDayCycle() || !parcel->getParcelDayCycle()) - { - day_length = pRegion->getDayLength(); - day_offset = pRegion->getDayOffset(); - pday = pRegion->getRegionDayCycle(); - } - else - { - day_length = parcel->getDayLength(); - day_offset = parcel->getDayOffset(); - pday = parcel->getParcelDayCycle(); - } - - if (getDayLength() != day_length) - setDayLength(day_length); - - if (getDayOffset() != day_offset) - setDayOffset(day_offset); - - if (pday) - selectDayCycle(pday); -} - void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo) { LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; @@ -824,48 +733,65 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI if (envinfo->mParcelId == INVALID_PARCEL_ID) { // the returned info applies to an entire region. - LLViewerRegion *pRegion = gAgent.getRegion(); - - pRegion->setDayLength(envinfo->mDayLength); - pRegion->setDayOffset(envinfo->mDayOffset); - pRegion->setIsDefaultDayCycle(envinfo->mIsDefault); - if (pRegion->getRegionDayCycleHash() != envinfo->mDayHash) - { - pRegion->setRegionDayCycle(pday); - pRegion->setRegionDayCycleHash(envinfo->mDayHash); - } - + LL_WARNS("LAPRAS") << "Setting Region environment" << LL_ENDL; + setEnvironment(ENV_REGION, pday, envinfo->mDayLength, envinfo->mDayOffset); if (parcel_id != INVALID_PARCEL_ID) - { // We requested a parcel environment but got back the region's. If this is the parcel we are in - // clear it out. - LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); - - if (parcel->getLocalID() == parcel_id) - { - parcel->clearParcelDayCycleInfo(); - } + { + LL_WARNS("LAPRAS") << "Had requested parcel environment #" << parcel_id << " but got region." << LL_ENDL; + clearEnvironment(ENV_PARCEL); } +// LLViewerRegion *pRegion = gAgent.getRegion(); +// +// pRegion->setDayLength(envinfo->mDayLength); +// pRegion->setDayOffset(envinfo->mDayOffset); +// pRegion->setIsDefaultDayCycle(envinfo->mIsDefault); +// if (pRegion->getRegionDayCycleHash() != envinfo->mDayHash) +// { +// pRegion->setRegionDayCycle(pday); +// pRegion->setRegionDayCycleHash(envinfo->mDayHash); +// } +// +// if (parcel_id != INVALID_PARCEL_ID) +// { // We requested a parcel environment but got back the region's. If this is the parcel we are in +// // clear it out. +// LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); +// +// if (parcel->getLocalID() == parcel_id) +// { +// parcel->clearParcelDayCycleInfo(); +// } +// } } else { LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); - if (parcel->getLocalID() == parcel_id) + LL_WARNS("LAPRAS") << "Have parcel environment #" << envinfo->mParcelId << LL_ENDL; + if (parcel && (parcel->getLocalID() != parcel_id)) { - parcel->setDayLength(envinfo->mDayLength); - parcel->setDayOffset(envinfo->mDayOffset); - parcel->setUsesDefaultDayCycle(envinfo->mIsDefault); - if (parcel->getParcelDayCycleHash() != envinfo->mDayHash) - { - parcel->setParcelDayCycle(pday); - parcel->setParcelDayCycleHash(envinfo->mDayHash); - } - + LL_WARNS("ENVIRONMENT") << "Requested parcel #" << parcel_id << " agent is on " << parcel->getLocalID() << LL_ENDL; + return; } + + setEnvironment(ENV_PARCEL, pday, envinfo->mDayLength, envinfo->mDayOffset); +// LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); +// +// if (parcel->getLocalID() == parcel_id) +// { +// parcel->setDayLength(envinfo->mDayLength); +// parcel->setDayOffset(envinfo->mDayOffset); +// parcel->setUsesDefaultDayCycle(envinfo->mIsDefault); +// if (parcel->getParcelDayCycleHash() != envinfo->mDayHash) +// { +// parcel->setParcelDayCycle(pday); +// parcel->setParcelDayCycleHash(envinfo->mDayHash); +// } +// +// } } /*TODO: track_altitudes*/ - selectAgentEnvironment(); + updateEnvironment(); } //========================================================================= @@ -1337,3 +1263,250 @@ void LLEnvironment::legacyLoadAllPresets() } } } + +//========================================================================= +namespace +{ + inline F32 get_wrapping_distance(F32 begin, F32 end) + { + if (begin < end) + { + return end - begin; + } + else if (begin > end) + { + return 1.0 - (begin - end); + } + + return 0; + } + + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key) + { + if (collection.empty()) + return collection.end(); + + LLSettingsDay::CycleTrack_t::iterator it = collection.upper_bound(key); + + if (it == collection.end()) + { // wrap around + it = collection.begin(); + } + + return it; + } + + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key) + { + if (collection.empty()) + return collection.end(); + + LLSettingsDay::CycleTrack_t::iterator it = collection.lower_bound(key); + + if (it == collection.end()) + { // all keyframes are lower, take the last one. + --it; // we know the range is not empty + } + else if ((*it).first > key) + { // the keyframe we are interested in is smaller than the found. + if (it == collection.begin()) + it = collection.end(); + --it; + } + + return it; + } + + LLSettingsDay::TrackBound_t get_bounding_entries(LLSettingsDay::CycleTrack_t &track, F32 keyframe) + { + return LLSettingsDay::TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); + } + +} +//========================================================================= + + +LLEnvironment::DayInstance::DayInstance() : + mDayCycle(), + mSky(), + mWater(), + mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), + mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET), + mBlenderSky(), + mBlenderWater(), + mInitialized(false), + mType(TYPE_INVALID) +{ } + +void LLEnvironment::DayInstance::update(F64Seconds delta) +{ + if (!mInitialized) + initialize(); + + if (mBlenderSky) + mBlenderSky->update(delta); + if (mBlenderWater) + mBlenderWater->update(delta); + + if (mSky) + mSky->update(); + if (mWater) + mWater->update(); +} + +void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset) +{ + if (mType == TYPE_FIXED) + LL_WARNS("ENVIRONMENT") << "Fixed day instance changed to Cycled" << LL_ENDL; + mType = TYPE_CYCLED; + mInitialized = false; + + mDayCycle = pday; + mDayLength = daylength; + mDayOffset = dayoffset; + + mBlenderSky.reset(); + mBlenderWater.reset(); + + mSky = LLSettingsVOSky::buildDefaultSky(); + mWater = LLSettingsVOWater::buildDefaultWater(); + + animate(); +} + + +void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) +{ + if (mType == TYPE_CYCLED) + LL_WARNS("ENVIRONMENT") << "Cycled day instance changed to FIXED" << LL_ENDL; + mType = TYPE_FIXED; + mInitialized = false; + + mSky = psky; + mBlenderSky.reset(); +} + +void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) +{ + if (mType == TYPE_CYCLED) + LL_WARNS("ENVIRONMENT") << "Cycled day instance changed to FIXED" << LL_ENDL; + mType = TYPE_FIXED; + mInitialized = false; + + mWater = pwater; + mBlenderWater.reset(); +} + +void LLEnvironment::DayInstance::initialize() +{ + mInitialized = true; + + if (!mWater) + mWater = LLSettingsVOWater::buildDefaultWater(); + if (!mSky) + mSky = LLSettingsVOSky::buildDefaultSky(); +} + +void LLEnvironment::DayInstance::clear() +{ + mType = TYPE_INVALID; + mDayCycle.reset(); + mSky.reset(); + mWater.reset(); + mDayLength = LLSettingsDay::DEFAULT_DAYLENGTH; + mDayOffset = LLSettingsDay::DEFAULT_DAYOFFSET; + mBlenderSky.reset(); + mBlenderWater.reset(); +} + +void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &skyblend, const LLSettingsBlender::ptr_t &waterblend) +{ + mBlenderSky = skyblend; + mBlenderWater = waterblend; +} + +F64 LLEnvironment::DayInstance::secondsToKeyframe(S64Seconds seconds) +{ + F64 frame = static_cast(seconds.value() % mDayLength.value()) / static_cast(mDayLength.value()); + + return llclamp(frame, 0.0, 1.0); +} + +void LLEnvironment::DayInstance::animate() +{ + F64Seconds now(LLDate::now().secondsSinceEpoch()); + + now += mDayOffset; + + if (!mDayCycle) + return; + + LLSettingsDay::CycleTrack_t &wtrack = mDayCycle->getCycleTrack(0); + + if (wtrack.empty()) + { + mWater.reset(); + mBlenderWater.reset(); + } + else if (wtrack.size() == 1) + { + mWater = boost::static_pointer_cast((*(wtrack.begin())).second); + mBlenderWater.reset(); + } + else + { + LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, secondsToKeyframe(now)); + F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + + mWater = boost::static_pointer_cast((*bounds.first).second)->buildClone(); + mBlenderWater = boost::make_shared(mWater, + (*bounds.first).second, (*bounds.second).second, timespan); + mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::DayInstance::onTrackTransitionDone, this, 0, _1)); + } + + // Day track 1 only for the moment + // sky + LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(1); + + if (track.empty()) + { + mSky.reset(); + mBlenderSky.reset(); + } + else if (track.size() == 1) + { + mSky = boost::static_pointer_cast((*(track.begin())).second); + mBlenderSky.reset(); + } + else + { + LLSettingsDay::TrackBound_t bounds = get_bounding_entries(track, secondsToKeyframe(now)); + F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + + mSky = boost::static_pointer_cast((*bounds.first).second)->buildClone(); + mBlenderSky = boost::make_shared(mSky, + (*bounds.first).second, (*bounds.second).second, timespan); + mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::DayInstance::onTrackTransitionDone, this, 1, _1)); + } +} + +void LLEnvironment::DayInstance::onTrackTransitionDone(S32 trackno, const LLSettingsBlender::ptr_t &blender) +{ + LL_WARNS("LAPRAS") << "onTrackTransitionDone for " << trackno << LL_ENDL; + F64Seconds now(LLDate::now().secondsSinceEpoch()); + + now += mDayOffset; + + LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(trackno); + + LLSettingsDay::TrackBound_t bounds = get_bounding_entries(track, secondsToKeyframe(now)); + + F32 distance = get_wrapping_distance((*bounds.first).first, (*bounds.second).first); + F64Seconds timespan = mDayLength * distance; + + LL_WARNS("LAPRAS") << "New sky blender. now=" << now << + " start=" << (*bounds.first).first << " end=" << (*bounds.second).first << + " span=" << timespan << LL_ENDL; + + blender->reset((*bounds.first).second, (*bounds.second).second, timespan); +} 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 fixedEnvironment_t; + typedef std::map namedSettingMap_t; typedef std::pair name_id_t; typedef std::vector 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 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 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 SkyList_t; typedef std::vector WaterList_t; typedef std::vector 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 > orphan_list_t; orphan_list_t mOrphanMap; - S64Seconds mDayLength; - S64Seconds mDayOffset; - bool mIsDefaultDayCycle; - LLSettingsDay::ptr_t mDayCycle; - size_t mDayCycleHash; - class CacheMissItem { public: -- cgit v1.3 From b50d546d5ffb520228926ff1f4e6b03c69b3f857 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 3 Aug 2018 16:13:22 -0700 Subject: MAINT-7699: More robust cap protocol, better support for delete and support for individual tracks, support for setting environment by asset id in the cap MAINT-7703: Initial flags sent in message protocol for parcels --- indra/llinventory/llparcel.cpp | 3 + indra/llinventory/llparcel.h | 9 ++ indra/llinventory/llsettingsbase.cpp | 1 - indra/llmessage/message_prehash.cpp | 4 +- indra/llmessage/message_prehash.h | 3 + indra/newview/llenvironment.cpp | 183 ++++++++++++++++++----------- indra/newview/llenvironment.h | 44 ++++--- indra/newview/llsettingsvo.cpp | 2 +- indra/newview/llviewerparcelmgr.cpp | 58 ++++----- scripts/messages/message_template.msg | 5 + scripts/messages/message_template.msg.sha1 | 2 +- 11 files changed, 186 insertions(+), 128 deletions(-) (limited to 'indra/llinventory/llparcel.cpp') diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp index 0908613c10..aff7f86fd4 100644 --- a/indra/llinventory/llparcel.cpp +++ b/indra/llinventory/llparcel.cpp @@ -231,6 +231,9 @@ void LLParcel::init(const LLUUID &owner_id, setAllowGroupAVSounds(TRUE); setAllowAnyAVSounds(TRUE); setHaveNewParcelLimitData(FALSE); + + setRegionAllowEnvironmentOverride(FALSE); + setParcelEnvironmentVersion(-1); } void LLParcel::overrideOwner(const LLUUID& owner_id, BOOL is_group_owned) diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index 6ef389d246..2497a069d7 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -511,6 +511,10 @@ public: { return mRegionDenyAgeUnverifiedOverride; } BOOL getRegionAllowAccessOverride() const { return mRegionAllowAccessoverride; } + BOOL getRegionAllowEnvironmentOverride() const + { return mRegionAllowEnvironmentOverride; } + S32 getParcelEnvironmentVersion() const + { return mCurrentEnvironmentVersion; } BOOL getAllowGroupAVSounds() const { return mAllowGroupAVSounds; } @@ -581,6 +585,9 @@ public: void setRegionDenyAnonymousOverride(BOOL override) { mRegionDenyAnonymousOverride = override; } void setRegionDenyAgeUnverifiedOverride(BOOL override) { mRegionDenyAgeUnverifiedOverride = override; } void setRegionAllowAccessOverride(BOOL override) { mRegionAllowAccessoverride = override; } + void setRegionAllowEnvironmentOverride(BOOL override) { mRegionAllowEnvironmentOverride = override; } + + void setParcelEnvironmentVersion(S32 version) { mCurrentEnvironmentVersion = version; } // Accessors for parcel sellWithObjects void setPreviousOwnerID(LLUUID prev_owner) { mPreviousOwnerID = prev_owner; } @@ -662,8 +669,10 @@ protected: BOOL mRegionDenyAnonymousOverride; BOOL mRegionDenyAgeUnverifiedOverride; BOOL mRegionAllowAccessoverride; + BOOL mRegionAllowEnvironmentOverride; BOOL mAllowGroupAVSounds; BOOL mAllowAnyAVSounds; + S32 mCurrentEnvironmentVersion; bool mIsDefaultDayCycle; diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 8bcf8a4973..e00dd2199c 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -300,7 +300,6 @@ bool LLSettingsBase::validate() { LL_WARNS("SETTINGS") << "Validation warnings: " << result["warnings"] << LL_ENDL; } - LL_WARNS("SETTINGS") << "Validation success is " << result["success"] << LL_ENDL; return result["success"].asBoolean(); } diff --git a/indra/llmessage/message_prehash.cpp b/indra/llmessage/message_prehash.cpp index 1ae8a6ac15..6e5923862b 100644 --- a/indra/llmessage/message_prehash.cpp +++ b/indra/llmessage/message_prehash.cpp @@ -1375,7 +1375,9 @@ char const* const _PREHASH_RegionDenyAgeUnverified = LLMessageStringTable::getIn char const* const _PREHASH_AgeVerificationBlock = LLMessageStringTable::getInstance()->getString("AgeVerificationBlock"); char const* const _PREHASH_RegionAllowAccessBlock = LLMessageStringTable::getInstance()->getString("RegionAllowAccessBlock"); char const* const _PREHASH_RegionAllowAccessOverride = LLMessageStringTable::getInstance()->getString("RegionAllowAccessOverride"); - +char const* const _PREHASH_ParcelEnvironmentBlock = LLMessageStringTable::getInstance()->getString("ParcelEnvironmentBlock"); +char const* const _PREHASH_ParcelEnvironmentVersion = LLMessageStringTable::getInstance()->getString("ParcelEnvironmentVersion"); +char const* const _PREHASH_RegionAllowEnvironmentOverride = LLMessageStringTable::getInstance()->getString("RegionAllowEnvironmentOverride"); char const* const _PREHASH_UCoord = LLMessageStringTable::getInstance()->getString("UCoord"); char const* const _PREHASH_VCoord = LLMessageStringTable::getInstance()->getString("VCoord"); char const* const _PREHASH_FaceIndex = LLMessageStringTable::getInstance()->getString("FaceIndex"); diff --git a/indra/llmessage/message_prehash.h b/indra/llmessage/message_prehash.h index 7910fde305..30763d426e 100644 --- a/indra/llmessage/message_prehash.h +++ b/indra/llmessage/message_prehash.h @@ -1375,6 +1375,9 @@ extern char const* const _PREHASH_RegionDenyAgeUnverified; extern char const* const _PREHASH_AgeVerificationBlock; extern char const* const _PREHASH_RegionAllowAccessBlock; extern char const* const _PREHASH_RegionAllowAccessOverride; +extern char const* const _PREHASH_ParcelEnvironmentBlock; +extern char const* const _PREHASH_ParcelEnvironmentVersion; +extern char const* const _PREHASH_RegionAllowEnvironmentOverride; extern char const* const _PREHASH_UCoord; extern char const* const _PREHASH_VCoord; extern char const* const _PREHASH_FaceIndex; diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index f4dedbc848..3bcdf345f1 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -61,6 +61,18 @@ //========================================================================= namespace { + const std::string KEY_ENVIRONMENT("environment"); + const std::string KEY_DAYASSET("day_asset"); + const std::string KEY_DAYCYCLE("day_cycle"); + const std::string KEY_DAYHASH("day_hash"); + const std::string KEY_DAYLENGTH("day_length"); + const std::string KEY_DAYOFFSET("day_offset"); + const std::string KEY_ISDEFAULT("is_default"); + const std::string KEY_PARCELID("parcel_id"); + const std::string KEY_REGIONID("region_id"); + const std::string KEY_TRACKALTS("track_altitudes"); + + //--------------------------------------------------------------------- LLTrace::BlockTimerStatHandle FTM_ENVIRONMENT_UPDATE("Update Environment Tick"); LLTrace::BlockTimerStatHandle FTM_SHADER_PARAM_UPDATE("Update Shader Parameters"); @@ -254,6 +266,8 @@ const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("07589e0e-8e2e-4864-8e58-07b516efd9 const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("8113ba47-3223-46ba-bae6-12c875091b32"); const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("90187088-d7f3-4656-8c27-8ba0e19e21e9"); +const S32 LLEnvironment::NO_TRACK(-1); + const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg //------------------------------------------------------------------------- @@ -269,6 +283,7 @@ LLEnvironment::LLEnvironment(): { } +#pragma optimize ("", off) void LLEnvironment::initSingleton() { LLSettingsSky::ptr_t p_default_sky = LLSettingsVOSky::buildDefaultSky(); @@ -280,16 +295,17 @@ void LLEnvironment::initSingleton() mEnvironments[ENV_DEFAULT] = mCurrentEnvironment; - requestRegionEnvironment(); + requestRegion(); - LLRegionInfoModel::instance().setUpdateCallback([this]() { onParcelChange(); }); gAgent.addParcelChangedCallback([this]() { onParcelChange(); }); //TODO: This frequently results in one more request than we need. It isn't breaking, but should be nicer. - gAgent.addRegionChangedCallback([this]() { requestRegionEnvironment(); }); + LLRegionInfoModel::instance().setUpdateCallback([this]() { requestRegion(); }); + gAgent.addRegionChangedCallback([this]() { requestRegion(); }); gAgent.whenPositionChanged([this](const LLVector3 &localpos, const LLVector3d &) { onAgentPositionHasChanged(localpos); }); } +#pragma optimize ("", on) LLEnvironment::~LLEnvironment() { @@ -391,6 +407,7 @@ bool LLEnvironment::isInventoryEnabled() const !gAgent.getRegionCapability("UpdateSettingsTaskInventory").empty()); } +#pragma optimize ("", off) void LLEnvironment::onParcelChange() { S32 parcel_id(INVALID_PARCEL_ID); @@ -403,11 +420,7 @@ void LLEnvironment::onParcelChange() requestParcel(parcel_id); } - -void LLEnvironment::requestRegionEnvironment() -{ - requestRegion(); -} +#pragma optimize ("", on) void LLEnvironment::onLegacyRegionSettings(LLSD data) { @@ -950,22 +963,10 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader) void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo) { - LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL; - - LLSettingsDay::ptr_t pday = LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData); - - LL_WARNS("ENVIRONMENT") << "serverhash=" << envinfo->mDayHash << " viewerhash=" << pday->getHash() << LL_ENDL; - if (envinfo->mParcelId == INVALID_PARCEL_ID) { // the returned info applies to an entire region. LL_WARNS("LAPRAS") << "Setting Region environment" << LL_ENDL; - setEnvironment(ENV_REGION, pday, envinfo->mDayLength, envinfo->mDayOffset); - if (parcel_id != INVALID_PARCEL_ID) - { - LL_WARNS("LAPRAS") << "Had requested parcel environment #" << parcel_id << " but got region." << LL_ENDL; - clearEnvironment(ENV_PARCEL); - } - + setEnvironment(ENV_REGION, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset); mTrackAltitudes = envinfo->mAltitudes; LL_WARNS("LAPRAS") << "Altitudes set to {" << mTrackAltitudes[0] << ", "<< mTrackAltitudes[1] << ", " << mTrackAltitudes[2] << ", " << mTrackAltitudes[3] << LL_ENDL; @@ -973,7 +974,6 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI else { LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel(); - LL_WARNS("LAPRAS") << "Have parcel environment #" << envinfo->mParcelId << LL_ENDL; if (parcel && (parcel->getLocalID() != parcel_id)) { @@ -981,23 +981,33 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI return; } - setEnvironment(ENV_PARCEL, pday, envinfo->mDayLength, envinfo->mDayOffset); + if (!envinfo->mDayCycle) + { + LL_WARNS("LAPRAS") << "Clearing environment on parcel #" << parcel_id << LL_ENDL; + clearEnvironment(ENV_PARCEL); + } + else + { + setEnvironment(ENV_PARCEL, envinfo->mDayCycle, envinfo->mDayLength, envinfo->mDayOffset); + } } updateEnvironment(); } //========================================================================= +#pragma optimize ("", off) void LLEnvironment::requestRegion() { if (!isExtendedEnvironmentEnabled()) - { + { /*TODO: When EEP is live on the entire grid, this can go away. */ LLEnvironmentRequest::initiate(); return; } requestParcel(INVALID_PARCEL_ID); } +#pragma optimize ("", on) void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { @@ -1048,8 +1058,14 @@ void LLEnvironment::requestParcel(S32 parcel_id) void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset) { - LLSettingsVOBase::getSettingsAsset(asset_id, - [this, parcel_id, day_length, day_offset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onUpdateParcelAssetLoaded(asset_id, settings, status, parcel_id, day_length, day_offset); }); + std::string coroname = + LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", + [this, parcel_id, asset_id, day_length, day_offset]() { coroUpdateEnvironment(parcel_id, NO_TRACK, + LLSettingsDay::ptr_t(), asset_id, day_length, day_offset, environment_apply_fn()); }); +// [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }); }); + +// LLSettingsVOBase::getSettingsAsset(asset_id, +// [this, parcel_id, day_length, day_offset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onUpdateParcelAssetLoaded(asset_id, settings, status, parcel_id, day_length, day_offset); }); } void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset) @@ -1096,17 +1112,19 @@ void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", - boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, - pday, day_length, day_offset, - [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); })); + [this, parcel_id, pday, day_length, day_offset]() { coroUpdateEnvironment(parcel_id, NO_TRACK, + pday, LLUUID::null, day_length, day_offset, environment_apply_fn()); }); +// [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }); }); } + + void LLEnvironment::resetParcel(S32 parcel_id) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", - boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id, - [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); })); + [this, parcel_id]() { coroResetEnvironment(parcel_id, NO_TRACK, environment_apply_fn()); }); +// [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }); }); } void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environment_apply_fn apply) @@ -1151,7 +1169,7 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ } else { - LLSD environment = result["environment"]; + LLSD environment = result[KEY_ENVIRONMENT]; if (environment.isDefined() && apply) { EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); @@ -1166,7 +1184,7 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ } } -void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, LLEnvironment::environment_apply_fn apply) +void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, S32 track_no, LLSettingsDay::ptr_t pday, LLUUID settings_asset, S32 day_length, S32 day_offset, LLEnvironment::environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1192,22 +1210,39 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd } LLSD body(LLSD::emptyMap()); - body["environment"] = LLSD::emptyMap(); + body[KEY_ENVIRONMENT] = LLSD::emptyMap(); - if (day_length >= 0) - body["environment"]["day_length"] = day_length; - if (day_offset >= 0) - body["environment"]["day_offset"] = day_offset; + if (track_no == NO_TRACK) + { // day length and offset are only applicable if we are addressing the entire day cycle. + if (day_length >= 0) + body[KEY_ENVIRONMENT][KEY_DAYLENGTH] = day_length; + if (day_offset >= 0) + body[KEY_ENVIRONMENT][KEY_DAYOFFSET] = day_offset; + } if (pday) - body["environment"]["day_cycle"] = pday->getSettings(); + body[KEY_ENVIRONMENT][KEY_DAYCYCLE] = pday->getSettings(); + else if (!settings_asset.isNull()) + body[KEY_ENVIRONMENT][KEY_DAYASSET] = settings_asset; + LL_WARNS("LAPRAS") << "Body = " << body << LL_ENDL; - if (parcel_id != INVALID_PARCEL_ID) + if ((parcel_id != INVALID_PARCEL_ID) || (track_no != NO_TRACK)) { std::stringstream query; + query << "?"; - query << "?parcelid=" << parcel_id; + if (parcel_id != INVALID_PARCEL_ID) + { + query << "parcelid=" << parcel_id; + + if (track_no != NO_TRACK) + query << "&"; + } + if (track_no != NO_TRACK) + { + query << "trackno=" << track_no; + } url += query.str(); } @@ -1228,7 +1263,7 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd } else { - LLSD environment = result["environment"]; + LLSD environment = result[KEY_ENVIRONMENT]; if (environment.isDefined() && apply) { EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); @@ -1243,7 +1278,7 @@ void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pd } } -void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn apply) +void LLEnvironment::coroResetEnvironment(S32 parcel_id, S32 track_no, environment_apply_fn apply) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -1254,11 +1289,22 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn app if (url.empty()) return; - if (parcel_id != INVALID_PARCEL_ID) + if ((parcel_id != INVALID_PARCEL_ID) || (track_no != NO_TRACK)) { std::stringstream query; + query << "?"; - query << "?parcelid=" << parcel_id; + if (parcel_id != INVALID_PARCEL_ID) + { + query << "parcelid=" << parcel_id; + + if (track_no != NO_TRACK) + query << "&"; + } + if (track_no != NO_TRACK) + { + query << "trackno=" << track_no; + } url += query.str(); } @@ -1279,7 +1325,7 @@ void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn app } else { - LLSD environment = result["environment"]; + LLSD environment = result[KEY_ENVIRONMENT]; if (environment.isDefined() && apply) { EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); @@ -1339,10 +1385,9 @@ LLEnvironment::EnvironmentInfo::EnvironmentInfo(): mDayLength(0), mDayOffset(0), mDayHash(0), - mDaycycleData(), + mDayCycle(), mAltitudes({ { 0.0, 0.0, 0.0, 0.0 } }), - mIsDefault(false), - mIsRegion(false) + mIsDefault(false) { } @@ -1350,32 +1395,28 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL { ptr_t pinfo = std::make_shared(); - if (environment.has("parcel_id")) - pinfo->mParcelId = environment["parcel_id"].asInteger(); - if (environment.has("region_id")) - pinfo->mRegionId = environment["region_id"].asUUID(); - if (environment.has("day_length")) - pinfo->mDayLength = LLSettingsDay::Seconds(environment["day_length"].asInteger()); - if (environment.has("day_offset")) - pinfo->mDayOffset = LLSettingsDay::Seconds(environment["day_offset"].asInteger()); - if (environment.has("day_hash")) - pinfo->mDayHash = environment["day_hash"].asInteger(); - if (environment.has("day_cycle")) - pinfo->mDaycycleData = environment["day_cycle"]; - if (environment.has("is_default")) - pinfo->mIsDefault = environment["is_default"].asBoolean(); - if (environment.has("track_altitudes")) - { - LL_WARNS("LAPRAS") << "track_altitudes=" << environment["track_altitudes"] << LL_ENDL; - - /*LAPRAS: TODO: Fix the simulator message. Shouldn't be 5, just 4*/ - int idx = 1; - for (F32 &altitude : pinfo->mAltitudes) + pinfo->mIsDefault = environment.has(KEY_ISDEFAULT) ? environment[KEY_ISDEFAULT].asBoolean() : true; + pinfo->mParcelId = environment.has(KEY_PARCELID) ? environment[KEY_PARCELID].asInteger() : INVALID_PARCEL_ID; + pinfo->mRegionId = environment.has(KEY_REGIONID) ? environment[KEY_REGIONID].asUUID() : LLUUID::null; + + if (environment.has(KEY_TRACKALTS)) + { + for (int idx = 0; idx < 3; idx++) { - altitude = environment["track_altitudes"][idx++].asReal(); + pinfo->mAltitudes[idx+1] = environment[KEY_TRACKALTS][idx].asReal(); } + pinfo->mAltitudes[0] = 0; + } + + if (environment.has(KEY_DAYCYCLE)) + { + pinfo->mDayCycle = LLSettingsVODay::buildFromEnvironmentMessage(environment[KEY_DAYCYCLE]); + pinfo->mDayLength = LLSettingsDay::Seconds(environment.has(KEY_DAYLENGTH) ? environment[KEY_DAYLENGTH].asInteger() : -1); + pinfo->mDayOffset = LLSettingsDay::Seconds(environment.has(KEY_DAYOFFSET) ? environment[KEY_DAYOFFSET].asInteger() : -1); + pinfo->mDayHash = environment.has(KEY_DAYHASH) ? environment[KEY_DAYHASH].asInteger() : 0; } + return pinfo; } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 6f8d4b5203..80d186c9e6 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -65,25 +65,24 @@ public: static const LLUUID KNOWN_SKY_SUNSET; static const LLUUID KNOWN_SKY_MIDNIGHT; + static const S32 NO_TRACK; + struct EnvironmentInfo { EnvironmentInfo(); typedef std::shared_ptr ptr_t; - S32 mParcelId; - LLUUID mRegionId; - S64Seconds mDayLength; - S64Seconds mDayOffset; - size_t mDayHash; - LLSD mDaycycleData; - std::array mAltitudes; - bool mIsDefault; - bool mIsRegion; - - - static ptr_t extract(LLSD); + S32 mParcelId; + LLUUID mRegionId; + S64Seconds mDayLength; + S64Seconds mDayOffset; + size_t mDayHash; + LLSettingsDay::ptr_t mDayCycle; + std::array mAltitudes; + bool mIsDefault; + static ptr_t extract(LLSD); }; enum EnvSelection_t @@ -226,8 +225,6 @@ public: //------------------------------------------- connection_t setEnvironmentChanged(environment_changed_fn cb); - void requestRegionEnvironment(); - void onLegacyRegionSettings(LLSD data); void requestRegion(); @@ -359,21 +356,20 @@ private: DayInstance::ptr_t getSelectedEnvironmentInstance(); - void updateCloudScroll(); - - void onParcelChange(); + void updateCloudScroll(); - void coroRequestEnvironment(S32 parcel_id, environment_apply_fn apply); - void coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, environment_apply_fn apply); - void coroResetEnvironment(S32 parcel_id, environment_apply_fn apply); + void onParcelChange(); - void recordEnvironment(S32 parcel_id, EnvironmentInfo::ptr_t environment); + void coroRequestEnvironment(S32 parcel_id, environment_apply_fn apply); + void coroUpdateEnvironment(S32 parcel_id, S32 track_no, LLSettingsDay::ptr_t pday, LLUUID settings_asset, S32 day_length, S32 day_offset, environment_apply_fn apply); + void coroResetEnvironment(S32 parcel_id, S32 track_no, environment_apply_fn apply); - void onAgentPositionHasChanged(const LLVector3 &localpos); + void recordEnvironment(S32 parcel_id, EnvironmentInfo::ptr_t environment); - void onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status); - void onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset); + void onAgentPositionHasChanged(const LLVector3 &localpos); + void onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status); + void onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset); }; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 010b5dec36..e464f3f8ef 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -269,7 +269,7 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i if (!settings) { status = 1; - LL_WARNS("SETTINGS") << "Unable to creat settings object." << LL_ENDL; + LL_WARNS("SETTINGS") << "Unable to create settings object." << LL_ENDL; } else { diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index ed529975d2..d263e15a10 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -1483,6 +1483,8 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use BOOL region_deny_transacted_override = false; // Deprecated BOOL region_deny_age_unverified_override = false; BOOL region_allow_access_override = true; + BOOL region_allow_environment_override = true; + S32 parcel_environment_version = 0; BOOL agent_parcel_update = false; // updating previous(existing) agent parcel S32 other_clean_time = 0; @@ -1573,6 +1575,12 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use msg->getBOOLFast(_PREHASH_RegionAllowAccessBlock, _PREHASH_RegionAllowAccessOverride, region_allow_access_override); } + if (msg->getNumberOfBlocks(_PREHASH_ParcelEnvironmentBlock)) + { + msg->getS32Fast(_PREHASH_ParcelEnvironmentBlock, _PREHASH_ParcelEnvironmentVersion, parcel_environment_version); + msg->getBOOLFast(_PREHASH_ParcelEnvironmentBlock, _PREHASH_RegionAllowEnvironmentOverride, region_allow_environment_override); + } + msg->getS32("ParcelData", "OtherCleanTime", other_clean_time ); // Actually extract the data. @@ -1590,6 +1598,8 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use } } + bool environment_changed = (parcel->getParcelEnvironmentVersion() != parcel_environment_version); + parcel->init(owner_id, FALSE, FALSE, FALSE, claim_date, claim_price_per_meter, rent_price_per_meter, @@ -1615,6 +1625,10 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use parcel->setRegionDenyAnonymousOverride(region_deny_anonymous_override); parcel->setRegionDenyAgeUnverifiedOverride(region_deny_age_unverified_override); parcel->setRegionAllowAccessOverride(region_allow_access_override); + + parcel->setParcelEnvironmentVersion(parcel_environment_version); + parcel->setRegionAllowEnvironmentOverride(region_allow_environment_override); + parcel->unpackMessage(msg); if (parcel == parcel_mgr.mAgentParcel) @@ -1632,9 +1646,6 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use // Let interesting parties know about agent parcel change. LLViewerParcelMgr* instance = LLViewerParcelMgr::getInstance(); - // Notify anything that wants to know when the agent changes parcels - gAgent.changeParcels(); - if (instance->mTeleportInProgress) { instance->mTeleportInProgress = FALSE; @@ -1648,12 +1659,21 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use instance->mTeleportFinishedSignal(instance->mTeleportInProgressPosition, false); } } - } - else if (agent_parcel_update) - { - // updated agent parcel - parcel_mgr.mAgentParcel->unpackMessage(msg); - } + + LL_WARNS("LAPRAS") << "Parcel environment version is " << parcel->getParcelEnvironmentVersion() << LL_ENDL; + // Notify anything that wants to know when the agent changes parcels + gAgent.changeParcels(); + } + else if (agent_parcel_update) + { + // updated agent parcel + parcel_mgr.mAgentParcel->unpackMessage(msg); + if ((LLEnvironment::instance().isExtendedEnvironmentEnabled() && environment_changed)) + { + LL_WARNS("LAPRAS") << "Parcel environment version is " << parcel->getParcelEnvironmentVersion() << LL_ENDL; + LLEnvironment::instance().requestParcel(local_id); + } + } } // Handle updating selections, if necessary. @@ -1835,26 +1855,6 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use }//if gAudiop }; - if (LLEnvironment::instance().isExtendedEnvironmentEnabled()) - { - LL_WARNS("LAPRAS") << "TODO: Hey Rider! Fix this. 1) don't rerequest parcel information. 2) if sequent_id == -1 we are selecting a parcel. Deal with that correctly." << LL_ENDL; - - if (sequence_id == SELECTED_PARCEL_SEQ_ID) - { - LL_WARNS("LAPRAS") << "TODO: Hay Rider! Fix this. Get environment for selected parcel." << LL_ENDL; - } - else if ((sequence_id == HOVERED_PARCEL_SEQ_ID) || - (sequence_id == COLLISION_NOT_IN_GROUP_PARCEL_SEQ_ID) || - (sequence_id == COLLISION_NOT_ON_LIST_PARCEL_SEQ_ID) || - (sequence_id == COLLISION_BANNED_PARCEL_SEQ_ID)) - { - /*NoOp*/ - } - else - { - LLEnvironment::instance().requestParcel(local_id); - } - } } void LLViewerParcelMgr::optionally_start_music(const std::string& music_url) diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg index c56eaae6fe..01397181e4 100755 --- a/scripts/messages/message_template.msg +++ b/scripts/messages/message_template.msg @@ -4503,6 +4503,11 @@ version 2.0 RegionAllowAccessBlock Single { RegionAllowAccessOverride BOOL } } + { + ParcelEnvironmentBlock Single + { ParcelEnvironmentVersion S32 } + { RegionAllowEnvironmentOverride BOOL } + } } // ParcelPropertiesUpdate diff --git a/scripts/messages/message_template.msg.sha1 b/scripts/messages/message_template.msg.sha1 index 5bc06ec042..ae8937f461 100755 --- a/scripts/messages/message_template.msg.sha1 +++ b/scripts/messages/message_template.msg.sha1 @@ -1 +1 @@ -337f351910b0c8821cb3d447bc6578516a043c80 \ No newline at end of file +4c5ec7187d1af05b52b5c1bbac68d46fbc65da05 \ No newline at end of file -- cgit v1.3 From 77b278b7f5615a6ba93b47c2a0d8a2338dc27dc2 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 12 Nov 2018 16:41:40 +0200 Subject: SL-9620 Viewer crashes after clicking "Commit" button while editing Day Cycle preset --- indra/llinventory/llparcel.cpp | 2 +- indra/llinventory/llparcel.h | 1 + indra/newview/llfloaterland.cpp | 1 + indra/newview/llfloaterregioninfo.cpp | 1 + indra/newview/llpanelenvironment.cpp | 97 +++++++++++++++++++++++++++-------- indra/newview/llpanelenvironment.h | 2 +- 6 files changed, 82 insertions(+), 22 deletions(-) (limited to 'indra/llinventory/llparcel.cpp') diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp index aff7f86fd4..e2469f3c7e 100644 --- a/indra/llinventory/llparcel.cpp +++ b/indra/llinventory/llparcel.cpp @@ -233,7 +233,7 @@ void LLParcel::init(const LLUUID &owner_id, setHaveNewParcelLimitData(FALSE); setRegionAllowEnvironmentOverride(FALSE); - setParcelEnvironmentVersion(-1); + setParcelEnvironmentVersion(INVALID_PARCEL_ENVIRONMENT_VERSION); } void LLParcel::overrideOwner(const LLUUID& owner_id, BOOL is_group_owned) diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index 2497a069d7..9ece9b58e5 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -102,6 +102,7 @@ const U32 RT_LIST = 0x1 << 4; const U32 RT_SELL = 0x1 << 5; const S32 INVALID_PARCEL_ID = -1; +const S32 INVALID_PARCEL_ENVIRONMENT_VERSION = -1; // Timeouts for parcels // default is 21 days * 24h/d * 60m/h * 60s/m *1000000 usec/s = 1814400000000 diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 0ff660fcad..25cbf2f576 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -3325,6 +3325,7 @@ void LLPanelLandEnvironment::refreshFromSource() LLHandle that_h = getHandle(); + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; LLEnvironment::instance().requestParcel(parcel->getLocalID(), [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 4fd23252fa..671f5aca9d 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -3450,6 +3450,7 @@ void LLPanelRegionEnvironment::refreshFromSource() { LLHandle that_h = getHandle(); + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; LLEnvironment::instance().requestRegion( [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index e848c6eaf1..df595632f8 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -124,6 +124,7 @@ LLPanelEnvironmentInfo::LLPanelEnvironmentInfo(): mCrossRegion(false), mNoSelection(false), mNoEnvironment(false), + mCurEnvVersion(INVALID_PARCEL_ENVIRONMENT_VERSION), mSettingsFloater(), mEditFloater() { @@ -388,20 +389,21 @@ bool LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) S32 rdo_selection = getChild(RDG_ENVIRONMENT_SELECT)->getSelectedIndex(); - getChild(RDG_ENVIRONMENT_SELECT)->setEnabled(enabled); - getChild(RDO_USEDEFAULT)->setEnabled(enabled && !is_legacy); + bool can_enable = enabled && mCurEnvVersion != INVALID_PARCEL_ENVIRONMENT_VERSION; + getChild(RDG_ENVIRONMENT_SELECT)->setEnabled(can_enable); + getChild(RDO_USEDEFAULT)->setEnabled(can_enable && !is_legacy); getChild(RDO_USEINV)->setEnabled(false); // these two are selected automatically based on getChild(RDO_USECUSTOM)->setEnabled(false); getChild(EDT_INVNAME)->setEnabled(FALSE); - getChild(BTN_SELECTINV)->setEnabled(enabled && !is_legacy); - getChild(BTN_EDIT)->setEnabled(enabled); - getChild(SLD_DAYLENGTH)->setEnabled(enabled && (rdo_selection != 0) && !is_legacy); - getChild(SLD_DAYOFFSET)->setEnabled(enabled && (rdo_selection != 0) && !is_legacy); - getChild(SLD_ALTITUDES)->setEnabled(enabled && isRegion() && !is_legacy); - getChild(ICN_GROUND)->setColor((enabled && isRegion() && !is_legacy) ? LLColor4::white : LLColor4::grey % 0.8f); - getChild(PNL_ENVIRONMENT_ALTITUDES)->setEnabled(enabled && isRegion() && !is_legacy); - getChild(CHK_ALLOWOVERRIDE)->setEnabled(enabled && isRegion() && !is_legacy); - getChild(BTN_APPLY)->setEnabled(enabled && (mDirtyFlag != 0)); + getChild(BTN_SELECTINV)->setEnabled(can_enable && !is_legacy); + getChild(BTN_EDIT)->setEnabled(can_enable); + getChild(SLD_DAYLENGTH)->setEnabled(can_enable && (rdo_selection != 0) && !is_legacy); + getChild(SLD_DAYOFFSET)->setEnabled(can_enable && (rdo_selection != 0) && !is_legacy); + getChild(SLD_ALTITUDES)->setEnabled(can_enable && isRegion() && !is_legacy); + getChild(ICN_GROUND)->setColor((can_enable && isRegion() && !is_legacy) ? LLColor4::white : LLColor4::grey % 0.8f); + getChild(PNL_ENVIRONMENT_ALTITUDES)->setEnabled(can_enable && isRegion() && !is_legacy); + getChild(CHK_ALLOWOVERRIDE)->setEnabled(can_enable && isRegion() && !is_legacy); + getChild(BTN_APPLY)->setEnabled(can_enable && (mDirtyFlag != 0)); getChild(BTN_CANCEL)->setEnabled(enabled && (mDirtyFlag != 0)); getChild(SDT_DROP_TARGET)->setDndEnabled(enabled && !is_legacy); @@ -429,7 +431,7 @@ void LLPanelEnvironmentInfo::setDirtyFlag(U32 flag) { bool can_edit = canEdit(); mDirtyFlag |= flag; - getChildView(BTN_APPLY)->setEnabled((mDirtyFlag != 0) && can_edit); + getChildView(BTN_APPLY)->setEnabled((mDirtyFlag != 0) && mCurEnvVersion != INVALID_PARCEL_ENVIRONMENT_VERSION && can_edit); getChildView(BTN_CANCEL)->setEnabled((mDirtyFlag != 0) && can_edit); } @@ -437,7 +439,7 @@ void LLPanelEnvironmentInfo::clearDirtyFlag(U32 flag) { bool can_edit = canEdit(); mDirtyFlag &= ~flag; - getChildView(BTN_APPLY)->setEnabled((mDirtyFlag != 0) && can_edit); + getChildView(BTN_APPLY)->setEnabled((mDirtyFlag != 0) && mCurEnvVersion != INVALID_PARCEL_ENVIRONMENT_VERSION && can_edit); getChildView(BTN_CANCEL)->setEnabled((mDirtyFlag != 0) && can_edit); } @@ -661,11 +663,19 @@ void LLPanelEnvironmentInfo::doApply() if (rdo_selection == 0) { + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; LLEnvironment::instance().resetParcel(parcel_id, [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); } else if (rdo_selection == 1) { + if (!mCurrentEnvironment) + { + // Attempting to save mid update? + LL_WARNS("ENVPANEL") << "Failed to apply changes from editor! Dirty state: " << mDirtyFlag << " update state: " << mCurEnvVersion << LL_ENDL; + return; + } + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; LLEnvironment::instance().updateParcel(parcel_id, mCurrentEnvironment->mDayCycle->getAssetId(), std::string(), mCurrentEnvironment->mDayLength.value(), mCurrentEnvironment->mDayOffset.value(), alts, @@ -673,13 +683,18 @@ void LLPanelEnvironmentInfo::doApply() } else { + if (!mCurrentEnvironment) + { + // Attempting to save mid update? + LL_WARNS("ENVPANEL") << "Failed to apply changes from editor! Dirty state: " << mDirtyFlag << " update state: " << mCurEnvVersion << LL_ENDL; + return; + } + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; LLEnvironment::instance().updateParcel(parcel_id, mCurrentEnvironment->mDayCycle, mCurrentEnvironment->mDayLength.value(), mCurrentEnvironment->mDayOffset.value(), alts, [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); } - // Todo: save altitudes once LLEnvironment::setRegionAltitudes() gets implemented - setControlsEnabled(false); } } @@ -748,6 +763,12 @@ void LLPanelEnvironmentInfo::onEditCommitted(LLSettingsDay::ptr_t newday) LL_WARNS("ENVPANEL") << "Editor committed an empty day. Do nothing." << LL_ENDL; return; } + if (!mCurrentEnvironment) + { + // Attempting to save mid update? + LL_WARNS("ENVPANEL") << "Failed to apply changes from editor! Dirty state: " << mDirtyFlag << " env version: " << mCurEnvVersion << LL_ENDL; + return; + } size_t newhash(newday->getHash()); size_t oldhash((mCurrentEnvironment->mDayCycle) ? mCurrentEnvironment->mDayCycle->getHash() : 0); @@ -761,11 +782,32 @@ void LLPanelEnvironmentInfo::onEditCommitted(LLSettingsDay::ptr_t newday) void LLPanelEnvironmentInfo::onEnvironmentChanged(LLEnvironment::EnvSelection_t env) { - if ((isRegion() && (env == LLEnvironment::ENV_REGION)) || - ((env == LLEnvironment::ENV_PARCEL) && (getParcelId() == LLViewerParcelMgr::instance().getAgentParcelId()))) + if (isRegion()) { - mCurrentEnvironment.reset(); - refreshFromSource(); + // Note: at the moment mCurEnvVersion is only applyable to parcels, we might need separate version control for regions + // but mCurEnvVersion still acts like indicator that update is pending + if (env == LLEnvironment::ENV_REGION) + { + mCurrentEnvironment.reset(); + refreshFromSource(); + } + } + else if ((env == LLEnvironment::ENV_PARCEL) && (getParcelId() == LLViewerParcelMgr::instance().getAgentParcelId())) + { + // Panel receives environment from different sources, from environment update callbacks, + // from hovers (causes callbacks on version change) and from personal requests + // filter out dupplicates and out of order packets by checking parcel environment version. + LL_DEBUGS("ENVPANEL") << "Received environment update " << mCurEnvVersion << " " << (getParcel() ? getParcel()->getParcelEnvironmentVersion() : (S32)-1) << LL_ENDL; + LLParcel *parcel = getParcel(); + if (parcel && mCurEnvVersion < parcel->getParcelEnvironmentVersion()) + { + mCurrentEnvironment.reset(); + refreshFromSource(); + } + else + { + refresh(); + } } } @@ -784,7 +826,7 @@ void LLPanelEnvironmentInfo::onPickerAssetDownloaded(LLSettingsBase::ptr_t setti } void LLPanelEnvironmentInfo::onEnvironmentReceived(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) -{ +{ if (parcel_id != getParcelId()) { LL_WARNS("ENVPANEL") << "Have environment for parcel " << parcel_id << " expecting " << getParcelId() << ". Discarding." << LL_ENDL; @@ -792,6 +834,21 @@ void LLPanelEnvironmentInfo::onEnvironmentReceived(S32 parcel_id, LLEnvironment: } mCurrentEnvironment = envifo; clearDirtyFlag(DIRTY_FLAG_MASK); + if (parcel_id == INVALID_PARCEL_ID) + { + // region, no version + mCurEnvVersion = 1; + } + else + { + LLParcel* parcel = getParcel(); + if (parcel) + { + // not always up to date, we will get onEnvironmentChanged() update in such case. + mCurEnvVersion = parcel->getParcelEnvironmentVersion(); + } + LL_DEBUGS("ENVPANEL") << " Setting environment version: " << mCurEnvVersion << LL_ENDL; + } refresh(); } diff --git a/indra/newview/llpanelenvironment.h b/indra/newview/llpanelenvironment.h index 2c070eb21f..bca7743145 100644 --- a/indra/newview/llpanelenvironment.h +++ b/indra/newview/llpanelenvironment.h @@ -160,7 +160,7 @@ protected: }; typedef std::map altitudes_data_t; altitudes_data_t mAltitudes; - + S32 mCurEnvVersion; private: -- cgit v1.3