Browse Source

add resume_until

David Rose 22 years ago
parent
commit
80862fe41a

+ 17 - 3
direct/src/interval/Interval.py

@@ -110,9 +110,23 @@ class Interval(DirectObject):
         self.__removeTask()
         return self.getT()
 
-    def resume(self, t0 = None):
-        if t0 != None:
-            self.setT(t0)
+    def resume(self, startT = None):
+        if startT != None:
+            self.setT(startT)
+        self.setupResume()
+        if not self.isPlaying():
+            self.__spawnTask()
+
+    def resumeUntil(self, endT):
+        duration = self.getDuration()
+        
+        if endT < 0 or endT >= duration:
+            self.__endT = duration
+            self.__endTAtEnd = 1
+        else:
+            self.__endT = endT
+            self.__endTAtEnd = 0
+
         self.setupResume()
         if not self.isPlaying():
             self.__spawnTask()

+ 24 - 0
direct/src/interval/cInterval.cxx

@@ -187,6 +187,30 @@ resume(double start_t) {
   _manager->add_c_interval(this, false);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: CInterval::resume_until
+//       Access: Published
+//  Description: Restarts the interval from the current point after a
+//               previous call to pause() (or a previous
+//               play-to-point-and-stop), to play until the indicated
+//               point and then stop.
+////////////////////////////////////////////////////////////////////
+void CInterval::
+resume_until(double end_t) {
+  double duration = get_duration();
+
+  if (end_t < 0.0 || end_t >= duration) {
+    _end_t = duration;
+    _end_t_at_end = true;
+  } else {
+    _end_t = end_t;
+    _end_t_at_end = false;
+  }
+
+  setup_resume();
+  _manager->add_c_interval(this, false);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: CInterval::finish
 //       Access: Published

+ 1 - 0
direct/src/interval/cInterval.h

@@ -91,6 +91,7 @@ PUBLISHED:
   double pause();
   void resume();
   void resume(double start_t);
+  void resume_until(double end_t);
   void finish();
   bool is_playing() const;