Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix check that cursor position is within window bounds (bevyengine#9662)
# Objective The recently introduced check that the cursor position returned by `Window::cursor_position()` is within the bounds of the window (bevyengine@3cf94e7) 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.
- Loading branch information