Browse Source

fix copyActor when subparts are in use

David Rose 19 years ago
parent
commit
d6049a6276
1 changed files with 16 additions and 1 deletions
  1. 16 1
      direct/src/actor/Actor.py

+ 16 - 1
direct/src/actor/Actor.py

@@ -237,7 +237,9 @@ class Actor(DirectObject, NodePath):
 
 
             # copy the part dictionary from other
             # copy the part dictionary from other
             self.__copyPartBundles(other)
             self.__copyPartBundles(other)
-            self.__subpartDict = copy_module.deepcopy(other.__subpartDict)
+            self.__copySubpartDict(other)
+
+            self.__subpartsComplete = other.__subpartsComplete
 
 
             # copy the anim dictionary from other
             # copy the anim dictionary from other
             self.__copyAnimControls(other)
             self.__copyAnimControls(other)
@@ -1690,6 +1692,19 @@ class Actor(DirectObject, NodePath):
                     Actor.notify.error("lod: %s has no matching part: %s" %
                     Actor.notify.error("lod: %s has no matching part: %s" %
                                        (lodName, partName))
                                        (lodName, partName))
 
 
+    def __copySubpartDict(self, other):
+        """Copies the subpartDict from another as this instance's own.
+        This makes a deep copy of the map and all of the names and
+        PartSubset objects within it.  We can't use copy.deepcopy()
+        because of the included C++ PartSubset objects."""
+
+        self.__subpartDict = {}
+        for partName, subpartDef in other.__subpartDict.items():
+            subpartDefCopy = subpartDef
+            if subpartDef:
+                truePartName, subset = subpartDef
+                subpartDefCopy = (truePartName, PartSubset(subset))
+            self.__subpartDict[partName] = subpartDef
 
 
     def __copyAnimControls(self, other):
     def __copyAnimControls(self, other):
         """__copyAnimControls(self, Actor)
         """__copyAnimControls(self, Actor)