Sleeping Wombat Common Library  0.50.0
swCommonLibrary
IInterpolator.h
Go to the documentation of this file.
1 #pragma once
2 
9 
20 template< typename KeyType >
21 struct Key;
22 
23 
24 enum class InterpolatorType : int16
25 {
26  Discrete,
27  Linear,
28  Cosinus,
29  Bezier
30 };
31 
32 
33 
37 template< typename KeyType >
39 {
40 private:
41 protected:
42 public:
43  explicit IInterpolator () = default;
44  virtual ~IInterpolator () = default;
45 
47  virtual KeyType Interpolate ( TimeType time, Key< KeyType >& left, Key< KeyType >& right ) = 0;
48 
51  virtual void Update ( const Key< KeyType >& leftKey,
52  const Key< KeyType >& rightKey,
53  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
54  UPtr< const IInterpolator< KeyType > >& rightInterpolator ) = 0;
55 
58  virtual KeyType LeftTangent ( const Key< KeyType >& left, const Key< KeyType >& right ) const = 0;
61  virtual KeyType RightTangent ( const Key< KeyType >& left, const Key< KeyType >& right ) const = 0;
62 };
63 
64 
66 template< typename KeyType >
67 class DummyInterpolator : public IInterpolator< KeyType >
68 {
69 private:
70 protected:
71 public:
72 
74  virtual KeyType Interpolate ( TimeType time, Key< KeyType >& left, Key< KeyType >& right ) { return KeyType(); }
75 
78  virtual void Update ( const Key< KeyType >& leftKey,
79  const Key< KeyType >& rightKey,
80  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
81  UPtr< const IInterpolator< KeyType > >& rightInterpolator )
82  {}
83 
86  virtual KeyType LeftTangent ( const Key< KeyType >& left, const Key< KeyType >& right ) const { return KeyType(); }
89  virtual KeyType RightTangent ( const Key< KeyType >& left, const Key< KeyType >& right ) const { return KeyType(); }
90 };
Base class for interpolators.
Definition: IInterpolator.h:38
Definition: UPtr.h:10
virtual KeyType RightTangent(const Key< KeyType > &left, const Key< KeyType > &right) const
Returns curve tangent. Function can be used by surrounding interpolators to smooth curve...
Definition: IInterpolator.h:89
virtual KeyType RightTangent(const Key< KeyType > &left, const Key< KeyType > &right) const =0
Returns curve tangent. Function can be used by surrounding interpolators to smooth curve...
virtual void Update(const Key< KeyType > &leftKey, const Key< KeyType > &rightKey, UPtr< const IInterpolator< KeyType > > &leftInterpolator, UPtr< const IInterpolator< KeyType > > &rightInterpolator)
Function updates interpolator, when left or right key value changes.
Definition: IInterpolator.h:78
virtual void Update(const Key< KeyType > &leftKey, const Key< KeyType > &rightKey, UPtr< const IInterpolator< KeyType > > &leftInterpolator, UPtr< const IInterpolator< KeyType > > &rightInterpolator)=0
Function updates interpolator, when left or right key value changes.
Plik zawiera definicje podstawowych typów zmiennych.
virtual KeyType LeftTangent(const Key< KeyType > &left, const Key< KeyType > &right) const
Returns curve tangent. Function can be used by surrounding interpolators to smooth curve...
Definition: IInterpolator.h:86
Animation key.
Definition: IInterpolator.h:21
virtual KeyType LeftTangent(const Key< KeyType > &left, const Key< KeyType > &right) const =0
Returns curve tangent. Function can be used by surrounding interpolators to smooth curve...
virtual KeyType Interpolate(TimeType time, Key< KeyType > &left, Key< KeyType > &right)=0
Main function invoked by evaluator.
virtual KeyType Interpolate(TimeType time, Key< KeyType > &left, Key< KeyType > &right)
Main function invoked by evaluator.
Definition: IInterpolator.h:74
Temporary interpolator for internal use.
Definition: IInterpolator.h:67