Skip to content

Commit 7935c7e

Browse files
authored
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`
1 parent 253cc6a commit 7935c7e

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

crates/bevy_picking/src/mesh_picking/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
//! to `true` and add a [`RayCastPickable`] component to the desired camera and target entities.
88
//!
99
//! To manually perform mesh ray casts independent of picking, use the [`MeshRayCast`] system parameter.
10+
//!
11+
//! ## Implementation Notes
12+
//!
13+
//! - The `position` reported in `HitData` is in world space. The `normal` is a vector pointing
14+
//! away from the face, it is not guaranteed to be normalized for scaled meshes.
1015
1116
pub mod ray_cast;
1217

crates/bevy_picking/src/window.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
//! window will be inserted as a pointer hit, listed behind all other pointer
77
//! hits. This means that when the pointer isn't hovering any other entities,
88
//! the picking events will be routed to the window.
9+
//!
10+
//! ## Implementation Notes
11+
//!
12+
//! - This backend does not provide `position` or `normal` in `HitData`.
913
1014
use core::f32;
1115

crates/bevy_sprite/src/picking_backend.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
//! A [`bevy_picking`] backend for sprites. Works for simple sprites and sprite atlases. Works for
22
//! sprites with arbitrary transforms. Picking is done based on sprite bounds, not visible pixels.
33
//! This means a partially transparent sprite is pickable even in its transparent areas.
4+
//!
5+
//! ## Implementation Notes
6+
//!
7+
//! - The `position` reported in `HitData` in in world space, and the `normal` is a normalized
8+
//! vector provided by the target's `GlobalTransform::back()`.
49
510
use crate::Sprite;
611
use bevy_app::prelude::*;

crates/bevy_ui/src/picking_backend.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
//! - `bevy_ui` can render on any camera with a flag, it is special, and is not tied to a particular
1919
//! camera.
2020
//! - To correctly sort picks, the order of `bevy_ui` is set to be the camera order plus 0.5.
21-
//! - The position reported in `HitData` is normalized relative to the node, with `(0.,0.,0.)` at the top
22-
//! left and `(1., 1., 0.)` in the bottom right. Coordinates are relative to the entire node, not just the visible region.
21+
//! - The `position` reported in `HitData` is normalized relative to the node, with `(0.,0.,0.)` at
22+
//! the top left and `(1., 1., 0.)` in the bottom right. Coordinates are relative to the entire
23+
//! node, not just the visible region. This backend does not provide a `normal`.
2324
2425
#![deny(missing_docs)]
2526

0 commit comments

Comments
 (0)