Merge pull request #51743 from fabriceci/3x-avoid-useless-snap

[3.x] Avoid useless call to move and collide during snapping
This commit is contained in:
Rémi Verschelde 2021-08-16 20:19:39 +02:00 committed by GitHub
commit dc1b18e832
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -1212,7 +1212,7 @@ Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_veloci
bool was_on_floor = on_floor;
Vector2 ret = move_and_slide(p_linear_velocity, up_direction, p_stop_on_slope, p_max_slides, p_floor_max_angle, p_infinite_inertia);
if (!was_on_floor || p_snap == Vector2()) {
if (!was_on_floor || p_snap == Vector2() || on_floor) {
return ret;
}

View File

@ -1172,7 +1172,7 @@ Vector3 KinematicBody::move_and_slide_with_snap(const Vector3 &p_linear_velocity
bool was_on_floor = on_floor;
Vector3 ret = move_and_slide(p_linear_velocity, up_direction, p_stop_on_slope, p_max_slides, p_floor_max_angle, p_infinite_inertia);
if (!was_on_floor || p_snap == Vector3()) {
if (!was_on_floor || p_snap == Vector3() || on_floor) {
return ret;
}