concinnity_core/physics/events.rs
1// What a step reports back: the ray hits a query answers, the sensor regions
2// something crossed, and the contacts strong enough to be worth hearing about.
3// All of it resolved to plain handles and vectors while the step still has
4// both sides of the pair in hand.
5
6use crate::physics::BodyHandle;
7
8/// One raycast hit: the surface point, its outward normal, and the distance
9/// from the ray origin.
10#[derive(Debug, Clone, Copy)]
11pub struct RayHit {
12 /// World-space surface point the ray hit.
13 pub point: [f32; 3],
14 /// Unit-length normal.
15 pub normal: [f32; 3],
16 /// Distance from the ray origin to the hit.
17 pub distance: f32,
18}
19
20/// One boundary crossing of a sensor region recorded during a step: something
21/// began or stopped overlapping the sensor tagged `tag`.
22#[derive(Debug, Clone, Copy)]
23pub struct SensorCrossing {
24 /// The caller's tag for the crossed sensor.
25 pub tag: u64,
26 /// The crossing body, `None` when it left the simulation this step.
27 pub other: Option<BodyHandle>,
28 /// `true` on the way in, `false` on the way out.
29 pub entered: bool,
30}
31
32/// One contact strong enough to pass the simulation's force threshold.
33#[derive(Debug, Clone, Copy)]
34pub struct ContactHit {
35 /// One side of the contact.
36 pub a: BodyHandle,
37 /// The other side of the contact.
38 pub b: BodyHandle,
39 /// Deepest contact point, in world space.
40 pub point: [f32; 3],
41 /// Unit-length normal, pointing from `a` toward `b`.
42 pub normal: [f32; 3],
43 /// Total contact impulse magnitude.
44 pub impulse: f32,
45}