Browse Source

support set_dt(0) in M_slave mode

David Rose 16 years ago
parent
commit
8a30b5fae0
3 changed files with 29 additions and 18 deletions
  1. 0 17
      panda/src/putil/clockObject.I
  2. 28 0
      panda/src/putil/clockObject.cxx
  3. 1 1
      panda/src/putil/clockObject.h

+ 0 - 17
panda/src/putil/clockObject.I

@@ -146,23 +146,6 @@ get_dt(Thread *current_thread) const {
   return cdata->_dt;
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: ClockObject::set_dt
-//       Access: Published
-//  Description: 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.
-////////////////////////////////////////////////////////////////////
-INLINE void ClockObject::
-set_dt(double dt) {
-  nassertv(dt != 0.0);
-  set_frame_rate(1.0 / dt);
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: ClockObject::get_max_dt
 //       Access: Published

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

@@ -224,6 +224,34 @@ set_frame_count(int frame_count, Thread *current_thread) {
     cdata->_frame_count / _user_frame_rate;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: ClockObject::set_dt
+//       Access: Published
+//  Description: 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.
+////////////////////////////////////////////////////////////////////
+void ClockObject::
+set_dt(double dt) {
+  if (_mode == M_slave) {
+    // In M_slave mode, we can set any dt we like.
+    CDWriter cdata(_cycler, Thread::get_current_thread());
+    cdata->_dt = dt;
+    if (dt != 0.0) {
+      set_frame_rate(1.0 / dt);
+    }
+
+  } else {
+    // In any other mode, we can only set non-zero dt.
+    nassertv(dt != 0.0);
+    set_frame_rate(1.0 / dt);
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: ClockObject::set_frame_rate
 //       Access: Published

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

@@ -94,7 +94,7 @@ PUBLISHED:
   INLINE double get_net_frame_rate(Thread *current_thread = Thread::get_current_thread()) const;
 
   INLINE double get_dt(Thread *current_thread = Thread::get_current_thread()) const;
-  INLINE void set_dt(double dt);
+  void set_dt(double dt);
   void set_frame_rate(double frame_rate);
 
   INLINE double get_max_dt() const;