From 375ea545a8534d83a72d3a90012cddfa43f47f6e Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Fri, 13 Apr 2007 01:36:44 +0000 Subject: [PATCH] added removeNonCollisions, removed default numSolidsInLeaves --- .../src/extensions_native/NodePath_extensions.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/direct/src/extensions_native/NodePath_extensions.py b/direct/src/extensions_native/NodePath_extensions.py index b6c0cf61e2..95771c71aa 100644 --- a/direct/src/extensions_native/NodePath_extensions.py +++ b/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