From d6049a6276caaecc8e7745e83fbec24b715dff3d Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 12 Oct 2006 00:49:16 +0000 Subject: [PATCH] fix copyActor when subparts are in use --- direct/src/actor/Actor.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/direct/src/actor/Actor.py b/direct/src/actor/Actor.py index 5f50fc3a1d..200d90e792 100644 --- a/direct/src/actor/Actor.py +++ b/direct/src/actor/Actor.py @@ -237,7 +237,9 @@ class Actor(DirectObject, NodePath): # copy the part dictionary from other self.__copyPartBundles(other) - self.__subpartDict = copy_module.deepcopy(other.__subpartDict) + self.__copySubpartDict(other) + + self.__subpartsComplete = other.__subpartsComplete # copy the anim dictionary from other self.__copyAnimControls(other) @@ -1690,6 +1692,19 @@ class Actor(DirectObject, NodePath): Actor.notify.error("lod: %s has no matching part: %s" % (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): """__copyAnimControls(self, Actor)