Sleeping Wombat Common Library  0.50.0
swCommonLibrary
Public Types | Public Member Functions | Public Attributes | Private Member Functions | List of all members
KeySet< KeyType > Struct Template Reference

Set of animation keys and interpolators. More...

#include <KeySet.h>

Public Types

typedef IInterpolator< KeyType > Interpolator
 

Public Member Functions

 KeySet ()
 Constructor insert default KeyType in time 0.0;.
 
Key< KeyType > * GetKey (TimeType time)
 
bool AddKey (TimeType time, const KeyType &value)
 Adds key. If key exists updates this key. More...
 
bool AddKey (TimeType time, const KeyType &value, InterpolatorType type)
 Adds key. If key exists updates this key. More...
 
bool UpdateKey (TimeType time, const KeyType &value)
 Updates key. More...
 
bool RemoveKey (TimeType time)
 Removes key. Last key can't be removed. More...
 
KeyType Evaluate (TimeType time)
 
bool ChangeInterpolator (Size idx, UPtr< Interpolator > &&interpolator)
 

Public Attributes

std::vector< Key< KeyType > > Keys
 
std::vector< UPtr< Interpolator > > Interpolators
 

Private Member Functions

std::vector< Key< KeyType > >::iterator FindKey (TimeType time)
 
std::vector< Key< KeyType > >::iterator FindPlace (TimeType time)
 
void AddDefaultInterpolator (Size keyIndex)
 Adds default interpolator for given type. Adds interpolator defined by function DefaultInterpolators::Create< KeyType> for key added under given index. More...
 
void UpdateInterpolator (Size index)
 Updates interpolator under index. If interpolator doesn't exists, nothing bad happens.
 

Detailed Description

template<typename KeyType>
struct KeySet< KeyType >

Set of animation keys and interpolators.

Attention
You can directly access Keys and Interpolators arrays but it's better to use functions designed to do this.

Member Function Documentation

template<typename KeyType >
void KeySet< KeyType >::AddDefaultInterpolator ( Size  keyIndex)
inlineprivate

Adds default interpolator for given type. Adds interpolator defined by function DefaultInterpolators::Create< KeyType> for key added under given index.

Parameters
[in]keyIndexIndex of added key.
template<typename KeyType >
bool KeySet< KeyType >::AddKey ( TimeType  time,
const KeyType &  value 
)
inline

Adds key. If key exists updates this key.

Returns
Returns false if key existed and have been updated.
template<typename KeyType >
bool KeySet< KeyType >::AddKey ( TimeType  time,
const KeyType &  value,
InterpolatorType  type 
)
inline

Adds key. If key exists updates this key.

Parameters
[in]typeAdds one of built in interpolators.
Returns
Returns false if key existed and have been updated.
template<typename KeyType >
KeyType KeySet< KeyType >::Evaluate ( TimeType  time)
inline
Todo:
Check if we can find keywith std::lower_bound or FindPlace. Messure performance in cases with multiple keys and choose better version.
template<typename KeyType >
bool KeySet< KeyType >::RemoveKey ( TimeType  time)
inline

Removes key. Last key can't be removed.

Returns
Returns false if key couldn't be found or it was last key..
template<typename KeyType >
bool KeySet< KeyType >::UpdateKey ( TimeType  time,
const KeyType &  value 
)
inline

Updates key.

Returns
Returns false if key couldn't be found.

The documentation for this struct was generated from the following file: