Browse Source

added removeNonCollisions, removed default numSolidsInLeaves

Darren Ranalli 18 years ago
parent
commit
375ea545a8
1 changed files with 14 additions and 1 deletions
  1. 14 1
      direct/src/extensions_native/NodePath_extensions.py

+ 14 - 1
direct/src/extensions_native/NodePath_extensions.py

@@ -1352,8 +1352,21 @@ def getNumDescendants(self):
 Dtool_funcToMethod(getNumDescendants, NodePath)
 del getNumDescendants
 #####################################################################
+def removeNonCollisions(self):
+        # remove anything that is not collision-related
+        stack = [self]
+        while len(stack):
+                np = stack.pop()
+                # if there are no CollisionNodes under this node, remove it
+                if np.findAllMatches('**/+CollisionNode').getNumPaths() == 0:
+                        np.detachNode()
+                else:
+                        stack.extend(np.getChildrenAsList())
+Dtool_funcToMethod(removeNonCollisions, NodePath)
+del removeNonCollisions
+#####################################################################
 
-def subdivideCollisions(self, numSolidsInLeaves = 2):
+def subdivideCollisions(self, numSolidsInLeaves):
         """
         expand CollisionNodes out into balanced trees, with a particular number
         of solids in the leaves