Skip to main content

concinnity_core/physics/
mod.rs

1//! The rigid-body simulation, and the driver that runs it over a world.
2//!
3//! Two halves that stay apart all the way down. The simulation is the solver:
4//! the shapes, body parameters, joints, layer masks, and step results that
5//! cross the boundary between a caller and the [`Simulation`], plus the
6//! [`PhysicsBudget`] a world reserves its bodies against. Everything crossing
7//! that boundary is plain data in the engine's `[f32; 3]` and Euler-degree
8//! representation, addressed by an opaque [`BodyHandle`]. That is what lets the
9//! simulation hold whatever math types it likes without those types reaching a
10//! caller, and it names no engine domain type in either direction.
11//!
12//! The driver around it builds a simulation from the world's physics content at
13//! init, steps it on the fixed tick, and writes the results back as component
14//! data: prop bodies, character rigs, probes, contact shaping, and layer
15//! resolution. Where a module holds both halves they sit in separate files,
16//! never one.
17//!
18//! Nothing here reads a clock, a file, or a device. The one thing only a host
19//! can supply is threads, which it lends through [`PhysicsFanout`]; a world
20//! with none steps on the calling thread.
21
22// What the simulation reserves for a world, derived from the counts the world
23// is measured by, and the ledger row reporting it.
24mod budget;
25// The move input a character rig is driven by and the result it reports.
26mod character;
27// Contact-event shaping: per-frame batching and the per-pair refractory.
28mod contacts;
29// The authored assets turned into the simulation's shapes and parameters.
30mod convert;
31// What a step reports back: contact, ray, and sensor crossings.
32mod events;
33// What a step hands out as independent work, and the seam a host lends its
34// threads through.
35mod fanout;
36// The opaque body identity a caller addresses the simulation by.
37mod handle;
38// The sorted lookup containers the driver's indices are kept in.
39mod index;
40// Prev/curr pose snapshots blended by the frame's accumulator alpha.
41mod interp;
42// The constraints two bodies can be tied together by, and their motors.
43mod joints;
44// The membership/filter bit pair, and the named layers resolved onto it.
45mod layers;
46// Raycast probe answering for animation IK and the follow camera.
47mod probes;
48// Prop bodies with their handle -> entity and tracked-entity indices.
49mod props;
50// Root-motion character rigs: one kinematic capsule per `CharacterRig`.
51mod rig;
52// The solver: broadphase, narrowphase, islands, contacts, joints, CCD.
53mod sim;
54// The system that builds and steps the simulation from the world's bodies,
55// driven by an optional `PhysicsConfig`.
56mod system;
57// The world's floor: the heightfield collider and the noise it is sampled from.
58mod terrain;
59// The collider shapes and dynamic body parameters a caller builds bodies from.
60mod types;
61
62#[cfg(test)]
63mod bench;
64#[cfg(test)]
65mod test_world;
66#[cfg(test)]
67mod tests;
68
69pub use budget::{PhysicsBudget, PhysicsCounts};
70pub use character::{CharacterMove, CharacterMoveInput};
71pub use events::{ContactHit, RayHit, SensorCrossing};
72pub use fanout::{Fanout, Inline, PhysicsFanout, SerialFanout};
73pub use handle::BodyHandle;
74pub use joints::{JointMotor, JointSpec};
75pub use layers::LayerMask;
76pub use sim::{
77    CharacterCapsule, ShapeCast, ShapeCastHit, SimConfig, Simulation, euler_deg_from_quat,
78    quat_from_euler_deg,
79};
80pub use system::PhysicsSystem;
81pub use types::{ColliderShape, DynamicParams};
82
83/// Acceleration due to gravity in world units per second squared. Shared with
84/// the third-person controller so its jump takeoff matches the rig's fall.
85pub const GRAVITY: f32 = 20.0;