H3D API
2.4.1
|
The PeriodicUpdate is a template modifier that changes the way the field is updated. More...
#include <H3D/PeriodicUpdate.h>
Public Types | |
enum | PeriodType { } |
Type defining how the period should be interpreted. More... | |
Public Member Functions | |
PeriodicUpdate (H3DFloat _period=0, PeriodType _period_type=COUNT) | |
Constructor. | |
~PeriodicUpdate () | |
Destructor. | |
virtual bool | timeToUpdate () |
Determines if it is time to check that the field is updated. More... | |
void | setPeriodType (PeriodType type) |
Set the type of the period. | |
void | setPeriod (H3DFloat _period) |
Set the period for the update. | |
virtual void | upToDate () |
upToDate is specialized to record the time of the call to the function in the last_up_to_date member. | |
![]() | |
virtual | ~PeriodicUpdateField () |
Destructor. | |
Protected Attributes | |
PeriodType | period_type |
The tye of the period. | |
H3DFloat | period |
The period of automatic updates/. | |
TimeStamp | last_up_to_date |
The time of the last call to upToDate. | |
unsigned int | counter |
The number of calls to timeToUpdate() since the last update. | |
The PeriodicUpdate is a template modifier that changes the way the field is updated.
Normally field updates are lazy so that the update function is only called if an event has been received and someone is asking for its value. Sometimes it is need however for the field to keep the value up-to-date always. This can be achieved by the AutoUpdate template modifier, however it will update as soon as an is received. This can be quite inefficient if in there are several fields routed to it that changes value and we only want it to update when all those fields has sent their events. With the PeriodicUpdate template modifier a field type can be changed so that it updates itself periodically as defined by the user. There are two types of periodic updates, time based and count based. If the PeriodicUpdate field is set to be time based the field the value specified by setPeriod defines a time in seconds between updates, e.g. a value of 2 makes it update every other second. If it is count based the field will update itself depending on how many scenegraph loop that has been executed since the last update. E.g. a value of 2 makes the field update every second scenegraph loop. The default behavior is for the field to update every scenegraph loop.
enum H3D::PeriodicUpdate::PeriodType |
|
inlinevirtual |
Determines if it is time to check that the field is updated.
This function will be called once per scenegraph loop and when it returns true the upToDate function will be run in the field.
Implements H3D::PeriodicUpdateField.
References H3D::PeriodicUpdate< BaseFieldType >::counter, H3D::PeriodicUpdate< BaseFieldType >::last_up_to_date, H3D::PeriodicUpdate< BaseFieldType >::period, and H3D::PeriodicUpdate< BaseFieldType >::period_type.