Update picking docs to include position space (#17859)

# Objective

Add reference to reported position space in picking backend docs.

Fixes #17844 

## Solution

Add explanatory docs to the implementation notes of each picking
backend.

## Testing

`cargo r -p ci -- doc-check` & `cargo r -p ci -- lints`
This commit is contained in:
sam edelsten 2025-02-15 19:08:12 +00:00 committed by GitHub
parent 253cc6a77b
commit 7935c7e95f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 2 deletions

View File

@ -7,6 +7,11 @@
//! to `true` and add a [`RayCastPickable`] component to the desired camera and target entities.
//!
//! To manually perform mesh ray casts independent of picking, use the [`MeshRayCast`] system parameter.
//!
//! ## Implementation Notes
//!
//! - The `position` reported in `HitData` is in world space. The `normal` is a vector pointing
//! away from the face, it is not guaranteed to be normalized for scaled meshes.
pub mod ray_cast;

View File

@ -6,6 +6,10 @@
//! window will be inserted as a pointer hit, listed behind all other pointer
//! hits. This means that when the pointer isn't hovering any other entities,
//! the picking events will be routed to the window.
//!
//! ## Implementation Notes
//!
//! - This backend does not provide `position` or `normal` in `HitData`.
use core::f32;

View File

@ -1,6 +1,11 @@
//! A [`bevy_picking`] backend for sprites. Works for simple sprites and sprite atlases. Works for
//! sprites with arbitrary transforms. Picking is done based on sprite bounds, not visible pixels.
//! This means a partially transparent sprite is pickable even in its transparent areas.
//!
//! ## Implementation Notes
//!
//! - The `position` reported in `HitData` in in world space, and the `normal` is a normalized
//! vector provided by the target's `GlobalTransform::back()`.
use crate::Sprite;
use bevy_app::prelude::*;

View File

@ -18,8 +18,9 @@
//! - `bevy_ui` can render on any camera with a flag, it is special, and is not tied to a particular
//! camera.
//! - To correctly sort picks, the order of `bevy_ui` is set to be the camera order plus 0.5.
//! - The position reported in `HitData` is normalized relative to the node, with `(0.,0.,0.)` at the top
//! left and `(1., 1., 0.)` in the bottom right. Coordinates are relative to the entire node, not just the visible region.
//! - The `position` reported in `HitData` is normalized relative to the node, with `(0.,0.,0.)` at
//! the top left and `(1., 1., 0.)` in the bottom right. Coordinates are relative to the entire
//! node, not just the visible region. This backend does not provide a `normal`.
#![deny(missing_docs)]