Browse Source

added getNumDescendants

Darren Ranalli 18 years ago
parent
commit
184ff2a257
1 changed files with 12 additions and 0 deletions
  1. 12 0
      direct/src/extensions_native/NodePath_extensions.py

+ 12 - 0
direct/src/extensions_native/NodePath_extensions.py

@@ -1340,6 +1340,18 @@ def flattenMultitex(self, stateFrom = None, target = None,
 Dtool_funcToMethod(flattenMultitex, NodePath)
 Dtool_funcToMethod(flattenMultitex, NodePath)
 del flattenMultitex
 del flattenMultitex
 #####################################################################
 #####################################################################
+def getNumDescendants(self):
+        num = 0
+        stack = [self]
+        while len(stack):
+                np = stack.pop()
+                numChildren = np.getNumChildren()
+                num += numChildren
+                stack.extend(np.getChildrenAsList())
+        return num
+Dtool_funcToMethod(getNumDescendants, NodePath)
+del getNumDescendants
+#####################################################################
 
 
 def subdivideCollisions(self, numSolidsInLeaves = 2):
 def subdivideCollisions(self, numSolidsInLeaves = 2):
         """
         """