Skip to content

Commit

Permalink
Release notes for accumulated mouse inputs (#1828)
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-i-cecile authored Nov 21, 2024
1 parent 0390208 commit fc35cb3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!-- Accumulated mouse inputs -->
<!-- https://github.com/bevyengine/bevy/pull/14044 -->

"How much has the player moved their mouse this frame" is a natural question for games when the player is trying to aim or scroll a map.
Unfortunately, the operating system, and thus [`winit`], only provides us with a stream of events, in the form of individual [`MouseMotion`] events.

To get the summarized information (and the equivalent [`MouseScroll`]) information that most game systems care about, you had to sum them yourself.

```rust
pub fn accumulate_mouse_motion_system(
mut mouse_motion_event: EventReader<MouseMotion>,
mut accumulated_mouse_motion: ResMut<AccumulatedMouseMotion>,
) {
let mut delta = Vec2::ZERO;
for event in mouse_motion_event.read() {
delta += event.delta;
}
accumulated_mouse_motion.delta = delta;
}
```

Bevy now does this for you, exposed in the new [`AccumulatedMouseMotion`] and [`AccumulatedMouseScroll`] resources.

[`winit`]: https://docs.rs/winit/latest/winit/
[`MouseMotion`]: https://docs.rs/bevy/0.15.0/bevy/input/mouse/struct.MouseMotion.html
[`MouseScroll`]: https://docs.rs/bevy/0.15.0/bevy/input/mouse/struct.MouseScroll.html
[`AccumulatedMouseMotion`]: https://docs.rs/bevy/0.15.0/bevy/input/mouse/struct.AccumulatedMouseMotion.html
[`AccumulatedMouseScroll`]: https://docs.rs/bevy/0.15.0/bevy/input/mouse/struct.AccumulatedMouseScroll.html
7 changes: 7 additions & 0 deletions release-content/0.15/release-notes/_release-notes.toml
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,13 @@ contributors = ["@IceSentry"]
prs = [14663]
file_name = "14663_shader_storage_buffer.md"

[[release_notes]]
title = "Accumulated mouse inputs"
authors = ["@Aztro-dev", "@alice-i-cecile"]
contributors = []
prs = [14044]
file_name = "14044_Accumulated_mouse_inputs.md"

[[release_notes]]
title = "Stable interpolation and smooth following"
authors = ["@mweatherley"]
Expand Down

0 comments on commit fc35cb3

Please sign in to comment.