Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_body_motion recovery and rest info #46148

Merged
merged 1 commit into from
Feb 18, 2021

Conversation

pouleyKetchoupp
Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp commented Feb 18, 2021

This change makes test_body_motion more reliable when the kinematic body recovers from being stuck.

Fixes #45259
Fixes #45971
Fixes #46134

Detailed changes:

  • When recovery occurs, the rest information is generated, in order to make sure collision results from test_move, move_and_collide and move_and_slide are consistent and return a collision in case of overlap.
    See regression Collision detection unreliable with KinematicBody2D inside CollisionPolygon2D #45971

  • The new calculation for recovery vector makes sure the recovery is never more than the overlap depth between shapes.
    This can help with cases where the kinematic body overlaps with several shapes.
    Recovery is made iteratively, without forcing a full overlap at each step. This helps with getting proper rest information when recovery occurs (previous point).
    Based on Fix multiple issues with test_body_motion() and test_body_ray_separation(). #35945 (comment)

  • One Way Collision:
    When attempting motion, contact direction is checked against motion before skipping in order to solve cases where kinematic bodies can sink into one-way collision shapes.
    Rest info now sets max contact depth in order to properly handle one-way collision, the same way it's done during the recovery step.

  • Low speed motion is now handled in the rest info, by never setting min_allowed_depth lower than motion length.
    Separation is always applied with full margin, otherwise contact is lost when low speed motion occurs right after higher speed motion.
    See regression Regression in KinematicBody2D.move_and_slide where slide is instable and body sometimes bounce up for few frames #46134

  • Similar changes are applied to 3D in order to make 2D and 3D consistent.


List of tested cases (in addition to the fixed regressions):

Note: most tests have been done on the 3.2 version, because many of the test projects haven't been ported to 4.0.

This change makes test_body_motion more reliable when the kinematic body
recovers from being stuck.

- When recovery occurs, the rest information is generated, in order to
make sure collision results from test_move, move_and_collide and
move_and_slide are consistent and return a collision in case of overlap.

- The new calculation for recovery vector makes sure the recovery is
never more than the overlap depth between shapes.
This can help with cases where the kinematic body overlaps with several
shapes.
Recovery is made iteratively, without forcing a full overlap at each
step. This helps with getting proper rest information when recovery
occurs.

- One Way Collision:
When attempting motion, contact direction is checked against motion
before skipping in order to solve cases where kinematic bodies can sink
into one-way collision shapes.
Rest info now sets max contact depth in order to properly handle one-way
collision.

- Low speed motion is now handled in the rest info, by never setting
min_allowed_depth lower than motion length.
Separation is always applied with full margin, otherwise contact is lost
when low speed motion occurs right after higher speed motion.

- Similar changes are applied to 3D in order to make 2D and 3D
consistent.
@akien-mga akien-mga merged commit 5529fe5 into godotengine:master Feb 18, 2021
@akien-mga
Copy link
Member

Thanks for the fix and the thorough regression testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment