-
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 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
- Circle colliders detect collisions correctly
- Rectangle colliders detect collisions correctly
- Capsule colliders work for character shapes
- Polygon colliders support arbitrary convex shapes
- Multiple colliders on one body work together
- Friction and restitution affect collision response
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
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