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 physics picking backend using bevy_picking #554

Merged
merged 10 commits into from
Nov 11, 2024
Merged

Add physics picking backend using bevy_picking #554

merged 10 commits into from
Nov 11, 2024

Conversation

Jondolf
Copy link
Owner

@Jondolf Jondolf commented Nov 11, 2024

Objective

Bevy 0.15 upstreams bevy_mod_picking as bevy_picking. Now that picking is first-party, we should add a collider picking backend, especially as bevy_mod_picking (which has an Avian backend) is on track for deprecation.

Solution

Add a PhysicsPickingPlugin! It is behind the bevy_picking default feature and must be added manually, but once it is enabled, picking is enabled for all colliders by default. Picking can be made opt-in using PhysicsPickingSettings::require_markers, in which case you must mark pickable entities with the PhysicsPickable component. The API and approach quite closely match the MeshPickingPlugin in Bevy 0.15.

The plugin is largely based on the Avian backend in bevy_mod_picking, with some tweaks to docs and naming. I also added a 2D version of the picking backend.

There is a new picking_3d example:

2024-11-11.02-56-18.mp4

(Note: The torus and conical frustum use trimesh colliders here, which is why the normals change a bit abruptly)

I have not added a 2D example (yet), but tested that it works:

2024-11-11.02-58-14.mp4

@Jondolf Jondolf added C-Enhancement New feature or request A-Spatial-Query Relates to spatial queries, such as ray casting, shape casting, and intersection tests labels Nov 11, 2024
@Jondolf Jondolf added this to the 0.2 milestone Nov 11, 2024
@Jondolf Jondolf enabled auto-merge (squash) November 11, 2024 10:29
@Jondolf Jondolf merged commit 5deada5 into main Nov 11, 2024
4 checks passed
@Jondolf Jondolf deleted the bevy_picking branch November 25, 2024 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Spatial-Query Relates to spatial queries, such as ray casting, shape casting, and intersection tests C-Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant