mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
asList() etc. no longer needed
This commit is contained in:
parent
cef263157d
commit
c69c8680e8
@ -50,7 +50,7 @@ class DirectLights(NodePath):
|
||||
light.removeNode()
|
||||
|
||||
def deleteAll(self):
|
||||
for light in self.asList():
|
||||
for light in self:
|
||||
self.delete(light)
|
||||
|
||||
def asList(self):
|
||||
|
@ -379,7 +379,7 @@ class DirectBoundingBox:
|
||||
# Get a node path's bounds
|
||||
nodeBounds = BoundingSphere()
|
||||
nodeBounds.extendBy(self.nodePath.node().getInternalBound())
|
||||
for child in self.nodePath.getChildrenAsList():
|
||||
for child in self.nodePath.getChildren():
|
||||
nodeBounds.extendBy(child.getBounds())
|
||||
return nodeBounds.makeCopy()
|
||||
|
||||
|
@ -72,7 +72,7 @@ class Mopath(DirectObject):
|
||||
self.tNurbsCurve.append(node)
|
||||
else:
|
||||
# Iterate over children if any
|
||||
for child in nodePath.getChildrenAsList():
|
||||
for child in nodePath.getChildren():
|
||||
self.__extractCurves(child)
|
||||
|
||||
def calcTime(self, tIn):
|
||||
|
@ -14,16 +14,16 @@
|
||||
# For iterating over children
|
||||
def getChildrenAsList(self):
|
||||
"""Converts a node path's child NodePathCollection into a list"""
|
||||
return self.getChildren().asList()
|
||||
return self.getChildren()
|
||||
|
||||
def printChildren(self):
|
||||
"""Prints out the children of the bottom node of a node path"""
|
||||
for child in self.getChildrenAsList():
|
||||
for child in self.getChildren():
|
||||
print child.getName()
|
||||
|
||||
def removeChildren(self):
|
||||
"""Deletes the children of the bottom node of a node path"""
|
||||
for child in self.getChildrenAsList():
|
||||
for child in self.getChildren():
|
||||
child.removeNode()
|
||||
|
||||
def toggleVis(self):
|
||||
@ -37,20 +37,20 @@
|
||||
|
||||
def showSiblings(self):
|
||||
"""Show all the siblings of a node path"""
|
||||
for sib in self.getParent().getChildrenAsList():
|
||||
for sib in self.getParent().getChildren():
|
||||
if sib.node() != self.node():
|
||||
sib.show()
|
||||
|
||||
def hideSiblings(self):
|
||||
"""Hide all the siblings of a node path"""
|
||||
for sib in self.getParent().getChildrenAsList():
|
||||
for sib in self.getParent().getChildren():
|
||||
if sib.node() != self.node():
|
||||
sib.hide()
|
||||
|
||||
def showAllDescendants(self):
|
||||
"""Show the node path and all its children"""
|
||||
self.show()
|
||||
for child in self.getChildrenAsList():
|
||||
for child in self.getChildren():
|
||||
child.showAllDescendants()
|
||||
|
||||
def isolate(self):
|
||||
@ -78,7 +78,7 @@
|
||||
|
||||
def lsNamesRecurse(self, indentString=' '):
|
||||
"""Walk down a tree and print out the path"""
|
||||
for nodePath in self.getChildrenAsList():
|
||||
for nodePath in self.getChildren():
|
||||
type = nodePath.node().getType().getName()
|
||||
name = nodePath.getName()
|
||||
print indentString + type + " " + name
|
||||
@ -261,7 +261,7 @@
|
||||
outputString = '%s.setScale(%s, %s, %s)' % (name, fmtStr, fmtStr, fmtStr)
|
||||
print outputString % (scale[0], scale[1], scale[2])
|
||||
if fRecursive:
|
||||
for child in self.getChildrenAsList():
|
||||
for child in self.getChildren():
|
||||
child.printTransform(other, sd, fRecursive)
|
||||
|
||||
def iPos(self, other = None):
|
||||
|
@ -7,13 +7,8 @@ from libpanda import *
|
||||
# For iterating over children
|
||||
def asList(self):
|
||||
"""Converts a NodePathCollection into a list"""
|
||||
if self.isEmpty():
|
||||
return []
|
||||
else:
|
||||
npList = []
|
||||
for nodePathIndex in range(self.getNumPaths()):
|
||||
npList.append(self.getPath(nodePathIndex))
|
||||
return npList
|
||||
print "Warning: NodePathCollection is no longer needed and deprecated. Iterate on the collection directly instead."
|
||||
return list(self)
|
||||
|
||||
Dtool_funcToMethod(asList, NodePathCollection)
|
||||
del asList
|
||||
|
@ -28,7 +28,8 @@ del id
|
||||
# For iterating over children
|
||||
def getChildrenAsList(self):
|
||||
"""Converts a node path's child NodePathCollection into a list"""
|
||||
return self.getChildren().asList()
|
||||
print "Warning: NodePath.getChildren() is deprecated. Use getChildren() instead."
|
||||
return list(self.getChildren())
|
||||
|
||||
Dtool_funcToMethod(getChildrenAsList, NodePath)
|
||||
del getChildrenAsList
|
||||
@ -36,7 +37,7 @@ del getChildrenAsList
|
||||
|
||||
def printChildren(self):
|
||||
"""Prints out the children of the bottom node of a node path"""
|
||||
for child in self.getChildrenAsList():
|
||||
for child in self.getChildren():
|
||||
print child.getName()
|
||||
Dtool_funcToMethod(printChildren, NodePath)
|
||||
del printChildren
|
||||
@ -44,8 +45,7 @@ del printChildren
|
||||
|
||||
def removeChildren(self):
|
||||
"""Deletes the children of the bottom node of a node path"""
|
||||
for child in self.getChildrenAsList():
|
||||
child.removeNode()
|
||||
self.getChildren().detach()
|
||||
Dtool_funcToMethod(removeChildren, NodePath)
|
||||
del removeChildren
|
||||
#####################################################################
|
||||
@ -64,7 +64,7 @@ del toggleVis
|
||||
|
||||
def showSiblings(self):
|
||||
"""Show all the siblings of a node path"""
|
||||
for sib in self.getParent().getChildrenAsList():
|
||||
for sib in self.getParent().getChildren():
|
||||
if sib.node() != self.node():
|
||||
sib.show()
|
||||
Dtool_funcToMethod(showSiblings, NodePath)
|
||||
@ -73,7 +73,7 @@ del showSiblings
|
||||
|
||||
def hideSiblings(self):
|
||||
"""Hide all the siblings of a node path"""
|
||||
for sib in self.getParent().getChildrenAsList():
|
||||
for sib in self.getParent().getChildren():
|
||||
if sib.node() != self.node():
|
||||
sib.hide()
|
||||
Dtool_funcToMethod(hideSiblings, NodePath)
|
||||
@ -83,7 +83,7 @@ del hideSiblings
|
||||
def showAllDescendants(self):
|
||||
"""Show the node path and all its children"""
|
||||
self.show()
|
||||
for child in self.getChildrenAsList():
|
||||
for child in self.getChildren():
|
||||
child.showAllDescendants()
|
||||
Dtool_funcToMethod(showAllDescendants, NodePath)
|
||||
del showAllDescendants
|
||||
@ -123,7 +123,7 @@ del lsNames
|
||||
#####################################################################
|
||||
def lsNamesRecurse(self, indentString=' '):
|
||||
"""Walk down a tree and print out the path"""
|
||||
for nodePath in self.getChildrenAsList():
|
||||
for nodePath in self.getChildren():
|
||||
type = nodePath.node().getType().getName()
|
||||
name = nodePath.getName()
|
||||
print indentString + type + " " + name
|
||||
@ -147,13 +147,10 @@ del reverseLsNames
|
||||
#####################################################################
|
||||
def getAncestry(self):
|
||||
"""Get a list of a node path's ancestors"""
|
||||
node = self.node()
|
||||
if (self.hasParent()):
|
||||
ancestry = self.getParent().getAncestry()
|
||||
ancestry.append(self)
|
||||
return ancestry
|
||||
else:
|
||||
return [self]
|
||||
print "NodePath.getAncestry() is deprecated. Use getAncestors() instead."""
|
||||
ancestors = list(self.getAncestors())
|
||||
ancestors.reverse()
|
||||
return ancestors
|
||||
|
||||
Dtool_funcToMethod(getAncestry, NodePath)
|
||||
del getAncestry
|
||||
@ -337,7 +334,7 @@ def printTransform(self, other = None, sd = 2, fRecursive = 0):
|
||||
outputString = '%s.setScale(%s, %s, %s)' % (name, fmtStr, fmtStr, fmtStr)
|
||||
print outputString % (scale[0], scale[1], scale[2])
|
||||
if fRecursive:
|
||||
for child in self.getChildrenAsList():
|
||||
for child in self.getChildren():
|
||||
child.printTransform(other, sd, fRecursive)
|
||||
|
||||
Dtool_funcToMethod(printTransform, NodePath)
|
||||
@ -1341,14 +1338,7 @@ Dtool_funcToMethod(flattenMultitex, NodePath)
|
||||
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
|
||||
return len(self.findAllMatches('**')) - 1
|
||||
Dtool_funcToMethod(getNumDescendants, NodePath)
|
||||
del getNumDescendants
|
||||
#####################################################################
|
||||
@ -1358,10 +1348,10 @@ def removeNonCollisions(self):
|
||||
while len(stack):
|
||||
np = stack.pop()
|
||||
# if there are no CollisionNodes under this node, remove it
|
||||
if np.findAllMatches('**/+CollisionNode').getNumPaths() == 0:
|
||||
if np.find('**/+CollisionNode').isEmpty():
|
||||
np.detachNode()
|
||||
else:
|
||||
stack.extend(np.getChildrenAsList())
|
||||
stack.extend(np.getChildren())
|
||||
Dtool_funcToMethod(removeNonCollisions, NodePath)
|
||||
del removeNonCollisions
|
||||
#####################################################################
|
||||
@ -1373,7 +1363,7 @@ def subdivideCollisions(self, numSolidsInLeaves):
|
||||
TODO: better splitting logic at each level of the tree wrt spatial separation
|
||||
and cost of bounding volume tests vs. cost of collision solid tests
|
||||
"""
|
||||
colNps = self.findAllMatches('**/+CollisionNode').asList()
|
||||
colNps = self.findAllMatches('**/+CollisionNode')
|
||||
for colNp in colNps:
|
||||
node = colNp.node()
|
||||
numSolids = node.getNumSolids()
|
||||
|
@ -19,6 +19,7 @@ def asTuple(self):
|
||||
"""
|
||||
Returns the vector as a tuple.
|
||||
"""
|
||||
return (self[0], self[1], self[2])
|
||||
print "Warning: VBase3.asTuple() is no longer needed and deprecated. Use the vector directly instead."
|
||||
return tuple(self)
|
||||
Dtool_funcToMethod(asTuple, VBase3)
|
||||
del asTuple
|
||||
|
@ -19,6 +19,8 @@ def asTuple(self):
|
||||
"""
|
||||
Returns the vector as a tuple.
|
||||
"""
|
||||
return (self[0], self[1], self[2], self[3])
|
||||
print "Warning: VBase4.asTuple() is no longer needed and deprecated. Use the vector directly instead."
|
||||
return tuple(self)
|
||||
|
||||
Dtool_funcToMethod(asTuple, VBase4)
|
||||
del asTuple
|
||||
|
@ -1042,7 +1042,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
|
||||
'gui item %s not in base.guiItems' %
|
||||
self.guiId)
|
||||
# Destroy children
|
||||
for child in self.getChildrenAsList():
|
||||
for child in self.getChildren():
|
||||
childGui = self.guiDict.get(child.getName())
|
||||
if childGui:
|
||||
childGui.destroy()
|
||||
@ -1071,7 +1071,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
|
||||
print space + 'Pos: ' + self.getPos().pPrintValues()
|
||||
print space + 'Scale: ' + self.getScale().pPrintValues()
|
||||
# Print out children info
|
||||
for child in self.getChildrenAsList():
|
||||
for child in self.getChildren():
|
||||
messenger.send(DGG.PRINT + child.getName(), [indent + 2])
|
||||
|
||||
def copyOptions(self, other):
|
||||
|
@ -90,7 +90,7 @@ class DirectScrolledFrame(DirectFrame):
|
||||
|
||||
def destroy(self):
|
||||
# Destroy children of the canvas
|
||||
for child in self.canvas.getChildrenAsList():
|
||||
for child in self.canvas.getChildren():
|
||||
childGui = self.guiDict.get(child.getName())
|
||||
if childGui:
|
||||
childGui.destroy()
|
||||
|
@ -2351,7 +2351,7 @@ class LevelEditor(NodePath, DirectObject):
|
||||
if DNAClassEqual(dnaNode, DNA_VIS_GROUP):
|
||||
return [[nodePath, dnaNode]]
|
||||
childVisGroups = []
|
||||
children = nodePath.getChildrenAsList()
|
||||
children = nodePath.getChildren()
|
||||
for child in children:
|
||||
childVisGroups = (childVisGroups + self.getDNAVisGroups(child))
|
||||
return childVisGroups
|
||||
@ -3492,14 +3492,14 @@ class LevelEditor(NodePath, DirectObject):
|
||||
if (DNAClassEqual(dnaNode, DNA_FLAT_BUILDING) or
|
||||
DNAClassEqual(dnaNode, DNA_LANDMARK_BUILDING)):
|
||||
base.direct.reparent(nodePath, fWrt = 1)
|
||||
children = nodePath.getChildrenAsList()
|
||||
children = nodePath.getChildren()
|
||||
for child in children:
|
||||
self.reparentStreetBuildings(child)
|
||||
|
||||
def consolidateStreetBuildings(self):
|
||||
# First put everything under the ATR group so the leftover
|
||||
# can be easily deleted
|
||||
originalChildren = self.NPToplevel.getChildrenAsList()
|
||||
originalChildren = self.NPToplevel.getChildren()
|
||||
self.addGroup(self.NPToplevel)
|
||||
atrGroup = self.NPParent
|
||||
atrGroup.setName('ATR')
|
||||
@ -3543,7 +3543,7 @@ class LevelEditor(NodePath, DirectObject):
|
||||
self.updateBarricadeDict(side, int(origBarricadeNum), sequenceNum)
|
||||
|
||||
def adjustPropChildren(self, nodePath, maxPropOffset = -4):
|
||||
for np in nodePath.getChildrenAsList():
|
||||
for np in nodePath.getChildren():
|
||||
dnaNode = self.findDNANode(np)
|
||||
if dnaNode:
|
||||
if DNAClassEqual(dnaNode, DNA_PROP):
|
||||
@ -3581,7 +3581,7 @@ class LevelEditor(NodePath, DirectObject):
|
||||
|
||||
def makeLongStreet(self):
|
||||
bldgGroup = self.consolidateStreetBuildings()
|
||||
bldgs = bldgGroup.getChildrenAsList()
|
||||
bldgs = bldgGroup.getChildren()
|
||||
numBldgs = len(bldgs)
|
||||
streetLength = self.calcLongStreetLength(bldgs)/2.0
|
||||
ref = None
|
||||
@ -3615,19 +3615,19 @@ class LevelEditor(NodePath, DirectObject):
|
||||
parent = self.panel.component('hull'))
|
||||
if streetCurveFilename:
|
||||
modelFile = loader.loadModel(Filename.fromOsSpecific(streetCurveFilename))
|
||||
#curves = modelFile.findAllMatches('**/+ClassicNurbsCurve').asList()
|
||||
#curves = modelFile.findAllMatches('**/+ClassicNurbsCurve')
|
||||
curves = {'inner':[], 'outer':[],'innersidest':[], 'outersidest':[]}
|
||||
curvesInner = modelFile.findAllMatches('**/*curve_inner*').asList()
|
||||
curvesInner = modelFile.findAllMatches('**/*curve_inner*')
|
||||
print("-------------- curvesInner-----------------")
|
||||
print curvesInner
|
||||
curvesOuter = modelFile.findAllMatches('**/*curve_outer*').asList()
|
||||
curvesOuter = modelFile.findAllMatches('**/*curve_outer*')
|
||||
print("---------------- curvesOuter---------------")
|
||||
print curvesOuter
|
||||
curveInnerSideSts = modelFile.findAllMatches('**/*curveside_inner*').asList()
|
||||
curveInnerSideSts = modelFile.findAllMatches('**/*curveside_inner*')
|
||||
print("--------- curveInnerSideSts----------")
|
||||
print curveInnerSideSts
|
||||
|
||||
curveOuterSideSts = modelFile.findAllMatches('**/*curveside_outer*').asList()
|
||||
curveOuterSideSts = modelFile.findAllMatches('**/*curveside_outer*')
|
||||
print("----------- curveOuterSideSits ----------")
|
||||
print curveOuterSideSts
|
||||
|
||||
@ -3758,7 +3758,7 @@ class LevelEditor(NodePath, DirectObject):
|
||||
base.direct.grid.fHprSnap = 0
|
||||
self.panel.fPlaneSnap.set(0)
|
||||
bldgGroup = self.consolidateStreetBuildings()
|
||||
bldgs = bldgGroup.getChildrenAsList()
|
||||
bldgs = bldgGroup.getChildren()
|
||||
|
||||
# streetWidth puts buildings on the edge of the street, not the middle
|
||||
currPoint = Point3(0)
|
||||
@ -3924,7 +3924,7 @@ class LevelEditor(NodePath, DirectObject):
|
||||
base.direct.grid.fHprSnap = 0
|
||||
self.panel.fPlaneSnap.set(0)
|
||||
bldgGroup = self.consolidateStreetBuildings()
|
||||
bldgs = bldgGroup.getChildrenAsList()
|
||||
bldgs = bldgGroup.getChildren()
|
||||
|
||||
# streetWidth puts buildings on the edge of the street, not the middle
|
||||
currPoint = Point3(0)
|
||||
|
@ -132,7 +132,7 @@ class ParticleEffect(NodePath):
|
||||
|
||||
# Remove all forces from the particles
|
||||
for fg in self.forceGroupDict.values():
|
||||
for f in fg.asList():
|
||||
for f in fg:
|
||||
particles.removeForce(f)
|
||||
|
||||
def removeAllParticles(self):
|
||||
|
@ -680,7 +680,7 @@ class MopathRecorder(AppShell, DirectObject):
|
||||
|
||||
def getChildIds(self, nodePath):
|
||||
ids = [nodePath.id()]
|
||||
kids = nodePath.getChildrenAsList()
|
||||
kids = nodePath.getChildren()
|
||||
for kid in kids:
|
||||
ids += self.getChildIds(kid)
|
||||
return ids
|
||||
|
@ -181,7 +181,7 @@ class MemoryExplorer(Pmw.MegaWidget, DirectObject):
|
||||
self.rootItem.getVertexBytes())
|
||||
|
||||
btIndex = 1
|
||||
for item in self.rootItem.getChildrenAsList():
|
||||
for item in self.rootItem.getChildren():
|
||||
self.buttons[btIndex]['width'] = self.getBTWidth(item.getVertexBytes(),
|
||||
self.rootItem.getVertexBytes())
|
||||
btIndex += 1
|
||||
@ -222,7 +222,7 @@ class MemoryExplorer(Pmw.MegaWidget, DirectObject):
|
||||
else:
|
||||
self.addSelfCtrl(item, item.getVertexBytes())
|
||||
|
||||
for child in item.getChildrenAsList():
|
||||
for child in item.getChildren():
|
||||
self.addChildCtrl(child, item.getVertexBytes())
|
||||
|
||||
self.setTitle(item.getPathName(), item.getVertexBytes())
|
||||
@ -238,7 +238,7 @@ class MemoryExplorer(Pmw.MegaWidget, DirectObject):
|
||||
self.buildList(self.render2dItem)
|
||||
|
||||
def buildList(self, parentItem):
|
||||
for nodePath in parentItem.nodePath.getChildrenAsList():
|
||||
for nodePath in parentItem.nodePath.getChildren():
|
||||
item = MemoryExplorerItem(parentItem, nodePath)
|
||||
parentItem.addChild(item)
|
||||
self.buildList(item)
|
||||
|
@ -176,7 +176,7 @@ class SceneGraphExplorerItem(TreeItem):
|
||||
|
||||
def GetSubList(self):
|
||||
sublist = []
|
||||
for nodePath in self.nodePath.getChildrenAsList():
|
||||
for nodePath in self.nodePath.getChildren():
|
||||
item = SceneGraphExplorerItem(nodePath, self.isItemEditable)
|
||||
sublist.append(item)
|
||||
return sublist
|
||||
|
Loading…
x
Reference in New Issue
Block a user