浏览代码

optimized avatar nodepath counts

Asad M. Zaman 20 年之前
父节点
当前提交
d38b81dc8d
共有 1 个文件被更改,包括 29 次插入16 次删除
  1. 29 16
      direct/src/actor/Actor.py

+ 29 - 16
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