Motive Animation System
An open source project by FPL.
 All Classes Functions Variables Typedefs Friends Pages
motive::Motivator Class Reference

Drives a value towards a target value, or along a path. More...

#include <motivator.h>

Inheritance diagram for motive::Motivator:
motive::MatrixMotivator4fTemplate< VectorConverter > motive::MotivatorNf motive::RigMotivator motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >

Detailed Description

Drives a value towards a target value, or along a path.

The value can be one-dimensional (e.g. a float), or multi-dimensional (e.g. a matrix). The dimension is determined by the sub-class: Motivator1f drives a float, MatrixMotivator4f drives a 4x4 float matrix.

Although you can instantiate a Motivator, you probably will not, since there is no mechanism to read data out of a Motivator. Generally, you will instantiate a derived class like Motivator1f, which provides accessor functions.

The way a Motivator's value moves towards its target is determined by the type of a motivator. The type is specified in Motivator::Initialize().

Note that a Motivator does not store any data itself. It is a handle into a MotiveProcessor. Each MotiveProcessor holds all data for motivators of its type.

Only one Motivator can reference a specific index in a MotiveProcessor. Therefore, when you copy a Motivator, the original motivator will become invalid.

Public Member Functions

 Motivator (const Motivator &original)
 
Motivatoroperator= (const Motivator &original)
 
 ~Motivator ()
 Remove ourselves from the MotiveProcessor when we're deleted.
 
void Invalidate ()
 
bool Valid () const
 
bool Sane () const
 
MotivatorType Type () const
 
MotiveDimension Dimensions () const
 

Protected Member Functions

 Motivator (const MotivatorInit &init, MotiveEngine *engine, MotiveDimension dimensions)
 
void InitializeWithDimension (const MotivatorInit &init, MotiveEngine *engine, MotiveDimension dimensions)
 
void Init (MotiveProcessor *processor, MotiveIndex index)
 These should only be called by MotiveProcessor!
 
void Reset ()
 
const MotiveProcessorProcessor () const
 

Protected Attributes

MotiveProcessorprocessor_
 
MotiveIndex index_
 

Friends

class MotiveProcessor
 

Constructor & Destructor Documentation

motive::Motivator::Motivator ( const Motivator original)
inline

Transfer ownership of original motivator to this motivator. original motivator is reset and must be initialized again before being read. We want to allow moves primarily so that we can have vectors of Motivators.

Note: This should be a move constructor instead of a copy constructor. However, VS2010~2012 requires move constructors to exist in any class that has a move constructed member. That would be a burden for users of Motivator, so we chose to be practical here instead of pedantically correct. We use the copy constructor and copy operator to do move behavior. See http://en.cppreference.com/w/cpp/language/move_operator

Member Function Documentation

MotiveDimension motive::Motivator::Dimensions ( ) const
inline

The number of basic values that this Motivator is driving. For example, a 3D position would return 3, since it drives three floats. A single 4x4 matrix would return 1, since it's driving one matrix. The basic value is determined by the MotiveProcessor backing this motivator.

void motive::Motivator::Invalidate ( )
inline

Detatch this Motivator from its MotiveProcessor. Functions other than Initialize() and Valid() can no longer be called afterwards.

Motivator& motive::Motivator::operator= ( const Motivator original)
inline

Allow Motivators to be moved. original is reset. See the copy constructor for details.

bool motive::Motivator::Sane ( ) const
inline

Check consistency of internal state. Useful for debugging. If this function ever returns false, there has been some sort of memory corruption or similar bug.

MotivatorType motive::Motivator::Type ( ) const
inline

Return the type of Motivator we've been initilized to. A Motivator can take on any type that matches its dimension. The Motivator's type is determined by the init param in Initialize().

bool motive::Motivator::Valid ( ) const
inline

Return true if this Motivator is currently being driven by a MotiveProcessor. That is, if it has been successfully initialized.

Friends And Related Function Documentation

friend class MotiveProcessor
friend

The MotiveProcessor uses the functions below. It does not modify data directly.

Member Data Documentation

MotiveIndex motive::Motivator::index_
protected

A MotiveProcessor processes one MotivatorType, and hosts every Motivator of that type. This index here uniquely identifies this Motivator to the MotiveProcessor.

MotiveProcessor* motive::Motivator::processor_
protected

All calls to an Motivator are proxied to an MotivatorProcessor. Motivator data and processing is centralized to allow for scalable optimizations (e.g. SIMD or parallelization).


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