H3D API  2.4.1
Public Types | Public Member Functions | Protected Attributes | List of all members
H3D::PeriodicUpdate< BaseFieldType > Class Template Reference

The PeriodicUpdate is a template modifier that changes the way the field is updated. More...

#include <H3D/PeriodicUpdate.h>

Inheritance diagram for H3D::PeriodicUpdate< BaseFieldType >:
Inheritance graph

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.
 
- Public Member Functions inherited from H3D::PeriodicUpdateField
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.
 

Detailed Description

template<class BaseFieldType>
class H3D::PeriodicUpdate< BaseFieldType >

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.

Member Enumeration Documentation

◆ PeriodType

template<class BaseFieldType >
enum H3D::PeriodicUpdate::PeriodType

Type defining how the period should be interpreted.

Enumerator
COUNT 

The period is specified in seconds.

The period is specified in number of scenegraph loops.

Member Function Documentation

◆ timeToUpdate()

template<class BaseFieldType >
virtual bool H3D::PeriodicUpdate< BaseFieldType >::timeToUpdate ( )
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.


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