Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::Interpolator< T > Class Template Reference

A template class for interpolating components between simulation frames for various purposes. More...

#include <ecs_world.hpp>

Public Member Functions

operator() (const T &previousState, const T &nextState, float simulationProgress=1.f) const
 Returns an interpolated value for a component between two given states.
 
CameraProperties operator() (const CameraProperties &previousState, const CameraProperties &nextState, float simulationProgress) const
 Interpolation override for the camera properties struct, mainly using linear interpolation for each member.
 
LightEmissionData operator() (const LightEmissionData &previousState, const LightEmissionData &nextState, float simulationProgress) const
 Interpolates light emission properties between previous and next simulation states using linear interpolation.
 
Placement operator() (const Placement &previousState, const Placement &nextState, float simulationProgress) const
 Override of the Placement component's Interpolator.
 
Transform operator() (const Transform &previousState, const Transform &nextState, float simulationProgress) const
 Override of the Transform component's Interpolator.
 
SceneHierarchyData operator() (const SceneHierarchyData &previousState, const SceneHierarchyData &nextState, float simulationProgress) const
 Override of the SceneHierarchyData Interpolator.
 
SimCore operator() (const SimCore &, const SimCore &next, float) const
 

Private Attributes

RangeMapperLinear mProgressLimits {0.f, 1.f, 0.f, 1.f}
 a functor that performs the actual interpolation in the default case
 

Detailed Description

template<typename T>
class ToyMaker::Interpolator< T >

A template class for interpolating components between simulation frames for various purposes.

Each simulation tick, two versions of a component are stored by each component array. The first version is the state of the component at T-0, and the next is the state of the component at T-<simulation step>.

Some systems tick at a different rate from the simulation system, eg., the rendering system, and as such may require a value between these two states to function as expected.

By default, the interpolator uses step interpolation which works with most types. A specialization of this class can override this behaviour for a component, and implement a better suited variant (such as linear or spherical interpolation) if needed.

Template Parameters
TThe type of component being interpolated

Member Function Documentation

◆ operator()() [1/5]

CameraProperties ToyMaker::Interpolator< CameraProperties >::operator() ( const CameraProperties & previousState,
const CameraProperties & nextState,
float simulationProgress ) const
inline

Interpolation override for the camera properties struct, mainly using linear interpolation for each member.

Template Parameters
CameraPropertiesSpecialization for the CameraProperties component.
Parameters
previousStateThe state of the component after the last simulation update.
nextStateThe state of the component at the end of this simulation update.
simulationProgressThe progress towards the next simulation update state.
Returns
CameraProperties The interpolated CameraProperties value.

◆ operator()() [2/5]

LightEmissionData ToyMaker::Interpolator< LightEmissionData >::operator() ( const LightEmissionData & previousState,
const LightEmissionData & nextState,
float simulationProgress ) const
inline

Interpolates light emission properties between previous and next simulation states using linear interpolation.

Template Parameters
Specializationfor LightEmissionData.
Parameters
previousStateThe state of the light at the end of the last simulation step.
nextStateThe state of the light at the end of this simulation step.
simulationProgressProgress towards the new state from the old state, a number between 0.0 and 1.0
Returns
LightEmissionData The interpolated light emission data.

◆ operator()() [3/5]

Placement ToyMaker::Interpolator< Placement >::operator() ( const Placement & previousState,
const Placement & nextState,
float simulationProgress ) const
inline

Override of the Placement component's Interpolator.

Uses linear interpolation for position and scale, and spherical interpolation for quaternions.

Template Parameters
Specializationof the Interpolator<T> object
Parameters
previousStateThe Placement value at the end of the last simulation step.
nextStateThe Placement value which will be at the start of the next simulation step.
simulationProgressProgress, as a number from 0 to 1, from the previousState to the nextState as of this frame.
Returns
Placement The interpolated Placement value.

◆ operator()() [4/5]

SceneHierarchyData ToyMaker::Interpolator< SceneHierarchyData >::operator() ( const SceneHierarchyData & previousState,
const SceneHierarchyData & nextState,
float simulationProgress ) const
inline

Override of the SceneHierarchyData Interpolator.

Simply returns SceneHierarchyData in its most current state, its state in the next simulation step.

Template Parameters
Specializationof Interpolator for SceneHierarchyData.
Parameters
previousStateThe state of the component at the end of the previous simulation step.
nextStateThe state of the component as it will be at the beginning of the next simulation step.
simulationProgressThe progress towards the next state from the previous state as a number between 0 and 1.
Returns
SceneHierarchyData The latest value of this component.

◆ operator()() [5/5]

Transform ToyMaker::Interpolator< Transform >::operator() ( const Transform & previousState,
const Transform & nextState,
float simulationProgress ) const
inline

Override of the Transform component's Interpolator.

Simple linear interpolation for this Transform's model matrix.

Template Parameters
Specializationof the Interpolator<T> object.
Parameters
previousStateThe state of Transform at the end of the last simulation step.
nextStateThe state of the Transform which will be at the beginning of the next simulation step.
simulationProgressThe progress towards the next state from the previous state, as a value betweeen 0 and 1.
Returns
Transform The interpolated value of Transform.

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