mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
added get_impact_velocity
This commit is contained in:
parent
d5af5d35c3
commit
ad6b8e1c80
@ -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()) #*#
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user