summaryrefslogtreecommitdiff
path: root/indra/llinventory
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2018-05-16 13:42:48 -0700
committerRider Linden <rider@lindenlab.com>2018-05-16 13:42:48 -0700
commit4975bd03c12673778616e1cca1811bf906bb42a6 (patch)
tree766dcc54d2a3980b4e8ec329bc1f747cfa68294c /indra/llinventory
parent3925e37532476c526375fd76143b2b5e1dcce9b9 (diff)
Splitting the blender up to support manual positioning as well as time. Phase1
Diffstat (limited to 'indra/llinventory')
-rw-r--r--indra/llinventory/llsettingsbase.cpp30
-rw-r--r--indra/llinventory/llsettingsbase.h79
2 files changed, 74 insertions, 35 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp
index f2dfeaf154..daf42fc073 100644
--- a/indra/llinventory/llsettingsbase.cpp
+++ b/indra/llinventory/llsettingsbase.cpp
@@ -52,8 +52,6 @@ const std::string LLSettingsBase::SETTING_NAME("name");
const std::string LLSettingsBase::SETTING_HASH("hash");
const std::string LLSettingsBase::SETTING_TYPE("type");
-const F64Seconds LLSettingsBlender::DEFAULT_THRESHOLD(0.01);
-
//=========================================================================
LLSettingsBase::LLSettingsBase():
mSettings(LLSD::emptyMap()),
@@ -535,21 +533,37 @@ bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range)
}
//=========================================================================
-void LLSettingsBlender::update(F64Seconds timedelta)
+void LLSettingsBlender::update(F64 blendf)
{
- mTimeSpent += timedelta;
- if (mTimeSpent >= mSeconds)
+}
+
+F64 LLSettingsBlender::setPosition(F64 blendf)
+{
+ if (blendf >= 1.0)
{
+ mTarget->replaceSettings(mFinal->getSettings());
LLSettingsBlender::ptr_t hold = shared_from_this(); // prevents this from deleting too soon
mOnFinished(shared_from_this());
- return;
+ return 1.0;
}
-
- F64 blendf = fmod(mTimeSpent.value(), mSeconds.value()) / mSeconds.value();
+ blendf = llclamp(blendf, 0.0, 1.0);
//_WARNS("LAPRAS") << "blending at " << (blendf * 100.0f) << "%" << LL_ENDL;
mTarget->replaceSettings(mInitial->getSettings());
mTarget->blend(mFinal, blendf);
+
+ return blendf;
}
+//-------------------------------------------------------------------------
+void LLSettingsBlenderTimeDelta::update(F64 timedelta)
+{
+ mTimeSpent += F64Seconds(timedelta);
+
+ F64 blendf = fmod(mTimeSpent.value(), mBlendSpan.value()) / mBlendSpan.value();
+
+ // Note no clamp here.
+
+ setPosition(blendf);
+}
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h
index 2220cca336..ee0a86010c 100644
--- a/indra/llinventory/llsettingsbase.h
+++ b/indra/llinventory/llsettingsbase.h
@@ -264,67 +264,92 @@ public:
typedef boost::signals2::signal<void(const ptr_t )> finish_signal_t;
typedef boost::signals2::connection connection_t;
- static const F64Seconds DEFAULT_THRESHOLD;
-
LLSettingsBlender(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, F64 span = 1.0) :
+ mOnFinished(),
mTarget(target),
mInitial(initsetting),
- mFinal(endsetting),
- mSeconds(seconds),
- mOnFinished(),
- mLastUpdate(0.0f),
- mTimeSpent(0.0f)
+ mFinal(endsetting)
{
mTarget->replaceSettings(mInitial->getSettings());
- mTimeStart = F64Seconds(LLDate::now().secondsSinceEpoch());
- mLastUpdate = mTimeStart;
}
- ~LLSettingsBlender() {}
+ virtual ~LLSettingsBlender() {}
- void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64Seconds seconds )
+ virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 span = 1.0)
{
mInitial = initsetting;
mFinal = endsetting;
- mSeconds = seconds;
mTarget->replaceSettings(mInitial->getSettings());
- mTimeStart.value(LLDate::now().secondsSinceEpoch());
- mLastUpdate = mTimeStart;
- mTimeSpent.value(0.0f);
- }
-
- connection_t setOnFinished(const finish_signal_t::slot_type &onfinished)
- {
- return mOnFinished.connect(onfinished);
}
- LLSettingsBase::ptr_t getTarget() const
+ LLSettingsBase::ptr_t getTarget() const
{
return mTarget;
}
- LLSettingsBase::ptr_t getInitial() const
+ LLSettingsBase::ptr_t getInitial() const
{
return mInitial;
}
- LLSettingsBase::ptr_t getFinal() const
+ LLSettingsBase::ptr_t getFinal() const
{
return mFinal;
}
- void update(F64Seconds time);
+ connection_t setOnFinished(const finish_signal_t::slot_type &onfinished)
+ {
+ return mOnFinished.connect(onfinished);
+ }
+
+ virtual void update(F64 blendf);
+ virtual F64 setPosition(F64 blendf);
private:
+ finish_signal_t mOnFinished;
+
LLSettingsBase::ptr_t mTarget;
LLSettingsBase::ptr_t mInitial;
LLSettingsBase::ptr_t mFinal;
- F64Seconds mSeconds;
- finish_signal_t mOnFinished;
+};
+
+class LLSettingsBlenderTimeDelta : public LLSettingsBlender
+{
+public:
+ LLSettingsBlenderTimeDelta(const LLSettingsBase::ptr_t &target,
+ const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64Seconds seconds) :
+ LLSettingsBlender(target, initsetting, endsetting, seconds.value()),
+ mBlendSpan(seconds),
+ mLastUpdate(0.0f),
+ mTimeSpent(0.0f)
+ {
+ mTimeStart = F64Seconds(LLDate::now().secondsSinceEpoch());
+ mLastUpdate = mTimeStart;
+ }
+
+ virtual ~LLSettingsBlenderTimeDelta()
+ {
+ }
+
+ virtual void reset(LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 span = 1.0) override
+ {
+ LLSettingsBlender::reset(initsetting, endsetting, span);
+
+ mBlendSpan.value(span);
+ mTimeStart.value(LLDate::now().secondsSinceEpoch());
+ mLastUpdate = mTimeStart;
+ mTimeSpent.value(0.0f);
+ }
+
+ virtual void update(F64 timedelta) override;
+
+private:
+ F64Seconds mBlendSpan;
F64Seconds mLastUpdate;
F64Seconds mTimeSpent;
F64Seconds mTimeStart;
};
+
#endif