Sleeping Wombat GUI  0.100
swGUI
AnimEvaluator.h
Go to the documentation of this file.
1 #pragma once
2 
9 
12 
13 
14 
25 template< typename KeyType, typename AddressType >
27 {
28 public:
30 private:
32  AddressType m_param;
33 
34 protected:
35 public:
37  explicit AnimEvaluator () = default;
38  explicit AnimEvaluator ( EngineObject* object, const std::string& propertyPath );
39  ~AnimEvaluator () = default;
40 
41 
42  void Evaluate ( EngineObject* object, TimeType time );
43 
46  bool AddKey ( TimeType time, const KeyType& value );
49  bool AddKey ( TimeType time, const KeyType& value, InterpolatorType interpolatorType );
52  bool UpdateKey ( TimeType time, const KeyType& newValue, UPtr< Interpolator >&& interpolator );
55  bool UpdateKey ( TimeType time, const KeyType& newValue );
58  bool RemoveKey ( TimeType time );
59 
62  bool ChangeInterpolator ( Size idx, UPtr< Interpolator >&& interpolator );
63 
65  const Key< KeyType >* GetKey ( TimeType time );
66 
68  virtual KeySet< KeyType >& GetKeySet ();
69 };
70 
71 
72 
73 //====================================================================================//
74 // Implementation
75 //====================================================================================//
76 
77 // ================================ //
78 //
79 template< typename KeyType, typename AddressType >
80 inline AnimEvaluator< KeyType, AddressType >::AnimEvaluator( EngineObject* object, const std::string& propertyPath )
81  : m_param( object, propertyPath )
82 {
83  //static_assert( std::is_member_function_pointer< &AddressType::GetValue >::value, "Template parameter AddressType must implement GetValue function." );
84  //static_assert( std::is_member_function_pointer< &AddressType::SetValue >::value, "Template parameter AddressType must implement SetValue function." );
85 
86  KeyType curValue = m_param.GetValue( object );
87  m_keySet.UpdateKey( TimeType( 0.0 ), curValue );
88 }
89 
90 
91 // ================================ //
92 //
93 template< typename KeyType, typename AddressType >
95 {
96  KeyType value = m_keySet.Evaluate( time );
97  m_param.SetValue( object, value );
98 }
99 
100 // ================================ //
101 //
102 template< typename KeyType, typename AddressType >
104 {
105  return m_keySet.AddKey( time, value );
106 }
107 
108 // ================================ //
109 //
110 template< typename KeyType, typename AddressType >
111 inline bool AnimEvaluator< KeyType, AddressType >::AddKey ( TimeType time, const KeyType & value, InterpolatorType interpolatorType )
112 {
113  return false;
114 }
115 
116 // ================================ //
117 //
118 template< typename KeyType, typename AddressType >
119 inline bool AnimEvaluator< KeyType, AddressType >::UpdateKey ( TimeType time, const KeyType & newValue, UPtr< Interpolator >&& interpolator )
120 {
121  return false;
122 }
123 
124 // ================================ //
125 //
126 template< typename KeyType, typename AddressType >
128 {
129  return m_keySet.UpdateKey( time, newValue );
130 }
131 
132 // ================================ //
133 //
134 template< typename KeyType, typename AddressType >
136 {
137  return m_keySet.RemoveKey( time );
138 }
139 
140 // ================================ //
141 //
142 template< typename KeyType, typename AddressType >
144 {
145  return m_keySet.ChangeInterpolator( idx, std::move( interpolator ) );
146 }
147 
148 // ================================ //
149 //
150 template< typename KeyType, typename AddressType >
152 {
153  return m_keySet.GetKey( time );
154 }
155 
156 // ================================ //
157 //
158 template< typename KeyType, typename AddressType >
160 {
161  return m_keySet;
162 }
Base class for interpolators.
Definition: IInterpolator.h:38
void Evaluate(EngineObject *object, TimeType time)
Definition: AnimEvaluator.h:94
IInterpolator< KeyType > Interpolator
Definition: AnimEvaluator.h:29
Definition: UPtr.h:10
KeyType
Definition: all_0.js:13
KeySet< KeyType > m_keySet
Definition: AnimEvaluator.h:31
Evaluates animation.
Definition: AnimEvaluator.h:26
AnimEvaluator()=default
Constructor for serialization only.
bool RemoveKey(TimeType time)
Removes key in given time.
Definition: AnimEvaluator.h:135
const Key< KeyType > * GetKey(TimeType time)
Return key in given time.
Definition: AnimEvaluator.h:151
InterpolatorType
Definition: IInterpolator.h:24
bool UpdateKey(TimeType time, const KeyType &newValue, UPtr< Interpolator > &&interpolator)
Udates key given by time. Sets new interpolator.
Definition: AnimEvaluator.h:119
Animation key.
Definition: IInterpolator.h:21
size_t Size
Definition: TypesDefinitions.h:35
Klasa bazowa dla obiektów, które mają być dostępne w edytorze poprzez rttr. Należy po niej odziedzicz...
Definition: EngineObject.h:22
Set of animation keys and interpolators.
Definition: KeySet.h:25
bool AddKey(TimeType time, const KeyType &value)
Adds key and sets default interpolator.
Definition: AnimEvaluator.h:103
~AnimEvaluator()=default
AddressType m_param
Definition: AnimEvaluator.h:32
bool ChangeInterpolator(Size idx, UPtr< Interpolator > &&interpolator)
Updates interpolator. Key remains unchanged.
Definition: AnimEvaluator.h:143
double TimeType
Definition: TypesDefinitions.h:39
virtual KeySet< KeyType > & GetKeySet()
Returns KeySet.
Definition: AnimEvaluator.h:159