"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 pandac.PandaModules import *
from PhasedObject import PhasedObject 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 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 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) cName = 'Phase%s-%d' % (name, self.__id)
cSphereNode = CollisionNode(cName) cSphereNode = CollisionNode(cName)
cSphereNode.setIntoCollideMask(self.phaseCollideMask) cSphereNode.setIntoCollideMask(self.phaseCollideMask)
cSphereNode.setFromCollideMask(BitMask32.allOff())
cSphereNode.addSolid(cSphere) cSphereNode.addSolid(cSphere)
cSphereNodePath = self.attachNewNode(cSphereNode) cSphereNodePath = self.attachNewNode(cSphereNode)
cSphereNodePath.show()
cSphereNodePath.stash() cSphereNodePath.stash()
self._colSpheres.append(cSphereNodePath) self._colSpheres.append(cSphereNodePath)
@ -169,16 +169,17 @@ class DistancePhasedNode(NodePath, DirectObject, PhasedObject):
self.ignore(self.__getExitEvent(phaseName)) self.ignore(self.__getExitEvent(phaseName))
def __handleEnterEvent(self, phaseName, cEntry): def __handleEnterEvent(self, phaseName, cEntry):
print cEntry
self.setPhase(phaseName) self.setPhase(phaseName)
def __handleExitEvent(self, phaseName, cEntry): def __handleExitEvent(self, phaseName, cEntry):
print cEntry
phase = self.getAliasPhase(phaseName) - 1 phase = self.getAliasPhase(phaseName) - 1
self.setPhase(phase) self.setPhase(phase)
def __oneTimeCollide(self): 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() base.eventMgr.doEvents()
class BufferedDistancePhasedNode(DistancePhasedNode): class BufferedDistancePhasedNode(DistancePhasedNode):
@ -198,11 +199,12 @@ class BufferedDistancePhasedNode(DistancePhasedNode):
""" """
notify = directNotify.newCategory("BufferedDistancePhasedObject") notify = directNotify.newCategory("BufferedDistancePhasedObject")
def __init__(self, name, bufferParamMap = {}): def __init__(self, name, bufferParamMap = {},
enterPrefix = 'enter', exitPrefix = 'exit', phaseCollideMask = BitMask32.allOn()):
sParams = dict(bufferParamMap) sParams = dict(bufferParamMap)
for key in sParams: for key in sParams:
sParams[key] = sParams[key][0] sParams[key] = sParams[key][0]
DistancePhasedNode.__init__(self, name, sParams) DistancePhasedNode.__init__(self, name, sParams, enterPrefix, exitPrefix, phaseCollideMask)
self.bufferParamMap = bufferParamMap self.bufferParamMap = bufferParamMap
self.bufferParamList = sorted(bufferParamMap.items(), self.bufferParamList = sorted(bufferParamMap.items(),
key = lambda x: x[1], key = lambda x: x[1],
@ -248,4 +250,3 @@ if __debug__ and 0:
p.reparentTo(render) p.reparentTo(render)
p._DistancePhasedNode__oneTimeCollide() p._DistancePhasedNode__oneTimeCollide()
base.eventMgr.doEvents() base.eventMgr.doEvents()

View File

@ -98,7 +98,6 @@ class PhasedObject:
Will force the unloading, in correct order, of all currently Will force the unloading, in correct order, of all currently
loaded phases. loaded phases.
""" """
print 'PO - cleanup'
if self.phase >= 0: if self.phase >= 0:
self.setPhase(-1) self.setPhase(-1)
@ -115,7 +114,7 @@ class PhasedObject:
lambda: self.__phaseNotFound('unload',aPhase))() lambda: self.__phaseNotFound('unload',aPhase))()
def __phaseNotFound(self, mode, 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__: if __debug__:
class AnfaPhasedObject(PhasedObject): class AnfaPhasedObject(PhasedObject):