NAP
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SmoothOperator< T > Class Template Reference

#include <smoothdamp.h>

Public Member Functions

 SmoothOperator (const T &currentValue, float smoothTime)
 
 SmoothOperator (const T &currentValue, float smoothTime, float maxSpeed)
 
T & update (const T &targetValue, float deltaTime)
 
const T & getValue () const
 
T & getValue ()
 
const T & getTarget () const
 
T & getTarget ()
 
const T & getVelocity () const
 
T & getVelocity ()
 
void setValue (const T &value)
 
NAPAPI void setValue (const float &value)
 
NAPAPI void setValue (const double &value)
 
NAPAPI void setValue (const glm::vec2 &value)
 
NAPAPI void setValue (const glm::vec3 &value)
 
NAPAPI void setValue (const glm::vec4 &value)
 
- Public Member Functions inherited from BaseSmoothOperator
 BaseSmoothOperator ()=default
 
 BaseSmoothOperator (float smoothTime)
 
 BaseSmoothOperator (float smoothTime, float maxSpeed)
 
virtual ~BaseSmoothOperator ()=default
 

Protected Member Functions

void init ()
 
NAPAPI void init ()
 
NAPAPI void init ()
 
NAPAPI void init ()
 
NAPAPI void init ()
 
NAPAPI void init ()
 

Protected Attributes

mValue
 
mTarget
 
mVelocity
 

Additional Inherited Members

- Public Attributes inherited from BaseSmoothOperator
float mSmoothTime = 1.0f
 
float mMaxSpeed = math::max<float>()
 

Description

template<typename T>
class nap::math::SmoothOperator< T >

Smooth Damp utility class. Gradually changes a value of type T towards a desired goal over time. This operator needs to be updated every frame! Call update() together with the new deltaTime and desired target value on application update. The update call returns the new smoothed value. Alternatively use getValue() to get the current smoothed value after update. This operator is a convenience wrapper around nap::math::smoothDamp<T>()

Inheritance diagram for SmoothOperator< T >:
[legend]
Collaboration diagram for SmoothOperator< T >:
[legend]

Constructor & Destructor Documentation

◆ SmoothOperator() [1/2]

SmoothOperator ( const T &  currentValue,
float  smoothTime 
)

Constructor that creates the operator based on a set of initial values

Parameters
currentValuethe value it should started blending from, often same as initial target
smoothTimethe time in seconds it will take to reach the target

◆ SmoothOperator() [2/2]

SmoothOperator ( const T &  currentValue,
float  smoothTime,
float  maxSpeed 
)

Constructor that creates the operator based on a set of initial values

Parameters
currentValuethe value it should started blending from, often same as initial target
smoothTimethe time in seconds it will take to reach the target
maxSpeedthe maximum blend speed

Member Function Documentation

◆ getTarget() [1/2]

T& getTarget ( )
Returns
the current target value

◆ getTarget() [2/2]

const T& getTarget ( ) const
Returns
the current target value

◆ getValue() [1/2]

T& getValue ( )
Returns
the current blend value

◆ getValue() [2/2]

const T& getValue ( ) const
Returns
the current blend value

◆ getVelocity() [1/2]

T& getVelocity ( )
Returns
the current velocity

◆ getVelocity() [2/2]

const T& getVelocity ( ) const
Returns
current velocity

◆ init() [1/6]

void init ( )
protected

This needs to be implemented by every template specialized class Should set

◆ init() [2/6]

NAPAPI void init ( )
protected

◆ init() [3/6]

NAPAPI void init ( )
protected

◆ init() [4/6]

NAPAPI void init ( )
protected

◆ init() [5/6]

NAPAPI void init ( )
protected

◆ init() [6/6]

NAPAPI void init ( )
protected

◆ setValue() [1/6]

NAPAPI void setValue ( const double &  value)

◆ setValue() [2/6]

NAPAPI void setValue ( const float &  value)

◆ setValue() [3/6]

NAPAPI void setValue ( const glm::vec2 &  value)

◆ setValue() [4/6]

NAPAPI void setValue ( const glm::vec3 &  value)

◆ setValue() [5/6]

NAPAPI void setValue ( const glm::vec4 &  value)

◆ setValue() [6/6]

void setValue ( const T &  value)

Sets the current blend value.

Parameters
valuethe value to set as blend value

◆ update()

T & update ( const T &  targetValue,
float  deltaTime 
)

Updates the current blend value based on the given targetValue

Parameters
targetValuethe value to blend to
deltaTimetime in seconds it took to complete the last compute cycle
Returns
the current blend value

Member Data Documentation

◆ mTarget

T mTarget
protected

◆ mValue

T mValue
protected

◆ mVelocity

T mVelocity
protected