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() sometimes failing to extracting collision information #43616

Closed
wants to merge 6 commits into from

Conversation

madmiraal
Copy link
Contributor

@madmiraal madmiraal commented Nov 17, 2020

Currently, in Godot physics 2D and 3D, test_body_motion() sometimes fails to extract collision information, which results in the collision being ignored. This problem is aggravated when the collision margin is reduced. The most common reason for reducing collision margins is to overcome the problem that touching, but not overlapping objects are treated as colliding. This PR ensures:

  1. Collision information is always correctly extracted regardless of the size of the collision margin
  2. Touching, but not overlapping objects are not treated as colliding

Fixes #16414
Fixes #23140
Fixes #36432
Fixes #37798
Fixes #43346
Addresses comment

Although these issues all have the same source, fixing them required making multiple changes:

  • Removing the dependence on a minimum contact depth
  • Removing collision solver checks for a minimum penetration
  • Preventing zero overlaps from being detected as collisions
  • Ensuring that the 3D Godot physics static and distance collision algorithms treat zero pixel overlaps the same

To facilitate these changes this PR has refactored Godot 2D and 3D SpaceSW, the Godot GJK EPA API and the Godot 3D solve_distance() algorithm. I have kept all these changes in separate commits to facilitate review and potential future troubleshooting (the refactoring changes modified a lot of lines of code, but they should not change behaviour).

The refactoring of SpaceSW is comprehensive. To isolate the disparate issues, the code was standardised, which involved:

  • Removing duplicated code, unnecessary loops and unnecessary checks
  • Adding missing checks and generating appropriate errors
  • Making all functions across 2D and 3D as similar as possible.
  • Changing variable names so the code is easier to understand.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #42574.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #43923.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #45519.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #37547.

Removes duplicated code, unnecessary loops and unnecessary checks.
Adds missing checks and generates appropriate errors.
To ensure that collision information is extracted and possible motion
is precise, the minimum contact depth must be 0. Therefore, there is no
need for this parameter.
Ensures callback is always called.
Enables callback to control minimum depth checks.
@madmiraal
Copy link
Contributor Author

Rebased following merge of #45852.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #45854.

@Emalton
Copy link

Emalton commented Jan 22, 2023

Is this something that can be merged? It appears like it could fix this type of behavior?
https://i.imgur.com/fdlxuTg.gif

@YuriSizov
Copy link
Contributor

A lot of the linked issues have been addressed in other PRs, and this hasn't been updated in a while. So I think this needs to be remade against the current master to only fix the remaining issues.

@YuriSizov YuriSizov closed this Feb 16, 2023
@YuriSizov YuriSizov removed this from the 4.0 milestone Feb 16, 2023
@Emalton
Copy link

Emalton commented Jul 4, 2023

@madmiraal Could you rebase your? Many of the issues you listed have been fixed already, but #23140 and #43346 are still not fixed so it would be great if your fixes could be upstreamed!

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