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 contact generation with backface collision disabled #55073

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

pouleyKetchoupp
Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp commented Nov 18, 2021

Replaced the previous implementation for backface collision handling (in test_axis function from SAT algorithm) with much simpler logic in the collision generation phase with face shapes, in order to get rid of wrong contacts when backface collision is disabled.

Now it just ignores the generated collision if the contact normal is against the face normal, with a threshold to keep edge contacts.

Added a special case for soft bodies to invert the collision instead of ignoring it, because for now it's the best solution to avoid soft bodies to go through concave shapes (they use small spheres for collision detection). This might be replaced with a better algorithm for soft bodies later (maybe CCD).

Fixes #54208


Additional tests on the following projects:

-MRP from #50218
Previous issue with wrong contacts with backface collision disabled still fixed.

-Test shapes from godotengine/godot-demo-projects#638
No regression spotted.

-Test with soft bodies to make sure they don't go through the ground more easily than before
soft-body-4.0.zip
No regression spotted.

-Backface collision test with multiple shape types
backface-collision-4.0.zip
Bodies go through the top plane (backface disabled) and collide with the bottom plane (backface enabled).

Replaced the previous implementation for backface collision handling (in
test_axis function from SAT algorithm) with much simpler logic in the
collision generation phase with face shapes, in order to get rid of
wrong contacts when backface collision is disabled.

Now it just ignores the generated collision if the contact normal is
against the face normal, with a threshold to keep edge contacts.

Added a special case for soft bodies to invert the collision instead of
ignoring it, because for now it's the best solution to avoid soft bodies
to go through concave shapes (they use small spheres). This might be
replaced with a better algorithm for soft bodies later.
@akien-mga akien-mga merged commit 2769163 into godotengine:master Nov 18, 2021
@akien-mga
Copy link
Member

Thanks!

@pouleyKetchoupp pouleyKetchoupp deleted the fix-backface-collision branch November 19, 2021 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ConcavePolygonShape3D property backface_collision does not disable backface collision between bodies
2 participants