mirror of
https://github.com/bevyengine/bevy
synced 2024-11-21 20:23:28 +00:00
Trivial bevy_picking
refactor (#16374)
# Objective Remove the rebinding and use `Rect::contains` in `bevy_picking::pointer::Location::is_in_viewport`.
This commit is contained in:
parent
a8c610a52d
commit
7b935c424b
1 changed files with 2 additions and 6 deletions
|
@ -9,7 +9,7 @@
|
||||||
//! driven by lower-level input devices and consumed by higher-level interaction systems.
|
//! driven by lower-level input devices and consumed by higher-level interaction systems.
|
||||||
|
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_math::{Rect, Vec2};
|
use bevy_math::Vec2;
|
||||||
use bevy_reflect::prelude::*;
|
use bevy_reflect::prelude::*;
|
||||||
use bevy_render::camera::{Camera, NormalizedRenderTarget};
|
use bevy_render::camera::{Camera, NormalizedRenderTarget};
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
|
@ -233,13 +233,9 @@ impl Location {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let position = Vec2::new(self.position.x, self.position.y);
|
|
||||||
|
|
||||||
camera
|
camera
|
||||||
.logical_viewport_rect()
|
.logical_viewport_rect()
|
||||||
.map(|Rect { min, max }| {
|
.map(|rect| rect.contains(self.position))
|
||||||
(position - min).min_element() >= 0.0 && (position - max).max_element() <= 0.0
|
|
||||||
})
|
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue