concinnity_physics/joints.rs
1// concinnity-physics/src/joints.rs
2//
3// The constraint shapes the simulation can be asked to build between two
4// bodies.
5// Angles are radians and velocities are per-second: the authored degrees are
6// converted once, by whoever reads the asset.
7
8/// Constraint shape connecting two bodies.
9#[derive(Debug, Clone, Copy, PartialEq)]
10pub enum JointSpec {
11 /// All six degrees of freedom locked: the bodies move and rotate as one
12 /// rigid assembly relative to their anchors.
13 Fixed,
14 /// Hinge: rotation is allowed only around one axis.
15 Revolute {
16 /// Hinge axis, in each body's local frame.
17 axis: [f32; 3],
18 /// Clamps the hinge angle, in radians.
19 limits: Option<[f32; 2]>,
20 /// Drives the hinge at a target angular velocity.
21 motor: Option<JointMotor>,
22 },
23 /// Ball-and-socket: translation locked, all three rotational axes free.
24 Spherical,
25 /// Slider: translation is allowed only along one axis.
26 Prismatic {
27 /// Slide axis, in each body's local frame.
28 axis: [f32; 3],
29 /// Clamps the slide distance, in world units.
30 limits: Option<[f32; 2]>,
31 /// Drives the slide at a target linear velocity.
32 motor: Option<JointMotor>,
33 },
34}
35
36/// Velocity-driven motor parameters for a revolute or prismatic joint.
37#[derive(Debug, Clone, Copy, PartialEq)]
38pub struct JointMotor {
39 /// Target velocity: radians/second for revolute, units/second for prismatic.
40 pub target_velocity: f32,
41 /// Maximum force the motor may apply to reach the target.
42 pub max_force: f32,
43}