Radium Engine  1.5.20
Loading...
Searching...
No Matches
KeyFramedValueInterpolators.hpp
1#pragma once
2
3#include <Core/Animation/KeyFramedValue.hpp>
4#include <Core/Animation/Pose.hpp>
5#include <Core/Animation/PoseOperation.hpp>
6#include <Core/Math/Interpolation.hpp>
7
8namespace Ra {
9namespace Core {
10namespace Animation {
11
18template <typename T>
19inline T linearInterpolate( const KeyFramedValue<T>& keyframes, Scalar t ) {
20 CORE_ASSERT( keyframes.size() > 0, "Keyframe vectors must contain at least one keyframe." );
21 auto [i, j, dt] = keyframes.findRange( t );
22 return Core::Math::linearInterpolate( keyframes[i].second, keyframes[j].second, dt );
23}
24
26template <>
27inline bool linearInterpolate<bool>( const KeyFramedValue<bool>& keyframes, const Scalar t ) {
28 CORE_ASSERT( keyframes.size() > 0, "Keyframe vectors must contain at least one keyframe." );
29 auto [i, j, dt] = keyframes.findRange( t );
30 CORE_UNUSED( j );
31 CORE_UNUSED( dt );
32 return keyframes[i].second;
33}
34
36template <>
37inline int linearInterpolate<int>( const KeyFramedValue<int>& keyframes, const Scalar t ) {
38 CORE_ASSERT( keyframes.size() > 0, "Keyframe vectors must contain at least one keyframe." );
39 auto [i, j, dt] = keyframes.findRange( t );
40 CORE_UNUSED( j );
41 CORE_UNUSED( dt );
42 return keyframes[i].second;
43}
44
46template <>
47inline Pose linearInterpolate<Pose>( const KeyFramedValue<Pose>& keyframes, Scalar t ) {
48 CORE_ASSERT( keyframes.size() > 0, "Keyframe vectors must contain at least one keyframe." );
49 auto [i, j, dt] = keyframes.findRange( t );
50 return interpolatePoses( keyframes[i].second, keyframes[j].second, dt );
51}
53
54} // namespace Animation
55} // namespace Core
56} // namespace Ra
std::tuple< size_t, size_t, Scalar > findRange(Scalar t) const
T linearInterpolate(const T &v0, const T &v1, const Scalar t)
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3