bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Picking event ordering

Open NthTensor opened this issue 1 year ago • 0 comments

Objective

Correctly order picking events.

Solution

Event ordering very long standing problem with mod picking, stemming from two related issues. The was that 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 to bevy_window::WindowEvent. This provides a unified input stream for both bevy_window and bevy_input events.
  • Replaces InputMove and InputPress with PointerInput, a new unified input event. 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.
  • Rolls pointer_events send_click_and_drag_events and send_drag_over_events into a single system, which operates directly on PointerEvent and triggers observers as output.

Status

This PR is unpolished. The core logic changes are present, but there's a lot of little details and polish. I've published this as a draft because I expect it to be X-Controversial and I want to get early fead-back on the overall solution. Nitpick away!

Testing

These changes are currently basically untested.

NthTensor avatar Aug 22 '24 01:08 NthTensor