diff --git a/direct/src/showbase/GravityWalker.py b/direct/src/showbase/GravityWalker.py index f9e7d984db..7b47bf595d 100755 --- a/direct/src/showbase/GravityWalker.py +++ b/direct/src/showbase/GravityWalker.py @@ -257,7 +257,7 @@ class GravityWalker(DirectObject.DirectObject): self.jumpDelayTask.remove() self.mayJump = 0 self.jumpDelayTask=taskMgr.doMethodLater( - 0.1, + 0.5, self.setMayJump, "jumpDelay-%s"%id(self)) @@ -291,7 +291,7 @@ class GravityWalker(DirectObject.DirectObject): self.rotationSpeed = 0 jump = 0 - if 0: + if 1: onScreenDebug.add("airborneHeight", self.lifter.getAirborneHeight()) #*# onScreenDebug.add("falling", self.falling) #*# onScreenDebug.add("isOnGround", self.lifter.isOnGround()) #*# diff --git a/panda/src/collide/collisionHandlerGravity.I b/panda/src/collide/collisionHandlerGravity.I index ef955595b4..d987c8ee57 100755 --- a/panda/src/collide/collisionHandlerGravity.I +++ b/panda/src/collide/collisionHandlerGravity.I @@ -68,6 +68,21 @@ is_on_ground() const { return get_airborne_height() == 0.0f && _current_velocity == 0.0f; } +//////////////////////////////////////////////////////////////////// +// Function: CollisionHandlerGravity::get_impact_velocity +// Access: Public +// Description: How hard did the object hit the ground. +// This value is set on impact with the ground. +// You may want to watch (poll) on is_on_groun() and +// when that is true, call get_impact_velocity(). +// Normally I avoid polling, but we are calling +// is_on_ground() frequently anyway. +//////////////////////////////////////////////////////////////////// +INLINE float CollisionHandlerGravity:: +get_impact_velocity() const { + return _impact_velocity; +} + //////////////////////////////////////////////////////////////////// // Function: CollisionHandlerGravity::add_velocity // Access: Public diff --git a/panda/src/collide/collisionHandlerGravity.cxx b/panda/src/collide/collisionHandlerGravity.cxx index 41a70fc859..bb5cc47681 100755 --- a/panda/src/collide/collisionHandlerGravity.cxx +++ b/panda/src/collide/collisionHandlerGravity.cxx @@ -34,6 +34,7 @@ CollisionHandlerGravity:: CollisionHandlerGravity() { _offset = 0.0f; _airborne_height = 0.0f; + _impact_velocity = 0.0f; _gravity = 32.174f; _current_velocity = 0.0f; _max_velocity = 400.0f; @@ -140,6 +141,7 @@ handle_entries() { if (_airborne_height < 0.001f && _current_velocity < 0.001f) { // ...the node is under the floor, so it has landed. + _impact_velocity = _current_velocity; // These values are used by is_on_ground(). _current_velocity = _airborne_height = 0.0f; } diff --git a/panda/src/collide/collisionHandlerGravity.h b/panda/src/collide/collisionHandlerGravity.h index bd5b339411..b7358e4137 100755 --- a/panda/src/collide/collisionHandlerGravity.h +++ b/panda/src/collide/collisionHandlerGravity.h @@ -42,6 +42,7 @@ PUBLISHED: INLINE float get_airborne_height() const; INLINE bool is_on_ground() const; + INLINE float get_impact_velocity() const; INLINE void add_velocity(float velocity); INLINE void set_velocity(float velocity); @@ -60,6 +61,7 @@ protected: private: float _offset; float _airborne_height; + float _impact_velocity; float _gravity; float _current_velocity; float _max_velocity;