Panda3D
|
A ClockObject keeps track of elapsed real time and discrete time. More...
#include "clockObject.h"
Classes | |
class | CData |
Public Types | |
enum | Mode { M_normal, M_non_real_time, M_forced, M_degrade, M_slave, M_limited, M_integer, M_integer_limited } |
Public Member Functions | |
double | calc_frame_rate_deviation (Thread *current_thread=Thread::get_current_thread()) const |
Returns the standard deviation of the frame times of the frames rendered over the past get_average_frame_rate_interval() seconds. | |
bool | check_errors (Thread *current_thread) |
Returns true if a clock error was detected since the last time check_errors() was called. | |
double | get_average_frame_rate (Thread *current_thread=Thread::get_current_thread()) const |
Returns the average frame rate in number of frames per second over the last get_average_frame_rate_interval() seconds. | |
double | get_average_frame_rate_interval () const |
Returns the interval of time (in seconds) over which get_average_frame_rate() averages the number of frames per second to compute the frame rate. | |
double | get_degrade_factor () const |
In degrade mode, returns the ratio by which the performance is degraded. | |
double | get_dt (Thread *current_thread=Thread::get_current_thread()) const |
Returns the elapsed time for the previous frame: the number of seconds elapsed between the last two calls to tick(). | |
int | get_frame_count (Thread *current_thread=Thread::get_current_thread()) const |
Returns the number of times tick() has been called since the ClockObject was created, or since it was last reset. | |
double | get_frame_time (Thread *current_thread=Thread::get_current_thread()) const |
Returns the time in seconds as of the last time tick() was called (typically, this will be as of the start of the current frame). | |
double | get_long_time () const |
Returns the actual number of seconds elapsed since the ClockObject was created, or since it was last reset. | |
double | get_max_dt () const |
Returns the current maximum allowable time elapsed between any two frames. | |
double | get_max_frame_duration (Thread *current_thread=Thread::get_current_thread()) const |
Returns the maximum frame duration over the last get_average_frame_rate_interval() seconds. | |
Mode | get_mode () const |
Returns the current mode of the clock. | |
double | get_net_frame_rate (Thread *current_thread=Thread::get_current_thread()) const |
Returns the average frame rate since the last reset. | |
double | get_real_time () const |
Returns the actual number of seconds elapsed since the ClockObject was created, or since it was last reset. | |
int | get_ref_count () const |
Returns the current reference count. | |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. | |
void | operator delete (void *ptr) |
void | operator delete (void *ptr, void *) |
void | operator delete[] (void *ptr) |
void | operator delete[] (void *, void *) |
void * | operator new (size_t size) |
void * | operator new (size_t size, void *ptr) |
void * | operator new[] (size_t size) |
void * | operator new[] (size_t size, void *ptr) |
void | ref () const |
Explicitly increments the reference count. | |
void | reset () |
Simultaneously resets both the time and the frame count to zero. | |
void | set_average_frame_rate_interval (double time) |
Specifies the interval of time (in seconds) over which get_average_frame_rate() averages the number of frames per second to compute the frame rate. | |
void | set_degrade_factor (double degrade_factor) |
In degrade mode, sets the ratio by which the performance is degraded. | |
void | set_dt (double dt) |
In non-real-time mode, sets the number of seconds that should appear to elapse between frames. | |
void | set_frame_count (int frame_count, Thread *current_thread=Thread::get_current_thread()) |
Resets the number of frames counted to the indicated number. | |
void | set_frame_rate (double frame_rate) |
In non-real-time mode, sets the number of frames per second that we should appear to be running. | |
void | set_frame_time (double time, Thread *current_thread=Thread::get_current_thread()) |
Changes the time as reported for the current frame to the indicated time. | |
void | set_max_dt (double max_dt) |
Sets a limit on the value returned by get_dt(). | |
void | set_mode (Mode mode) |
Changes the mode of the clock. | |
void | set_real_time (double time) |
Resets the clock to the indicated time. | |
void | sync_frame_time (Thread *current_thread=Thread::get_current_thread()) |
Resets the frame time to the current real time. | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. | |
void | tick (Thread *current_thread=Thread::get_current_thread()) |
Instructs the clock that a new frame has just begun. | |
virtual bool | unref () const |
Explicitly decrements the reference count. | |
void | weak_ref (WeakPointerToVoid *ptv) |
Adds the indicated PointerToVoid as a weak reference to this object. | |
void | weak_unref (WeakPointerToVoid *ptv) |
Removes the indicated PointerToVoid as a weak reference to this object. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static ClockObject * | get_global_clock () |
Returns a pointer to the global ClockObject. | |
static void | init_type () |
Static Public Attributes | |
static void(* | _start_clock_busy_wait )() = ClockObject::dummy_clock_wait |
static void(* | _start_clock_wait )() = ClockObject::dummy_clock_wait |
static void(* | _stop_clock_wait )() = ClockObject::dummy_clock_wait |
Protected Member Functions | |
bool | do_test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
bool | do_test_ref_count_nonzero () const |
Returns true if the reference count is nonzero, false otherwise. |
A ClockObject keeps track of elapsed real time and discrete time.
In normal mode, get_frame_time() returns the time as of the last time tick() was called. This is the "discrete" time, and is usually used to get the time as of, for instance, the beginning of the current frame.
In other modes, as set by set_mode() or the clock-mode config variable, get_frame_time() may return other values to simulate different timing effects, for instance to perform non-real-time animation. See set_mode().
In all modes, get_real_time() always returns the elapsed real time in seconds since the ClockObject was constructed, or since it was last reset.
You can create your own ClockObject whenever you want to have your own local timer. There is also a default, global ClockObject intended to represent global time for the application; this is normally set up to tick every frame so that its get_frame_time() will return the time for the current frame.
Definition at line 65 of file clockObject.h.
double ClockObject::calc_frame_rate_deviation | ( | Thread * | current_thread = Thread::get_current_thread() | ) | const |
Returns the standard deviation of the frame times of the frames rendered over the past get_average_frame_rate_interval() seconds.
This number gives an estimate of the chugginess of the frame rate; if it is large, there is a large variation in the frame rate; if is small, all of the frames are consistent in length.
A large value might also represent just a recent change in frame rate, for instance, because the camera has just rotated from looking at a simple scene to looking at a more complex scene.
Definition at line 345 of file clockObject.cxx.
bool ClockObject::check_errors | ( | Thread * | current_thread | ) | [inline] |
Returns true if a clock error was detected since the last time check_errors() was called.
A clock error means that something happened, an OS or BIOS bug, for instance, that makes the current value of the clock somewhat suspect, and an application may wish to resynchronize with any external clocks.
Definition at line 256 of file clockObject.I.
References TrueClock::get_error_count().
Referenced by GraphicsEngine::render_frame().
bool ReferenceCount::do_test_ref_count_integrity | ( | ) | const [protected, inherited] |
Does some easy checks to make sure that the reference count isn't completely bogus.
Returns true if ok, false otherwise.
Reimplemented in NodeReferenceCount, CachedTypedWritableReferenceCount, and NodeCachedReferenceCount.
Definition at line 29 of file referenceCount.cxx.
Referenced by ReferenceCount::do_test_ref_count_nonzero(), and ReferenceCount::test_ref_count_integrity().
bool ReferenceCount::do_test_ref_count_nonzero | ( | ) | const [protected, inherited] |
Returns true if the reference count is nonzero, false otherwise.
Definition at line 56 of file referenceCount.cxx.
References ReferenceCount::do_test_ref_count_integrity().
Referenced by ReferenceCount::test_ref_count_nonzero().
double ClockObject::get_average_frame_rate | ( | Thread * | current_thread = Thread::get_current_thread() | ) | const |
Returns the average frame rate in number of frames per second over the last get_average_frame_rate_interval() seconds.
This measures the virtual frame rate if the clock is in M_non_real_time mode.
Definition at line 298 of file clockObject.cxx.
double ClockObject::get_average_frame_rate_interval | ( | ) | const [inline] |
Returns the interval of time (in seconds) over which get_average_frame_rate() averages the number of frames per second to compute the frame rate.
Definition at line 241 of file clockObject.I.
double ClockObject::get_degrade_factor | ( | ) | const [inline] |
In degrade mode, returns the ratio by which the performance is degraded.
A value of 2.0 causes the clock to be slowed down by a factor of two (reducing performance to 1/2 what would be otherwise).
This has no effect if mode is not M_degrade.
Definition at line 193 of file clockObject.I.
double ClockObject::get_dt | ( | Thread * | current_thread = Thread::get_current_thread() | ) | const [inline] |
Returns the elapsed time for the previous frame: the number of seconds elapsed between the last two calls to tick().
Definition at line 141 of file clockObject.I.
Referenced by PhysicsCollisionHandler::apply_friction(), CollisionHandlerGravity::handle_entries(), and CollisionHandlerFloor::handle_entries().
int ClockObject::get_frame_count | ( | Thread * | current_thread = Thread::get_current_thread() | ) | const [inline] |
Returns the number of times tick() has been called since the ClockObject was created, or since it was last reset.
This is generally the number of frames that have been rendered.
Definition at line 113 of file clockObject.I.
Referenced by AdaptiveLru::begin_epoch(), BufferResidencyTracker::begin_frame(), RecorderController::begin_playback(), RecorderController::begin_record(), VideoTexture::consider_update(), Character::cull_callback(), VideoTexture::do_has_ram_image(), ClientBase::do_poll(), GeomCacheManager::evict_old_entries(), DisplayRegion::make_screenshot_filename(), RecorderController::play_frame(), RecorderController::record_frame(), GeomCacheEntry::refresh(), GraphicsEngine::render_frame(), PandaFramework::report_frame_rate(), PandaFramework::reset_frame_rate(), and set_frame_count().
double ClockObject::get_frame_time | ( | Thread * | current_frame = Thread::get_current_thread() | ) | const [inline] |
Returns the time in seconds as of the last time tick() was called (typically, this will be as of the start of the current frame).
This is generally the kind of time you want to ask for in most rendering and animation contexts, since it's important that all of the animation for a given frame remains in sync with each other.
Definition at line 48 of file clockObject.I.
Referenced by RecorderController::begin_playback(), RecorderController::begin_record(), Camera::cleanup_aux_scene_data(), FadeLODNode::cull_callback(), UvScrollNode::cull_callback(), SceneGraphAnalyzerMeter::cull_callback(), FrameRateMeter::cull_callback(), ClientBase::do_poll(), MouseWatcher::do_transmit_data(), PolylightNode::flicker(), PGSliderBar::item_press(), SmoothMover::mark_position(), CullableObject::munge_geom(), TimedCycle::next_element(), MouseWatcher::note_activity(), RecorderController::play_frame(), PGSliderBar::press(), PGEntry::press(), RecorderController::record_frame(), PandaFramework::report_frame_rate(), PandaFramework::reset_frame_rate(), PGEntry::set_cursor_position(), TimedCycle::set_cycle_time(), PGEntry::set_focus(), set_frame_time(), SmoothMover::set_phony_timestamp(), CInterval::setup_play(), CInterval::setup_resume(), CInterval::step_play(), PointerEventList::total_turns(), Character::update(), and PartBundle::update().
ClockObject * ClockObject::get_global_clock | ( | ) | [inline, static] |
Returns a pointer to the global ClockObject.
This is the ClockObject that most code should use for handling scene graph rendering and animation.
Definition at line 271 of file clockObject.I.
Referenced by PhysicsCollisionHandler::apply_friction(), AdaptiveLru::begin_epoch(), BufferResidencyTracker::begin_frame(), RecorderController::begin_playback(), RecorderController::begin_record(), Camera::cleanup_aux_scene_data(), SmoothMover::compute_smooth_position(), VideoTexture::consider_update(), PGSliderBar::cull_callback(), FadeLODNode::cull_callback(), UvScrollNode::cull_callback(), Character::cull_callback(), VideoTexture::do_has_ram_image(), ClientBase::do_poll(), MouseWatcher::do_transmit_data(), GeomCacheManager::evict_old_entries(), TimedCycle::fillin(), PolylightNode::flicker(), CollisionHandlerGravity::handle_entries(), CollisionHandlerFloor::handle_entries(), CacheStats::init(), PGSliderBar::item_press(), DisplayRegion::make_screenshot_filename(), SmoothMover::mark_position(), CacheStats::maybe_report(), CullableObject::munge_geom(), MouseWatcher::note_activity(), RecorderController::play_frame(), ClientBase::poll(), PGSliderBar::press(), PGEntry::press(), VertexDataSaveFile::read_data(), RecorderController::record_frame(), GeomCacheEntry::refresh(), GraphicsEngine::render_frame(), PandaFramework::report_frame_rate(), PandaFramework::reset_frame_rate(), PGEntry::set_cursor_position(), PGEntry::set_focus(), SmoothMover::set_phony_timestamp(), CInterval::setup_play(), CInterval::setup_resume(), CInterval::step_play(), PointerEventList::total_turns(), Character::update(), PartBundle::update(), and WinGraphicsWindow::window_proc().
double ClockObject::get_long_time | ( | ) | const [inline] |
Returns the actual number of seconds elapsed since the ClockObject was created, or since it was last reset.
This is similar to get_real_time(), except that it uses the most accurate counter we have over a long period of time, and so it is less likely to drift. However, it may not be very precise for measuring short intervals. On Windows, for instace, this is only accurate to within about 55 milliseconds.
Definition at line 87 of file clockObject.I.
double ClockObject::get_max_dt | ( | ) | const [inline] |
Returns the current maximum allowable time elapsed between any two frames.
See set_max_dt().
Definition at line 156 of file clockObject.I.
double ClockObject::get_max_frame_duration | ( | Thread * | current_thread = Thread::get_current_thread() | ) | const |
Returns the maximum frame duration over the last get_average_frame_rate_interval() seconds.
Definition at line 314 of file clockObject.cxx.
ClockObject::Mode ClockObject::get_mode | ( | ) | const [inline] |
double ClockObject::get_net_frame_rate | ( | Thread * | current_thread = Thread::get_current_thread() | ) | const [inline] |
Returns the average frame rate since the last reset.
This is simply the total number of frames divided by the total elapsed time. This reports the virtual frame rate if the clock is in (or has been in) M_non_real_time mode.
Definition at line 128 of file clockObject.I.
double ClockObject::get_real_time | ( | ) | const [inline] |
Returns the actual number of seconds elapsed since the ClockObject was created, or since it was last reset.
This is useful for doing real timing measurements, e.g. for performance statistics.
This returns the most precise timer we have for short time intervals, but it may tend to drift over the long haul. If more accurate timekeeping is needed over a long period of time, use get_long_time() instead.
Definition at line 68 of file clockObject.I.
Referenced by PathFollow::do_follow(), TimedCycle::fillin(), CacheStats::maybe_report(), VertexDataSaveFile::read_data(), set_real_time(), PathFollow::start(), sync_frame_time(), tick(), and WinGraphicsWindow::window_proc().
int ReferenceCount::get_ref_count | ( | ) | const [inline, inherited] |
Returns the current reference count.
Definition at line 155 of file referenceCount.I.
References ReferenceCount::test_ref_count_integrity().
Referenced by TransformState::clear_cache(), RenderState::clear_cache(), RenderState::finalize(), RenderEffects::finalize(), RenderEffect::finalize(), RenderAttrib::finalize(), InternalName::finalize(), TransformState::get_num_unused_states(), RenderState::get_num_unused_states(), TransformState::list_cycles(), RenderState::list_cycles(), GeomVertexFormat::remove_column(), TransformState::unref(), RenderState::unref(), RenderState::~RenderState(), and TransformState::~TransformState().
WeakReferenceList * ReferenceCount::get_weak_list | ( | ) | const [inline, inherited] |
Returns the WeakReferenceList associated with this ReferenceCount object.
If there has never been a WeakReferenceList associated with this object, creates one now.
Definition at line 307 of file referenceCount.I.
Referenced by ReferenceCount::weak_ref().
bool ReferenceCount::has_weak_list | ( | ) | const [inline, inherited] |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise.
In general, this will be true if there was ever a WeakPointerTo created for this object (even if there is not any for it now).
Definition at line 294 of file referenceCount.I.
Referenced by ReferenceCount::weak_unref().
void ReferenceCount::local_object | ( | ) | [inline, inherited] |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack.
This allows the object to be passed to functions that will increment and decrement the object's reference count temporarily, and it will prevent the object from being deleted (inappropriately), when the reference count returns to zero. It actually achieves this by setting a large positive value in the reference count field.
Definition at line 276 of file referenceCount.I.
Referenced by PGTop::cull_callback(), BoundingSphere::extend_by_hexahedron(), AsyncTaskManager::find_task(), AsyncTaskManager::find_tasks(), and AsyncTaskManager::find_tasks_matching().
void ReferenceCount::ref | ( | ) | const [inline, inherited] |
Explicitly increments the reference count.
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
Definition at line 179 of file referenceCount.I.
References ReferenceCount::test_ref_count_integrity().
Referenced by CachedTypedWritableReferenceCount::cache_ref(), TypedWritable::decode_raw_from_bam_stream(), NodeCachedReferenceCount::node_ref(), NodeReferenceCount::node_ref(), BamCacheRecord::set_data(), CullableObject::set_draw_callback(), and ModelRoot::set_reference().
void ClockObject::reset | ( | ) | [inline] |
Simultaneously resets both the time and the frame count to zero.
Definition at line 98 of file clockObject.I.
References set_frame_count(), set_frame_time(), and set_real_time().
void ClockObject::set_average_frame_rate_interval | ( | double | time | ) | [inline] |
Specifies the interval of time (in seconds) over which get_average_frame_rate() averages the number of frames per second to compute the frame rate.
Changing this does not necessarily immediately change the result of get_average_frame_rate(), until this interval of time has elapsed again.
Setting this to zero disables the computation of get_average_frame_rate().
Definition at line 226 of file clockObject.I.
void ClockObject::set_degrade_factor | ( | double | degrade_factor | ) | [inline] |
In degrade mode, sets the ratio by which the performance is degraded.
A value of 2.0 causes the clock to be slowed down by a factor of two (reducing performance to 1/2 what would be otherwise).
This has no effect if mode is not M_degrade.
Definition at line 208 of file clockObject.I.
void ClockObject::set_dt | ( | double | dt | ) |
In non-real-time mode, sets the number of seconds that should appear to elapse between frames.
In forced mode or limited mode, sets our target dt. In normal mode, this has no effect.
Also see set_frame_rate(), which is a different way to specify the same quantity.
Definition at line 239 of file clockObject.cxx.
References Thread::get_current_thread(), and set_frame_rate().
void ClockObject::set_frame_count | ( | int | frame_count, |
Thread * | current_thread = Thread::get_current_thread() |
||
) |
Resets the number of frames counted to the indicated number.
Also see reset(), set_real_time(), and set_frame_time().
Definition at line 210 of file clockObject.cxx.
References get_frame_count(), and Thread::get_pipeline_stage().
Referenced by reset().
void ClockObject::set_frame_rate | ( | double | frame_rate | ) |
In non-real-time mode, sets the number of frames per second that we should appear to be running.
In forced mode or limited mode, sets our target frame rate. In normal mode, this has no effect.
Also see set_dt(), which is a different way to specify the same quantity.
Definition at line 267 of file clockObject.cxx.
References Thread::get_current_thread(), and Thread::get_pipeline_stage().
Referenced by set_dt().
void ClockObject::set_frame_time | ( | double | time, |
Thread * | current_thread = Thread::get_current_thread() |
||
) |
Changes the time as reported for the current frame to the indicated time.
Normally, the way to adjust the frame time is via tick(); this function is provided only for occasional special adjustments.
Definition at line 184 of file clockObject.cxx.
References get_frame_time(), and Thread::get_pipeline_stage().
Referenced by reset().
void ClockObject::set_max_dt | ( | double | max_dt | ) | [inline] |
Sets a limit on the value returned by get_dt().
If this value is less than zero, no limit is imposed; otherwise, this is the maximum value that will ever be returned by get_dt(), regardless of how much time has actually elapsed between frames.
This limit is only imposed in real-time mode; in non-real-time mode, the dt is fixed anyway and max_dt is ignored.
This is generally used to guarantee reasonable behavior even in the presence of a very slow or chuggy frame rame.
Definition at line 178 of file clockObject.I.
void ClockObject::set_mode | ( | ClockObject::Mode | mode | ) |
Changes the mode of the clock.
Normally, the clock is in mode M_normal. In this mode, each call to tick() will set the value returned by get_frame_time() to the current real time; thus, the clock simply reports time advancing.
Other possible modes:
M_non_real_time - the clock ignores real time completely; at each call to tick(), it pretends that exactly dt seconds have elapsed since the last call to tick(). You may set the value of dt with set_dt() or set_frame_rate().
M_limited - the clock will run as fast as it can, as in M_normal, but will not run faster than the rate specified by set_frame_rate(). If the application would run faster than this rate, the clock will slow down the application.
M_integer - the clock will run as fast as it can, but the rate will be constrained to be an integer multiple or divisor of the rate specified by set_frame_rate(). The clock will slow down the application a bit to guarantee this.
M_integer_limited - a combination of M_limited and M_integer; the clock will not run faster than set_frame_rate(), and if it runs slower, it will run at a integer divisor of that rate.
M_forced - the clock forces the application to run at the rate specified by set_frame_rate(). If the application would run faster than this rate, the clock will slow down the application; if the application would run slower than this rate, the clock slows down time so that the application believes it is running at the given rate.
M_degrade - the clock runs at real time, but the application is slowed down by a set factor of its frame rate, specified by set_degrade_factor().
M_slave - the clock does not advance, but relies on the user to call set_frame_time() and/or set_frame_count() each frame.
Definition at line 128 of file clockObject.cxx.
References Thread::get_current_thread(), and Thread::get_pipeline_stage().
void ClockObject::set_real_time | ( | double | time | ) |
Resets the clock to the indicated time.
This changes only the real time of the clock as reported by get_real_time(), but does not immediately change the time reported by get_frame_time()--that will change after the next call to tick(). Also see reset(), set_frame_time(), and set_frame_count().
Definition at line 160 of file clockObject.cxx.
References get_real_time().
Referenced by reset().
void ClockObject::sync_frame_time | ( | Thread * | current_thread = Thread::get_current_thread() | ) |
Resets the frame time to the current real time.
This is similar to tick(), except that it does not advance the frame counter and does not affect dt. This is intended to be used in the middle of a particularly long frame to compensate for the time that has already elapsed.
In non-real-time mode, this function has no effect (because in this mode all frames take the same length of time).
Definition at line 513 of file clockObject.cxx.
References get_real_time().
bool ReferenceCount::test_ref_count_integrity | ( | ) | const [inline, inherited] |
Does some easy checks to make sure that the reference count isn't completely bogus.
Returns true if ok, false otherwise.
Reimplemented in NodeReferenceCount, CachedTypedWritableReferenceCount, and NodeCachedReferenceCount.
Definition at line 236 of file referenceCount.I.
References ReferenceCount::do_test_ref_count_integrity().
Referenced by EggGroupNode::add_child(), InternalName::find_ancestor(), InternalName::get_ancestor(), ReferenceCount::get_ref_count(), InternalName::get_top(), ReferenceCount::ref(), EggVertex::test_gref_integrity(), EggVertex::test_pref_integrity(), EggNode::test_under_integrity(), EggPrimitive::test_vref_integrity(), EggGroup::test_vref_integrity(), MouseWatcher::throw_event_pattern(), ReferenceCount::unref(), and EggNode::update_under().
bool ReferenceCount::test_ref_count_nonzero | ( | ) | const [inline, inherited] |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
Returns true if ok, false otherwise.
Definition at line 252 of file referenceCount.I.
References ReferenceCount::do_test_ref_count_nonzero().
Referenced by CopyOnWritePointer::test_ref_count_nonzero().
void ClockObject::tick | ( | Thread * | current_thread = Thread::get_current_thread() | ) |
Instructs the clock that a new frame has just begun.
In normal, real-time mode, get_frame_time() will henceforth report the time as of this instant as the current start-of-frame time. In non-real-time mode, get_frame_time() will be incremented by the value of dt.
Definition at line 374 of file clockObject.cxx.
References Thread::get_pipeline_stage(), and get_real_time().
Referenced by GraphicsEngine::render_frame().
bool ReferenceCount::unref | ( | ) | const [inline, virtual, inherited] |
Explicitly decrements the reference count.
Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete().
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
The return value is true if the new reference count is nonzero, false if it is zero.
Reimplemented in GeomVertexArrayFormat, GeomVertexFormat, InternalName, RenderAttrib, RenderEffects, RenderState, and TransformState.
Definition at line 214 of file referenceCount.I.
References ReferenceCount::test_ref_count_integrity().
Referenced by CachedTypedWritableReferenceCount::cache_unref(), TypedWritable::decode_raw_from_bam_stream(), RenderEffect::finalize(), NodeCachedReferenceCount::node_unref(), NodeReferenceCount::node_unref(), TransformState::unref(), RenderState::unref(), RenderEffects::unref(), RenderAttrib::unref(), InternalName::unref(), GeomVertexFormat::unref(), and GeomVertexArrayFormat::unref().
void ReferenceCount::weak_ref | ( | WeakPointerToVoid * | ptv | ) | [inline, inherited] |
Adds the indicated PointerToVoid as a weak reference to this object.
Definition at line 321 of file referenceCount.I.
References WeakReferenceList::add_reference(), and ReferenceCount::get_weak_list().
void ReferenceCount::weak_unref | ( | WeakPointerToVoid * | ptv | ) | [inline, inherited] |
Removes the indicated PointerToVoid as a weak reference to this object.
It must have previously been added via a call to weak_ref().
Definition at line 334 of file referenceCount.I.
References WeakReferenceList::clear_reference(), and ReferenceCount::has_weak_list().