diff options
author | Richard Linden <none@none> | 2014-02-19 12:32:08 -0800 |
---|---|---|
committer | Richard Linden <none@none> | 2014-02-19 12:32:08 -0800 |
commit | ef591d280eb3c5bae7da20540ad4cbb30858d0aa (patch) | |
tree | ff387e884e25eaa8a47adff4110ce02edfe67387 /indra/llcommon/llcriticaldamp.h | |
parent | ce7e19d33a74e89059c2196da9c439d0eb9b21c1 (diff) | |
parent | 6661628d5c68855ddffc54a3f2578f93ada84de1 (diff) |
Merge with release
Diffstat (limited to 'indra/llcommon/llcriticaldamp.h')
-rwxr-xr-x | indra/llcommon/llcriticaldamp.h | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/indra/llcommon/llcriticaldamp.h b/indra/llcommon/llcriticaldamp.h index 52f052ae25..1fb6a1af29 100755 --- a/indra/llcommon/llcriticaldamp.h +++ b/indra/llcommon/llcriticaldamp.h @@ -28,26 +28,46 @@ #ifndef LL_LLCRITICALDAMP_H #define LL_LLCRITICALDAMP_H -#include <map> +#include <vector> #include "llframetimer.h" +#include "llunits.h" -class LL_COMMON_API LLCriticalDamp +class LL_COMMON_API LLSmoothInterpolation { public: - LLCriticalDamp(); + LLSmoothInterpolation(); // MANIPULATORS static void updateInterpolants(); // ACCESSORS - static F32 getInterpolant(const F32 time_constant, BOOL use_cache = TRUE); + static F32 getInterpolant(F32SecondsImplicit time_constant, bool use_cache = true); -protected: + template<typename T> + static T lerp(T a, T b, F32SecondsImplicit time_constant, bool use_cache = true) + { + F32 interpolant = getInterpolant(time_constant, use_cache); + return ((a * (1.f - interpolant)) + + (b * interpolant)); + } + +protected: + static F32 calcInterpolant(F32 time_constant); + + struct CompareTimeConstants; static LLFrameTimer sInternalTimer; // frame timer for calculating deltas - static std::map<F32, F32> sInterpolants; + struct Interpolant + { + F32 mTimeScale; + F32 mInterpolant; + }; + typedef std::vector<Interpolant> interpolant_vec_t; + static interpolant_vec_t sInterpolants; static F32 sTimeDelta; }; +typedef LLSmoothInterpolation LLCriticalDamp; + #endif // LL_LLCRITICALDAMP_H |