Sleeping Wombat Common Library  0.50.0
swCommonLibrary
DiscreteInterpolator.h
Go to the documentation of this file.
1 #pragma once
2 
8 #include "IInterpolator.h"
9 
10 
11 
15 template< typename KeyType >
16 class DiscreteInterpolator : public IInterpolator< KeyType >
17 {
18 private:
19 protected:
20 public:
22  explicit DiscreteInterpolator () = default;
24  explicit DiscreteInterpolator ( const Key< KeyType >& leftKey,
25  const Key< KeyType >& rightKey,
26  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
27  UPtr< const IInterpolator< KeyType > >& rightInterpolator );
28  ~DiscreteInterpolator() = default;
29 
31  virtual KeyType Interpolate ( TimeType time, Key< KeyType >& left, Key< KeyType >& right ) override;
32 
35  virtual void Update ( const Key< KeyType >& leftKey,
36  const Key< KeyType >& rightKey,
37  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
38  UPtr< const IInterpolator< KeyType > >& rightInterpolator ) override;
39 
42  virtual KeyType LeftTangent ( const Key< KeyType >& left, const Key< KeyType >& right ) const override;
45  virtual KeyType RightTangent ( const Key< KeyType >& left, const Key< KeyType >& right ) const override;
46 };
47 
48 //====================================================================================//
49 // Implementation
50 //====================================================================================//
51 
52 
53 // ================================ //
54 //
55 template< typename KeyType >
57  const Key< KeyType >& rightKey,
58  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
59  UPtr< const IInterpolator< KeyType > >& rightInterpolator )
60 {}
61 
62 // ================================ //
63 //
64 template< typename KeyType >
65 inline KeyType DiscreteInterpolator< KeyType >::Interpolate ( TimeType time, Key< KeyType >& left, Key< KeyType >& right )
66 {
67  return left.Value;
68 }
69 
70 // ================================ //
71 //
72 template< typename KeyType >
73 inline void DiscreteInterpolator< KeyType >::Update ( const Key< KeyType >& leftKey, const Key< KeyType >& rightKey, UPtr< const IInterpolator< KeyType > >& leftInterpolator, UPtr< const IInterpolator< KeyType > >& rightInterpolator )
74 {}
75 
76 // ================================ //
77 //
78 template< typename KeyType >
79 inline KeyType DiscreteInterpolator< KeyType >::LeftTangent ( const Key< KeyType >& left, const Key< KeyType >& right ) const
80 {
81  return KeyType( 0 );
82 }
83 
84 // ================================ //
85 //
86 template< typename KeyType >
87 inline KeyType DiscreteInterpolator< KeyType >::RightTangent ( const Key< KeyType >& left, const Key< KeyType >& right ) const
88 {
89  return KeyType( 0 );
90 }
virtual void Update(const Key< KeyType > &leftKey, const Key< KeyType > &rightKey, UPtr< const IInterpolator< KeyType > > &leftInterpolator, UPtr< const IInterpolator< KeyType > > &rightInterpolator) override
Function updates interpolator, when left or right key value changes.
Definition: DiscreteInterpolator.h:73
Base class for interpolators.
Definition: IInterpolator.h:38
Definition: UPtr.h:10
DiscreteInterpolator()=default
Constructor for serialization.
virtual KeyType RightTangent(const Key< KeyType > &left, const Key< KeyType > &right) const override
Returns curve tangent. Function can be used by surrounding interpolators to smooth curve...
Definition: DiscreteInterpolator.h:87
virtual KeyType LeftTangent(const Key< KeyType > &left, const Key< KeyType > &right) const override
Returns curve tangent. Function can be used by surrounding interpolators to smooth curve...
Definition: DiscreteInterpolator.h:79
Animation key.
Definition: IInterpolator.h:21
virtual KeyType Interpolate(TimeType time, Key< KeyType > &left, Key< KeyType > &right) override
Interpolates value.
Definition: DiscreteInterpolator.h:65
Definition: DiscreteInterpolator.h:16