The base class for timeline components. More...
#include "cInterval.h"
Public Member Functions | |
CInterval (const std::string &name, double duration, bool open_ended) | |
bool | check_t_callback () |
Returns true if the wants_t_callback() flag is true and the interval's t value has changed since the last call to check_t_callback(), false otherwise. More... | |
void | clear_to_initial () |
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... | |
void | finish () |
Stops the interval from playing and sets it to its final state. More... | |
virtual TypeHandle | force_init_type () |
bool | get_auto_finish () const |
bool | get_auto_pause () const |
const std::string & | get_done_event () const |
double | get_duration () const |
CIntervalManager * | get_manager () const |
const std::string & | get_name () const |
bool | get_open_ended () const |
double | get_play_rate () const |
State | get_state () const |
double | get_t () const |
virtual TypeHandle | get_type () const |
bool | get_wants_t_callback () const |
Returns the state of the 'wants_t_callback' flag. More... | |
bool | is_playing () const |
bool | is_stopped () const |
void | loop (double start_t=0.0, double end_t=-1.0, double play_rate=1.0) |
Starts the interval playing by registering it with the current CIntervalManager. More... | |
void | mark_dirty () |
Called by a derived class to indicate the interval has been changed internally and must be recomputed before its duration may be returned. More... | |
virtual void | output (std::ostream &out) const |
double | pause () |
Stops the interval from playing but leaves it in its current state. More... | |
void | priv_do_event (double t, EventType event) |
Calls the appropriate event function indicated by the EventType. More... | |
virtual void | priv_finalize () |
This is called to stop an interval, forcing it to whatever state it would be after it played all the way through. More... | |
virtual void | priv_initialize (double t) |
This replaces the first call to priv_step(), and indicates that the interval has just begun. More... | |
virtual void | priv_instant () |
This is called in lieu of priv_initialize() . More... | |
virtual void | priv_interrupt () |
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... | |
virtual void | priv_reverse_finalize () |
Called generally following a priv_reverse_initialize(), this indicates the interval should set itself to the initial state. More... | |
virtual void | priv_reverse_initialize (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... | |
virtual void | priv_reverse_instant () |
This is called in lieu of priv_reverse_initialize() . More... | |
virtual void | priv_step (double t) |
Advances the time on the interval. More... | |
void | resume () |
Restarts the interval from its current point after a previous call to pause(). More... | |
void | resume (double start_t) |
Restarts the interval from the indicated point after a previous call to pause(). More... | |
void | resume_until (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... | |
void | set_auto_finish (bool auto_finish) |
void | set_auto_pause (bool auto_pause) |
void | set_done_event (const std::string &event) |
void | set_manager (CIntervalManager *manager) |
void | set_play_rate (double play_rate) |
void | set_t (double t) |
void | set_wants_t_callback (bool wants_t_callback) |
Changes the state of the 'wants_t_callback' flag. More... | |
void | setup_play (double start_time, double end_time, double play_rate, bool do_loop) |
Called to prepare the interval for automatic timed playback, e.g. More... | |
void | setup_resume () |
Called to prepare the interval for restarting at the current point within the interval after an interruption. More... | |
void | setup_resume_until (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... | |
void | start (double start_t=0.0, double end_t=-1.0, double play_rate=1.0) |
Starts the interval playing by registering it with the current CIntervalManager. More... | |
bool | step_play () |
Should be called once per frame to execute the automatic timed playback begun with setup_play(). More... | |
virtual void | write (std::ostream &out, int indent_level) const |
Public Member Functions inherited from TypedReferenceCount | |
TypedReferenceCount (const TypedReferenceCount ©) | |
void | operator= (const TypedReferenceCount ©) |
Public Member Functions inherited from TypedObject | |
TypedObject (const TypedObject ©)=default | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_typed_object () const |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
int | get_best_parent_from_Set (const std::set< int > &) const |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More... | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. More... | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. More... | |
TypedObject & | operator= (const TypedObject ©)=default |
Public Member Functions inherited from ReferenceCount | |
int | get_ref_count () const |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. More... | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More... | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More... | |
void | ref () const |
Explicitly increments the reference count. More... | |
bool | ref_if_nonzero () const |
Atomically increases the reference count of this object if it is not zero. More... | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
virtual bool | unref () const |
Explicitly decrements the reference count. More... | |
WeakReferenceList * | weak_ref () |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref () |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from TypedReferenceCount | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from TypedObject | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. More... | |
Static Public Member Functions inherited from ReferenceCount | |
static TypeHandle | get_class_type () |
static void | init_type () |
Public Attributes | |
get_auto_finish | |
Returns the state of the 'auto_finish' flag. More... | |
get_auto_pause | |
Returns the state of the 'auto_pause' flag. More... | |
get_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... | |
get_duration | |
Returns the duration of the interval in seconds. More... | |
get_manager | |
Returns the CIntervalManager object which will be responsible for playing this interval. More... | |
get_name | |
Returns the interval's name. More... | |
get_open_ended | |
Returns the state of the "open_ended" flag. More... | |
get_play_rate | |
Returns the play rate as set by the last call to start(), loop(), or set_play_rate(). More... | |
get_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... | |
get_t | |
Returns the current time of the interval: the last value of t passed to priv_initialize(), priv_step(), or priv_finalize(). More... | |
is_playing | |
Returns true if the interval is currently playing, false otherwise. More... | |
is_stopped | |
Returns true if the interval is in either its initial or final states (but not in a running or paused state). More... | |
set_auto_finish | |
Changes the state of the 'auto_finish' flag. More... | |
set_auto_pause | |
Changes the state of the 'auto_pause' flag. More... | |
set_done_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... | |
set_manager | |
Indicates the CIntervalManager object which will be responsible for playing this interval. More... | |
set_play_rate | |
Changes the play rate of the interval. More... | |
set_t | |
Explicitly sets the time within the interval. More... | |
Public Attributes inherited from TypedObject | |
get_type | |
Public Attributes inherited from ReferenceCount | |
get_ref_count | |
Returns the current reference count. More... | |
Friends | |
class | CMetaInterval |
The base class for timeline components.
A CInterval represents a single action, event, or collection of nested intervals that will be performed at some specific time or over a period of time.
This is essentially similar to the Python "Interval" class, but it is implemented in C++ (hence the name). Intervals that may be implemented in C++ will inherit from this class; Intervals that must be implemented in Python will inherit from the similar Python class.
Definition at line 35 of file cInterval.h.
|
inline |
Returns true if the wants_t_callback() flag is true and the interval's t value has changed since the last call to check_t_callback(), false otherwise.
Definition at line 178 of file cInterval.I.
References get_t, and get_wants_t_callback().
void CInterval::clear_to_initial | ( | ) |
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.
Calling this is like pausing the interval and discarding it, creating a new one in its place.
Definition at line 237 of file cInterval.cxx.
References pause().
void CInterval::finish | ( | ) |
Stops the interval from playing and sets it to its final state.
Definition at line 211 of file cInterval.cxx.
References CIntervalManager::find_c_interval(), get_name, get_state, priv_finalize(), priv_instant(), and CIntervalManager::remove_c_interval().
|
inline |
Returns the state of the 'wants_t_callback' flag.
Definition at line 145 of file cInterval.I.
Referenced by check_t_callback().
void CInterval::loop | ( | double | start_t = 0.0 , |
double | end_t = -1.0 , |
||
double | play_rate = 1.0 |
||
) |
Starts the interval playing by registering it with the current CIntervalManager.
The interval will play until it is interrupted with finish() or pause(), looping back to start_t when it reaches end_t.
If end_t is less than zero, it indicates the end of the interval.
Definition at line 154 of file cInterval.cxx.
References CIntervalManager::add_c_interval(), and setup_play().
void CInterval::mark_dirty | ( | ) |
Called by a derived class to indicate the interval has been changed internally and must be recomputed before its duration may be returned.
Definition at line 654 of file cInterval.cxx.
Referenced by CMetaInterval::set_precision().
double CInterval::pause | ( | ) |
Stops the interval from playing but leaves it in its current state.
It may later be resumed from this point by calling resume().
Definition at line 164 of file cInterval.cxx.
References CIntervalManager::find_c_interval(), get_name, get_state, get_t, priv_interrupt(), and CIntervalManager::remove_c_interval().
Referenced by clear_to_initial().
void CInterval::priv_do_event | ( | double | t, |
EventType | event | ||
) |
Calls the appropriate event function indicated by the EventType.
Definition at line 283 of file cInterval.cxx.
References priv_finalize(), priv_initialize(), priv_instant(), priv_interrupt(), priv_reverse_finalize(), priv_reverse_initialize(), priv_reverse_instant(), and priv_step().
|
virtual |
This is called to stop an interval, forcing it to whatever state it would be after it played all the way through.
It's generally invoked by set_final_t().
Reimplemented in CMetaInterval.
Definition at line 369 of file cInterval.cxx.
References get_duration, and priv_step().
Referenced by finish(), priv_do_event(), and step_play().
|
virtual |
This replaces the first call to priv_step(), and indicates that the interval has just begun.
This may be overridden by derived classes that need to do some explicit initialization on the first call.
Reimplemented in CMetaInterval, and CLerpNodePathInterval.
Definition at line 329 of file cInterval.cxx.
References priv_step().
Referenced by priv_do_event(), and step_play().
|
virtual |
This is called in lieu of priv_initialize() .
. priv_step() .. priv_finalize(), when everything is to happen within one frame. The interval should initialize itself, then leave itself in the final state.
Reimplemented in CMetaInterval, CLerpNodePathInterval, HideInterval, and ShowInterval.
Definition at line 342 of file cInterval.cxx.
References get_duration, and priv_step().
Referenced by finish(), priv_do_event(), and step_play().
|
virtual |
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.
But the interval should remain in its current state in anticipation of being eventually restarted when the calls to priv_step() eventually resume.
The purpose of this function is to allow self-running intervals like sound intervals to stop the actual sound playback during the pause.
Reimplemented in CMetaInterval.
Definition at line 427 of file cInterval.cxx.
Referenced by pause(), priv_do_event(), and step_play().
|
virtual |
Called generally following a priv_reverse_initialize(), this indicates the interval should set itself to the initial state.
Reimplemented in CMetaInterval.
Definition at line 410 of file cInterval.cxx.
References priv_step().
Referenced by priv_do_event(), and step_play().
|
virtual |
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.
Reimplemented in CMetaInterval, and CLerpNodePathInterval.
Definition at line 383 of file cInterval.cxx.
References priv_step().
Referenced by priv_do_event(), and step_play().
|
virtual |
This is called in lieu of priv_reverse_initialize() .
. priv_step() .. priv_reverse_finalize(), when everything is to happen within one frame. The interval should initialize itself, then leave itself in the initial state.
Reimplemented in CMetaInterval, CLerpNodePathInterval, HideInterval, and ShowInterval.
Definition at line 397 of file cInterval.cxx.
References priv_step().
Referenced by priv_do_event(), and step_play().
|
virtual |
Advances the time on the interval.
The time may either increase (the normal case) or decrease (e.g. if the interval is being played by a slider).
Reimplemented in CMetaInterval, CLerpNodePathInterval, CLerpAnimEffectInterval, CConstrainPosHprInterval, CConstrainHprInterval, CConstrainPosInterval, CConstrainTransformInterval, and WaitInterval.
Definition at line 357 of file cInterval.cxx.
Referenced by priv_do_event(), priv_finalize(), priv_initialize(), priv_instant(), priv_reverse_finalize(), priv_reverse_initialize(), priv_reverse_instant(), and step_play().
void CInterval::resume | ( | ) |
Restarts the interval from its current point after a previous call to pause().
Definition at line 180 of file cInterval.cxx.
References CIntervalManager::add_c_interval(), and setup_resume().
void CInterval::resume | ( | double | start_t | ) |
Restarts the interval from the indicated point after a previous call to pause().
Definition at line 190 of file cInterval.cxx.
References CIntervalManager::add_c_interval(), set_t, and setup_resume().
void CInterval::resume_until | ( | 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.
Definition at line 202 of file cInterval.cxx.
References CIntervalManager::add_c_interval(), and setup_resume_until().
|
inline |
Changes the state of the 'wants_t_callback' flag.
If this is true, the interval will be returned by CIntervalManager::get_event() each time the interval's time value has been changed, regardless of whether it has any external events.
Definition at line 135 of file cInterval.I.
void CInterval::setup_play | ( | double | start_t, |
double | end_t, | ||
double | play_rate, | ||
bool | do_loop | ||
) |
Called to prepare the interval for automatic timed playback, e.g.
via a Python task. The interval will be played from start_t to end_t, at a time factor specified by play_rate. start_t must always be less than end_t (except for the exception for end_t == -1, below), but if play_rate is negative the interval will be played backwards.
Specify end_t of -1 to play the entire interval from start_t.
Call step_play() repeatedly to execute the interval.
Definition at line 463 of file cInterval.cxx.
void CInterval::setup_resume | ( | ) |
Called to prepare the interval for restarting at the current point within the interval after an interruption.
Definition at line 499 of file cInterval.cxx.
References ClockObject::get_frame_time, ClockObject::get_global_clock(), and get_t.
Referenced by resume(), and setup_resume_until().
void CInterval::setup_resume_until | ( | 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.
Definition at line 516 of file cInterval.cxx.
References get_duration, and setup_resume().
Referenced by resume_until().
void CInterval::start | ( | double | start_t = 0.0 , |
double | end_t = -1.0 , |
||
double | play_rate = 1.0 |
||
) |
Starts the interval playing by registering it with the current CIntervalManager.
The interval will play to the end and stop.
If end_t is less than zero, it indicates the end of the interval.
Definition at line 141 of file cInterval.cxx.
References CIntervalManager::add_c_interval(), and setup_play().
bool CInterval::step_play | ( | ) |
Should be called once per frame to execute the automatic timed playback begun with setup_play().
Returns true if the interval should continue, false if it is done and should stop.
Definition at line 538 of file cInterval.cxx.
References get_duration, ClockObject::get_frame_time, ClockObject::get_global_clock(), get_open_ended, is_stopped, priv_finalize(), priv_initialize(), priv_instant(), priv_interrupt(), priv_reverse_finalize(), priv_reverse_initialize(), priv_reverse_instant(), and priv_step().
|
inline |
Returns the state of the 'auto_finish' flag.
See set_auto_finish().
Definition at line 131 of file cInterval.h.
|
inline |
Returns the state of the 'auto_pause' flag.
See set_auto_pause().
Definition at line 130 of file cInterval.h.
|
inline |
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.
Definition at line 128 of file cInterval.h.
|
inline |
Returns the duration of the interval in seconds.
Definition at line 124 of file cInterval.h.
Referenced by CMetaInterval::priv_finalize(), priv_finalize(), CLerpNodePathInterval::priv_instant(), CMetaInterval::priv_instant(), priv_instant(), setup_resume_until(), and step_play().
|
inline |
Returns the CIntervalManager object which will be responsible for playing this interval.
Note that this can only return a C++ object; if the particular CIntervalManager object has been extended in the scripting language, this will return the encapsulated C++ object, not the full extended object.
Definition at line 132 of file cInterval.h.
|
inline |
Returns the interval's name.
Definition at line 123 of file cInterval.h.
Referenced by CIntervalManager::add_c_interval(), finish(), and pause().
|
inline |
Returns the state of the "open_ended" flag.
This is primarily intended for instantaneous intervals like FunctionIntervals; it indicates true if the interval has some lasting effect that should be applied even if the interval doesn't get started until after its finish time, or false if the interval is a transitive thing that doesn't need to be called late.
Definition at line 125 of file cInterval.h.
Referenced by step_play().
double CInterval::get_play_rate |
Returns the play rate as set by the last call to start(), loop(), or set_play_rate().
Definition at line 133 of file cInterval.h.
|
inline |
Indicates the state the interval believes it is in: whether it has been started, is currently in the middle, or has been finalized.
Definition at line 126 of file cInterval.h.
|
inline |
Returns the current time of the interval: the last value of t passed to priv_initialize(), priv_step(), or priv_finalize().
Definition at line 129 of file cInterval.h.
Referenced by check_t_callback(), pause(), and setup_resume().
bool CInterval::is_playing |
Returns true if the interval is currently playing, false otherwise.
Definition at line 134 of file cInterval.h.
|
inline |
Returns true if the interval is in either its initial or final states (but not in a running or paused state).
Definition at line 127 of file cInterval.h.
Referenced by step_play().
|
inline |
Changes the state of the 'auto_finish' flag.
If this is true, the interval may be arbitrarily finished when the system needs to reset due to some external event by calling CIntervalManager::interrupt(). If this is false (the default), the interval must always be explicitly finished or paused.
Definition at line 131 of file cInterval.h.
|
inline |
Changes the state of the 'auto_pause' flag.
If this is true, the interval may be arbitrarily interrupted when the system needs to reset due to some external event by calling CIntervalManager::interrupt(). If this is false (the default), the interval must always be explicitly finished or paused.
Definition at line 130 of file cInterval.h.
|
inline |
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.
Definition at line 128 of file cInterval.h.
|
inline |
Indicates the CIntervalManager object which will be responsible for playing this interval.
This defaults to the global CIntervalManager; you should need to change this only if you have special requirements for playing this interval.
Definition at line 132 of file cInterval.h.
void CInterval::set_play_rate |
void CInterval::set_t |
Explicitly sets the time within the interval.
Normally, you would use start() .. finish() to let the time play normally, but this may be used to set the time to some particular value.
Definition at line 129 of file cInterval.h.
Referenced by resume().