Browse Source

added get_max_frame_duration

Darren Ranalli 17 years ago
parent
commit
146233c46d
2 changed files with 22 additions and 0 deletions
  1. 21 0
      panda/src/putil/clockObject.cxx
  2. 1 0
      panda/src/putil/clockObject.h

+ 21 - 0
panda/src/putil/clockObject.cxx

@@ -277,6 +277,27 @@ get_average_frame_rate(Thread *current_thread) const {
   }
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: ClockObject::get_max_frame_duration
+//       Access: Published
+//  Description: Returns the maximum frame duration over the last
+//               get_average_frame_rate_interval() seconds.
+////////////////////////////////////////////////////////////////////
+double ClockObject::
+get_max_frame_duration(Thread *current_thread) const {
+  CDStageReader cdata(_cycler, 0, current_thread);
+  double max_duration = 0.0;
+  double cur_duration = 0.0;
+  size_t i;
+  for (i = 0; i < _ticks.size() - 1; i++) {
+    cur_duration = _ticks[i + 1] - _ticks[i];
+    if (cur_duration > max_duration) {
+      max_duration = cur_duration;
+    }
+  }
+  return max_duration;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: ClockObject::calc_frame_time_deviation
 //       Access: Published

+ 1 - 0
panda/src/putil/clockObject.h

@@ -108,6 +108,7 @@ PUBLISHED:
   INLINE void set_average_frame_rate_interval(double time);
   INLINE double get_average_frame_rate_interval() const;
   double get_average_frame_rate(Thread *current_thread = Thread::get_current_thread()) const;
+  double get_max_frame_duration(Thread *current_thread = Thread::get_current_thread()) const;
   double calc_frame_rate_deviation(Thread *current_thread = Thread::get_current_thread()) const;
 
   void tick(Thread *current_thread = Thread::get_current_thread());