finishIntervalsMatching

This commit is contained in:
David Rose 2003-06-26 20:01:25 +00:00
parent 13c78ac7f1
commit dc6772b566
3 changed files with 38 additions and 0 deletions

View File

@ -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.

View File

@ -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

View File

@ -59,6 +59,7 @@ PUBLISHED:
int interrupt();
int get_num_intervals() const;
int get_max_index() const;
void step();
int get_next_event();