concinnity_physics/types.rs
1// concinnity-physics/src/types.rs
2//
3// The collision shapes and body parameters the simulation is asked to build.
4// Plain data in the engine's `[f32; 3]` representation: no simulation math type
5// appears here, so a caller never has to name one.
6
7/// A collision shape, in the body's local space.
8#[derive(Debug, Clone, Copy, PartialEq)]
9pub enum ColliderShape {
10 /// Box with the given half-extents along x, y, z.
11 Cuboid {
12 /// Half-extents along each axis.
13 half_extents: [f32; 3],
14 },
15 /// Sphere of the given radius.
16 Ball {
17 /// Sphere radius.
18 radius: f32,
19 },
20 /// Y-axis capsule: a cylinder of `2 * half_height` capped by hemispheres.
21 Capsule {
22 /// Half the cylindrical section's height.
23 half_height: f32,
24 /// Cap and cylinder radius.
25 radius: f32,
26 },
27}
28
29/// Physical parameters for a dynamic (freely simulated) body.
30#[derive(Debug, Clone, Copy, PartialEq)]
31pub struct DynamicParams {
32 /// Mass in kilograms. `0.0` derives mass from the shape's volume.
33 pub mass: f32,
34 /// Coulomb friction coefficient.
35 pub friction: f32,
36 /// Bounciness in `[0, 1]`.
37 pub restitution: f32,
38 /// Multiplier on the world gravity for this body.
39 pub gravity_scale: f32,
40 /// Linear velocity damping (air drag).
41 pub linear_damping: f32,
42}