diff options
author | Graham Linden <graham@lindenlab.com> | 2018-06-02 23:28:48 +0100 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2018-06-02 23:28:48 +0100 |
commit | 7136956b90614bbd236be0e30231781c04346220 (patch) | |
tree | 01c0a7477370652fdbdeebb5a3ad5d3a422e3929 /indra/llinventory | |
parent | 7d6743f42d09bfcc39c0930aa342638d8273b722 (diff) |
Use more typedefs to simplify sync between viewer and sim env settings code.
Diffstat (limited to 'indra/llinventory')
-rw-r--r-- | indra/llinventory/llsettingsbase.cpp | 51 | ||||
-rw-r--r-- | indra/llinventory/llsettingsbase.h | 64 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.cpp | 93 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.h | 65 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.cpp | 40 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.h | 30 | ||||
-rw-r--r-- | indra/llinventory/llsettingswater.cpp | 19 | ||||
-rw-r--r-- | indra/llinventory/llsettingswater.h | 25 |
8 files changed, 225 insertions, 162 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index a661d52b7f..23afbdfa3a 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -35,7 +35,7 @@ //========================================================================= namespace { - const F64 BREAK_POINT = 0.5; + const LLSettingsBase::BlendFactor BREAK_POINT = 0.5; } //========================================================================= @@ -272,7 +272,8 @@ size_t LLSettingsBase::getHash() const LLSD hash_settings = llsd_shallow(getSettings(), LLSDMap(SETTING_NAME, false)(SETTING_ID, false)(SETTING_HASH, false)("*", true)); - return boost::hash<LLSD>{}(hash_settings); + boost::hash<LLSD> hasher; + return hasher(hash_settings); } bool LLSettingsBase::validate() @@ -340,17 +341,35 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida validated.insert(validateType.getName()); // Fields for specific settings. - for (auto &test: validations) + for (validation_list_t::iterator itv = validations.begin(); itv != validations.end(); ++itv) { - if (!test.verify(settings)) +#ifdef VALIDATION_DEBUG + LLSD oldvalue; + if (settings.has((*itv).getName())) + { + oldvalue = llsd_clone(mSettings[(*itv).getName()]); + } +#endif + + if (!(*itv).verify(settings)) { std::stringstream errtext; - errtext << "Settings LLSD fails validation and could not be corrected for '" << test.getName() << "'!\n"; + errtext << "Settings LLSD fails validation and could not be corrected for '" << (*itv).getName() << "'!\n"; errors.append( errtext.str() ); isValid = false; } - validated.insert(test.getName()); + validated.insert((*itv).getName()); + +#ifdef VALIDATION_DEBUG + if (!oldvalue.isUndefined()) + { + if (!compare_llsd(settings[(*itv).getName()], oldvalue)) + { + LL_WARNS("SETTINGS") << "Setting '" << (*itv).getName() << "' was changed: " << oldvalue << " -> " << settings[(*itv).getName()] << LL_ENDL; + } + } +#endif } // strip extra entries @@ -366,9 +385,9 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida } } - for (const std::string &its: strip) + for (stringset_t::iterator its = strip.begin(); its != strip.end(); ++its) { - settings.erase(its); + settings.erase(*its); } return LLSDMap("success", LLSD::Boolean(isValid)) @@ -533,13 +552,14 @@ bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range) } //========================================================================= -void LLSettingsBlender::update(F64 blendf) +void LLSettingsBlender::update(const LLSettingsBase::BlendFactor& blendf) { setPosition(blendf); } -F64 LLSettingsBlender::setPosition(F64 blendf) +F64 LLSettingsBlender::setPosition(const LLSettingsBase::TrackPosition& blendf_in) { + LLSettingsBase::TrackPosition blendf = blendf_in; if (blendf >= 1.0) { triggerComplete(); @@ -565,14 +585,14 @@ void LLSettingsBlender::triggerComplete() } //------------------------------------------------------------------------- -F64 LLSettingsBlenderTimeDelta::calculateBlend(F64 spanpos, F64 spanlen) const +LLSettingsBase::BlendFactor LLSettingsBlenderTimeDelta::calculateBlend(const LLSettingsBase::TrackPosition& spanpos, const LLSettingsBase::TrackPosition& spanlen) const { - return fmod(spanpos, spanlen) / spanlen; + return LLSettingsBase::BlendFactor(fmod((F64)spanpos, (F64)spanlen) / (F64)spanlen); } -void LLSettingsBlenderTimeDelta::update(F64 timedelta) +void LLSettingsBlenderTimeDelta::advance(const LLSettingsBase::Seconds& timedelta) { - mTimeSpent += LLSettingsBase::Seconds(timedelta); + mTimeSpent += timedelta; if (mTimeSpent > mBlendSpan) { @@ -580,8 +600,7 @@ void LLSettingsBlenderTimeDelta::update(F64 timedelta) return; } - F64 blendf = calculateBlend(mTimeSpent.value(), mBlendSpan.value()); - // Note no clamp here. + LLSettingsBase::BlendFactor blendf = calculateBlend(mTimeSpent, mBlendSpan); setPosition(blendf); } diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 6f072a4e50..a8e1cc5eea 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -45,8 +45,14 @@ #include "llinventorysettings.h" +#define PTR_NAMESPACE std +#define SETTINGS_OVERRIDE override + +//#define PTR_NAMESPACE boost +//#define SETTINGS_OVERRIDE + class LLSettingsBase : - public std::enable_shared_from_this<LLSettingsBase>, + public PTR_NAMESPACE::enable_shared_from_this<LLSettingsBase>, private boost::noncopyable { friend class LLEnvironment; @@ -56,6 +62,8 @@ class LLSettingsBase : public: typedef F64Seconds Seconds; + typedef F64 BlendFactor; + typedef F64 TrackPosition; static const std::string SETTING_ID; static const std::string SETTING_NAME; @@ -64,7 +72,7 @@ public: typedef std::map<std::string, S32> parammapping_t; - typedef std::shared_ptr<LLSettingsBase> ptr_t; + typedef PTR_NAMESPACE::shared_ptr<LLSettingsBase> ptr_t; virtual ~LLSettingsBase() { }; @@ -107,12 +115,17 @@ public: //--------------------------------------------------------------------- // - inline void setValue(const std::string &name, const LLSD &value) + inline void setLLSD(const std::string &name, const LLSD &value) { mSettings[name] = value; mDirty = true; } + inline void setValue(const std::string &name, const LLSD &value) + { + setLLSD(name, value); + } + inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) const { if (!mSettings.has(name)) @@ -120,6 +133,11 @@ public: return mSettings[name]; } + inline void setValue(const std::string &name, F32 v) + { + setLLSD(name, LLSD::Real(v)); + } + inline void setValue(const std::string &name, const LLVector2 &value) { setValue(name, value.getValue()); @@ -150,7 +168,7 @@ public: setValue(name, value.getValue()); } - inline F64 getBlendFactor() const + inline BlendFactor getBlendFactor() const { return mBlendedFactor; } @@ -165,7 +183,7 @@ public: (const_cast<LLSettingsBase *>(this))->updateSettings(); } - virtual void blend(const ptr_t &end, F64 blendf) = 0; + virtual void blend(const ptr_t &end, BlendFactor blendf) = 0; virtual bool validate(); @@ -220,8 +238,8 @@ protected: typedef std::set<std::string> stringset_t; // combining settings objects. Customize for specific setting types - virtual void lerpSettings(const LLSettingsBase &other, F64 mix); - LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, F64 mix) const; + virtual void lerpSettings(const LLSettingsBase &other, BlendFactor mix); + LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, BlendFactor mix) const; /// when lerping between settings, some may require special handling. /// Get a list of these key to be skipped by the default settings lerp. @@ -248,7 +266,7 @@ protected: LLSD cloneSettings() const; - inline void setBlendFactor(F64 blendfactor) + inline void setBlendFactor(BlendFactor blendfactor) { mBlendedFactor = blendfactor; } @@ -256,18 +274,18 @@ protected: void markDirty() { mDirty = true; } private: - bool mDirty = true; + bool mDirty; LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; - F64 mBlendedFactor; + BlendFactor mBlendedFactor; }; -class LLSettingsBlender : public std::enable_shared_from_this<LLSettingsBlender> +class LLSettingsBlender : public PTR_NAMESPACE::enable_shared_from_this<LLSettingsBlender> { public: - typedef std::shared_ptr<LLSettingsBlender> ptr_t; + typedef PTR_NAMESPACE::shared_ptr<LLSettingsBlender> ptr_t; typedef boost::signals2::signal<void(const ptr_t )> finish_signal_t; typedef boost::signals2::connection connection_t; @@ -287,7 +305,7 @@ public: virtual ~LLSettingsBlender() {} - virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 /*span*/ = 1.0) + virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::Seconds& span) { // note: the 'span' reset parameter is unused by the base class. if (!mInitial) @@ -322,10 +340,10 @@ public: return mOnFinished.connect(onfinished); } - virtual void update(F64 blendf); - virtual F64 setPosition(F64 blendf); + virtual void update(const LLSettingsBase::BlendFactor& blendf); + virtual F64 setPosition(const LLSettingsBase::TrackPosition& position); - virtual void switchTrack(S32 trackno, F64 position = -1.0) { /*NoOp*/ } + virtual void switchTrack(S32 trackno, const LLSettingsBase::BlendFactor& position) { /*NoOp*/ } protected: void triggerComplete(); @@ -341,7 +359,7 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender { public: LLSettingsBlenderTimeDelta(const LLSettingsBase::ptr_t &target, - const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64Seconds seconds) : + const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, LLSettingsBase::Seconds seconds) : LLSettingsBlender(target, initsetting, endsetting), mBlendSpan(seconds), mLastUpdate(0.0f), @@ -355,20 +373,20 @@ public: { } - virtual void reset(LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 span = 1.0) override + virtual void reset(LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::Seconds& span) SETTINGS_OVERRIDE { LLSettingsBlender::reset(initsetting, endsetting, span); - mBlendSpan.value(span); - mTimeStart.value(LLDate::now().secondsSinceEpoch()); + mBlendSpan = span; + mTimeStart = LLSettingsBase::Seconds(LLDate::now().secondsSinceEpoch()); mLastUpdate = mTimeStart; - mTimeSpent.value(0.0f); + mTimeSpent = LLSettingsBase::Seconds(0.0); } - virtual void update(F64 timedelta) override; + virtual void advance(const LLSettingsBase::Seconds& timedelta); protected: - F64 calculateBlend(F64 spanpos, F64 spanlen) const; + LLSettingsBase::BlendFactor calculateBlend(const LLSettingsBase::TrackPosition& spanpos, const LLSettingsBase::TrackPosition& spanlen) const; LLSettingsBase::Seconds mBlendSpan; LLSettingsBase::Seconds mLastUpdate; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 3f2238bf7a..cd2102a527 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -42,7 +42,22 @@ namespace LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment"); LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment"); - LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key) + template<typename T> + inline T get_wrapping_distance(T begin, T 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, const LLSettingsBase::TrackPosition& key) { if (collection.empty()) return collection.end(); @@ -57,7 +72,7 @@ namespace return it; } - LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key) + LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key) { if (collection.empty()) return collection.end(); @@ -102,7 +117,7 @@ const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water const S32 LLSettingsDay::FRAME_MAX(56); // *LAPRAS* Change when Agni -const LLUUID LLSettingsDay::DEFAULT_ASSET_ID("94d296c2-6e05-963c-6b62-671199121dbb"); +static const LLUUID DEFAULT_ASSET_ID("94d296c2-6e05-963c-6b62-671199121dbb"); //========================================================================= LLSettingsDay::LLSettingsDay(const LLSD &data) : @@ -136,20 +151,20 @@ LLSD LLSettingsDay::getSettings() const LLSD tracks(LLSD::emptyArray()); - for (auto &track: mDayTracks) + for (CycleList_t::const_iterator itTrack = mDayTracks.begin(); itTrack != mDayTracks.end(); ++itTrack) { LLSD trackout(LLSD::emptyArray()); - for (auto &frame: track) + for (CycleTrack_t::const_iterator itFrame = (*itTrack).begin(); itFrame != (*itTrack).end(); ++itFrame) { - F32 frame_time = frame.first; - LLSettingsBase::ptr_t data = frame.second; + F32 frame = (*itFrame).first; + LLSettingsBase::ptr_t data = (*itFrame).second; size_t datahash = data->getHash(); std::stringstream keyname; keyname << datahash; - trackout.append(LLSD(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(frame_time))(SETTING_KEYNAME, keyname.str()))); + trackout.append(LLSD(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(frame))(SETTING_KEYNAME, keyname.str()))); in_use[keyname.str()] = data; } tracks.append(trackout); @@ -157,12 +172,12 @@ LLSD LLSettingsDay::getSettings() const settings[SETTING_TRACKS] = tracks; LLSD frames(LLSD::emptyMap()); - for (auto &used_frame: in_use) + for (std::map<std::string, LLSettingsBase::ptr_t>::iterator itFrame = in_use.begin(); itFrame != in_use.end(); ++itFrame) { - LLSD framesettings = llsd_clone(used_frame.second->getSettings(), + LLSD framesettings = llsd_clone((*itFrame).second->getSettings(), LLSDMap("*", true)(SETTING_NAME, false)(SETTING_ID, false)(SETTING_HASH, false)); - frames[used_frame.first] = framesettings; + frames[(*itFrame).first] = framesettings; } settings[SETTING_FRAMES] = frames; @@ -212,8 +227,9 @@ bool LLSettingsDay::initialize() LLSD curtrack = tracks[i]; for (LLSD::array_const_iterator it = curtrack.beginArray(); it != curtrack.endArray(); ++it) { - F32 keyframe = (*it)[SETTING_KEYKFRAME].asReal(); - keyframe = llclamp(keyframe, 0.0f, 1.0f); + LLSettingsBase::Seconds keyframe = LLSettingsBase::Seconds((*it)[SETTING_KEYKFRAME].asReal()); + // is this supposed to be a blend factor or a time value? + //keyframe = llclamp((F32)keyframe, 0.0f, 1.0f); LLSettingsBase::ptr_t setting; if ((*it).has(SETTING_KEYNAME)) @@ -223,7 +239,7 @@ bool LLSettingsDay::initialize() setting = used[(*it)[SETTING_KEYNAME]]; if (setting && setting->getSettingType() != "water") { - LL_WARNS("SETTINGS", "DAYCYCLE") << "Water track referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; + LL_WARNS("DAYCYCLE") << "Water track referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; setting.reset(); } } @@ -232,7 +248,7 @@ bool LLSettingsDay::initialize() setting = used[(*it)[SETTING_KEYNAME]]; if (setting && setting->getSettingType() != "sky") { - LL_WARNS("SETTINGS", "DAYCYCLE") << "Sky track #" << i << " referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; + LL_WARNS("DAYCYCLE") << "Sky track #" << i << " referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL; setting.reset(); } } @@ -296,7 +312,6 @@ LLSD LLSettingsDay::defaults() dfltsetting[SETTING_FRAMES] = frames; dfltsetting[SETTING_TYPE] = "daycycle"; - return dfltsetting; } @@ -475,7 +490,6 @@ void LLSettingsDay::startDayCycle() LL_WARNS("DAYCYCLE") << "Attempt to start day cycle on uninitialized object." << LL_ENDL; return; } - } @@ -497,15 +511,15 @@ LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno) keyframes.reserve(track.size()); - for (auto &frame: track) + for (CycleTrack_t::iterator it = track.begin(); it != track.end(); ++it) { - keyframes.push_back(frame.first); + keyframes.push_back((*it).first); } return keyframes; } -bool LLSettingsDay::moveTrackKeyframe(S32 trackno, F32 old_frame, F32 new_frame) +bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::Seconds& old_frame, const LLSettingsBase::Seconds& new_frame) { if ((trackno < 0) || (trackno >= TRACK_MAX)) { @@ -524,7 +538,9 @@ bool LLSettingsDay::moveTrackKeyframe(S32 trackno, F32 old_frame, F32 new_frame) { LLSettingsBase::ptr_t base = iter->second; track.erase(iter); - track[llclamp(new_frame, 0.0f, 1.0f)] = base; + // why are we clamping a time value as if its a blend factor + //track[llclamp(new_frame, 0.0f, 1.0f)] = base; + track[new_frame] = base; return true; } @@ -532,7 +548,7 @@ bool LLSettingsDay::moveTrackKeyframe(S32 trackno, F32 old_frame, F32 new_frame) } -bool LLSettingsDay::removeTrackKeyframe(S32 trackno, F32 frame) +bool LLSettingsDay::removeTrackKeyframe(S32 trackno, const LLSettingsBase::Seconds& frame) { if ((trackno < 0) || (trackno >= TRACK_MAX)) { @@ -552,17 +568,18 @@ bool LLSettingsDay::removeTrackKeyframe(S32 trackno, F32 frame) return false; } -void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe) +void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::Seconds& keyframe) { setSettingsAtKeyframe(water, keyframe, TRACK_WATER); } -LLSettingsWater::ptr_t LLSettingsDay::getWaterAtKeyframe(F32 keyframe) const +LLSettingsWater::ptr_t LLSettingsDay::getWaterAtKeyframe(const LLSettingsBase::Seconds& keyframe) const { - return std::dynamic_pointer_cast<LLSettingsWater>(getSettingsAtKeyframe(keyframe, TRACK_WATER)); + LLSettingsBase* p = getSettingsAtKeyframe(keyframe, TRACK_WATER).get(); + return LLSettingsWater::ptr_t((LLSettingsWater*)p); } -void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, F32 keyframe, S32 track) +void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, const LLSettingsBase::Seconds& keyframe, S32 track) { if ((track < 1) || (track >= TRACK_MAX)) { @@ -573,18 +590,18 @@ void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, F32 keyfra setSettingsAtKeyframe(sky, keyframe, track); } -LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(F32 keyframe, S32 track) const +LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const { if ((track < 1) || (track >= TRACK_MAX)) { LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL; return LLSettingsSky::ptr_t(); } - - return std::dynamic_pointer_cast<LLSettingsSky>(getSettingsAtKeyframe(keyframe, track)); + LLSettingsBase* p = getSettingsAtKeyframe(keyframe, track).get(); + return LLSettingsSky::ptr_t((LLSettingsSky*)p); } -void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, F32 keyframe, S32 track) +void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::Seconds& keyframe, S32 track) { if ((track < 0) || (track >= TRACK_MAX)) { @@ -592,11 +609,12 @@ void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, return; } - mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = settings; + //mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = settings; + mDayTracks[track][keyframe] = settings; setDirtyFlag(true); } -LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(F32 keyframe, S32 track) const +LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const { if ((track < 0) || (track >= TRACK_MAX)) { @@ -614,19 +632,24 @@ LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(F32 keyframe, S32 tra return LLSettingsBase::ptr_t(); } -F32 LLSettingsDay::getUpperBoundFrame(S32 track, F32 keyframe) +LLSettingsBase::TrackPosition LLSettingsDay::getUpperBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe) { return get_wrapping_atafter(mDayTracks[track], keyframe)->first; } -F32 LLSettingsDay::getLowerBoundFrame(S32 track, F32 keyframe) +LLSettingsBase::TrackPosition LLSettingsDay::getLowerBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe) { return get_wrapping_atbefore(mDayTracks[track], keyframe)->first; } -LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F32 keyframe) +LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe) { return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe)); } +LLUUID LLSettingsDay::GetDefaultAssetId() +{ + return DEFAULT_ASSET_ID; +} + //========================================================================= diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index f7e5710dc1..b9038506d1 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -35,12 +35,15 @@ class LLSettingsSky; // These are alias for LLSettingsWater::ptr_t and LLSettingsSky::ptr_t respectively. // Here for definitions only. -typedef std::shared_ptr<LLSettingsWater> LLSettingsWaterPtr_t; -typedef std::shared_ptr<LLSettingsSky> LLSettingsSkyPtr_t; +typedef PTR_NAMESPACE::shared_ptr<LLSettingsWater> LLSettingsWaterPtr_t; +typedef PTR_NAMESPACE::shared_ptr<LLSettingsSky> LLSettingsSkyPtr_t; class LLSettingsDay : public LLSettingsBase { public: + // 32-bit as LLSD only supports that width at present + typedef S32Seconds Seconds; + static const std::string SETTING_KEYID; static const std::string SETTING_KEYNAME; static const std::string SETTING_KEYKFRAME; @@ -63,13 +66,12 @@ public: static const S32 TRACK_MAX; static const S32 FRAME_MAX; - static const LLUUID DEFAULT_ASSET_ID; - - typedef std::map<F32, LLSettingsBase::ptr_t> CycleTrack_t; - typedef std::vector<CycleTrack_t> CycleList_t; - typedef std::shared_ptr<LLSettingsDay> ptr_t; - typedef std::vector<F32> KeyframeList_t; - typedef std::pair<CycleTrack_t::iterator, CycleTrack_t::iterator> TrackBound_t; + typedef std::map<LLSettingsBase::TrackPosition, LLSettingsBase::ptr_t> CycleTrack_t; + typedef std::vector<CycleTrack_t> CycleList_t; + typedef PTR_NAMESPACE::shared_ptr<LLSettingsDay> ptr_t; + typedef PTR_NAMESPACE::weak_ptr<LLSettingsDay> wptr_t; + typedef std::vector<LLSettingsBase::TrackPosition> KeyframeList_t; + typedef std::pair<CycleTrack_t::iterator, CycleTrack_t::iterator> TrackBound_t; //--------------------------------------------------------------------- LLSettingsDay(const LLSD &data); @@ -78,29 +80,29 @@ public: bool initialize(); virtual ptr_t buildClone() = 0; - virtual LLSD getSettings() const override; - virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_DAYCYCLE; } + virtual LLSD getSettings() const SETTINGS_OVERRIDE; + virtual LLSettingsType::type_e getSettingTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_DAYCYCLE; } //--------------------------------------------------------------------- - virtual std::string getSettingType() const override { return std::string("daycycle"); } + virtual std::string getSettingType() const SETTINGS_OVERRIDE { return std::string("daycycle"); } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &other, F64 mix) override; + virtual void blend(const LLSettingsBase::ptr_t &other, F64 mix) SETTINGS_OVERRIDE; static LLSD defaults(); //--------------------------------------------------------------------- KeyframeList_t getTrackKeyframes(S32 track); - bool moveTrackKeyframe(S32 track, F32 old_frame, F32 new_frame); - bool removeTrackKeyframe(S32 track, F32 frame); - - void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe); - LLSettingsWaterPtr_t getWaterAtKeyframe(F32 keyframe) const; - void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track); - LLSettingsSkyPtr_t getSkyAtKeyframe(F32 keyframe, S32 track) const; - void setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, F32 keyframe, S32 track); - LLSettingsBase::ptr_t getSettingsAtKeyframe(F32 keyframe, S32 track) const; + bool moveTrackKeyframe(S32 track, const LLSettingsBase::Seconds& old_frame, const LLSettingsBase::Seconds& new_frame); + bool removeTrackKeyframe(S32 track, const LLSettingsBase::Seconds& frame); + + void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::Seconds& keyframe); + LLSettingsWaterPtr_t getWaterAtKeyframe(const LLSettingsBase::Seconds& keyframe) const; + void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, const LLSettingsBase::Seconds& keyframe, S32 track); + LLSettingsSkyPtr_t getSkyAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const; + void setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::Seconds& keyframe, S32 track); + LLSettingsBase::ptr_t getSettingsAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const; //--------------------------------------------------------------------- void startDayCycle(); @@ -113,18 +115,20 @@ public: void setInitialized(bool value = true) { mInitialized = value; } CycleTrack_t & getCycleTrack(S32 track); - virtual validation_list_t getValidationList() const override; + virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE; static validation_list_t validationList(); - virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } - F32 getUpperBoundFrame(S32 track, F32 keyframe); - F32 getLowerBoundFrame(S32 track, F32 keyframe); + LLSettingsBase::TrackPosition getUpperBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe); + LLSettingsBase::TrackPosition getLowerBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe); + + static LLUUID GetDefaultAssetId(); protected: LLSettingsDay(); - virtual void updateSettings() override; + virtual void updateSettings() SETTINGS_OVERRIDE; bool mInitialized; @@ -135,10 +139,9 @@ private: 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); + static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe); + static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe); + TrackBound_t getBoundingEntries(CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe); }; #endif diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index cdd5b156d2..95502f47c3 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -106,12 +106,11 @@ const std::string LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR("exp_s const std::string LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM("linear_term"); const std::string LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM("constant_term"); -const LLUUID LLSettingsSky::DEFAULT_SUN_ID("cce0f112-878f-4586-a2e2-a8f104bba271"); // dataserver -const LLUUID LLSettingsSky::DEFAULT_MOON_ID("d07f6eed-b96a-47cd-b51d-400ad4a1c428"); // dataserver -const LLUUID LLSettingsSky::DEFAULT_CLOUD_ID("1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b"); - // *LAPRAS* Change when Agni! -const LLUUID LLSettingsSky::DEFAULT_ASSET_ID("cec9af47-90d4-9093-5245-397e5c9e7749"); +static const LLUUID DEFAULT_SUN_ID("cce0f112-878f-4586-a2e2-a8f104bba271"); // dataserver +static const LLUUID DEFAULT_MOON_ID("d07f6eed-b96a-47cd-b51d-400ad4a1c428"); // dataserver +static const LLUUID DEFAULT_CLOUD_ID("1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b"); +static const LLUUID DEFAULT_ASSET_ID("cec9af47-90d4-9093-5245-397e5c9e7749"); const std::string LLSettingsSky::SETTING_LEGACY_HAZE("legacy_haze"); @@ -218,7 +217,7 @@ LLSettingsSky::validation_list_t mieValidationList() bool validateLegacyHaze(LLSD &value) { LLSettingsSky::validation_list_t legacyHazeValidations = legacyHazeValidationList(); - llassert(value.type() == LLSD::Type::TypeMap); + llassert(value.type() == LLSD::TypeMap); LLSD result = LLSettingsBase::settingValidation(value, legacyHazeValidations); if (result["errors"].size() > 0) { @@ -242,14 +241,14 @@ bool validateRayleighLayers(LLSD &value) for (LLSD::array_iterator itf = value.beginArray(); itf != value.endArray(); ++itf) { LLSD& layerConfig = (*itf); - if (layerConfig.type() == LLSD::Type::TypeMap) + if (layerConfig.type() == LLSD::TypeMap) { if (!validateRayleighLayers(layerConfig)) { allGood = false; } } - else if (layerConfig.type() == LLSD::Type::TypeArray) + else if (layerConfig.type() == LLSD::TypeArray) { return validateRayleighLayers(layerConfig); } @@ -260,7 +259,7 @@ bool validateRayleighLayers(LLSD &value) } return allGood; } - llassert(value.type() == LLSD::Type::TypeMap); + llassert(value.type() == LLSD::TypeMap); LLSD result = LLSettingsBase::settingValidation(value, rayleighValidations); if (result["errors"].size() > 0) { @@ -284,14 +283,14 @@ bool validateAbsorptionLayers(LLSD &value) for (LLSD::array_iterator itf = value.beginArray(); itf != value.endArray(); ++itf) { LLSD& layerConfig = (*itf); - if (layerConfig.type() == LLSD::Type::TypeMap) + if (layerConfig.type() == LLSD::TypeMap) { if (!validateAbsorptionLayers(layerConfig)) { allGood = false; } } - else if (layerConfig.type() == LLSD::Type::TypeArray) + else if (layerConfig.type() == LLSD::TypeArray) { return validateAbsorptionLayers(layerConfig); } @@ -302,7 +301,7 @@ bool validateAbsorptionLayers(LLSD &value) } return allGood; } - llassert(value.type() == LLSD::Type::TypeMap); + llassert(value.type() == LLSD::TypeMap); LLSD result = LLSettingsBase::settingValidation(value, absorptionValidations); if (result["errors"].size() > 0) { @@ -326,14 +325,14 @@ bool validateMieLayers(LLSD &value) for (LLSD::array_iterator itf = value.beginArray(); itf != value.endArray(); ++itf) { LLSD& layerConfig = (*itf); - if (layerConfig.type() == LLSD::Type::TypeMap) + if (layerConfig.type() == LLSD::TypeMap) { if (!validateMieLayers(layerConfig)) { allGood = false; } } - else if (layerConfig.type() == LLSD::Type::TypeArray) + else if (layerConfig.type() == LLSD::TypeArray) { return validateMieLayers(layerConfig); } @@ -379,7 +378,7 @@ LLSettingsSky::LLSettingsSky(): void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) { - LLSettingsSky::ptr_t other = std::static_pointer_cast<LLSettingsSky>(end); + LLSettingsSky::ptr_t other((LLSettingsSky*)end.get()); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); replaceSettings(blenddata); @@ -416,8 +415,6 @@ LLSettingsSky::stringset_t LLSettingsSky::getSlerpKeys() const return slepSet; } - - LLSettingsSky::validation_list_t LLSettingsSky::getValidationList() const { return LLSettingsSky::validationList(); @@ -512,7 +509,6 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList() validation.push_back(Validator(SETTING_SUN_ARC_RADIANS, true, LLSD::TypeReal, boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.1f))))); - validation.push_back(Validator(SETTING_RAYLEIGH_CONFIG, true, LLSD::TypeArray, &validateRayleighLayers)); validation.push_back(Validator(SETTING_ABSORPTION_CONFIG, true, LLSD::TypeArray, &validateAbsorptionLayers)); @@ -771,9 +767,6 @@ LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy) void LLSettingsSky::updateSettings() { - LL_RECORD_BLOCK_TIME(FTM_UPDATE_SKYVALUES); - //LL_INFOS("WINDLIGHT", "SKY", "EEP") << "WL Parameters are dirty. Reticulating Splines..." << LL_ENDL; - mPositionsDirty = isDirty(); mLightingDirty = isDirty(); @@ -1051,3 +1044,8 @@ void LLSettingsSky::calculateLightSettings() const mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; mFadeColor.setAlpha(0); } + +LLUUID LLSettingsSky::GetDefaultAssetId() +{ + return DEFAULT_ASSET_ID; +}
\ No newline at end of file diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 839de033b3..fd613e4299 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -88,13 +88,7 @@ public: static const std::string SETTING_LEGACY_HAZE; - static const LLUUID DEFAULT_SUN_ID; - static const LLUUID DEFAULT_MOON_ID; - static const LLUUID DEFAULT_CLOUD_ID; - - static const LLUUID DEFAULT_ASSET_ID; - - typedef std::shared_ptr<LLSettingsSky> ptr_t; + typedef PTR_NAMESPACE::shared_ptr<LLSettingsSky> ptr_t; //--------------------------------------------------------------------- LLSettingsSky(const LLSD &data); @@ -103,11 +97,11 @@ public: virtual ptr_t buildClone() = 0; //--------------------------------------------------------------------- - virtual std::string getSettingType() const override { return std::string("sky"); } - virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_SKY; } + virtual std::string getSettingType() const SETTINGS_OVERRIDE { return std::string("sky"); } + virtual LLSettingsType::type_e getSettingTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_SKY; } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) override; + virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; static LLSD defaults(); @@ -374,7 +368,7 @@ public: virtual void loadTextures() { }; //===================================================================== - virtual validation_list_t getValidationList() const override; + virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE; static validation_list_t validationList(); static LLSD translateLegacySettings(const LLSD& legacy); @@ -415,7 +409,9 @@ public: LLColor3 getSunDiffuse() const; LLColor4 getTotalAmbient() const; - virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } + + static LLUUID GetDefaultAssetId(); protected: static const std::string SETTING_LEGACY_EAST_ANGLE; @@ -424,13 +420,13 @@ protected: LLSettingsSky(); - virtual stringset_t getSlerpKeys() const override; - virtual stringset_t getSkipInterpolateKeys() const override; - virtual void updateSettings() override; + virtual stringset_t getSlerpKeys() const SETTINGS_OVERRIDE; + virtual stringset_t getSkipInterpolateKeys() const SETTINGS_OVERRIDE; + virtual void updateSettings() SETTINGS_OVERRIDE; private: - mutable bool mPositionsDirty = true; - mutable bool mLightingDirty = true; + mutable bool mPositionsDirty; + mutable bool mLightingDirty; static LLSD rayleighConfigDefault(); static LLSD absorptionConfigDefault(); diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index aa1f0f1935..03e174b454 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -67,11 +67,8 @@ const std::string LLSettingsWater::SETTING_LEGACY_SCALE_BELOW("scaleBelow"); const std::string LLSettingsWater::SETTING_LEGACY_WAVE1_DIR("wave1Dir"); const std::string LLSettingsWater::SETTING_LEGACY_WAVE2_DIR("wave2Dir"); -const LLUUID LLSettingsWater::DEFAULT_WATER_NORMAL_ID(DEFAULT_WATER_NORMAL); - // *LAPRAS* Change when Agni -const LLUUID LLSettingsWater::DEFAULT_ASSET_ID("ce4cfe94-700a-292c-7c22-a2d9201bd661"); - +static const LLUUID DEFAULT_ASSET_ID("ce4cfe94-700a-292c-7c22-a2d9201bd661"); //========================================================================= LLSettingsWater::LLSettingsWater(const LLSD &data) : @@ -98,7 +95,7 @@ LLSD LLSettingsWater::defaults() dfltsetting[SETTING_FOG_MOD] = LLSD::Real(0.25f); dfltsetting[SETTING_FRESNEL_OFFSET] = LLSD::Real(0.5f); dfltsetting[SETTING_FRESNEL_SCALE] = LLSD::Real(0.3999); - dfltsetting[SETTING_NORMAL_MAP] = LLSD::UUID(DEFAULT_WATER_NORMAL_ID); + dfltsetting[SETTING_NORMAL_MAP] = LLSD::UUID(DEFAULT_WATER_NORMAL); dfltsetting[SETTING_NORMAL_SCALE] = LLVector3(2.0f, 2.0f, 2.0f).getValue(); dfltsetting[SETTING_SCALE_ABOVE] = LLSD::Real(0.0299f); dfltsetting[SETTING_SCALE_BELOW] = LLSD::Real(0.2000f); @@ -168,7 +165,7 @@ LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf) { - LLSettingsWater::ptr_t other = std::static_pointer_cast<LLSettingsWater>(end); + LLSettingsWater::ptr_t other((LLSettingsWater*)end.get()); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); replaceSettings(blenddata); @@ -227,3 +224,13 @@ LLSettingsWater::validation_list_t LLSettingsWater::validationList() return validation; } +LLUUID LLSettingsWater::GetDefaultAssetId() +{ + return DEFAULT_ASSET_ID; +} + +LLUUID LLSettingsWater::GetDefaultWaterNormalAssetId() +{ + return DEFAULT_WATER_NORMAL; +} + diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index a85a471bc5..92e9869e45 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -46,11 +46,7 @@ public: static const std::string SETTING_WAVE1_DIR; static const std::string SETTING_WAVE2_DIR; - static const LLUUID DEFAULT_WATER_NORMAL_ID; - - static const LLUUID DEFAULT_ASSET_ID; - - typedef std::shared_ptr<LLSettingsWater> ptr_t; + typedef PTR_NAMESPACE::shared_ptr<LLSettingsWater> ptr_t; //--------------------------------------------------------------------- LLSettingsWater(const LLSD &data); @@ -59,11 +55,11 @@ public: virtual ptr_t buildClone() = 0; //--------------------------------------------------------------------- - virtual std::string getSettingType() const override { return std::string("water"); } - virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_WATER; } + virtual std::string getSettingType() const SETTINGS_OVERRIDE { return std::string("water"); } + virtual LLSettingsType::type_e getSettingTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_WATER; } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) override; + virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; static LLSD defaults(); @@ -208,12 +204,15 @@ public: } - virtual validation_list_t getValidationList() const override; + virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE; static validation_list_t validationList(); static LLSD translateLegacySettings(LLSD legacy); - virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } + + static LLUUID GetDefaultAssetId(); + static LLUUID GetDefaultWaterNormalAssetId(); protected: static const std::string SETTING_LEGACY_BLUR_MULTIPILER; @@ -231,11 +230,11 @@ protected: LLSettingsWater(); - LLVector4 mWaterPlane; - F32 mWaterFogKS; + LLVector4 mWaterPlane; + F32 mWaterFogKS; private: - LLUUID mNextNormalMapID; + LLUUID mNextNormalMapID; }; #endif |