From d38b81dc8de7f88a65ba91cc723ad564d2d44d4c Mon Sep 17 00:00:00 2001 From: "Asad M. Zaman" Date: Wed, 8 Mar 2006 18:37:46 +0000 Subject: [PATCH] optimized avatar nodepath counts --- direct/src/actor/Actor.py | 45 +++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/direct/src/actor/Actor.py b/direct/src/actor/Actor.py index 8bf6a76b7b..2444477515 100644 --- a/direct/src/actor/Actor.py +++ b/direct/src/actor/Actor.py @@ -97,6 +97,7 @@ class Actor(DirectObject, NodePath): self.__controlJoints = {} self.__LODNode = None + self.switches = None if (other == None): # act like a normal constructor @@ -190,21 +191,7 @@ class Actor(DirectObject, NodePath): self.loadAnims(anims) else: - # act like a copy constructor - # copy the scene graph elements of other - otherCopy = other.copyTo(hidden) - otherCopy.detachNode() - # assign these elements to ourselve - self.gotName = other.gotName - self.assign(otherCopy) - self.setGeomNode(otherCopy.getChild(0)) - - # copy the part dictionary from other - self.__copyPartBundles(other) - self.__subpartDict = copy_module.deepcopy(other.__subpartDict) - - # copy the anim dictionary from other - self.__copyAnimControls(other) + self.copyActor(other, True) # overwrite everything # For now, all Actors will by default set their top bounding # volume to be the "final" bounding volume: the bounding @@ -229,6 +216,32 @@ class Actor(DirectObject, NodePath): self.Actor_deleted = 1 self.cleanup() + def copyActor(self, other, overwrite=False): + # act like a copy constructor + self.gotName = other.gotName + + # copy the scene graph elements of other + if (overwrite): + otherCopy = other.copyTo(hidden) + otherCopy.detachNode() + # assign these elements to ourselve (overwrite) + self.assign(otherCopy) + else: + # just copy these to ourselve + otherCopy = other.copyTo(self) + self.setGeomNode(otherCopy.getChild(0)) + + # copy the part dictionary from other + self.__copyPartBundles(other) + self.__subpartDict = copy_module.deepcopy(other.__subpartDict) + + # copy the anim dictionary from other + self.__copyAnimControls(other) + + # copy the switches for lods + self.switches = other.switches + self.__LODNode = self.find('**/+LODNode') + def __cmp__(self, other): # Actor inherits from NodePath, which inherits a definition of # __cmp__ from FFIExternalObject that uses the NodePath's @@ -360,7 +373,7 @@ class Actor(DirectObject, NodePath): self.__animControlDict = {} self.__controlJoints = {} - if self.__LODNode: + if self.__LODNode and (not self.__LODNode.isEmpty()): self.__LODNode.removeNode() self.__LODNode = None