diff options
author | Graham Linden <graham@lindenlab.com> | 2018-06-04 23:12:21 +0100 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2018-06-04 23:12:21 +0100 |
commit | cd8f0da2d187df69a99a665ea11faaa4e13b7a12 (patch) | |
tree | 45d02c7c8bf5387c35393ccc980a52fe0907ab75 /indra/llinventory | |
parent | 38271e9980f2ccb6b80b27cd063933748247a7be (diff) |
Fix use of new typedefs in inventory settings code in llenvironment.
Diffstat (limited to 'indra/llinventory')
-rw-r--r-- | indra/llinventory/llsettingsbase.cpp | 12 | ||||
-rw-r--r-- | indra/llinventory/llsettingsbase.h | 31 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.cpp | 42 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.h | 24 | ||||
-rw-r--r-- | indra/llinventory/llsettingswater.cpp | 2 |
5 files changed, 53 insertions, 58 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 23afbdfa3a..76b1e0b2a6 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -35,7 +35,7 @@ //========================================================================= namespace { - const LLSettingsBase::BlendFactor BREAK_POINT = 0.5; + const LLSettingsBase::TrackPosition BREAK_POINT = 0.5; } //========================================================================= @@ -554,10 +554,10 @@ bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range) //========================================================================= void LLSettingsBlender::update(const LLSettingsBase::BlendFactor& blendf) { - setPosition(blendf); + setBlendFactor(blendf); } -F64 LLSettingsBlender::setPosition(const LLSettingsBase::TrackPosition& blendf_in) +F64 LLSettingsBlender::setBlendFactor(const LLSettingsBase::BlendFactor& blendf_in) { LLSettingsBase::TrackPosition blendf = blendf_in; if (blendf >= 1.0) @@ -565,7 +565,7 @@ F64 LLSettingsBlender::setPosition(const LLSettingsBase::TrackPosition& blendf_i triggerComplete(); return 1.0; } - blendf = llclamp(blendf, 0.0, 1.0); + blendf = llclamp(blendf, 0.0f, 1.0f); mTarget->replaceSettings(mInitial->getSettings()); if (!mFinal || (mInitial == mFinal) || (blendf == 0.0)) @@ -590,7 +590,7 @@ LLSettingsBase::BlendFactor LLSettingsBlenderTimeDelta::calculateBlend(const LLS return LLSettingsBase::BlendFactor(fmod((F64)spanpos, (F64)spanlen) / (F64)spanlen); } -void LLSettingsBlenderTimeDelta::advance(const LLSettingsBase::Seconds& timedelta) +void LLSettingsBlenderTimeDelta::applyTimeDelta(const LLSettingsBase::Seconds& timedelta) { mTimeSpent += timedelta; @@ -602,5 +602,5 @@ void LLSettingsBlenderTimeDelta::advance(const LLSettingsBase::Seconds& timedelt LLSettingsBase::BlendFactor blendf = calculateBlend(mTimeSpent, mBlendSpan); - setPosition(blendf); + update(blendf); } diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index a8e1cc5eea..374a2ec246 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -48,9 +48,6 @@ #define PTR_NAMESPACE std #define SETTINGS_OVERRIDE override -//#define PTR_NAMESPACE boost -//#define SETTINGS_OVERRIDE - class LLSettingsBase : public PTR_NAMESPACE::enable_shared_from_this<LLSettingsBase>, private boost::noncopyable @@ -63,7 +60,7 @@ class LLSettingsBase : public: typedef F64Seconds Seconds; typedef F64 BlendFactor; - typedef F64 TrackPosition; + typedef F32 TrackPosition; // 32-bit as these are stored in LLSD as such static const std::string SETTING_ID; static const std::string SETTING_NAME; @@ -305,7 +302,7 @@ public: virtual ~LLSettingsBlender() {} - virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::Seconds& span) + virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::TrackPosition&) { // note: the 'span' reset parameter is unused by the base class. if (!mInitial) @@ -341,9 +338,15 @@ public: } virtual void update(const LLSettingsBase::BlendFactor& blendf); - virtual F64 setPosition(const LLSettingsBase::TrackPosition& position); + virtual void applyTimeDelta(const LLSettingsBase::Seconds& delta) + { + llassert(false); + // your derived class needs to implement an override of this func + } + + virtual F64 setBlendFactor(const LLSettingsBase::BlendFactor& position); - virtual void switchTrack(S32 trackno, const LLSettingsBase::BlendFactor& position) { /*NoOp*/ } + virtual void switchTrack(S32 trackno, const LLSettingsBase::TrackPosition& position) { /*NoOp*/ } protected: void triggerComplete(); @@ -359,9 +362,9 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender { public: LLSettingsBlenderTimeDelta(const LLSettingsBase::ptr_t &target, - const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, LLSettingsBase::Seconds seconds) : + const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, LLSettingsBase::Seconds blend_span) : LLSettingsBlender(target, initsetting, endsetting), - mBlendSpan(seconds), + mBlendSpan(blend_span), mLastUpdate(0.0f), mTimeSpent(0.0f) { @@ -373,22 +376,22 @@ public: { } - virtual void reset(LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::Seconds& span) SETTINGS_OVERRIDE + virtual void reset(LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::TrackPosition& blend_span) SETTINGS_OVERRIDE { - LLSettingsBlender::reset(initsetting, endsetting, span); + LLSettingsBlender::reset(initsetting, endsetting, blend_span); - mBlendSpan = span; + mBlendSpan = blend_span; mTimeStart = LLSettingsBase::Seconds(LLDate::now().secondsSinceEpoch()); mLastUpdate = mTimeStart; mTimeSpent = LLSettingsBase::Seconds(0.0); } - virtual void advance(const LLSettingsBase::Seconds& timedelta); + virtual void applyTimeDelta(const LLSettingsBase::Seconds& timedelta) SETTINGS_OVERRIDE; protected: LLSettingsBase::BlendFactor calculateBlend(const LLSettingsBase::TrackPosition& spanpos, const LLSettingsBase::TrackPosition& spanlen) const; - LLSettingsBase::Seconds mBlendSpan; + LLSettingsBase::TrackPosition mBlendSpan; LLSettingsBase::Seconds mLastUpdate; LLSettingsBase::Seconds mTimeSpent; LLSettingsBase::Seconds mTimeStart; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index cd2102a527..00391ca82d 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -51,7 +51,7 @@ namespace } else if (begin > end) { - return 1.0 - (begin - end); + return T(1.0) - (begin - end); } return 0; @@ -227,9 +227,8 @@ bool LLSettingsDay::initialize() LLSD curtrack = tracks[i]; for (LLSD::array_const_iterator it = curtrack.beginArray(); it != curtrack.endArray(); ++it) { - 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::TrackPosition keyframe = LLSettingsBase::TrackPosition((*it)[SETTING_KEYKFRAME].asReal()); + keyframe = llclamp(keyframe, 0.0f, 1.0f); LLSettingsBase::ptr_t setting; if ((*it).has(SETTING_KEYNAME)) @@ -262,10 +261,6 @@ bool LLSettingsDay::initialize() hassky |= true; mDayTracks[i][keyframe] = setting; } - else - { - LL_WARNS("SETTINGS", "DAYCYCLE") << "Skipping frame on track #" << i << " at time index " << keyframe << LL_ENDL; - } } } @@ -312,6 +307,7 @@ LLSD LLSettingsDay::defaults() dfltsetting[SETTING_FRAMES] = frames; dfltsetting[SETTING_TYPE] = "daycycle"; + return dfltsetting; } @@ -365,7 +361,7 @@ namespace continue; } - F32 frame = elem[LLSettingsDay::SETTING_KEYKFRAME].asReal(); + LLSettingsBase::TrackPosition frame = elem[LLSettingsDay::SETTING_KEYKFRAME].asReal(); if ((frame < 0.0) || (frame > 1.0)) { frame = llclamp(frame, 0.0f, 1.0f); @@ -483,8 +479,6 @@ LLSettingsDay::CycleTrack_t &LLSettingsDay::getCycleTrack(S32 track) //========================================================================= void LLSettingsDay::startDayCycle() { - LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); - if (!mInitialized) { LL_WARNS("DAYCYCLE") << "Attempt to start day cycle on uninitialized object." << LL_ENDL; @@ -519,7 +513,7 @@ LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno) return keyframes; } -bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::Seconds& old_frame, const LLSettingsBase::Seconds& new_frame) +bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::TrackPosition& old_frame, const LLSettingsBase::TrackPosition& new_frame) { if ((trackno < 0) || (trackno >= TRACK_MAX)) { @@ -538,8 +532,7 @@ bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::Seconds { LLSettingsBase::ptr_t base = iter->second; track.erase(iter); - // why are we clamping a time value as if its a blend factor - //track[llclamp(new_frame, 0.0f, 1.0f)] = base; + track[llclamp(new_frame, 0.0f, 1.0f)] = base; track[new_frame] = base; return true; } @@ -548,7 +541,7 @@ bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::Seconds } -bool LLSettingsDay::removeTrackKeyframe(S32 trackno, const LLSettingsBase::Seconds& frame) +bool LLSettingsDay::removeTrackKeyframe(S32 trackno, const LLSettingsBase::TrackPosition& frame) { if ((trackno < 0) || (trackno >= TRACK_MAX)) { @@ -568,18 +561,18 @@ bool LLSettingsDay::removeTrackKeyframe(S32 trackno, const LLSettingsBase::Secon return false; } -void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::Seconds& keyframe) +void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::TrackPosition& keyframe) { setSettingsAtKeyframe(water, keyframe, TRACK_WATER); } -LLSettingsWater::ptr_t LLSettingsDay::getWaterAtKeyframe(const LLSettingsBase::Seconds& keyframe) const +LLSettingsWater::ptr_t LLSettingsDay::getWaterAtKeyframe(const LLSettingsBase::TrackPosition& keyframe) const { LLSettingsBase* p = getSettingsAtKeyframe(keyframe, TRACK_WATER).get(); return LLSettingsWater::ptr_t((LLSettingsWater*)p); } -void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, const LLSettingsBase::Seconds& keyframe, S32 track) +void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, const LLSettingsBase::TrackPosition& keyframe, S32 track) { if ((track < 1) || (track >= TRACK_MAX)) { @@ -590,18 +583,18 @@ void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, const LLSe setSettingsAtKeyframe(sky, keyframe, track); } -LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const +LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(const LLSettingsBase::TrackPosition& 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(); } - LLSettingsBase* p = getSettingsAtKeyframe(keyframe, track).get(); - return LLSettingsSky::ptr_t((LLSettingsSky*)p); + + return PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(getSettingsAtKeyframe(keyframe, track)); } -void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::Seconds& keyframe, S32 track) +void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::TrackPosition& keyframe, S32 track) { if ((track < 0) || (track >= TRACK_MAX)) { @@ -609,12 +602,11 @@ void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, return; } - //mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = settings; - mDayTracks[track][keyframe] = settings; + mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = settings; setDirtyFlag(true); } -LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(const LLSettingsBase::Seconds& keyframe, S32 track) const +LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const { if ((track < 0) || (track >= TRACK_MAX)) { diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 6f54833c74..6635bc0c5a 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -59,9 +59,9 @@ public: static const Seconds DEFAULT_DAYOFFSET; static const Seconds MAXIMUM_DAYOFFSET; - static const S32 TRACK_WATER; - static const S32 TRACK_MAX; - static const S32 FRAME_MAX; + static const S32 TRACK_WATER; + static const S32 TRACK_MAX; + static const S32 FRAME_MAX; typedef std::map<LLSettingsBase::TrackPosition, LLSettingsBase::ptr_t> CycleTrack_t; typedef std::vector<CycleTrack_t> CycleList_t; @@ -91,15 +91,15 @@ public: //--------------------------------------------------------------------- KeyframeList_t getTrackKeyframes(S32 track); - 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; + bool moveTrackKeyframe(S32 track, const LLSettingsBase::TrackPosition& old_frame, const LLSettingsBase::TrackPosition& new_frame); + bool removeTrackKeyframe(S32 track, const LLSettingsBase::TrackPosition& frame); + + void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::TrackPosition& keyframe); + LLSettingsWaterPtr_t getWaterAtKeyframe(const LLSettingsBase::TrackPosition& keyframe) const; + void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, const LLSettingsBase::TrackPosition& keyframe, S32 track); + LLSettingsSkyPtr_t getSkyAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const; + void setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::TrackPosition& keyframe, S32 track); + LLSettingsBase::ptr_t getSettingsAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const; //--------------------------------------------------------------------- void startDayCycle(); diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index 03e174b454..ba147baed7 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -165,7 +165,7 @@ LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf) { - LLSettingsWater::ptr_t other((LLSettingsWater*)end.get()); + LLSettingsWater::ptr_t other = PTR_NAMESPACE::static_pointer_cast<LLSettingsWater>(end); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); replaceSettings(blenddata); |