-
-
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
Picking event ordering #14862
Picking event ordering #14862
Conversation
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.
It's a little hard to review in combination with the upstream pr, as they're getting rid of most of these events. In that way, it might be confusing for our users if they can read a CursorEntered
event from WindowEvent
but then also a PointerEntered
derived from that same event. Upstreaming picking is essential so moving it forward is probably worth the cost, but it would be nice to know when their changes will land, so hopefully it doesn't need to be visible to users. It would make me nervous to do a release and churn on those changes.
Substantively, the unification strategy makes a lot of sense, and code looks good so far, with the caveat that I'm not familiar with picking internals.
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
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.
I agree with the core architectural choices, and this is looking good.
I've left a few small notes on docs, and InputPlugin
needs to be renamed :) Once that's done I'm good to merge this.
Objective
Correctly order picking events. Resolves #5984.
Solution
Event ordering very long standing problem with mod picking, stemming from two related issues. The first problem was that
Pointer<T>
events of different types couldn't be ordered, but we have already gotten around that in the upstream by switching to observers. Since observers run in the order they are triggered, this isn't an issue.The second problem was that the underlying event streams that picking uses to create it's pointer interaction events also lacked ordering, and the systems that generated the points couldn't interleave events. This PR fixes that by unifying the event streams and integrating the various interaction systems.
The concrete changes are as follows:
bevy_winit::WinitEvent
has been moved tobevy_window::WindowEvent
. This provides a unified (and more importantly, ordered) input stream for bothbevy_window
andbevy_input
events.InputMove
andInputPress
withPointerInput
, a new unified input event which drives picking and interaction. This event is built to have drop-in forward compatibility with winit's upcoming pointer abstraction. I have added code to emulate it using the current winit input abstractions, but this entire thing will be much more robust when it lands.pointer_events
send_click_and_drag_events
andsend_drag_over_events
into a single system, which operates directly onPointerEvent
and triggers observers as output.The PR also improves docs and takes the opportunity to refactor/streamline the pointer event dispatch logic.
Status & Testing
This PR is now feature complete and documented. While it is theoretically possible to add unit tests for the ordering, building the picking mocking for that will take a little while.
Feedback on the chosen ordering of events is within-scope.
Migration Guide
For users switching from
bevy_mod_picking
tobevy_picking
:On<T>
component, use.observe(|trigger: Trigger<T>|)
. You may now apply multiple handlers to the same entity using this command.bevy_picking::event::pointer_events
for current information. You may need to adjust your event handling logic accordingly.PointerCancel
has been replaced withPointer<Cancled>
, which now has the semantics of an OS touch pointer cancel event.InputMove
andInputPress
have been merged intoPointerInput
. The use remains exactly the same.EventReader
. This functionality may be re-implemented later.For users of
bevy_winit
:bevy_winit::WinitEvent
has moved tobevy_window::WindowEvent
. If this was the only thing you depended onbevy_winit
for, you should switch your dependency tobevy_window
.bevy_window
now depends onbevy_input
. The dependencies ofbevy_input
are a subset of the existing dependencies forbevy_window
so this should be non-breaking.