"switch inheritance order to satisfy MRO requirements. Removed debugging code. One-off traverse on render instead of only this object in order to preserve eventHandler states. Proper propagation of init parameters"

This commit is contained in:
Josh Wilson 2007-04-07 06:44:39 +00:00
parent 0698befa25
commit 1b12685fee
2 changed files with 10 additions and 10 deletions

View File

@ -3,7 +3,7 @@ from direct.directnotify import DirectNotifyGlobal
from pandac.PandaModules import *
from PhasedObject import PhasedObject
class DistancePhasedNode(NodePath, DirectObject, PhasedObject):
class DistancePhasedNode(PhasedObject, DirectObject, NodePath):
"""
This class defines a PhasedObject,NodePath object that will handle the phasing
of an object in the scene graph according to its distance from some
@ -110,9 +110,9 @@ class DistancePhasedNode(NodePath, DirectObject, PhasedObject):
cName = 'Phase%s-%d' % (name, self.__id)
cSphereNode = CollisionNode(cName)
cSphereNode.setIntoCollideMask(self.phaseCollideMask)
cSphereNode.setFromCollideMask(BitMask32.allOff())
cSphereNode.addSolid(cSphere)
cSphereNodePath = self.attachNewNode(cSphereNode)
cSphereNodePath.show()
cSphereNodePath.stash()
self._colSpheres.append(cSphereNodePath)
@ -169,16 +169,17 @@ class DistancePhasedNode(NodePath, DirectObject, PhasedObject):
self.ignore(self.__getExitEvent(phaseName))
def __handleEnterEvent(self, phaseName, cEntry):
print cEntry
self.setPhase(phaseName)
def __handleExitEvent(self, phaseName, cEntry):
print cEntry
phase = self.getAliasPhase(phaseName) - 1
self.setPhase(phase)
def __oneTimeCollide(self):
base.cTrav.traverse(self)
# we use render here since if we only try to
# traverse ourself, we end up calling exit
# events for the rest of the eventHandlers. >:(
base.cTrav.traverse(render)
base.eventMgr.doEvents()
class BufferedDistancePhasedNode(DistancePhasedNode):
@ -198,11 +199,12 @@ class BufferedDistancePhasedNode(DistancePhasedNode):
"""
notify = directNotify.newCategory("BufferedDistancePhasedObject")
def __init__(self, name, bufferParamMap = {}):
def __init__(self, name, bufferParamMap = {},
enterPrefix = 'enter', exitPrefix = 'exit', phaseCollideMask = BitMask32.allOn()):
sParams = dict(bufferParamMap)
for key in sParams:
sParams[key] = sParams[key][0]
DistancePhasedNode.__init__(self, name, sParams)
DistancePhasedNode.__init__(self, name, sParams, enterPrefix, exitPrefix, phaseCollideMask)
self.bufferParamMap = bufferParamMap
self.bufferParamList = sorted(bufferParamMap.items(),
key = lambda x: x[1],
@ -248,4 +250,3 @@ if __debug__ and 0:
p.reparentTo(render)
p._DistancePhasedNode__oneTimeCollide()
base.eventMgr.doEvents()

View File

@ -98,7 +98,6 @@ class PhasedObject:
Will force the unloading, in correct order, of all currently
loaded phases.
"""
print 'PO - cleanup'
if self.phase >= 0:
self.setPhase(-1)
@ -115,7 +114,7 @@ class PhasedObject:
lambda: self.__phaseNotFound('unload',aPhase))()
def __phaseNotFound(self, mode, aPhase):
assert self.notify.warning('skipping phase %s%s\n' % (mode,aPhase))
assert self.notify.debug('%s%s() not found!\n' % (mode,aPhase))
if __debug__:
class AnfaPhasedObject(PhasedObject):