1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! Entity picking via ray casting.
//!
//! Pick entities under the mouse cursor or from arbitrary rays:
//!
//! - [`pick_entities`]: Find all entities intersecting a ray (bounding box)
//! - [`pick_closest_entity`]: Find the nearest entity
//! - `pick_entities_trimesh`: Precise mesh intersection (requires `physics`)
//! - [`PickingRay`]: Ray definition for custom picking
//! - [`PickingResult`]: Hit information (entity, distance, position)
//!
//! # Basic Picking (Bounding Boxes)
//!
//! Fast picking using axis-aligned bounding boxes:
//!
//! ```ignore
//! fn on_mouse_input(&mut self, world: &mut World, button: MouseButton, state: KeyState) {
//! if button == MouseButton::Left && state == KeyState::Pressed {
//! let mouse_pos = world.resources.input.mouse.position;
//! let ray = PickingRay::from_screen_position(world, mouse_pos);
//!
//! if let Some(result) = pick_closest_entity(world, &ray, &PickingOptions::default()) {
//! println!("Hit entity {:?} at distance {}", result.entity, result.distance);
//! self.selected = Some(result.entity);
//! }
//! }
//! }
//! ```
//!
//! # Precise Trimesh Picking
//!
//! For accurate mesh intersection (requires `physics` feature):
//!
//! ```ignore
//! // Register entity for trimesh picking (do once after spawning)
//! register_entity_for_trimesh_picking(world, entity);
//!
//! // Or register entire hierarchy
//! register_entity_hierarchy_for_trimesh_picking(world, root_entity);
//!
//! // Pick with mesh precision
//! if let Some(result) = pick_closest_entity_trimesh(world, &ray) {
//! let hit_position = result.position; // Exact world position
//! let hit_normal = result.normal; // Surface normal at hit
//! }
//! ```
//!
//! # Frustum Picking (Selection Box)
//!
//! Select multiple entities within a screen rectangle:
//!
//! ```ignore
//! let entities = pick_entities_in_frustum(
//! world,
//! start_screen_pos,
//! end_screen_pos,
//! &PickingOptions::default(),
//! );
//! ```
//!
//! # Ground Position from Screen
//!
//! Project screen position onto the ground plane:
//!
//! ```ignore
//! if let Some(ground_pos) = get_ground_position_from_screen(world, mouse_pos, 0.0) {
//! // ground_pos is Vec3 on the Y=0 plane
//! }
//! ```
//!
//! # Picking Options
//!
//! ```ignore
//! let options = PickingOptions {
//! max_distance: 1000.0, // Maximum ray distance
//! include_transparent: false, // Skip transparent materials
//! layer_mask: u32::MAX, // Filter by render layers
//! };
//! ```
//!
//! # PickingResult Fields
//!
//! | Field | Description |
//! |-------|-------------|
//! | `entity` | Hit entity handle |
//! | `distance` | Distance from ray origin |
//! | `position` | World-space hit point |
//! | `normal` | Surface normal (trimesh only) |
//!
//! [`pick_entities`]: queries::pick_entities
//! [`pick_closest_entity`]: queries::pick_closest_entity
//! [`PickingRay`]: queries::PickingRay
//! [`PickingResult`]: queries::PickingResult
pub use *;
pub use *;
pub use *;