diff options
author | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2020-01-05 17:15:51 +0100 |
---|---|---|
committer | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2020-01-05 17:35:49 +0100 |
commit | fc1f0d76e713ae49d253dd3934ea79599a70b94a (patch) | |
tree | 8c602215e513139fef8c05bf282a5374da033b52 | |
parent | 2299fb819808f5cab5140d31abe7e4dc0b0707df (diff) |
Don't update the floor_velocity with the current linear_velocity.
Updating the floor velocity with the body's current linear velocity
discards the velocity component provided by the body's angular
rotation. Without the current contact point there is no way to calculate
the current velocity component provided by the body's angular rotation
therefore we need to use the velocity calculated at the time of the
collision.
Fixes #34807.
-rw-r--r-- | scene/3d/physics_body.cpp | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 44dc3d0c26..c2860c25d8 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -1151,17 +1151,8 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve } } - Vector3 current_floor_velocity = floor_velocity; - if (on_floor && on_floor_body.is_valid()) { - //this approach makes sure there is less delay between the actual body velocity and the one we saved - PhysicsDirectBodyState *bs = PhysicsServer::get_singleton()->body_get_direct_state(on_floor_body); - if (bs) { - current_floor_velocity = bs->get_linear_velocity(); - } - } - // Hack in order to work with calling from _process as well as from _physics_process; calling from thread is risky - Vector3 motion = (current_floor_velocity + body_velocity) * (Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time()); + Vector3 motion = (floor_velocity + body_velocity) * (Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time()); on_floor = false; on_floor_body = RID(); |