From f29545a1670a56c894d884789f02da9fa3c64027 Mon Sep 17 00:00:00 2001 From: Dave Schuyler Date: Wed, 19 Nov 2003 03:54:52 +0000 Subject: [PATCH] removed shown ray; jumping straight up; --- direct/src/showbase/NonPhysicsWalker.py | 25 +++++++++++++------------ direct/src/showbase/PhysicsWalker.py | 14 +++++++++----- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/direct/src/showbase/NonPhysicsWalker.py b/direct/src/showbase/NonPhysicsWalker.py index 1060f13f33..c94494a5ce 100755 --- a/direct/src/showbase/NonPhysicsWalker.py +++ b/direct/src/showbase/NonPhysicsWalker.py @@ -121,19 +121,20 @@ class NonPhysicsWalker(DirectObject.DirectObject): del self.pusher del self.lifter - def collisionsOff(self): - assert(self.debugPrint("collisionsOff")) - self.cTrav.removeCollider(self.cSphereNodePath) - self.cTrav.removeCollider(self.cRayNodePath) + 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) + self.cTrav.addCollider(self.cRayNodePath, self.lifter) + else: + self.cTrav.removeCollider(self.cSphereNodePath) + self.cTrav.removeCollider(self.cRayNodePath) - # Now that we have disabled collisions, make one more pass - # right now to ensure we aren't standing in a wall. - self.oneTimeCollide() - - def collisionsOn(self): - assert(self.debugPrint("collisionsOn")) - self.cTrav.addCollider(self.cSphereNodePath, self.pusher) - self.cTrav.addCollider(self.cRayNodePath, self.lifter) + # 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): """ diff --git a/direct/src/showbase/PhysicsWalker.py b/direct/src/showbase/PhysicsWalker.py index c77fdac051..21a1778a14 100755 --- a/direct/src/showbase/PhysicsWalker.py +++ b/direct/src/showbase/PhysicsWalker.py @@ -148,7 +148,6 @@ class PhysicsWalker(DirectObject.DirectObject): else: # useCollisionHandlerQueue self.cRayQueue = CollisionHandlerQueue() self.cTrav.addCollider(self.cRayNodePath, self.cRayQueue) - self.cRayNodePath.show() def determineHeight(self): """ @@ -550,7 +549,7 @@ class PhysicsWalker(DirectObject.DirectObject): else: # ...the avatar is very close to the ground (close enough to be # considered on the ground). - if self.isAirborne: + if self.isAirborne and physObject.getVelocity().getZ() <= 0.0: # ...the avatar has landed. contactLength = contact.length() if contactLength>self.__hardLandingForce: @@ -565,9 +564,14 @@ class PhysicsWalker(DirectObject.DirectObject): #print "jump" #self.__jumpButton=0 messenger.send("jumpStart") - jumpVec=Vec3(contact+Vec3.up()) - #jumpVec=Vec3(rotAvatarToPhys.xform(jumpVec)) - jumpVec.normalize() + if 0: + # ...jump away from walls and with with the slope normal. + jumpVec=Vec3(contact+Vec3.up()) + #jumpVec=Vec3(rotAvatarToPhys.xform(jumpVec)) + jumpVec.normalize() + else: + # ...jump straight up, even if next to a wall. + jumpVec=Vec3.up() jumpVec*=self.avatarControlJumpForce physObject.addImpulse(Vec3(jumpVec)) self.isAirborne = 1 # Avoid double impulse before fully airborne.