Skip to main content

concinnity_core/components/
camera_probe.rs

1// src/components/camera_probe.rs
2
3use crate::ecs::SkinnedMeshHandle;
4
5/// Runtime-only occlusion probe for the third-person follow camera.
6///
7/// The third-person controller publishes one and refreshes `pivot` /
8/// `desired` (the orbit pivot and the unclamped camera position) every
9/// frame; `PhysicsSystem` (which steps earlier) raycasts from the pivot
10/// toward the previous frame's desired position and writes back the largest
11/// unobstructed `clearance`, excluding the followed character's own capsule.
12/// The controller then pulls the camera inside that distance so walls do not
13/// cut between camera and character.
14///
15/// Not authored in world files: it has no `args`.
16#[derive(Debug, Clone, Default)]
17pub struct CameraProbe {
18    /// The followed `SkinnedMesh`, whose rig capsule the ray must ignore.
19    pub target: SkinnedMeshHandle,
20    /// Orbit pivot in world space (the ray origin).
21    pub pivot: [f32; 3],
22    /// Unclamped camera position the controller wants this frame.
23    pub desired: [f32; 3],
24    /// Largest unobstructed distance from `pivot` toward `desired`, or
25    /// `None` when the path is clear (or unanswered).
26    pub clearance: Option<f32>,
27}