Closed alice-i-cecile closed 1 month ago
Thank you Alice, reading through this now. 🙂
Small correction of a common misconception. Picking does not require raycasting, that is just one of the hit testing methods.
I use both crates extensively and have written extensions in my own game. I will keep an eye on this and will be available for code reviews. Excited to see this start!
I'd like to give a quick update here laying out the next steps. Most of the existing mod_picking
code has been moved over, and but the work is still ongoing. Picking had basically has two flaws
We managed to (mostly) resolve the first one of these issues with observers. Here's how I want to resolve the second:
bevy_winit::WinitEvent
to bevy_window::WindowEvent
and use it as the basic input stream for picking.InputMove
and InputPress
into PointerInput
, and update the dispatchers to preserve order.Pointer<X>
events. This will be a single system that triggers observers in a way that matches the input stream ordering.These are implemented here: https://github.com/bevyengine/bevy/pull/14862.
This will conclude the minimum necessary work for the up-streaming (for the core logic at least, there may still be work in documenting, testing, and adding back-ends). Here's a few other things we will want to do after this is complete:
picking
into input
. Winit is also moving to a unified pointer abstraction, so we will need to do this anyway at some point.Closing as "effectively complete".
Why we need picking (and raycasting)
To be glib,
bevy_mod_picking
by @aevyrie allows users to point at things and click on them. Picking is the pattern of turning pointer events (like mouse clicks or touches) into the hover/selection/deselection of objects (meshes, sprites, UI...) via hit testing, of which raycasting is one common form.Bevy needs an equivalent set of tools for:
Interaction
component and focus handlingbalanced breakfastscene editor or interactive debuggerWhile the first application can and currently is solved by relying on an external crate, this is still limiting because:
main
, as it's not part of our CI.For the remaining use cases, we simply can't rely on an external crate that relies on Bevy due to circular dependencies which present severe technical and organizational challenges.
Why we should upstream rather than re-implement
Of course, the next question is "why should we upstream a crate, rather than simply building it ourselves!". After all, it wasn't invented here, for a very narrow definition of "here".
However, as I previously discussed in https://github.com/bevyengine/rfcs/pull/63, reinventing rather than upstreaming popular, functioning crates is both risky and wasteful. While this functionality may seem simple at first glance, hard-won experience shows that there are a large number of ergonomic, design and performance concerns that must be carefully navigated.
bevy_mod_picking
is a stable, beloved part of Bevy's ecosystem. While it may not be perfect in its current form, it decidedly works: with good performance, a lovely API and a generally low-bug experience. Building our own equivalent will take longer, involve dramatically more controversy, and leave us at a worse starting point.Organizational strategy for upstreaming
I've been working closely with @aevyrie and other members of the community to plan this migration. As part of that, we have a pair of junior volunteers from Purdue: Avi and Xavier who are helping us with this work (this issue is a sibling to https://github.com/bevyengine/bevy/issues/12349). Please be patient and kind with them as they work, but remember that they're here to learn and improve.
During this discussion, we've outlined a few key strategies to minimize the pain of this complex migration:
The essential problems to avoid are:
If you have breaking concerns or ideas, please, please open issues to record them (and link this issue). We want to hear them, and to improve all areas of the engine: we just don't want the migration to fall into disarray :)
Technical pathway to upstreaming
Note: this has been updated to reflect evolving plans!
bevy_mod_picking
's components into a newbevy_picking
cratebevy_mod_picking
Interaction
bevy_event_dispatch
bevy_picking
Related work
83
615
3805
3570
4264
5769
8157
10141