Cafu Engine
DeathMatch::ExtrapolatorT< T > Class Template Reference

Linearly extrapolates a value over a period of time. More...

#include "Interpolator.hpp"

Inheritance diagram for DeathMatch::ExtrapolatorT< T >:

Public Member Functions

 ExtrapolatorT (T &v)
 
void ReInit ()
 Used to re-initialize this extrapolator at the current value. More...
 
void NotifyOverwriteUpdate ()
 The user calls this method in order to let the extrapolator know that the extrapolated value was changed externally. More...
 
void UpdateRef (const T &Ref)
 Sets a new reference value: the value that the extrapolated value currently "should have". More...
 
void Interpolate (float Time)
 Advances the extrapolation over the given time. More...
 

Detailed Description

template<class T>
class DeathMatch::ExtrapolatorT< T >

Linearly extrapolates a value over a period of time.

The course of the extrapolation is adapted/updated whenever a new reference value is set. This is mostly intended for game entities on clients, where we try to extrapolate values close to where we expect the next server update will bring them to.

Unfortunately, extrapolation is less useful and worthwhile than it initially seems, because when it is applied to entity origins, all kinds of unwanted side effects can happen: items that fall to the floor penetrate the ground plane, then resurface; the wings of closing doors bump into each other, then retract; lifts overshoot their halting position; grenades that are deflected by walls briefly vanish into them; etc.

Member Function Documentation

template<class T >
void DeathMatch::ExtrapolatorT< T >::Interpolate ( float  Time)
inlinevirtual

Advances the extrapolation over the given time.

Implements DeathMatch::ApproxBaseT.

template<class T >
void DeathMatch::ExtrapolatorT< T >::NotifyOverwriteUpdate ( )
inlinevirtual

The user calls this method in order to let the extrapolator know that the extrapolated value was changed externally.

Implements DeathMatch::ApproxBaseT.

template<class T >
void DeathMatch::ExtrapolatorT< T >::ReInit ( )
inlinevirtual

Used to re-initialize this extrapolator at the current value.

Implements DeathMatch::ApproxBaseT.

template<class T >
void DeathMatch::ExtrapolatorT< T >::UpdateRef ( const T &  Ref)
inline

Sets a new reference value: the value that the extrapolated value currently "should have".

m_Value was extrapolated starting from its own value at the time the reference value was last set, using the gradient m_Gradient that was applied over the the extrapolation time m_ExtTime. If the new reference value Ref now turns out to be different from m_Value, it used a gradient TrueG other than the expected gradient from the previous m_LastRef to m_LastRef. Considering that the value changed from m_LastRef to Ref, and assuming that this time TrueG will remain constant over the next extrapolation period, the new expected value is Ref + (Ref - m_LastRef), and the change that is required to get from m_Value to the new expected value is 2*Ref - m_LastRef - m_Value.


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