diff --git a/direct/src/interval/Interval.py b/direct/src/interval/Interval.py index e43fc8c013..3dde27b6be 100644 --- a/direct/src/interval/Interval.py +++ b/direct/src/interval/Interval.py @@ -145,6 +145,15 @@ class Interval(DirectObject): self.privFinalize() self.privPostEvent() self.__removeTask() + + def clearToInitial(self): + # This method resets the interval's internal state to the + # initial state, abandoning any parts of the interval that + # have not yet been called. Calling it is like pausing the + # interval and creating a new one in its place. + self.pause() + self.state = CInterval.SInitial + self.currT = 0.0 def isPlaying(self): return taskMgr.hasTaskNamed(self.getName() + '-play') @@ -326,18 +335,6 @@ class Interval(DirectObject): # The rest of these methods are duplicates of functions defined # for the CInterval class via the file CInterval-extensions.py. - def play(self, *args, **kw): - self.notify.error("using deprecated Interval.play() interface") - self.start(*args, **kw) - - def stop(self): - self.notify.error("using deprecated Interval.stop() interface") - self.finish() - - def setFinalT(self): - self.notify.error("using deprecated Interval.setFinalT() interface") - self.finish() - def privPostEvent(self): # Call after calling any of the priv* methods to do any required # Python finishing steps. diff --git a/direct/src/interval/cInterval.cxx b/direct/src/interval/cInterval.cxx index b22f19a820..19561f895a 100644 --- a/direct/src/interval/cInterval.cxx +++ b/direct/src/interval/cInterval.cxx @@ -246,6 +246,23 @@ finish() { } } +//////////////////////////////////////////////////////////////////// +// Function: CInterval::clear_to_initial +// Access: Published +// Description: Pauses the interval, if it is playing, and resets its +// state to its initial state, abandoning any state +// changes already in progress in the middle of the +// interval. Calling this is like pausing the interval +// and discarding it, creating a new one in its place. +//////////////////////////////////////////////////////////////////// +void CInterval:: +clear_to_initial() { + pause(); + + _state = S_initial; + _curr_t = 0.0; +} + //////////////////////////////////////////////////////////////////// // Function: CInterval::is_playing // Access: Published diff --git a/direct/src/interval/cInterval.h b/direct/src/interval/cInterval.h index 48d08dda89..54869c99bc 100644 --- a/direct/src/interval/cInterval.h +++ b/direct/src/interval/cInterval.h @@ -94,6 +94,7 @@ PUBLISHED: void resume(double start_t); void resume_until(double end_t); void finish(); + void clear_to_initial(); bool is_playing() const; // These functions control the actual playback of the interval.