mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
Perform relative_cursor_position
calculation vectorwise in ui_focus_system
(#8795)
# Objective This calculation is performed componentwise but all the values are vectors so it should be using vector operations. Works correctly with the `relative_cursor_position` example.
This commit is contained in:
parent
dc3de5f9b8
commit
a1494e53df
1 changed files with 2 additions and 6 deletions
|
@ -227,12 +227,8 @@ pub fn ui_focus_system(
|
|||
|
||||
// The mouse position relative to the node
|
||||
// (0., 0.) is the top-left corner, (1., 1.) is the bottom-right corner
|
||||
let relative_cursor_position = cursor_position.map(|cursor_position| {
|
||||
Vec2::new(
|
||||
(cursor_position.x - min.x) / node.node.size().x,
|
||||
(cursor_position.y - min.y) / node.node.size().y,
|
||||
)
|
||||
});
|
||||
let relative_cursor_position = cursor_position
|
||||
.map(|cursor_position| (cursor_position - min) / node.node.size());
|
||||
|
||||
// If the current cursor position is within the bounds of the node, consider it for
|
||||
// clicking
|
||||
|
|
Loading…
Reference in a new issue