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

Add ContactReportingPlugin #182

Merged
merged 7 commits into from
Oct 16, 2023
Merged

Add ContactReportingPlugin #182

merged 7 commits into from
Oct 16, 2023

Conversation

Jondolf
Copy link
Owner

@Jondolf Jondolf commented Oct 16, 2023

Objective

Collision events and CollidingEntities updates are currently handled by the narrow phase, and some parts of the engine are dependent on collision events. This coupling is a bit unnecessary and annoying; if you made a custom narrow phase, you would also need to handle collision events manually. Not all apps also need collision events, so it would be nice if you could disable it.

Solution

Move all collision event logic into a new ContactReportingPlugin and add PhysicsStepSet::ReportContacts.

The narrow phase is now only responsible for managing Collisions and adding contacts to it. Contact reporting is fully separate from everything else, so collision detection, sleeping and everything else should work without it.

The main remaining issue is that the collision states like during_current_frame are handled in a somewhat confusing and error-prone way. Ideally, the narrow phase wouldn't need to manage them, but for detecting which collisions have ended (and in the future, reusing previous contact manifolds), it might be necessary.

Also added `PhysicsStepSet::ReportContacts`
Now only the narrow phase is responsible for handling collision states.
Collision detection should work without `ContactReportingPlugin`.

Waking up bodies on collision ended now also uses `Collisions` instead of events.
Sleeping should work without `ContactReportingPlugin`.
@Jondolf Jondolf added the A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality label Oct 16, 2023
@Jondolf Jondolf merged commit a9d3c14 into main Oct 16, 2023
@Jondolf Jondolf deleted the contact-reporting-plugin branch October 17, 2023 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant