Loading [MathJax]/jax/output/HTML-CSS/config.js
Radium Engine  1.5.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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 
8 namespace Ra {
9 namespace Core {
10 namespace Animation {
11 
18 template <typename T>
19 inline 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 
26 template <>
27 inline 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 
36 template <>
37 inline 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 
46 template <>
47 inline 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)
Definition: Cage.cpp:3