Panda3D
|
The base class for timeline components. More...
#include "cInterval.h"
Public Member Functions | |
CInterval (const 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 |
Returns the state of the 'auto_finish' flag. More... | |
bool | get_auto_pause () const |
Returns the state of the 'auto_pause' flag. More... | |
const string & | get_done_event () const |
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 | get_duration () const |
Returns the duration of the interval in seconds. More... | |
CIntervalManager * | get_manager () const |
Returns the CIntervalManager object which will be responsible for playing this interval. More... | |
const string & | get_name () const |
Returns the interval's name. More... | |
bool | get_open_ended () const |
Returns the state of the "open_ended" flag. More... | |
double | get_play_rate () const |
Returns the play rate as set by the last call to start(), loop(), or set_play_rate(). More... | |
State | get_state () const |
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 | get_t () const |
Returns the current time of the interval: the last value of t passed to priv_initialize(), priv_step(), or priv_finalize(). More... | |
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 |
Returns true if the interval is currently playing, false otherwise. More... | |
bool | is_stopped () const |
Returns true if the interval is in either its initial or final states (but not in a running or paused state). More... | |
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 (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) |
Changes the state of the 'auto_finish' flag. More... | |
void | set_auto_pause (bool auto_pause) |
Changes the state of the 'auto_pause' flag. More... | |
void | set_done_event (const string &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... | |
void | set_manager (CIntervalManager *manager) |
Indicates the CIntervalManager object which will be responsible for playing this interval. More... | |
void | set_play_rate (double play_rate) |
Changes the play rate of the interval. More... | |
void | set_t (double t) |
Explicitly sets the time within the interval. More... | |
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 (ostream &out, int indent_level) const |
![]() | |
TypedReferenceCount (const TypedReferenceCount ©) | |
void | operator= (const TypedReferenceCount ©) |
![]() | |
TypedObject (const TypedObject ©) | |
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... | |
void | operator= (const TypedObject ©) |
![]() | |
int | get_ref_count () const |
Returns the current reference count. More... | |
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 | 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... | |
void | weak_ref (WeakPointerToVoid *ptv) |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref (WeakPointerToVoid *ptv) |
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 TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
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 TypeHandle | get_class_type () |
static void | init_type () |
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 39 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 232 of file cInterval.I.
References get_name(), TypeHandle::get_name(), get_t(), and get_wants_t_callback().
Referenced by get_manager().
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 268 of file cInterval.cxx.
References is_playing(), and pause().
Referenced by finish().
void CInterval::finish | ( | ) |
Stops the interval from playing and sets it to its final state.
Definition at line 239 of file cInterval.cxx.
References clear_to_initial(), get_name(), get_state(), priv_finalize(), and priv_instant().
Referenced by resume_until().
|
inline |
Returns the state of the 'auto_finish' flag.
See set_auto_finish().
Definition at line 165 of file cInterval.I.
References set_wants_t_callback().
Referenced by set_auto_finish().
|
inline |
Returns the state of the 'auto_pause' flag.
See set_auto_pause().
Definition at line 138 of file cInterval.I.
References set_auto_finish().
Referenced by set_auto_pause().
|
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 99 of file cInterval.I.
References get_t().
Referenced by set_done_event().
|
inline |
Returns the duration of the interval in seconds.
Definition at line 32 of file cInterval.I.
References get_open_ended().
Referenced by get_name(), CMetaInterval::priv_finalize(), priv_finalize(), CLerpNodePathInterval::priv_instant(), CMetaInterval::priv_instant(), priv_instant(), priv_interrupt(), CLerpNodePathInterval::priv_reverse_instant(), CConstrainTransformInterval::priv_step(), CConstrainPosInterval::priv_step(), CConstrainHprInterval::priv_step(), CConstrainPosHprInterval::priv_step(), CLerpAnimEffectInterval::priv_step(), setup_play(), setup_resume_until(), step_play(), and CLerpInterval::string_blend_type().
|
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 220 of file cInterval.I.
References check_t_callback().
Referenced by set_manager().
|
inline |
Returns the interval's name.
Definition at line 22 of file cInterval.I.
References get_duration().
Referenced by CIntervalManager::add_c_interval(), check_t_callback(), finish(), is_playing(), pause(), CMetaInterval::pop_event(), priv_interrupt(), CLerpNodePathInterval::priv_reverse_instant(), CConstrainTransformInterval::priv_step(), CConstrainPosInterval::priv_step(), CConstrainHprInterval::priv_step(), CConstrainPosHprInterval::priv_step(), and CLerpAnimEffectInterval::priv_step().
|
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 49 of file cInterval.I.
References get_state().
Referenced by get_duration(), and step_play().
double CInterval::get_play_rate | ( | ) | const |
Returns the play rate as set by the last call to start(), loop(), or set_play_rate().
Definition at line 294 of file cInterval.cxx.
References set_play_rate().
Referenced by is_playing().
|
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 61 of file cInterval.I.
References is_stopped().
Referenced by finish(), CIntervalManager::get_global_ptr(), get_open_ended(), pause(), and set_t().
|
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 111 of file cInterval.I.
References set_auto_pause().
Referenced by check_t_callback(), get_done_event(), pause(), and setup_resume().
|
inline |
Returns the state of the 'wants_t_callback' flag.
Definition at line 191 of file cInterval.I.
References set_manager().
Referenced by check_t_callback(), and set_wants_t_callback().
bool CInterval::is_playing | ( | ) | const |
Returns true if the interval is currently playing, false otherwise.
Definition at line 282 of file cInterval.cxx.
References get_name(), and get_play_rate().
Referenced by clear_to_initial(), set_play_rate(), and set_t().
|
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 73 of file cInterval.I.
References set_done_event().
Referenced by get_state(), and step_play().
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 169 of file cInterval.cxx.
References pause(), and setup_play().
Referenced by start().
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 746 of file cInterval.cxx.
Referenced by CMetaInterval::add_c_interval(), CMetaInterval::add_ext_index(), CMetaInterval::pop_level(), CMetaInterval::push_level(), CMetaInterval::set_interval_start_time(), CMetaInterval::set_precision(), and step_play().
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 182 of file cInterval.cxx.
References get_name(), get_state(), get_t(), priv_interrupt(), and resume().
Referenced by clear_to_initial(), loop(), and set_play_rate().
void CInterval::priv_do_event | ( | double | t, |
EventType | event | ||
) |
Calls the appropriate event function indicated by the EventType.
Definition at line 325 of file cInterval.cxx.
References priv_finalize(), priv_initialize(), priv_instant(), priv_interrupt(), priv_reverse_finalize(), priv_reverse_initialize(), priv_reverse_instant(), and CConstrainTransformInterval::priv_step().
Referenced by set_play_rate(), and CMetaInterval::timeline().
|
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 422 of file cInterval.cxx.
References get_duration(), priv_reverse_initialize(), and CConstrainTransformInterval::priv_step().
Referenced by finish(), CIntervalManager::get_global_ptr(), priv_do_event(), priv_step(), 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 374 of file cInterval.cxx.
References priv_instant(), and CConstrainTransformInterval::priv_step().
Referenced by priv_do_event(), set_t(), 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 390 of file cInterval.cxx.
References get_duration(), CConstrainTransformInterval::priv_step(), and priv_step().
Referenced by finish(), CIntervalManager::get_global_ptr(), priv_do_event(), priv_initialize(), 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 493 of file cInterval.cxx.
References get_duration(), get_name(), and setup_play().
Referenced by pause(), priv_do_event(), priv_reverse_finalize(), set_t(), 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 472 of file cInterval.cxx.
References priv_interrupt(), and CConstrainTransformInterval::priv_step().
Referenced by priv_do_event(), priv_reverse_instant(), 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 439 of file cInterval.cxx.
References priv_reverse_instant(), and CConstrainTransformInterval::priv_step().
Referenced by priv_do_event(), priv_finalize(), set_t(), 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 456 of file cInterval.cxx.
References priv_reverse_finalize(), and CConstrainTransformInterval::priv_step().
Referenced by priv_do_event(), priv_reverse_initialize(), 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 407 of file cInterval.cxx.
References priv_finalize().
Referenced by priv_instant().
void CInterval::resume | ( | ) |
Restarts the interval from its current point after a previous call to pause().
Definition at line 200 of file cInterval.cxx.
References setup_resume().
Referenced by pause(), and set_play_rate().
void CInterval::resume | ( | double | start_t | ) |
Restarts the interval from the indicated point after a previous call to pause().
Definition at line 212 of file cInterval.cxx.
References resume_until(), 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 227 of file cInterval.cxx.
References finish(), and setup_resume_until().
Referenced by resume().
|
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 154 of file cInterval.I.
References get_auto_finish().
Referenced by get_auto_pause().
|
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 127 of file cInterval.I.
References get_auto_pause().
Referenced by get_t().
|
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 86 of file cInterval.I.
References get_done_event().
Referenced by is_stopped().
|
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 205 of file cInterval.I.
References get_manager().
Referenced by get_wants_t_callback().
void CInterval::set_play_rate | ( | double | play_rate | ) |
Changes the play rate of the interval.
If the interval is already started, this changes its speed on-the-fly. Note that since play_rate is a parameter to start() and loop(), the next call to start() or loop() will reset this parameter.
Definition at line 308 of file cInterval.cxx.
References is_playing(), pause(), priv_do_event(), and resume().
Referenced by get_play_rate().
void CInterval::set_t | ( | double | 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 95 of file cInterval.cxx.
References get_state(), is_playing(), priv_initialize(), priv_interrupt(), priv_reverse_initialize(), CConstrainTransformInterval::priv_step(), setup_resume(), and start().
Referenced by resume().
|
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 179 of file cInterval.I.
References get_wants_t_callback().
Referenced by get_auto_finish().
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 538 of file cInterval.cxx.
References get_duration(), ClockObject::get_frame_time(), ClockObject::get_global_clock(), and setup_resume().
Referenced by loop(), priv_interrupt(), and start().
void CInterval::setup_resume | ( | ) |
Called to prepare the interval for restarting at the current point within the interval after an interruption.
Definition at line 577 of file cInterval.cxx.
References ClockObject::get_frame_time(), ClockObject::get_global_clock(), get_t(), and setup_resume_until().
Referenced by resume(), set_t(), setup_play(), 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 597 of file cInterval.cxx.
References get_duration(), setup_resume(), and step_play().
Referenced by resume_until(), and setup_resume().
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 151 of file cInterval.cxx.
References loop(), and setup_play().
Referenced by set_t().
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 621 of file cInterval.cxx.
References get_duration(), ClockObject::get_frame_time(), ClockObject::get_global_clock(), get_open_ended(), is_stopped(), mark_dirty(), priv_finalize(), priv_initialize(), priv_instant(), priv_interrupt(), priv_reverse_finalize(), priv_reverse_initialize(), priv_reverse_instant(), and CConstrainTransformInterval::priv_step().
Referenced by setup_resume_until().