Browse Source

*** empty log message ***

Mark Mine 24 years ago
parent
commit
cb9c410ee2
3 changed files with 31 additions and 22 deletions
  1. 14 13
      direct/src/interval/Interval.py
  2. 6 5
      direct/src/interval/MultiTrack.py
  3. 11 4
      direct/src/interval/Track.py

+ 14 - 13
direct/src/interval/Interval.py

@@ -8,6 +8,7 @@ import Task
 # Interval events
 # Interval events
 IVAL_NONE = 0
 IVAL_NONE = 0
 IVAL_INIT = 1
 IVAL_INIT = 1
+IVAL_DONE = 2
 
 
 class Interval(DirectObject):
 class Interval(DirectObject):
     """Interval class: Base class for timeline functionality"""
     """Interval class: Base class for timeline functionality"""
@@ -80,7 +81,7 @@ class Interval(DirectObject):
     def setFinalT(self):
     def setFinalT(self):
 	""" setFinalT()
 	""" setFinalT()
 	"""
 	"""
-	self.setT(self.getDuration(), event=IVAL_NONE)
+	self.setT(self.getDuration(), event=IVAL_DONE)
 
 
     def play(self, t0=0.0, duration=0.0, scale=1.0):
     def play(self, t0=0.0, duration=0.0, scale=1.0):
         """ play(t0, duration)
         """ play(t0, duration)
@@ -135,21 +136,21 @@ class Interval(DirectObject):
         t = self.clock.getFrameTime()
         t = self.clock.getFrameTime()
         te = self.offset + ((t - self.startT) * self.scale)
         te = self.offset + ((t - self.startT) * self.scale)
         if (te < self.endTime):
         if (te < self.endTime):
-            # If first call, init intervals
-	    if (self.firstTime):
-		self.setT(te, event = IVAL_INIT)
-		self.firstTime = 0
-	    else:
-            	self.setT(te)
+            if (self.firstTime):
+                # If first call, init intervals
+                self.setT(te, event = IVAL_INIT)
+                self.firstTime = 0
+            else:
+                self.setT(te)
             return Task.cont
             return Task.cont
         else:
         else:
             te = self.endTime
             te = self.endTime
-            # If first call, init intervals
-	    if (self.firstTime):
-		self.setT(te, event = IVAL_INIT)
-		self.firstTime = 0
-	    else:
-                self.setT(te)
+            if (self.firstTime):
+                # If first call, init intervals
+                self.setT(te, event = IVAL_INIT)
+                self.firstTime = 0
+            else:
+                self.setT(te, IVAL_DONE)
             messenger.send(self.name + "-loop")
             messenger.send(self.name + "-loop")
             return Task.done
             return Task.done
 
 

+ 6 - 5
direct/src/interval/MultiTrack.py

@@ -46,13 +46,14 @@ class MultiTrack(Interval):
 	"""
 	"""
 	for track in self.tlist:
 	for track in self.tlist:
             # Compare time with track's end times
             # Compare time with track's end times
-            if (t > track.duration):
+            if (event == IVAL_INIT) or (event == IVAL_DONE):
+                # always call setT if INIT or DONE event
+                track.setT(t, event)
+            elif (t >= track.duration) and (self.prev_t < track.duration):
                 # If t > track.duration, only call if just crossing over
                 # If t > track.duration, only call if just crossing over
-                # or this is an IVAL_INIT event
-                if (self.prev_t < track.duration) or (event == IVAL_INIT):
-                    track.setT(t, event)
+                track.setT(t, event)
             else:
             else:
-                # Update track
+                # t within track, update track
                 track.setT(t, event)
                 track.setT(t, event)
 
 
     # Print out representation of MultiTrack
     # Print out representation of MultiTrack

+ 11 - 4
direct/src/interval/Track.py

@@ -182,7 +182,9 @@ class Track(Interval):
 	    for ival, itime, itype, tStart, tEnd in self.ilist:
 	    for ival, itime, itype, tStart, tEnd in self.ilist:
                 # Compare time with each ival's start/end times
                 # Compare time with each ival's start/end times
                 if (t < tStart):
                 if (t < tStart):
-                    if (self.prev_t > tStart):
+                    if (event == IVAL_DONE):
+                        ival.setT(ival.getDuration(), event)
+                    elif (self.prev_t > tStart):
                         # We just crossed the start of this interval
                         # We just crossed the start of this interval
                         # going backwards (e.g. via the slider)
                         # going backwards (e.g. via the slider)
                         # Execute this interval at its start time
                         # Execute this interval at its start time
@@ -191,17 +193,22 @@ class Track(Interval):
                     break
                     break
                 elif (t >= tStart) and (t <= tEnd):
                 elif (t >= tStart) and (t <= tEnd):
                     # Between start/end, record current interval
                     # Between start/end, record current interval
-                    currentInterval = ival
                     # Make sure event == IVAL_INIT if entering new interval
                     # Make sure event == IVAL_INIT if entering new interval
                     if ((event == IVAL_NONE) and
                     if ((event == IVAL_NONE) and
                         ((self.prev_t < tStart) or
                         ((self.prev_t < tStart) or
                           (ival != self.currentInterval))):
                           (ival != self.currentInterval))):
                         event = IVAL_INIT
                         event = IVAL_INIT
                     # Evaluate interval at interval relative time
                     # Evaluate interval at interval relative time
-                    currentInterval.setT(t - tStart, event)
+                    if (event == IVAL_DONE):
+                        ival.setT(ival.getDuration(), event)
+                    else:
+                        ival.setT(t - tStart, event)
+                    currentInterval = ival
                 elif (t > tEnd):
                 elif (t > tEnd):
                     # Crossing over interval end 
                     # Crossing over interval end 
-                    if (((event == IVAL_NONE) and (self.prev_t < tEnd)) or
+                    if ((((event == IVAL_NONE) or (event == IVAL_DONE)) and
+                         (self.prev_t < tEnd))
+                        or
                         ((event == IVAL_INIT) and ival.getfOpenEnded())):
                         ((event == IVAL_INIT) and ival.getfOpenEnded())):
                         # If we've just crossed the end of this interval
                         # If we've just crossed the end of this interval
                         # or its an INIT event after the interval's end
                         # or its an INIT event after the interval's end