summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2019-02-05 15:09:32 -0800
committerRider Linden <rider@lindenlab.com>2019-02-05 15:09:32 -0800
commitce40f88ecb09c91061f7a18ad2b52dcaa3df7ca3 (patch)
treee0cdc1eaf9df54ce7a7521e1c4e65071d96188b7
parent801ce79b7259aaa3e09fefec40f37861946c062c (diff)
Better calculation of time remaining in span for track animator (from SL-10465)
-rw-r--r--indra/llinventory/llsettingsbase.h1
-rw-r--r--indra/newview/llenvironment.cpp28
2 files changed, 28 insertions, 1 deletions
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h
index 9e03052892..45d2fa0027 100644
--- a/indra/llinventory/llsettingsbase.h
+++ b/indra/llinventory/llsettingsbase.h
@@ -519,6 +519,7 @@ public:
inline void setIgnoreTimeDeltaThreshold(bool val) { mIgnoreTimeDelta = val; }
inline bool getIgnoreTimeDeltaThreshold() const { return mIgnoreTimeDelta; }
+ inline void setTimeSpent(LLSettingsBase::Seconds time) { mTimeSpent = time; }
protected:
LLSettingsBase::BlendFactor calculateBlend(const LLSettingsBase::TrackPosition& spanpos, const LLSettingsBase::TrackPosition& spanlen) const;
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index bf8cf4b552..fa583bdc9c 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -170,6 +170,20 @@ namespace
return llclamp(position, 0.0f, 1.0f);
}
+ inline LLSettingsBase::BlendFactor convert_time_to_blend_factor(const LLSettingsBase::Seconds& time, const LLSettingsBase::Seconds& len, LLSettingsDay::CycleTrack_t &track)
+ {
+ LLSettingsBase::TrackPosition position = convert_time_to_position(time, len);
+ LLSettingsDay::TrackBound_t bounds(get_bounding_entries(track, position));
+
+ LLSettingsBase::TrackPosition spanlength(get_wrapping_distance((*bounds.first).first, (*bounds.second).first));
+ if (position < (*bounds.first).first)
+ position += 1.0;
+
+ LLSettingsBase::TrackPosition start = position - (*bounds.first).first;
+
+ return static_cast<LLSettingsBase::BlendFactor>(start / spanlength);
+ }
+
//---------------------------------------------------------------------
class LLTrackBlenderLoopingTime : public LLSettingsBlenderTimeDelta
{
@@ -186,12 +200,14 @@ namespace
// must happen prior to getBoundingEntries call...
mTrackNo = selectTrackNumber(trackno);
- LLSettingsDay::TrackBound_t initial = getBoundingEntries(getAdjustedNow());
+ LLSettingsBase::Seconds now(getAdjustedNow());
+ LLSettingsDay::TrackBound_t initial = getBoundingEntries(now);
mInitial = (*initial.first).second;
mFinal = (*initial.second).second;
mBlendSpan = getSpanTime(initial);
+ initializeTarget(now);
setOnFinished([this](const LLSettingsBlender::ptr_t &){ onFinishedSpan(); });
}
@@ -248,6 +264,16 @@ namespace
return bounds;
}
+ void initializeTarget(LLSettingsBase::Seconds time)
+ {
+ LLSettingsBase::BlendFactor blendf(convert_time_to_blend_factor(time, mCycleLength, mDay->getCycleTrack(mTrackNo)));
+
+ blendf = llclamp(blendf, 0.0, 0.999);
+ setTimeSpent(LLSettingsBase::Seconds(blendf * mBlendSpan));
+
+ setBlendFactor(blendf);
+ }
+
LLSettingsBase::Seconds getAdjustedNow() const
{
LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch());