jakobhellermann / bevy_editor_pls

In-App editor tools for bevy applications
Other
758 stars 78 forks source link

Fixed Mouse Control Glitches #92

Closed rs017991 closed 10 months ago

rs017991 commented 10 months ago

As of Bevy 0.12, EventReader buffers are no longer cleared between frames, causing the accumulation of non-consumed events.

In the case of systems that ignore events conditionally (like if a button is not pressed down), then unless you clear the buffer, all of those events will be replayed the next time the user presses the button, causing erratic behaviour.

For bevy_editor_pls, the consequence of not clearing the buffers is that if you move the mouse in between different pans/orbits/scrolling, the camera jerks erratically as soon as you press the button. The further it moved when the button wasn't pressed, the worse the effect.

I fixed this by clearing the buffers at any time that a system would return prior to the buffer being read. I audited non-mouse EventReaders as well; in those cases the consequences were likely just wasted memory, but I figured that I ought to fix all of them at once.

See also: https://github.com/bevyengine/bevy/issues/10860

jakobhellermann commented 10 months ago

thanks for the PR and the detailed explanation!