Skip to content

[Feature] 2D rigid body creation and management #119

Description

@vmarcella

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

pubenumRigidBodyType{Static,Dynamic,Kinematic,}pubstructRigidBody2D{// handle to physics world body}pubstructRigidBody2DBuilder{body_type:RigidBodyType,position:[f32;2],rotation:f32,mass:f32,}implRigidBody2DBuilder{pubfnnew(body_type:RigidBodyType) -> Self;pubfnwith_position(self,x:f32,y:f32) -> Self;pubfnwith_rotation(self,radians:f32) -> Self;pubfnwith_mass(self,mass:f32) -> Self;pubfnbuild(self,world:&mutPhysicsWorld2D) -> RigidBody2D;}implRigidBody2D{pubfnposition(&self) -> [f32;2];pubfnrotation(&self) -> f32;pubfnset_position(&mutself,x:f32,y:f32);pubfnset_velocity(&mutself,vx:f32,vy:f32);pubfnapply_force(&mutself,fx:f32,fy:f32);pubfnapply_impulse(&mutself,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

No one assigned

    Labels

    enhancementNew feature or requestlambda-rsIssues pertaining to the core frameworklambda-rs-platformIssues pertaining to the dependency & platform wrappersphysicsAll things related to physics

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions