Skip to main content

concinnity_core/components/
ground_probes.rs

1// src/components/ground_probes.rs
2
3use alloc::vec::Vec;
4
5use crate::ecs::SkinnedMeshHandle;
6
7/// One downward ground probe: a ray and, once physics has answered it, the
8/// hit it found.
9#[derive(Debug, Clone, Copy, Default)]
10pub struct GroundProbe {
11    /// Ray origin in world space.
12    pub origin: [f32; 3],
13    /// Maximum hit distance along -Y from the origin.
14    pub max_dist: f32,
15    /// The surface point and normal the ray found, or `None` (unanswered,
16    /// or no ground within range).
17    pub hit: Option<([f32; 3], [f32; 3])>,
18}
19
20/// Runtime-only ground-probe exchange for one animated character.
21///
22/// `AnimationSystem` publishes one per graph target with IK chains and
23/// refreshes each probe's ray from the animated end-joint position every
24/// frame; `PhysicsSystem` (which steps earlier) answers the previous frame's
25/// rays with raycast hits. The one-frame-stale ray origin is invisible at
26/// animation rates.
27///
28/// Not authored in world files: it has no `args`.
29#[derive(Debug, Clone, Default)]
30pub struct GroundProbes {
31    /// The `SkinnedMesh` resource whose IK chains these probes serve.
32    pub target: SkinnedMeshHandle,
33    /// One probe per IK chain, in the graph's `ik_chains` order.
34    pub probes: Vec<GroundProbe>,
35}