Overview
Add collision shapes that can be attached to rigid bodies to enable collision
detection. Support common 2D primitives.
Current State
No collision shapes exist & requires rigid bodies to be implemented.
Scope
Goals:
- Circle collider (position, radius)
- Rectangle/box collider (half-extents)
- Capsule collider (height, radius)
- Convex polygon collider
- Attach multiple shapes to one body
Non-Goals:
- Concave/decomposed shapes (deferred)
- Collision detection callbacks
- Collision layers/masks
Proposed API
pub struct Collider2D {
// handle
}
pub enum ColliderShape2D {
Circle { radius: f32 },
Rectangle { half_width: f32, half_height: f32 },
Capsule { half_height: f32, radius: f32 },
ConvexPolygon { vertices: Vec<[f32; 2]> },
}
pub struct Collider2DBuilder {
shape: ColliderShape2D,
offset: [f32; 2],
density: f32,
friction: f32,
restitution: f32,
}
impl Collider2DBuilder {
pub fn circle(radius: f32) -> Self;
pub fn rectangle(half_width: f32, half_height: f32) -> Self;
pub fn capsule(half_height: f32, radius: f32) -> Self;
pub fn polygon(vertices: Vec<[f32; 2]>) -> Self;
pub fn with_offset(self, x: f32, y: f32) -> Self;
pub fn with_density(self, density: f32) -> Self;
pub fn with_friction(self, friction: f32) -> Self;
pub fn with_restitution(self, bounce: f32) -> Self;
pub fn build(self, body: &mut RigidBody2D) -> Collider2D;
}
Acceptance Criteria
Affected Crates
lambda-rs, lambda-rs-platform
Notes
- Density affects mass calculation
- Restitution: 0 = no bounce, 1 = perfect bounce
- Friction: 0 = ice, 1 = high grip
Overview
Add collision shapes that can be attached to rigid bodies to enable collision
detection. Support common 2D primitives.
Current State
No collision shapes exist & requires rigid bodies to be implemented.
Scope
Goals:
Non-Goals:
Proposed API
Acceptance Criteria
Affected Crates
lambda-rs, lambda-rs-platform
Notes