//! This module contains a basic backend that implements picking for window1//! entities.2//!3//! Pointers can exist on windows, images, and gpu texture views. With4//! [`update_window_hits`] enabled, when a pointer hovers over a window that5//! window will be inserted as a pointer hit, listed behind all other pointer6//! hits. This means that when the pointer isn't hovering any other entities,7//! the picking events will be routed to the window.8//!9//! ## Implementation Notes10//!11//! - This backend does not provide `position` or `normal` in `HitData`.1213use core::f32;1415use bevy_camera::NormalizedRenderTarget;16use bevy_ecs::prelude::*;1718use crate::{19backend::{HitData, PointerHits},20pointer::{Location, PointerId, PointerLocation},21};2223/// Generates pointer hit events for window entities.24///25/// A pointer is treated as hitting a window when it is located on that window. The order26/// of the hit event is negative infinity, meaning it should appear behind all other entities.27///28/// The depth of the hit will be listed as zero.29pub fn update_window_hits(30pointers: Query<(&PointerId, &PointerLocation)>,31mut output_events: EventWriter<PointerHits>,32) {33for (pointer_id, pointer_location) in pointers.iter() {34if let Some(Location {35target: NormalizedRenderTarget::Window(window_ref),36..37}) = pointer_location.location38{39let entity = window_ref.entity();40let hit_data = HitData::new(entity, 0.0, None, None);41output_events.write(PointerHits::new(42*pointer_id,43vec![(entity, hit_data)],44f32::NEG_INFINITY,45));46}47}48}495051