Sfoglia il codice sorgente

enable intra-frame animation interpolation

David Rose 19 anni fa
parent
commit
ce4568d89e
1 ha cambiato i file con 10 aggiunte e 7 eliminazioni
  1. 10 7
      direct/src/interval/ActorInterval.py

+ 10 - 7
direct/src/interval/ActorInterval.py

@@ -71,19 +71,19 @@ class ActorInterval(Interval.Interval):
             if startFrame != None:
             if startFrame != None:
                 self.startFrame = startFrame
                 self.startFrame = startFrame
             elif startTime != None:
             elif startTime != None:
-                self.startFrame = int(math.floor(startTime * self.frameRate + 0.0001))
+                self.startFrame = startTime * self.frameRate
             else:
             else:
                 self.startFrame = 0
                 self.startFrame = 0
 
 
             if endFrame != None:
             if endFrame != None:
                 self.endFrame = endFrame
                 self.endFrame = endFrame
             elif endTime != None:
             elif endTime != None:
-                self.endFrame = int(math.floor(endTime * self.frameRate + 0.0001))
+                self.endFrame = endTime * self.frameRate
             elif duration != None:
             elif duration != None:
                 if startTime == None:
                 if startTime == None:
                     startTime = float(self.startFrame) / float(self.frameRate)
                     startTime = float(self.startFrame) / float(self.frameRate)
                 endTime = startTime + duration
                 endTime = startTime + duration
-                self.endFrame = int(math.floor(duration * self.frameRate + 0.0001))
+                self.endFrame = duration * self.frameRate
             else:
             else:
                 # No end frame specified.  Choose the maximum of all
                 # No end frame specified.  Choose the maximum of all
                 # of the controls' numbers of frames.
                 # of the controls' numbers of frames.
@@ -129,7 +129,7 @@ class ActorInterval(Interval.Interval):
             absFrame = self.startFrame + frameCount
             absFrame = self.startFrame + frameCount
 
 
         # Calc integer frame number
         # Calc integer frame number
-        absFrame = int(math.floor(absFrame + 0.0001))
+        intFrame = int(math.floor(absFrame + 0.0001))
 
 
         # Pose anim
         # Pose anim
 
 
@@ -140,7 +140,7 @@ class ActorInterval(Interval.Interval):
             # Each animControl might have a different number of frames.
             # Each animControl might have a different number of frames.
             numFrames = control.getNumFrames()
             numFrames = control.getNumFrames()
             if self.loopAnim:
             if self.loopAnim:
-                frame = absFrame % numFrames
+                frame = (intFrame % numFrames) + (absFrame - intFrame)
             else:
             else:
                 frame = max(min(absFrame, numFrames - 1), 0)
                 frame = max(min(absFrame, numFrames - 1), 0)
 
 
@@ -152,12 +152,15 @@ class ActorInterval(Interval.Interval):
         self.currT = t
         self.currT = t
 
 
     def privFinalize(self):
     def privFinalize(self):
-        if self.implicitDuration:
+        if self.implicitDuration and not self.loopAnim:
             # As a special case, we ensure we end up posed to the last
             # As a special case, we ensure we end up posed to the last
             # frame of the animation if the original duration was
             # frame of the animation if the original duration was
             # implicit.  This is necessary only to guard against
             # implicit.  This is necessary only to guard against
             # possible roundoff error in computing the final frame
             # possible roundoff error in computing the final frame
-            # from the duration.
+            # from the duration.  We don't do this in the case of a
+            # looping animation, however, because this would introduce
+            # a hitch in the animation when it plays back-to-back with
+            # the next cycle.
             if self.reverse:
             if self.reverse:
                 for control in self.controls:
                 for control in self.controls:
                     control.pose(self.startFrame)
                     control.pose(self.startFrame)