6 #include <Core/Containers/AlignedAllocator.hpp>
7 #include <Core/Math/Math.hpp>
30 virtual inline size_t size()
const = 0;
46 virtual inline std::vector<Scalar>
getTimes()
const = 0;
61 template <
typename VALUE_TYPE>
66 using KeyFrame = std::pair<Scalar, VALUE_TYPE>;
85 inline std::vector<Scalar>
getTimes()
const override {
87 #pragma omp parallel for
88 for (
int i = 0; i < int(
m_keyframes.size() ); ++i ) {
118 auto upper = std::upper_bound(
120 return a.first < b.first;
124 auto lower = upper - 1;
143 if (
size() == 1 )
return false;
163 inline VALUE_TYPE
at(
const Scalar& t,
const Interpolator& interpolator )
const {
164 return interpolator( *
this, t );
181 std::tuple<size_t, size_t, Scalar>
findRange( Scalar t )
const {
183 if ( t <
m_keyframes.begin()->first ) {
return { 0, 0, 0_ra }; }
187 return { i, i, 0_ra };
192 auto upper = std::upper_bound(
194 return a.first < b.first;
201 const size_t i = std::distance(
m_keyframes.begin(), lower );
202 return { i, i, 0_ra };
205 const size_t i = std::distance(
m_keyframes.begin(), lower );
206 const Scalar t0 = lower->first;
207 const Scalar t1 = upper->first;
208 return { i, i + 1, ( t - t0 ) / ( t1 - t0 ) };
228 return !( *
this == keyframe );
virtual std::vector< Scalar > getTimes() const =0
virtual size_t size() const =0
virtual void moveKeyFrame(size_t i, const Scalar &t)=0
virtual bool removeKeyFrame(size_t i)=0
void insertInterpolatedKeyFrame(const Scalar &t, const Interpolator &interpolator)
bool operator==(const KeyFramedValue &keyframe) const
std::pair< Scalar, VALUE_TYPE > KeyFrame
The type for a keyframe.
bool operator!=(const KeyFramedValue &keyframe) const
size_t size() const override
std::vector< Scalar > getTimes() const override
void insertKeyFrame(const Scalar &t, const VALUE_TYPE &frame)
void moveKeyFrame(size_t i, const Scalar &t) override
KeyFrames m_keyframes
The list of keyframes.
VALUE_TYPE at(const Scalar &t, const Interpolator &interpolator) const
std::vector< KeyFrame > KeyFrames
The type for the keyframes container.
bool removeKeyFrame(size_t i) override
KeyFramedValue(Scalar t, VALUE_TYPE frame)
const KeyFrame & operator[](size_t i) const
std::tuple< size_t, size_t, Scalar > findRange(Scalar t) const
const KeyFrames & getKeyFrames() const
std::function< VALUE_TYPE(const KeyFramedValue< VALUE_TYPE > &, Scalar)> Interpolator
The type for interpolators.
std::enable_if<!std::numeric_limits< T >::is_integer, bool >::type areApproxEqual(T x, T y, T espilonBoostFactor=T(10))
Compare two numbers such that |x-y| < espilon*epsilonBoostFactor.