DataBlock_Predict_Float Class Reference

#include <DataBlock_Predict_Float.h>

Inheritance diagram for DataBlock_Predict_Float:

Inheritance graph
[legend]
Collaboration diagram for DataBlock_Predict_Float:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 DataBlock_Predict_Float ()
virtual ~DataBlock_Predict_Float ()
virtual void Poll (DataBlockReason *reason)
virtual void ParseMessage (MessageHelper *message)
virtual void GiveDeltaHint (void *pdata, int dataLen)
virtual void GiveDeltaHint (const float delta)
virtual void ContinuityBreak (unsigned char breakTypes)
bool IsAttached (void *data)
void RegisterInClassPointer (float *data)
void SetMinError (float minerror=0.1f)
void SetMaxError (float maxerror=1.0f)
void SetMinDistance (float distance=0.1f)
void SetMaxDistance (float distance=1.0f)
void SetInterpolationFilter (float interpolation=0.1f)
void SetQuadratic (void)
void SetLinear (void)
void SetLagged (const float time=0.0f)
void SetSnapToDifference (const float difference=-1.0f)
void BoundaryEnable (void)
void BoundaryDisable (void)
void BoundaryWrapAround (void)
void BoundaryCapped (void)
void BoundaryLowerUpper (const float lower, const float upper)
void BoundaryApplyToMaster (void)
void BoundaryDoNotApplyToMaster (void)
void SetValueFloat (void)
void SetValueShortFloat (void)
void SetDeltaFloat (void)
void SetDeltaShortFloat (void)

Static Public Member Functions

static
DataBlock_Predict_Float
Register (float *data)
static bool BoundaryApplyToValue (ReplicaObject *object, float &value)

Protected Member Functions

float ApplyBoundaryToValue (const float value) const
int AddDataBlockData (DynamicMessageHelper *message, const float sample, const float time, const float delta)

Protected Attributes

float * mData
bool mContinuityBreak
bool mIsDistanceBased
float mMinDistance
float mMaxDistance
float mMinError
bool mIsQuadratic
bool mGotData
bool mImplementTeleport
bool mDoPrep
float mTestData
float mMaxError
float mInterpolationFilter
RegistryManagerMap
< int,
SessionBlock_Predict_Float > 
mPerSessionData
ReplicaData mReplicaData
MasterData mMasterData
bool mDoneMasterPoll
std::map< float,
ParsedData > 
mParsedByTime
float mLagged
float mFirstLaggedTime
float mSnapToDifference
bool mBoundaryEnable
bool mBoundaryIsWrap
float mBoundaryLower
float mBoundaryUpper
bool mBoundaryWriteBack
float mLastGoodDataTime
bool mShortValue
bool mShortDelta

Classes

struct  MasterData
struct  ParsedData
struct  ReplicaData
struct  SessionBlock_Predict_Float


Detailed Description

This DataBlock derived class tries to perform data prediction on float variable types.
This class operates on three levels.
1) It constantly checks the data value and notes down changes based on what it thinks are continuity changes using the extrapolation model for the master side.
2) Each {value,delta and time} update sent to a replica object is stored and using this information the extrapolation/interpolation is checked against what the current value is doing. If the extrapolation is too far off based on the input tolerance values then the master copy of the extrapolation data is used to calculate a new more accurate prediction model.
3) The replica version of this class receives {value,delta and time} updates and extrapolates these. When performing extrapolation/interpolation the contents of the class member variable is read and the interpolation filter is used to smooth the update from the contents to the network value. When a continuity break is received the interpolation filter is ignored.
The DataBlock type can also vary the accuracy of the tolerance used dependant on the calculated distance to the observer object for a session. If there is no observer or the distance couldn't be calculated (kReplicaObject_InfiniteDistance is returned by CalculateDistanceToObject) then the minimum tolerance is used.

Constructor & Destructor Documentation

DataBlock_Predict_Float (  ) 

The ctor performs some basic initialisation

virtual ~DataBlock_Predict_Float (  )  [virtual]

The dtor makes sure everything is tidy


Member Function Documentation

virtual void Poll ( DataBlockReason reason  )  [virtual]

A poll function that is called by ReplicaNet to check for updates to this particular data block. If this virtual method is implemented by a derived class this base class method should be called before a data packet is created. Processing for this function may occur during the thread context of ReplicaNet so processing time used by this function should be kept to a minimum to avoid performance issues.

Parameters:
reason the reason code that is passed in to this class to enable a response to be calculated

Reimplemented from DataBlock.

virtual void ParseMessage ( MessageHelper message  )  [virtual]

This parses a message for the derived class of this data block. Processing for this function may occur during the thread context of ReplicaNet so processing time used by this function should be kept to a minimum to avoid performance issues.

Parameters:
message The current message buffer that contains the packet data

Reimplemented from DataBlock.

virtual void GiveDeltaHint ( void *  pdata,
int  dataLen 
) [virtual]

This is a feedback function used by a master ReplicaObject that enables an application to give a delta hint to a DataBlock. The delta should be expressed in units of change per second.

Parameters:
pdata the pointer to the data type to give a hint for
dataLem the length of the data type

Reimplemented from DataBlock.

virtual void GiveDeltaHint ( const float  delta  )  [virtual]

This is a feedback function used by a master ReplicaObject that enables an application to give a delta hint to a DataBlock. This float type call maps to the opaque data type call.

Parameters:
This delta hint is a float type

Reimplemented from DataBlock.

virtual void ContinuityBreak ( unsigned char  breakTypes  )  [virtual]

This is used by a master ReplicaObject to set a continuity break for the data block and provides useful information to any extrapolation algorithms.

Parameters:
breakTypes The break types to use for this break. For example : DataBlock::kSuddenChange | DataBlock::kTeleport

Reimplemented from DataBlock.

bool IsAttached ( void *  data  )  [virtual]

Given a data pointer this function identifies if this data block is attached to the pointer.

Returns:
returns true if the data pointer is attached to this data block.

Reimplemented from DataBlock.

static DataBlock_Predict_Float* Register ( float *  data  )  [static]

This registers the memory area with this data block type and returns a new pointer

Parameters:
data the start of the memory to check
Returns:
Returns a pointer that can be used to attach to a ReplicaObject

void RegisterInClassPointer ( float *  data  )  [inline]

This registers the memory area with this data block type. This is used when the memory is in datablocks that are allocated as part of a bigger class.

Parameters:
data the start of the memory to check

void SetMinError ( float  minerror = 0.1f  ) 

This sets the minimum error that is tolerated for this variable type

Parameters:
minerror the minimum error to tolerate

void SetMaxError ( float  maxerror = 1.0f  ) 

This sets the maximum error that is tolerated for this variable type

Parameters:
maxerror the maximum error to tolerate

void SetMinDistance ( float  distance = 0.1f  ) 

Sets the minimum distance start point for the minimum error to take effect

Parameters:
the distance

void SetMaxDistance ( float  distance = 1.0f  ) 

Sets the maximum distance start point for the maximum error to take effect

Parameters:
the distance

void SetInterpolationFilter ( float  interpolation = 0.1f  ) 

This sets the interpolation filter factor to use when extrapolating this variable type
0 < interpolation <= 1.0f
1.0f Is very hard interpolation and 0.1f is very soft. 0.1f Is the default.

Parameters:
interpolation the interpolation to use

void SetQuadratic ( void   )  [inline]

For distance based interpolation this makes the calculation based on a quadratic formula. The default is linear.

void SetLinear ( void   )  [inline]

For distance based interpolation this makes the calculation based on a linear formula. The default is linear.

void SetLagged ( const float  time = 0.0f  ) 

Allows this replica DataBlock to use interpolation for a period specified by time. This has the effect of permanently lagging the changes made to the variable attached to this DataBlock. This option uses some extra memory to store updates until they can be actioned. This function can be used at any time. Each replica DataBlock can use a different time value. With ReplicaObjects that change owner there may be a pause in updates visible until the new master continues the movement and sends updates.

Parameters:
time The time is seconds, so using SetLagged(0.2f) will cause all changes in this variable to appear to be 0.2 seconds behind the master object. Using a value less than or equal to 0.0f will disable this feature.

void SetSnapToDifference ( const float  difference = -1.0f  ) 

Allows this replica DataBlock to snap to the extrapolated value if the difference is greater than the configured difference. For a replica DataBlock if the difference between this DataBlock and the extrapolated value is greater than the configured amount then the extrapolated value is applied without any interpolation filter. This option can be changed as often as required and can be configured differently for each peer.

Parameters:
difference The default value is -1.0f meaning this feature is disabled. Any value greater than or equal to 0.0f will enable this feature.

void BoundaryEnable ( void   ) 

Enable the boundary value checking code. This allows the DataBlock to have wrap around values (for example 0 <= angle < 360) or values that are capped. The upper and lower boundary and wrap around or capped are set by the other Boundary prefixed functions. The default is for this feature to be disabled. If enabled on a master then the user value will not be modified however the internal value used will be capped/wrapped before applying any update filtering. If enabled on a client then the user value will be capped/wrapped.

void BoundaryDisable ( void   ) 

Disables any boundary checking code.

void BoundaryLowerUpper ( const float  lower,
const float  upper 
)

Where lower <= value < upper for wrapped checks and lower <= value <= upper for capped checks.

void BoundaryApplyToMaster ( void   ) 

If the boundary value checking is enabled this will also write-back the boundary check to the master's client value. This write-back will happen the next time this DataBlock is polled. The default is for this value write-back to be disabled.

void BoundaryDoNotApplyToMaster ( void   ) 

Disables BoundaryApplyToMaster().

static bool BoundaryApplyToValue ( ReplicaObject object,
float &  value 
) [static]

Utility function to apply the boundary checking rules configured for a Predict_Float DataBlock to a variable. The variable must be registered with ReplicaNet as DataBlock_Predict_Float.

Returns:
True is returned if the variable was registered and false if not registered.

void SetValueFloat ( void   ) 

Set this DataBlock to use full 32 bit floating point values when propagating the value. This is the default option.

void SetValueShortFloat ( void   ) 

Set this DataBlock to use short 16 bit floating point values when propagating the value.

void SetDeltaFloat ( void   ) 

Set this DataBlock to use full 32 bit floating point values when propagating the value. This is the default option.

void SetDeltaShortFloat ( void   ) 

Set this DataBlock to use short 16 bit floating point values when propagating the value.


Generated on Sat Jun 28 22:02:22 2008 for ReplicaNet and RNLobby by  doxygen 1.5.3