浏览代码

define sync_frame_time

David Rose 23 年之前
父节点
当前提交
aee3bf8fae
共有 2 个文件被更改,包括 22 次插入0 次删除
  1. 21 0
      panda/src/express/clockObject.cxx
  2. 1 0
      panda/src/express/clockObject.h

+ 21 - 0
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:

+ 1 - 0
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();