Panda3D
Public Types | Public Member Functions | Static Public Member Functions | List of all members
CMetaInterval Class Reference

This interval contains a list of nested intervals, each of which has its own begin and end times. More...

Inheritance diagram for CMetaInterval:
CInterval TypedReferenceCount TypedObject ReferenceCount MetaInterval Parallel ParallelEndTogether Sequence Track

Public Types

enum  DefType { DT_c_interval = 0, DT_ext_index = 1, DT_push_level = 2, DT_pop_level = 3 }
 
enum  RelativeStart { RS_previous_end = 0, RS_previous_begin = 1, RS_level_begin = 2 }
 
- Public Types inherited from CInterval
enum  EventType {
  ET_initialize = 0, ET_instant = 1, ET_step = 2, ET_finalize = 3,
  ET_reverse_initialize = 4, ET_reverse_instant = 5, ET_reverse_finalize = 6, ET_interrupt = 7
}
 
enum  State { S_initial = 0, S_started = 1, S_paused = 2, S_final = 3 }
 

Public Member Functions

 __init__ (const CMetaInterval)
 
 __init__ (str name)
 
int addCInterval (CInterval c_interval, double rel_time, CMetaInterval::RelativeStart rel_to)
 Adds a new CInterval to the list. More...
 
int addExtIndex (int ext_index, str name, double duration, bool open_ended, double rel_time, CMetaInterval::RelativeStart rel_to)
 Adds a new external interval to the list. More...
 
 clearIntervals ()
 Resets the list of intervals and prepares for receiving a new list. More...
 
CInterval getCInterval (int n)
 Return the CInterval pointer associated with the nth interval definition. More...
 
CMetaInterval::DefType getDefType (int n)
 Returns the type of the nth interval definition that has been added. More...
 
int getEventIndex ()
 If a previous call to is_event_ready() returned true, this returns the index number (added via add_event_index()) of the external interval that needs to be played. More...
 
double getEventT ()
 If a previous call to is_event_ready() returned true, this returns the t value that should be fed to the given interval. More...
 
CInterval::EventType getEventType ()
 If a previous call to is_event_ready() returned true, this returns the type of the event (initialize, step, finalize, etc.) for the given interval. More...
 
int getExtIndex (int n)
 Return the external interval index number associated with the nth interval definition. More...
 
double getIntervalEndTime (str name)
 Returns the actual end time, relative to the beginning of the interval, of the child interval with the given name, if found, or -1 if the interval is not found. More...
 
double getIntervalStartTime (str name)
 Returns the actual start time, relative to the beginning of the interval, of the child interval with the given name, if found, or -1 if the interval is not found. More...
 
int getNumDefs ()
 Returns the number of interval and push/pop definitions that have been added to the meta interval. More...
 
double getPrecision ()
 Returns the precision with which time measurements are compared. More...
 
bool isEventReady ()
 Returns true if a recent call to priv_initialize(), priv_step(), or priv_finalize() has left some external intervals ready to play. More...
 
 popEvent ()
 Acknowledges that the external interval on the top of the queue has been extracted, and is about to be serviced by the scripting language. More...
 
int popLevel (double duration)
 Finishes a level marked by a previous call to push_level(), and returns to the previous level. More...
 
int pushLevel (str name, double rel_time, CMetaInterval::RelativeStart rel_to)
 Marks the beginning of a nested level of child intervals. More...
 
bool setIntervalStartTime (str name, double rel_time, CMetaInterval::RelativeStart rel_to)
 Adjusts the start time of the child interval with the given name, if found. More...
 
 setPrecision (double precision)
 Indicates the precision with which time measurements are compared. More...
 
 timeline (Ostream out)
 Outputs a list of all events in the order in which they occur. More...
 
- Public Member Functions inherited from CInterval
 __init__ (const CInterval)
 
 clearToInitial ()
 Pauses the interval, if it is playing, and resets its state to its initial state, abandoning any state changes already in progress in the middle of the interval. More...
 
 finish ()
 Stops the interval from playing and sets it to its final state. More...
 
bool getAutoFinish ()
 Returns the state of the 'auto_finish' flag. More...
 
bool getAutoPause ()
 Returns the state of the 'auto_pause' flag. More...
 
str getDoneEvent ()
 Returns the event that is generated whenever the interval reaches its final state, whether it is explicitly finished or whether it gets there on its own. More...
 
double getDuration ()
 Returns the duration of the interval in seconds. More...
 
CIntervalManager getManager ()
 Returns the CIntervalManager object which will be responsible for playing this interval. More...
 
str getName ()
 Returns the interval's name. More...
 
bool getOpenEnded ()
 Returns the state of the "open_ended" flag. More...
 
double getPlayRate ()
 Returns the play rate as set by the last call to start(), loop(), or set_play_rate(). More...
 
CInterval::State getState ()
 Indicates the state the interval believes it is in: whether it has been started, is currently in the middle, or has been finalized. More...
 
double getT ()
 Returns the current time of the interval: the last value of t passed to priv_initialize(), priv_step(), or priv_finalize(). More...
 
bool getWantsTCallback ()
 Returns the state of the 'wants_t_callback' flag. More...
 
bool isPlaying ()
 Returns true if the interval is currently playing, false otherwise. More...
 
bool isStopped ()
 Returns true if the interval is in either its initial or final states (but not in a running or paused state). More...
 
 loop (double start_t, double end_t, double play_rate)
 Starts the interval playing by registering it with the current CIntervalManager. More...
 
 output (Ostream out)
 
double pause ()
 Stops the interval from playing but leaves it in its current state. More...
 
 privDoEvent (double t, CInterval::EventType event)
 
 privFinalize ()
 This is called to stop an interval, forcing it to whatever state it would be after it played all the way through. More...
 
 privInitialize (double t)
 This replaces the first call to priv_step(), and indicates that the interval has just begun. More...
 
 privInstant ()
 This is called in lieu of priv_initialize() . More...
 
 privInterrupt ()
 This is called while the interval is playing to indicate that it is about to be interrupted; that is, priv_step() will not be called for a length of time. More...
 
 privReverseFinalize ()
 Called generally following a priv_reverse_initialize(), this indicates the interval should set itself to the initial state. More...
 
 privReverseInitialize (double t)
 Similar to priv_initialize(), but this is called when the interval is being played backwards; it indicates that the interval should start at the finishing state and undo any intervening intervals. More...
 
 privReverseInstant ()
 This is called in lieu of priv_reverse_initialize() . More...
 
 privStep (double t)
 Advances the time on the interval. More...
 
 resume ()
 Restarts the interval from its current point after a previous call to pause(). More...
 
 resume (double start_t)
 Restarts the interval from the indicated point after a previous call to pause(). More...
 
 resumeUntil (double end_t)
 Restarts the interval from the current point after a previous call to pause() (or a previous play-to-point-and-stop), to play until the indicated point and then stop. More...
 
 setAutoFinish (bool auto_finish)
 Changes the state of the 'auto_finish' flag. More...
 
 setAutoPause (bool auto_pause)
 Changes the state of the 'auto_pause' flag. More...
 
 setDoneEvent (str event)
 Sets the event that is generated whenever the interval reaches its final state, whether it is explicitly finished or whether it gets there on its own. More...
 
 setManager (CIntervalManager manager)
 Indicates the CIntervalManager object which will be responsible for playing this interval. More...
 
 setPlayRate (double play_rate)
 Changes the play rate of the interval. More...
 
 setT (double t)
 Explicitly sets the time within the interval. More...
 
 setupPlay (double start_time, double end_time, double play_rate, bool do_loop)
 Called to prepare the interval for automatic timed playback, e.g. More...
 
 setupResume ()
 Called to prepare the interval for restarting at the current point within the interval after an interruption. More...
 
 setupResumeUntil (double end_t)
 Called to prepare the interval for restarting from the current point after a previous call to pause() (or a previous play-to-point-and-stop), to play until the indicated point and then stop. More...
 
 setWantsTCallback (bool wants_t_callback)
 Changes the state of the 'wants_t_callback' flag. More...
 
 start (double start_t, double end_t, double play_rate)
 Starts the interval playing by registering it with the current CIntervalManager. More...
 
bool stepPlay ()
 Should be called once per frame to execute the automatic timed playback begun with setup_play(). More...
 
 write (Ostream out, int indent_level)
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly. More...
 
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type. More...
 
- Public Member Functions inherited from ReferenceCount
int getRefCount ()
 Returns the current reference count. More...
 
 ref ()
 Explicitly increments the reference count. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
bool unref ()
 Explicitly decrements the reference count. More...
 

Static Public Member Functions

static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from CInterval
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle getClassType ()
 

Additional Inherited Members

- Public Attributes inherited from CInterval
bool auto_finish
 Returns the state of the 'auto_finish' flag. More...
 
bool auto_pause
 Returns the state of the 'auto_pause' flag. More...
 
const String done_event
 Returns the event that is generated whenever the interval reaches its final state, whether it is explicitly finished or whether it gets there on its own. More...
 
double duration
 Returns the duration of the interval in seconds. More...
 
CIntervalManager manager
 Returns the CIntervalManager object which will be responsible for playing this interval. More...
 
const String name
 Returns the interval's name. More...
 
bool open_ended
 Returns the state of the "open_ended" flag. More...
 
double play_rate
 Returns the play rate as set by the last call to start(), loop(), or set_play_rate(). More...
 
bool playing
 Returns true if the interval is currently playing, false otherwise. More...
 
CInterval::State state
 Indicates the state the interval believes it is in: whether it has been started, is currently in the middle, or has been finalized. More...
 
bool stopped
 Returns true if the interval is in either its initial or final states (but not in a running or paused state). More...
 
double t
 Returns the current time of the interval: the last value of t passed to priv_initialize(), priv_step(), or priv_finalize(). More...
 
- Public Attributes inherited from TypedObject
TypeHandle type
 Returns the TypeHandle representing this object's type. More...
 
- Public Attributes inherited from ReferenceCount
int ref_count
 The current reference count. More...
 

Detailed Description

This interval contains a list of nested intervals, each of which has its own begin and end times.

Some of them may overlap and some of them may not.

Member Enumeration Documentation

◆ DefType

enum DefType
Enumerator
DT_c_interval 
DT_ext_index 
DT_push_level 
DT_pop_level 

◆ RelativeStart

Enumerator
RS_previous_end 
RS_previous_begin 
RS_level_begin 

Member Function Documentation

◆ __init__() [1/2]

__init__ ( const  CMetaInterval)

◆ __init__() [2/2]

__init__ ( str  name)

◆ addCInterval()

int addCInterval ( CInterval  c_interval,
double  rel_time,
CMetaInterval::RelativeStart  rel_to 
)

Adds a new CInterval to the list.

The interval will be played when the indicated time (relative to the given point) has been reached.

The return value is the index of the def entry representing the new interval.

◆ addExtIndex()

int addExtIndex ( int  ext_index,
str  name,
double  duration,
bool  open_ended,
double  rel_time,
CMetaInterval::RelativeStart  rel_to 
)

Adds a new external interval to the list.

This represents some object in the external scripting language that has properties similar to a CInterval (for instance, a Python Interval object).

The CMetaInterval object cannot play this external interval directly, but it records a placeholder for it and will ask the scripting language to play it when it is time, via is_event_ready() and related methods.

The ext_index number itself is simply a handle that the scripting language makes up and associates with its interval object somehow. The CMetaInterval object does not attempt to interpret this value.

The return value is the index of the def entry representing the new interval.

◆ clearIntervals()

clearIntervals ( )

Resets the list of intervals and prepares for receiving a new list.

◆ getCInterval()

CInterval getCInterval ( int  n)

Return the CInterval pointer associated with the nth interval definition.

It is only valid to call this if get_def_type(n) returns DT_c_interval.

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getDefType()

CMetaInterval::DefType getDefType ( int  n)

Returns the type of the nth interval definition that has been added.

◆ getEventIndex()

int getEventIndex ( )

If a previous call to is_event_ready() returned true, this returns the index number (added via add_event_index()) of the external interval that needs to be played.

◆ getEventT()

double getEventT ( )

If a previous call to is_event_ready() returned true, this returns the t value that should be fed to the given interval.

◆ getEventType()

CInterval::EventType getEventType ( )

If a previous call to is_event_ready() returned true, this returns the type of the event (initialize, step, finalize, etc.) for the given interval.

◆ getExtIndex()

int getExtIndex ( int  n)

Return the external interval index number associated with the nth interval definition.

It is only valid to call this if get_def_type(n) returns DT_ext_index.

◆ getIntervalEndTime()

double getIntervalEndTime ( str  name)

Returns the actual end time, relative to the beginning of the interval, of the child interval with the given name, if found, or -1 if the interval is not found.

◆ getIntervalStartTime()

double getIntervalStartTime ( str  name)

Returns the actual start time, relative to the beginning of the interval, of the child interval with the given name, if found, or -1 if the interval is not found.

◆ getNumDefs()

int getNumDefs ( )

Returns the number of interval and push/pop definitions that have been added to the meta interval.

◆ getPrecision()

double getPrecision ( )

Returns the precision with which time measurements are compared.

See set_precision().

◆ isEventReady()

bool isEventReady ( )

Returns true if a recent call to priv_initialize(), priv_step(), or priv_finalize() has left some external intervals ready to play.

If this returns true, call get_event_index(), get_event_t(), and pop_event() to retrieve the relevant information.

◆ popEvent()

popEvent ( )

Acknowledges that the external interval on the top of the queue has been extracted, and is about to be serviced by the scripting language.

This prepares the interval so the next call to is_event_ready() will return information about the next external interval on the queue, if any.

◆ popLevel()

int popLevel ( double  duration)

Finishes a level marked by a previous call to push_level(), and returns to the previous level.

If the duration is not negative, it represents a phony duration to assign to the level, for the purposes of sequencing later intervals. Otherwise, the level's duration is computed based on the intervals within the level.

◆ pushLevel()

int pushLevel ( str  name,
double  rel_time,
CMetaInterval::RelativeStart  rel_to 
)

Marks the beginning of a nested level of child intervals.

Within the nested level, a RelativeStart time of RS_level_begin refers to the start of the level, and the first interval added within the level is always relative to the start of the level.

The return value is the index of the def entry created by this push.

◆ setIntervalStartTime()

bool setIntervalStartTime ( str  name,
double  rel_time,
CMetaInterval::RelativeStart  rel_to 
)

Adjusts the start time of the child interval with the given name, if found.

This may be either a C++ interval added via add_c_interval(), or an external interval added via add_ext_index(); the name must match exactly.

If the interval is found, its start time is adjusted, and all subsequent intervals are adjusting accordingly, and true is returned. If a matching interval is not found, nothing is changed and false is returned.

◆ setPrecision()

setPrecision ( double  precision)

Indicates the precision with which time measurements are compared.

For numerical accuracy, all floating-point time values are converted to integer values internally by scaling by the precision factor. The larger the number given here, the smaller the delta of time that can be differentiated; the limit is the maximum integer that can be represented in the system.

◆ timeline()

timeline ( Ostream  out)

Outputs a list of all events in the order in which they occur.