bevy/crates
Martin Dickopp a166b65241
Fix check that cursor position is within window bounds (#9662)
# Objective

The recently introduced check that the cursor position returned by
`Window::cursor_position()` is within the bounds of the window
(3cf94e7c9d)
has the following issue:

If *w* is the window width, points within the window satisfy the
condition 0 ≤ *x* < *w*, but the code assumes the condition 0 ≤ *x* ≤
*w*. In other words, if *x* = *w*, the point is not within the window
bounds. Likewise for the height. This program demonstrates the issue:

```rust
use bevy::{prelude::*, window::WindowResolution};

fn main() {
    let mut window = Window {
        resolution: WindowResolution::new(100.0, 100.0),
        ..default()
    };

    window.set_cursor_position(Some(Vec2::new(100.0, 0.0)));

    println!("{:?}", window.cursor_position());
}
```

It prints `Some(Vec2(100.0, 0.0))` instead of the expected `None`.

## Solution

- Exclude the upper bound, i.e., the window width for the *x* position
and the window height for the *y* position.
2023-09-03 13:27:21 +00:00
..
bevy_a11y Bump Version after Release (#9106) 2023-07-10 21:19:27 +00:00
bevy_animation Fixing some doc comments (#9646) 2023-08-31 19:05:49 +00:00
bevy_app Refactor EventReader::iter to read (#9631) 2023-08-30 14:20:03 +00:00
bevy_asset Fixing some doc comments (#9646) 2023-08-31 19:05:49 +00:00
bevy_audio Fixing some doc comments (#9646) 2023-08-31 19:05:49 +00:00
bevy_core Remove Resource and add Debug to TaskPoolOptions (#9485) 2023-08-20 22:32:41 +00:00
bevy_core_pipeline Remove redundant math in tonemapping. (#9669) 2023-09-02 21:11:40 +00:00
bevy_derive bevy_derive: Fix #[deref] breaking other attributes (#9551) 2023-08-28 17:36:18 +00:00
bevy_diagnostic Add DiagnosticsStore::iter_mut (#9679) 2023-09-03 13:26:13 +00:00
bevy_dylib Bump Version after Release (#9106) 2023-07-10 21:19:27 +00:00
bevy_dynamic_plugin Bump Version after Release (#9106) 2023-07-10 21:19:27 +00:00
bevy_ecs Fix unsoundness in QueryState::is_empty (#9463) 2023-09-02 23:43:22 +00:00
bevy_ecs_compile_fail_tests Fix CI for Rust 1.72 (#9562) 2023-08-25 12:34:24 +00:00
bevy_encase_derive Bump Version after Release (#9106) 2023-07-10 21:19:27 +00:00
bevy_gilrs Refactor EventReader::iter to read (#9631) 2023-08-30 14:20:03 +00:00
bevy_gizmos Reorder render sets, refactor bevy_sprite to take advantage (#9236) 2023-08-27 14:33:49 +00:00
bevy_gltf only take up to the max number of joints (#9351) 2023-08-28 16:58:45 +00:00
bevy_hierarchy Split ComputedVisibility into two components to allow for accurate change detection and speed up visibility propagation (#9497) 2023-09-01 13:00:18 +00:00
bevy_input Refactor EventReader::iter to read (#9631) 2023-08-30 14:20:03 +00:00
bevy_internal fix clippy::default_constructed_unit_structs and trybuild errors (#9144) 2023-07-13 22:23:04 +00:00
bevy_log Update tracy-client requirement from 0.15 to 0.16 (#9436) 2023-08-15 07:45:21 +00:00
bevy_macro_utils Add some more helpful errors to BevyManifest when it doesn't find Cargo.toml (#9207) 2023-07-19 12:05:04 +00:00
bevy_macros_compile_fail_tests bevy_derive: Fix #[deref] breaking other attributes (#9551) 2023-08-28 17:36:18 +00:00
bevy_math Fix erronenous glam version (#9653) 2023-08-31 12:55:17 +00:00
bevy_mikktspace Fix erronenous glam version (#9653) 2023-08-31 12:55:17 +00:00
bevy_pbr Explicitly make instance_index vertex output @interpolate(flat) (#9675) 2023-09-02 18:11:13 +00:00
bevy_ptr Put #[repr(transparent)] attr to bevy_ptr types (#9068) 2023-07-14 18:55:15 +00:00
bevy_reflect Fix some nightly warnings (#9672) 2023-09-02 18:35:06 +00:00
bevy_reflect_compile_fail_tests Fix CI for Rust 1.72 (#9562) 2023-08-25 12:34:24 +00:00
bevy_render Improve SpatialBundle docs (#9673) 2023-09-02 23:44:12 +00:00
bevy_scene Fix some nightly warnings (#9672) 2023-09-02 18:35:06 +00:00
bevy_sprite Use instancing for sprites (#9597) 2023-09-02 18:03:19 +00:00
bevy_tasks elaborate on TaskPool and bevy tasks (#8750) 2023-08-11 21:07:28 +00:00
bevy_text Split ComputedVisibility into two components to allow for accurate change detection and speed up visibility propagation (#9497) 2023-09-01 13:00:18 +00:00
bevy_time Move schedule name into Schedule (#9600) 2023-08-28 20:44:48 +00:00
bevy_transform Fixing some doc comments (#9646) 2023-08-31 19:05:49 +00:00
bevy_ui bevy_ui: reflect missing types (#9677) 2023-09-02 20:41:17 +00:00
bevy_utils Add system.map(...) for transforming the output of a system (#8526) 2023-08-28 16:36:46 +00:00
bevy_window Fix check that cursor position is within window bounds (#9662) 2023-09-03 13:27:21 +00:00
bevy_winit Fix some nightly warnings (#9672) 2023-09-02 18:35:06 +00:00