diff --git a/panda/src/express/clockObject.cxx b/panda/src/express/clockObject.cxx index a0ff1f8d80..5daaf4b146 100644 --- a/panda/src/express/clockObject.cxx +++ b/panda/src/express/clockObject.cxx @@ -136,6 +136,27 @@ tick() { _frame_count++; } +//////////////////////////////////////////////////////////////////// +// Function: ClockObject::sync_frame_time +// Access: Published +// Description: 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). +//////////////////////////////////////////////////////////////////// +void ClockObject:: +sync_frame_time() { + if (_mode == M_normal) { + _reported_frame_time = get_real_time(); + } +} + //////////////////////////////////////////////////////////////////// // Function: get_time_of_day // Description: diff --git a/panda/src/express/clockObject.h b/panda/src/express/clockObject.h index cee4a93b1e..06a3e6534d 100644 --- a/panda/src/express/clockObject.h +++ b/panda/src/express/clockObject.h @@ -95,6 +95,7 @@ PUBLISHED: INLINE void set_max_dt(double max_dt); void tick(); + void sync_frame_time(); INLINE static ClockObject *get_global_clock();