diff --git a/direct/src/interval/IntervalManager.py b/direct/src/interval/IntervalManager.py index 1fd186d0ef..de688f0b87 100644 --- a/direct/src/interval/IntervalManager.py +++ b/direct/src/interval/IntervalManager.py @@ -3,6 +3,7 @@ from DirectNotifyGlobal import * import EventManager import Interval import types +import fnmatch class IntervalManager(CIntervalManager): @@ -52,6 +53,27 @@ class IntervalManager(CIntervalManager): return self.ivals[index] return None + def finishIntervalsMatching(self, pattern): + count = 0 + + maxIndex = self.getMaxIndex() + for index in range(maxIndex): + ival = self.getCInterval(index) + if ival and \ + fnmatch.fnmatchcase(ival.getName(), pattern): + # Finish and remove this interval. Finishing it + # automatically removes it. + count += 1 + if self.ivals[index]: + # Finish the python version if we have it + self.ivals[index].finish() + else: + # Otherwise, it's a C-only interval. + ival.finish() + + return count + + def step(self): # This method should be called once per frame to perform all # of the per-frame processing on the active intervals. diff --git a/direct/src/interval/cIntervalManager.cxx b/direct/src/interval/cIntervalManager.cxx index 7d650de10b..0a940b772b 100644 --- a/direct/src/interval/cIntervalManager.cxx +++ b/direct/src/interval/cIntervalManager.cxx @@ -244,6 +244,21 @@ get_num_intervals() const { return _name_index.size(); } +//////////////////////////////////////////////////////////////////// +// Function: CIntervalManager::get_max_index +// Access: Published +// Description: Returns one more than the largest interval index +// number in the manager. If you walk through all the +// values between (0, get_max_index()] and call +// get_c_interval() on each number, you will retrieve +// all of the managed intervals (and possibly a number +// of NULL pointers as well). +//////////////////////////////////////////////////////////////////// +int CIntervalManager:: +get_max_index() const { + return _intervals.size(); +} + //////////////////////////////////////////////////////////////////// // Function: CIntervalManager::step // Access: Published diff --git a/direct/src/interval/cIntervalManager.h b/direct/src/interval/cIntervalManager.h index 64ef55aed5..17e064a440 100644 --- a/direct/src/interval/cIntervalManager.h +++ b/direct/src/interval/cIntervalManager.h @@ -59,6 +59,7 @@ PUBLISHED: int interrupt(); int get_num_intervals() const; + int get_max_index() const; void step(); int get_next_event();