-
Notifications
You must be signed in to change notification settings - Fork 2
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 2D rigid bodies that can be added to the physics world with configurable
mass, velocity, and body type (static, dynamic, kinematic).
Current State
Requires PhysicsWorld2D to be implemented. No rigid body support exists.
Scope
Goals:
- Create static rigid bodies (immovable, infinite mass)
- Create dynamic rigid bodies (affected by forces/gravity)
- Create kinematic rigid bodies (user-controlled movement)
- Set position, rotation, velocity
- Apply forces and impulses
Non-Goals:
- Collision shapes
- Collision response
- Joints/constraints
Proposed API
pub enum RigidBodyType {
Static,
Dynamic,
Kinematic,
}
pub struct RigidBody2D {
// handle to physics world body
}
pub struct RigidBody2DBuilder {
body_type: RigidBodyType,
position: [f32; 2],
rotation: f32,
mass: f32,
}
impl RigidBody2DBuilder {
pub fn new(body_type: RigidBodyType) -> Self;
pub fn with_position(self, x: f32, y: f32) -> Self;
pub fn with_rotation(self, radians: f32) -> Self;
pub fn with_mass(self, mass: f32) -> Self;
pub fn build(self, world: &mut PhysicsWorld2D) -> RigidBody2D;
}
impl RigidBody2D {
pub fn position(&self) -> [f32; 2];
pub fn rotation(&self) -> f32;
pub fn set_position(&mut self, x: f32, y: f32);
pub fn set_velocity(&mut self, vx: f32, vy: f32);
pub fn apply_force(&mut self, fx: f32, fy: f32);
pub fn apply_impulse(&mut self, ix: f32, iy: f32);
}Acceptance Criteria
- Static bodies remain fixed regardless of forces
- Dynamic bodies respond to gravity and forces
- Kinematic bodies can be moved programmatically
- Position and rotation can be queried after stepping
- Forces and impulses affect dynamic bodies correctly
Affected Crates
lambda-rs, lambda-rs-platform
Notes
- Bodies without shapes won't collide but can still move
- Handle system prevents dangling references
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