mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-05 03:15:07 -04:00
added doByDistance
This commit is contained in:
parent
b290f53d74
commit
a291b6ea1e
@ -66,6 +66,28 @@ class DoCollectionManager:
|
|||||||
matches.append(value)
|
matches.append(value)
|
||||||
return matches
|
return matches
|
||||||
|
|
||||||
|
def _compareDistance(self, do1, do2):
|
||||||
|
has1 = hasattr(do1, 'getPos')
|
||||||
|
has2 = hasattr(do2, 'getPos')
|
||||||
|
if not has1 and not has2:
|
||||||
|
return 0
|
||||||
|
if not has1:
|
||||||
|
return 1
|
||||||
|
if not has2:
|
||||||
|
return -1
|
||||||
|
dist1 = do1.getPos(localAvatar).length()
|
||||||
|
dist2 = do2.getPos(localAvatar).length()
|
||||||
|
if (dist1 < dist2):
|
||||||
|
return -1
|
||||||
|
return 1
|
||||||
|
|
||||||
|
def doByDistance(self):
|
||||||
|
objs = self.doId2do.values()
|
||||||
|
objs.sort(cmp=self._compareDistance)
|
||||||
|
for obj in objs:
|
||||||
|
print '%s\t%s\t%s' % (obj.doId, obj.getPos(localAvatar).length(),
|
||||||
|
obj.dclass.getName())
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
def printObjects(self):
|
def printObjects(self):
|
||||||
format="%10s %10s %10s %30s %20s"
|
format="%10s %10s %10s %30s %20s"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user