diff options
-rw-r--r-- | indra/llinventory/llsettingsbase.cpp | 30 | ||||
-rw-r--r-- | indra/llinventory/llsettingsbase.h | 79 | ||||
-rw-r--r-- | indra/newview/llenvironment.cpp | 14 |
3 files changed, 81 insertions, 42 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 diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 98da6ea22f..f2d64f7e40 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1380,9 +1380,9 @@ void LLEnvironment::DayInstance::update(F64Seconds delta) initialize(); if (mBlenderSky) - mBlenderSky->update(delta); + mBlenderSky->update(delta.value()); if (mBlenderWater) - mBlenderWater->update(delta); + mBlenderWater->update(delta.value()); // if (mSky) // mSky->update(); @@ -1495,7 +1495,7 @@ void LLEnvironment::DayInstance::animate() F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); mWater = std::static_pointer_cast<LLSettingsVOWater>((*bounds.first).second)->buildClone(); - mBlenderWater = std::make_shared<LLSettingsBlender>(mWater, + mBlenderWater = std::make_shared<LLSettingsBlenderTimeDelta>(mWater, (*bounds.first).second, (*bounds.second).second, timespan); mBlenderWater->setOnFinished( [this](LLSettingsBlender::ptr_t blender) { onTrackTransitionDone(0, blender); }); @@ -1523,7 +1523,7 @@ void LLEnvironment::DayInstance::animate() F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first); mSky = std::static_pointer_cast<LLSettingsVOSky>((*bounds.first).second)->buildClone(); - mBlenderSky = std::make_shared<LLSettingsBlender>(mSky, + mBlenderSky = std::make_shared<LLSettingsBlenderTimeDelta>(mSky, (*bounds.first).second, (*bounds.second).second, timespan); mBlenderSky->setOnFinished( [this](LLSettingsBlender::ptr_t blender) { onTrackTransitionDone(1, blender); }); @@ -1548,7 +1548,7 @@ void LLEnvironment::DayInstance::onTrackTransitionDone(S32 trackno, const LLSett " start=" << (*bounds.first).first << " end=" << (*bounds.second).first << " span=" << timespan << LL_ENDL; - blender->reset((*bounds.first).second, (*bounds.second).second, timespan); + blender->reset((*bounds.first).second, (*bounds.second).second, timespan.value()); } //------------------------------------------------------------------------- @@ -1574,7 +1574,7 @@ void LLEnvironment::DayTransition::animate() mNextInstance->animate(); mWater = mStartWater->buildClone(); - mBlenderWater = std::make_shared<LLSettingsBlender>(mWater, mStartWater, mNextInstance->getWater(), mTransitionTime); + mBlenderWater = std::make_shared<LLSettingsBlenderTimeDelta>(mWater, mStartWater, mNextInstance->getWater(), mTransitionTime); mBlenderWater->setOnFinished( [this](LLSettingsBlender::ptr_t blender) { mBlenderWater.reset(); @@ -1584,7 +1584,7 @@ void LLEnvironment::DayTransition::animate() }); mSky = mStartSky->buildClone(); - mBlenderSky = std::make_shared<LLSettingsBlender>(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime); + mBlenderSky = std::make_shared<LLSettingsBlenderTimeDelta>(mSky, mStartSky, mNextInstance->getSky(), mTransitionTime); mBlenderSky->setOnFinished( [this](LLSettingsBlender::ptr_t blender) { mBlenderSky.reset(); |