Browse Source

adding out of world detection

Dave Schuyler 22 years ago
parent
commit
1f92189aa4

+ 19 - 11
direct/src/showbase/GravityWalker.py

@@ -349,13 +349,18 @@ class GravityWalker(DirectObject.DirectObject):
         as floor, but are nearly vertical.  This ray is
         a hack to help deal with the cliff.
         """
+        #print "FixCliff() ...self.collisionsActive=%s, self.moving=%s, self.lifter.hasContact()=%s"%(
+        #        self.collisionsActive, self.moving, self.lifter.hasContact())
         if (self.collisionsActive
                 and self.moving
-                and self.lifter.isInOuterSpace()):
+                and not self.lifter.hasContact()):
             temp = self.cRayNodePath.getZ()
             self.cRayNodePath.setZ(14.0)
             self.oneTimeCollide()
             self.cRayNodePath.setZ(temp)
+            if not self.lifter.hasContact():
+                # ...we're still in outer space.
+                messenger.send("walkerIsOutOfWorld", [self.avatarNodePath])
         return Task.cont
     
     def placeOnFloor(self):
@@ -401,16 +406,19 @@ class GravityWalker(DirectObject.DirectObject):
             "jumpDelay-%s"%id(self))
 
     def displayDebugInfo(self):
-        onScreenDebug.add("airborneHeight", self.lifter.getAirborneHeight()) #*#
-        onScreenDebug.add("falling", self.falling) #*#
-        onScreenDebug.add("isOnGround", self.lifter.isOnGround()) #*#
-        onScreenDebug.add("gravity", self.lifter.getGravity()) #*#
-        onScreenDebug.add("jumpForce", self.avatarControlJumpForce) #*#
-        onScreenDebug.add("mayJump", self.mayJump) #*#
-        onScreenDebug.add("impact", self.lifter.getImpactVelocity()) #*#
-        onScreenDebug.add("velocity", self.lifter.getVelocity()) #*#
-        onScreenDebug.add("isAirborne", self.isAirborne) #*#
-        onScreenDebug.add("inOuterSpace", self.lifter.isInOuterSpace()) #*#
+        """
+        For debug use.
+        """
+        onScreenDebug.add("airborneHeight", self.lifter.getAirborneHeight())
+        onScreenDebug.add("falling", self.falling)
+        onScreenDebug.add("isOnGround", self.lifter.isOnGround())
+        onScreenDebug.add("gravity", self.lifter.getGravity())
+        onScreenDebug.add("jumpForce", self.avatarControlJumpForce)
+        onScreenDebug.add("mayJump", self.mayJump)
+        onScreenDebug.add("impact", self.lifter.getImpactVelocity())
+        onScreenDebug.add("velocity", self.lifter.getVelocity())
+        onScreenDebug.add("isAirborne", self.isAirborne)
+        onScreenDebug.add("hasContact", self.lifter.hasContact())
 
     def handleAvatarControls(self, task):
         """

+ 4 - 2
direct/src/showbase/NonPhysicsWalker.py

@@ -162,6 +162,10 @@ class NonPhysicsWalker(DirectObject.DirectObject):
         """
         Check on the arrow keys and update the avatar.
         """
+        if not self.lifter.hasContact():
+            # hack fix for falling through the floor:
+            messenger.send("walkerIsOutOfWorld", [self.avatarNodePath])
+
         # get the button states:
         forward = inputState.isSet("forward")
         reverse = inputState.isSet("reverse")
@@ -211,11 +215,9 @@ class NonPhysicsWalker(DirectObject.DirectObject):
     
     def doDeltaPos(self):
         assert(self.debugPrint("doDeltaPos()"))
-        pass
     
     def reset(self):
         assert(self.debugPrint("reset()"))
-        pass
 
     def enableAvatarControls(self):
         """

+ 1 - 0
direct/src/showbase/PhysicsWalker.py

@@ -415,6 +415,7 @@ class PhysicsWalker(DirectObject.DirectObject):
             # DCR: don't reset X and Y; allow player to move
             self.reset()
             self.avatarNodePath.setZ(50.0)
+            messenger.send("walkerIsOutOfWorld", [self.avatarNodePath])
 
         # get the button states:
         forward = inputState.isSet("forward")