-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Make sprite picking opt-in #17225
Make sprite picking opt-in #17225
Conversation
c80bad8
to
a0008cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking better :) Final changes:
- Move marker component to bevy_picking, and call it
Pickable
. - Split apart the components and call the camera one
SpritePickingCamera
.
Follow-up:
- use this design for mesh-picking as well
What are your thoughts on a I'd be happy to tackle the follow-up :) |
On second thought, I don't think this makes sense. Cameras could be used for distinct backends, so generalizing seems wrong. |
Exactly my thinking. |
//! # Usage | ||
//! | ||
//! This backend is strictly opt-in. For entities to be considered for sprite picking, you should | ||
//! mark them with [`Pickable`] and their respective cameras with [`SpritePickingCamera`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes you want things to be opt-out, especially if everything is interactive, or if you are just debugging.
More importantly, we should make sure our backends are consistent, at least the first party ones. The mesh picking backend has a resource that controls whether it is opt in or opt out. Instead of changing this behavior for everyone, the need for this PR suggests we need both, and we should match the mesh picking backend.
https://docs.rs/bevy/latest/bevy/picking/mesh_picking/struct.MeshPickingSettings.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, the debugging use case is a good argument for making this configurable 🤔 I would like to unify this across all of our backends though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only qualm is that we lose some performance benefit, but I'm in agreement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is the question of whether it should be opt in by default or not. Backend consistency says it should be opt out, but perhaps we want to push users to opt in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my experience working on mod_picking, it's a better experience for users if it starts as opt-out, because it removes friction and steps to just get things working. Once it is working, it's then another small step to switch to opt-in if they decide to.
…` to `SpritePickingSettings`
I've pushed some changes:
I also think that the |
Agree with everything here. Doing a pass to standardize all backends and make them all opt-in would be great. |
# Objective PR #17225 allowed for sprite picking to be opt-in. After some discussion, it was agreed that `PickingBehavior` should be used to opt-in to sprite picking behavior for entities. This leads to `PickingBehavior` having two purposes: mark an entity for use in a backend, and describe how it should be picked. Discussion led to the name `Pickable`making more sense (also: this is what the component was named before upstreaming). A follow-up pass will be made after this PR to unify backends. ## Solution Replace all instances of `PickingBehavior` and `picking_behavior` with `Pickable` and `pickable`, respectively. ## Testing CI ## Migration Guide Change all instances of `PickingBehavior` to `Pickable`.
Objective
Fixes #16903.
Solution
SpritePickingCamera
component for cameras and usage of a newPickable
component for entities.sprite_picking
example to reflect these changes.Testing
Ran the
sprite_picking
exampleOpen Questions
Migration Guide
The sprite picking backend is now strictly opt-in using the
SpritePickingCamera
andPickable
components. You should add thePickable
component any entities that you want sprite picking to be enabled for, and mark their respective cameras withSpritePickingCamera
.