Plasma Engine  2.0
Loading...
Searching...
No Matches
plDefaultTimeStepSmoothing Class Reference

Implements a simple time step smoothing algorithm. More...

#include <DefaultTimeStepSmoothing.h>

Inheritance diagram for plDefaultTimeStepSmoothing:

Public Member Functions

virtual plTime GetSmoothedTimeStep (plTime rawTimeStep, const plClock *pClock) override
 The function to override to implement time step smoothing.
 
virtual void Reset (const plClock *pClock) override
 Called when plClock::Reset(), plClock::Load() or plClock::SetPaused(true) was called.
 
void SetLerpFactor (float f)
 Changes the factor with which to lerp from the last used time step to the new average time step. Default is 0.2.
 

Detailed Description

Implements a simple time step smoothing algorithm.

The description for the algorithm was taken from here: http://bitsquid.blogspot.de/2010/10/time-step-smoothing.html

This class implements that algorithm pretty much verbatim. It does not implement keeping track of the time dept and paying that off later, though.

Member Function Documentation

◆ GetSmoothedTimeStep()

plTime plDefaultTimeStepSmoothing::GetSmoothedTimeStep ( plTime rawTimeStep,
const plClock * pClock )
overridevirtual

The function to override to implement time step smoothing.

Parameters
RawTimeStepThe actual raw time difference since the last clock update without any modification.
pClockThe clock that calls this time step smoother. Can be used to look up the clock speed and min/max time step.
Note
It is the responsibility of each plTimeStepSmoothing class to implement clock speed and also to clamp the time step to the min/max values. This allows the smoothing algorithm to override these values, if necessary.

Implements plTimeStepSmoothing.

◆ Reset()

void plDefaultTimeStepSmoothing::Reset ( const plClock * pClock)
overridevirtual

Called when plClock::Reset(), plClock::Load() or plClock::SetPaused(true) was called.

Parameters
pClockThe clock that is calling this function.

Implements plTimeStepSmoothing.

◆ SetLerpFactor()

void plDefaultTimeStepSmoothing::SetLerpFactor ( float f)
inline

Changes the factor with which to lerp from the last used time step to the new average time step. Default is 0.2.

A value of 1.0 would mean that the new average time step is used immediately. The lower the value the more slowly the time step will change from its previous value to the new average value, thus smoothing the time step even more.


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