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