Repository navigation
[Feature] 2D joints and constraints #123
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestlambda-rsIssues pertaining to the core frameworkIssues pertaining to the core frameworklambda-rs-platformIssues pertaining to the dependency & platform wrappersIssues pertaining to the dependency & platform wrappersphysicsAll things related to physicsAll things related to physics
Description
Overview
Add joints that connect rigid bodies together with various constraint types
for doors, chains, vehicles, and character rigs.
Current State
No response
Scope
Goals:
- Revolute joint (hinge, rotation only)
- Prismatic joint (slider, translation only)
- Distance joint (fixed distance between points)
- Spring joint (soft distance constraint)
- Motor support on applicable joints
Non-Goals:
- Rope/chain simulation
- Breakable joints
- Gear joints
Proposed API
pub struct Joint2D {
// handle
}
pub struct RevoluteJointBuilder {
body_a: RigidBodyHandle,
body_b: RigidBodyHandle,
anchor_a: [f32; 2],
anchor_b: [f32; 2],
motor_speed: Option<f32>,
motor_torque: Option<f32>,
}
pub struct DistanceJointBuilder {
body_a: RigidBodyHandle,
body_b: RigidBodyHandle,
anchor_a: [f32; 2],
anchor_b: [f32; 2],
rest_length: f32,
stiffness: f32,
damping: f32,
}
impl RevoluteJointBuilder {
pub fn new(body_a: RigidBodyHandle, body_b: RigidBodyHandle) -> Self;
pub fn with_anchors(self, a: [f32; 2], b: [f32; 2]) -> Self;
pub fn with_motor(self, speed: f32, max_torque: f32) -> Self;
pub fn build(self, world: &mut PhysicsWorld2D) -> Joint2D;
}Acceptance Criteria
- Revolute joint constrains rotation around anchor
- Prismatic joint constrains to linear motion
- Distance joint maintains fixed distance
- Spring joint provides soft constraint with oscillation
- Motors can drive joint motion
- Example demonstrating a swinging door or pendulum
Affected Crates
lambda-rs, lambda-rs-platform
Notes
- Anchors in local body coordinates
- Stiffness/damping for spring behavior
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestlambda-rsIssues pertaining to the core frameworkIssues pertaining to the core frameworklambda-rs-platformIssues pertaining to the dependency & platform wrappersIssues pertaining to the dependency & platform wrappersphysicsAll things related to physicsAll things related to physics
Activity
fix(lambda-rs-args): Optimize parsed argument lookup and positional a…