diff --git a/direct/src/interval/Interval.py b/direct/src/interval/Interval.py index dbcffdf8db..502d7ca0f1 100644 --- a/direct/src/interval/Interval.py +++ b/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() diff --git a/direct/src/interval/cInterval.cxx b/direct/src/interval/cInterval.cxx index c58a5e9333..f9af175a66 100644 --- a/direct/src/interval/cInterval.cxx +++ b/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 diff --git a/direct/src/interval/cInterval.h b/direct/src/interval/cInterval.h index 14922ce2c1..1dafbf5eb6 100644 --- a/direct/src/interval/cInterval.h +++ b/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;