Przeglądaj źródła

*** empty log message ***

gregw 24 lat temu
rodzic
commit
3230b9283f
2 zmienionych plików z 47 dodań i 35 usunięć
  1. 45 33
      direct/src/actor/Actor.py
  2. 2 2
      direct/src/actor/DistributedActor.py

+ 45 - 33
direct/src/actor/Actor.py

@@ -766,8 +766,8 @@ class Actor(PandaObject, NodePath):
         Stop named animation on the given part of the actor.
         Stop named animation on the given part of the actor.
         If no name specified then stop all animations on the actor.
         If no name specified then stop all animations on the actor.
         NOTE: stops all LODs"""
         NOTE: stops all LODs"""
-        for lodName in self.__animControlDict.keys():
-            animControlDict = self.__animControlDict[lodName]
+        for thisLod in self.__animControlDict.keys():
+            animControlDict = self.__animControlDict[thisLod]
             # assemble lists of parts and anims
             # assemble lists of parts and anims
             if (partName == None):
             if (partName == None):
                 partNames = animControlDict.keys()
                 partNames = animControlDict.keys()
@@ -782,28 +782,28 @@ class Actor(PandaObject, NodePath):
             for thisPart in partNames:
             for thisPart in partNames:
                 for thisAnim in animNames:
                 for thisAnim in animNames:
                     # only stop if it's bound
                     # only stop if it's bound
-                    if isinstance(animControlDict[thisPart][thisAnim],
+                    if isinstance(animControlDict[thisPart][thisAnim][1],
                                   AnimControl):
                                   AnimControl):
-                            animControlDict[thisPart][thisAnim].stop()
+                        animControlDict[thisPart][thisAnim][1].stop()
         
         
     def play(self, animName, partName=None):
     def play(self, animName, partName=None):
         """play(self, string, string=None)
         """play(self, string, string=None)
         Play the given animation on the given part of the actor.
         Play the given animation on the given part of the actor.
         If no part is specified, try to play on all parts. NOTE:
         If no part is specified, try to play on all parts. NOTE:
         plays over ALL LODs"""
         plays over ALL LODs"""
-        for lodName in self.__animControlDict.keys():
-            animControlDict = self.__animControlDict[lodName]
+        for thisLod in self.__animControlDict.keys():
+            animControlDict = self.__animControlDict[thisLod]
             if (partName == None):
             if (partName == None):
                 # play all parts
                 # play all parts
                 for thisPart in animControlDict.keys():            
                 for thisPart in animControlDict.keys():            
                     animControl = self.getAnimControl(animName, thisPart,
                     animControl = self.getAnimControl(animName, thisPart,
-                                                        lodName)
+                                                        thisLod)
                     if (animControl != None):
                     if (animControl != None):
                         animControl.play()
                         animControl.play()
 
 
             else:
             else:
                 animControl = self.getAnimControl(animName, partName,
                 animControl = self.getAnimControl(animName, partName,
-                                                    lodName)
+                                                    thisLod)
                 if (animControl != None):
                 if (animControl != None):
                     animControl.play()
                     animControl.play()
 
 
@@ -814,19 +814,19 @@ class Actor(PandaObject, NodePath):
         restarting at zero frame if requested. If no part name
         restarting at zero frame if requested. If no part name
         is given then try to loop on all parts. NOTE: loops on
         is given then try to loop on all parts. NOTE: loops on
         all LOD's"""
         all LOD's"""
-        for lodName in self.__animControlDict.keys():
-            animControlDict = self.__animControlDict[lodName]
+        for thisLod in self.__animControlDict.keys():
+            animControlDict = self.__animControlDict[thisLod]
             if (partName == None):
             if (partName == None):
                 # loop all parts
                 # loop all parts
                 for thisPart in animControlDict.keys():
                 for thisPart in animControlDict.keys():
                     animControl = self.getAnimControl(animName, thisPart,
                     animControl = self.getAnimControl(animName, thisPart,
-                                                        lodName)
+                                                        thisLod)
                     if (animControl != None):
                     if (animControl != None):
                         animControl.loop(restart)
                         animControl.loop(restart)
             else:
             else:
                 # loop a specific part
                 # loop a specific part
                 animControl = self.getAnimControl(animName, partName,
                 animControl = self.getAnimControl(animName, partName,
-                                                    lodName)
+                                                    thisLod)
                 if (animControl != None):
                 if (animControl != None):
                     animControl.loop(restart)
                     animControl.loop(restart)
         
         
@@ -835,19 +835,19 @@ class Actor(PandaObject, NodePath):
         Pose the actor in position found at given frame in the specified
         Pose the actor in position found at given frame in the specified
         animation for the specified part. If no part is specified attempt
         animation for the specified part. If no part is specified attempt
         to apply pose to all parts. NOTE: poses all LODs"""
         to apply pose to all parts. NOTE: poses all LODs"""
-        for lodName in self.__animControlDict.keys():
-            animControlDict = self.__animControlDict[lodName]
+        for thisLod in self.__animControlDict.keys():
+            animControlDict = self.__animControlDict[thisLod]
             if (partName==None):
             if (partName==None):
                 # pose all parts
                 # pose all parts
                 for thisPart in animControlDict.keys():
                 for thisPart in animControlDict.keys():
                     animControl = self.getAnimControl(animName, thisPart,
                     animControl = self.getAnimControl(animName, thisPart,
-                                                        lodName)
+                                                        thisLod)
                     if (animControl != None):
                     if (animControl != None):
                         animControl.pose(frame)
                         animControl.pose(frame)
             else:
             else:
                 # pose a specific part
                 # pose a specific part
                 animControl = self.getAnimControl(animName, partName,
                 animControl = self.getAnimControl(animName, partName,
-                                                    lodName)
+                                                    thisLod)
                 if (animControl != None):
                 if (animControl != None):
                     animControl.pose(frame)
                     animControl.pose(frame)
         
         
@@ -863,7 +863,7 @@ class Actor(PandaObject, NodePath):
                 if (animControlDict[partName].has_key(animName)):
                 if (animControlDict[partName].has_key(animName)):
                     # make sure the anim is bound first
                     # make sure the anim is bound first
                     self.bindAnim(animName, partName, lodName)
                     self.bindAnim(animName, partName, lodName)
-                    return animControlDict[partName][animName]
+                    return animControlDict[partName][animName][1]
                 else:
                 else:
                     # anim was not present
                     # anim was not present
                     Actor.notify.warning("couldn't find anim: %s" % (animName))
                     Actor.notify.warning("couldn't find anim: %s" % (animName))
@@ -935,8 +935,8 @@ class Actor(PandaObject, NodePath):
         to 'lodRoot' for non-LOD actors) and dict of corresponding
         to 'lodRoot' for non-LOD actors) and dict of corresponding
         anims in the form animName:animPath{}"""
         anims in the form animName:animPath{}"""
         
         
-        #Actor.notify.debug("in loadAnims: %s, part: %s, lod: %s" %
-        #                   (anims, partName, lodName))
+        Actor.notify.debug("in loadAnims: %s, part: %s, lod: %s" %
+                          (anims, partName, lodName))
 
 
         for animName in anims.keys():
         for animName in anims.keys():
             # make sure this lod in in anim control dict
             # make sure this lod in in anim control dict
@@ -954,9 +954,10 @@ class Actor(PandaObject, NodePath):
                 animDict = {}
                 animDict = {}
                 self.__animControlDict[lodName][partName] = animDict
                 self.__animControlDict[lodName][partName] = animDict
 
 
-            # store the file path for now, we assume its been preloaded
-            # and will bind it only when played
-            self.__animControlDict[lodName][partName][animName] = anims[animName]
+            # store the file path and None in place of the animControl.
+            # we will bind it only when played
+            self.__animControlDict[lodName][partName][animName] = \
+                                                                [anims[animName], None]
 
 
 
 
     def unloadAnims(self, anims, partName="modelRoot", lodName="lodRoot"):
     def unloadAnims(self, anims, partName="modelRoot", lodName="lodRoot"):
@@ -975,19 +976,23 @@ class Actor(PandaObject, NodePath):
             lodNames = self.__animControlDict.keys()
             lodNames = self.__animControlDict.keys()
         else:
         else:
             lodNames = [lodName]
             lodNames = [lodName]
+
         if (partName == None):
         if (partName == None):
             partNames = self.__animControlDict[lodNames[0]].keys()
             partNames = self.__animControlDict[lodNames[0]].keys()
         else:
         else:
             partNames = [partName]
             partNames = [partName]
 
 
+        if (anims==None):
+            anims = self.__animControlDict[lodNames[0]][partNames[0]].keys()
+
         for lodName in lodNames:
         for lodName in lodNames:
             for partName in partNames:
             for partName in partNames:
-                for animName in anims.keys():
+                for animName in anims:
                     # delete the anim control
                     # delete the anim control
-                    del(self.__animControlDict[lodName][partName][animName])
-                    # store the filepath for reloading
-                    self.__animControlDict[lodName][partName][animName] = \
-                                                            anims[animName]
+                    animControlPair = self.__animControlDict[lodName][partName][animName]
+                    if animControlPair[1] != None:
+                        del(animControlPair[1])
+                        animControlPair.append(None)
     
     
     def bindAnim(self, animName, partName="modelRoot", lodName="lodRoot"):
     def bindAnim(self, animName, partName="modelRoot", lodName="lodRoot"):
         """bindAnim(self, string, string='modelRoot', string='lodRoot')
         """bindAnim(self, string, string='modelRoot', string='lodRoot')
@@ -1019,13 +1024,13 @@ class Actor(PandaObject, NodePath):
             Actor.notify.debug("actor has no animation %s", animName)
             Actor.notify.debug("actor has no animation %s", animName)
             
             
         # only bind if not already bound!
         # only bind if not already bound!
-        if isinstance(self.__animControlDict[lodName][partName][animName],
+        if isinstance(self.__animControlDict[lodName][partName][animName][1],
                       AnimControl):
                       AnimControl):
             return None
             return None
 
 
         # fetch a copy from the modelPool, or if we weren't careful
         # fetch a copy from the modelPool, or if we weren't careful
         # enough to preload, fetch from disk :(
         # enough to preload, fetch from disk :(
-        animPath = self.__animControlDict[lodName][partName][animName]
+        animPath = self.__animControlDict[lodName][partName][animName][0]
         anim = loader.loadModelOnce(animPath)
         anim = loader.loadModelOnce(animPath)
         animBundle = \
         animBundle = \
                    (anim.find("**/+AnimBundleNode").node()).getBundle()
                    (anim.find("**/+AnimBundleNode").node()).getBundle()
@@ -1042,7 +1047,8 @@ class Actor(PandaObject, NodePath):
             Actor.notify.error("Null AnimControl: %s" % (animName))
             Actor.notify.error("Null AnimControl: %s" % (animName))
         else:
         else:
             # store the animControl
             # store the animControl
-            self.__animControlDict[lodName][partName][animName] = animControl
+            self.__animControlDict[lodName][partName][animName][1] = \
+                                                                   animControl
             Actor.notify.debug("binding anim: %s to part: %s, lod: %s" %
             Actor.notify.debug("binding anim: %s to part: %s, lod: %s" %
                            (animName, partName, lodName))
                            (animName, partName, lodName))
         return animControl
         return animControl
@@ -1077,11 +1083,15 @@ class Actor(PandaObject, NodePath):
                 for animName in other.__animControlDict[lodName][partName].keys():
                 for animName in other.__animControlDict[lodName][partName].keys():
                     # if the anim is bound copy the animControl
                     # if the anim is bound copy the animControl
                     if isinstance(
                     if isinstance(
-                        other.__animControlDict[lodName][partName][animName],
+                        other.__animControlDict[lodName][partName][animName][1],
                         AnimControl):
                         AnimControl):
                         # get the anim
                         # get the anim
                         animBundle = \
                         animBundle = \
-                                   other.__animControlDict[lodName][partName][animName].getAnim()
+                                   other.__animControlDict[lodName][partName][animName][1].getAnim()
+                        # get the animPath
+                        animPath = \
+                                   other.__animControlDict[lodName][partName][animName][0]
+                        
                         # get the part
                         # get the part
                         partBundleNode = \
                         partBundleNode = \
                                        (self.__partBundleDict[lodName][partName].node())
                                        (self.__partBundleDict[lodName][partName].node())
@@ -1092,9 +1102,11 @@ class Actor(PandaObject, NodePath):
                             Actor.notify.error("Null animControl: %s" % (animName))
                             Actor.notify.error("Null animControl: %s" % (animName))
                         else:
                         else:
                             # store the anim control
                             # store the anim control
-                            self.__animControlDict[lodName][partName][animName] = animControl
+                            self.__animControlDict[lodName][partName][animName] = [animPath, animControl]
                     else:
                     else:
                         # else just copy what's there
                         # else just copy what's there
                         self.__animControlDict[lodName][partName][animName] = \
                         self.__animControlDict[lodName][partName][animName] = \
                         other.__animControlDict[lodName][partName][animName]
                         other.__animControlDict[lodName][partName][animName]
 
 
+
+

+ 2 - 2
direct/src/actor/DistributedActor.py

@@ -20,6 +20,6 @@ class DistributedActor(DistributedNode.DistributedNode, Actor.Actor):
         return None
         return None
 
 
     def disable(self):
     def disable(self):
-        # remove anims here
-        print("####\n#### anim dump!\n####")
+        # remove all anims, on all parts and all lods
+        Actor.Actor.unloadAnims(None, None, None)
         DistributedNode.DistributedNode.disable(self)
         DistributedNode.DistributedNode.disable(self)