*** empty log message ***

This commit is contained in:
Dave Schuyler 2005-05-05 21:42:36 +00:00
parent a2eb3859cb
commit 948d428141

View File

@ -30,10 +30,71 @@ class ObserverWalker(NonPhysicsWalker.NonPhysicsWalker):
"""
Set up the avatar for collisions
"""
NonPhysicsWalker.NonPhysicsWalker.initializeCollisions(
self, collisionTraverser, avatarNodePath,
avatarRadius, floorOffset, reach)
self.cTrav.removeCollider(self.cRayNodePath)
"""
Set up the avatar for collisions
"""
assert not avatarNodePath.isEmpty()
self.cTrav = collisionTraverser
self.avatarNodePath = avatarNodePath
# Set up the collision sphere
# This is a sphere on the ground to detect barrier collisions
self.cSphere = CollisionSphere(0.0, 0.0, 0.0, avatarRadius)
cSphereNode = CollisionNode('NPW.cSphereNode')
cSphereNode.addSolid(self.cSphere)
self.cSphereNodePath = avatarNodePath.attachNewNode(cSphereNode)
cSphereNode.setFromCollideMask(self.cSphereBitMask)
cSphereNode.setIntoCollideMask(BitMask32.allOff())
# set up wall collision mechanism
self.pusher = CollisionHandlerPusher()
self.pusher.setInPattern("enter%in")
self.pusher.setOutPattern("exit%in")
self.pusher.addCollider(self.cSphereNodePath, avatarNodePath)
# activate the collider with the traverser and pusher
self.setCollisionsActive(1)
class Foo:
def hasContact(self):
return 1
self.lifter = Foo()
def deleteCollisions(self):
del self.cTrav
del self.cSphere
self.cSphereNodePath.removeNode()
del self.cSphereNodePath
del self.pusher
def setCollisionsActive(self, active = 1):
assert(self.debugPrint("setCollisionsActive(active%s)"%(active,)))
if self.collisionsActive != active:
self.collisionsActive = active
if active:
self.cTrav.addCollider(self.cSphereNodePath, self.pusher)
else:
self.cTrav.removeCollider(self.cSphereNodePath)
# Now that we have disabled collisions, make one more pass
# right now to ensure we aren't standing in a wall.
self.oneTimeCollide()
def oneTimeCollide(self):
"""
Makes one quick collision pass for the avatar, for instance as
a one-time straighten-things-up operation after collisions
have been disabled.
"""
tempCTrav = CollisionTraverser("oneTimeCollide")
tempCTrav.addCollider(self.cSphereNodePath, self.pusher)
tempCTrav.traverse(render)
def enableAvatarControls(self):
"""