Add physics picking backend using bevy_picking
#554
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Bevy 0.15 upstreams
bevy_mod_picking
asbevy_picking
. Now that picking is first-party, we should add a collider picking backend, especially asbevy_mod_picking
(which has an Avian backend) is on track for deprecation.Solution
Add a
PhysicsPickingPlugin
! It is behind thebevy_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 usingPhysicsPickingSettings::require_markers
, in which case you must mark pickable entities with thePhysicsPickable
component. The API and approach quite closely match theMeshPickingPlugin
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