Conversation
…ther minor updates.
…orce is 0 in both dimensions
…, mass recomputing, and slot allocation
…ify collider attachment
| mesh_builder: &mut MeshBuilder, | ||
| x: f32, | ||
| y: f32, | ||
| ) -> &mut MeshBuilder { |
Check failure
Code scanning / clippy
mismatched types Error
| mesh_builder: &mut MeshBuilder, | ||
| x: f32, | ||
| y: f32, | ||
| ) -> &mut MeshBuilder { |
Check failure
Code scanning / clippy
mismatched types Error
| return mesh_builder.with_vertex( | ||
| VertexBuilder::new() | ||
| .with_position([x, y, 0.0]) | ||
| .with_normal([0.0, 0.0, 1.0]) | ||
| .with_color([1.0, 1.0, 1.0]) | ||
| .build(), | ||
| ); |
Check failure
Code scanning / clippy
mismatched types Error
| return mesh_builder.with_vertex( | ||
| VertexBuilder::new() | ||
| .with_position([x, y, 0.0]) | ||
| .with_normal([0.0, 0.0, 1.0]) | ||
| .with_color([1.0, 1.0, 1.0]) | ||
| .build(), | ||
| ); |
Check failure
Code scanning / clippy
mismatched types Error
| }, | ||
| ]; | ||
|
|
||
| let mut mesh_builder = MeshBuilder::new(); |
Check failure
Code scanning / clippy
use of moved value: mesh_builder Error
| }, | ||
| ]; | ||
|
|
||
| let mut mesh_builder = MeshBuilder::new(); |
Check failure
Code scanning / clippy
use of moved value: mesh_builder Error
| ]; | ||
|
|
||
| let mut mesh_builder = MeshBuilder::new(); | ||
| mesh_builder.with_attributes(attributes.clone()); |
Check failure
Code scanning / clippy
use of moved value: mesh_builder Error
| ]; | ||
|
|
||
| let mut mesh_builder = MeshBuilder::new(); | ||
| mesh_builder.with_attributes(attributes.clone()); |
Check failure
Code scanning / clippy
use of moved value: mesh_builder Error
| }); | ||
| } | ||
|
|
||
| let mesh = mesh_builder.build(); |
Check failure
Code scanning / clippy
use of moved value: mesh_builder Error
| }); | ||
| } | ||
|
|
||
| let mesh = mesh_builder.build(); |
Check failure
Code scanning / clippy
use of moved value: mesh_builder Error
There was a problem hiding this comment.
Pull request overview
Adds 2D collider support to the existing 2D rigid-body physics surface, including a backend implementation (Rapier), public builder APIs, integration tests, and a demo to exercise the new behavior.
Changes:
- Introduces
Collider2Dhandle types, shape enums, materials, andCollider2DBuilderwith validation inlambda-rs. - Implements Rapier-backed collider attachment (circle/rectangle/capsule/convex polygon) with compound-collider support and material combine semantics in
lambda-rs-platform. - Adds integration tests and a new
physics_colliders_2ddemo plus accompanying documentation/spec updates.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/specs/physics/colliders-2d.md | New draft spec defining 2D collider API/behavior/validation requirements. |
| docs/specs/README.md | Adds the colliders spec to the specs index and updates metadata. |
| demos/physics/src/bin/physics_colliders_2d.rs | New visual/demo app exercising collider shapes, materials, density, offsets/rotation, and compound colliders. |
| demos/physics/Cargo.toml | Registers the new physics_colliders_2d demo binary under physics-2d. |
| demos/README.md | Documents physics demos and how to run the new colliders demo. |
| crates/lambda-rs/tests/integration.rs | Adds a top-level integration test entrypoint and gates physics tests behind physics-2d. |
| crates/lambda-rs/tests/physics_2d/mod.rs | Adds a physics integration test module root and basic smoke tests. |
| crates/lambda-rs/tests/physics_2d/colliders.rs | Integration tests for collider shapes and local-rotation behavior. |
| crates/lambda-rs/tests/physics_2d/materials.rs | Integration tests validating friction/restitution/density effects. |
| crates/lambda-rs/tests/physics_2d/compound_colliders.rs | Integration tests validating compound colliders affect collision extent. |
| crates/lambda-rs/src/physics/mod.rs | Wires in and re-exports the new collider module/types. |
| crates/lambda-rs/src/physics/collider_2d.rs | Implements public collider API, validation, and backend calls. |
| crates/lambda-rs/src/physics/rigid_body_2d.rs | Adds internal helpers for backend slot access and “live handle” validation. |
| crates/lambda-rs-platform/src/physics/mod.rs | Re-exports the new backend collider error type. |
| crates/lambda-rs-platform/src/physics/rapier2d.rs | Adds collider storage/attachment, material combine encoding, and mass-planning for density-driven mass semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// Builds a Rapier rigid body builder with `lambda-rs` invariants applied. | ||
| /// | ||
| /// Bodies created by this backend do not lock the 2D rotation axis. Dynamic | ||
| /// bodies are expected to rotate in response to collisions. |
| //! 2D physics integration tests. | ||
| //! | ||
| //! These tests validate `lambda-rs` 2D physics behavior through the public API | ||
| //! surface, including cross-crate wiring through `lambda-rs-platform`. | ||
|
|
||
| mod colliders; | ||
| mod compound_colliders; | ||
| mod materials; | ||
|
|
||
| use lambda::physics::{ | ||
| PhysicsWorld2DBuilder, | ||
| RigidBody2DBuilder, | ||
| RigidBodyType, |
Summary
Add 2D collider support on top of the rigid body implementation, including
public builder APIs in
lambda-rs, Rapier-backed shape attachment inlambda-rs-platform, integration coverage, and a demo that exercises material,density, local transform, and compound-collider behavior.
This PR introduces circle, rectangle, capsule, and convex polygon colliders,
supports attaching multiple colliders to a single rigid body, and verifies
collision response through integration tests and a visual demo.
Related Issues
N/A
Changes
Collider2D,ColliderShape2D,Collider2DBuilder, and collidervalidation/error handling to
lambda-rsattachment to
lambda-rs-platformrigid body
to collider construction
compound-collider behavior
physics_colliders_2ddemo covering primitives, materials,density, local rotation, and compound colliders
lambda-rsand reduce backend errorhandling to backend-owned failures
Rapier combine rules
synchronization
Type of Change
Affected Crates
lambda-rslambda-rs-platformlambda-rs-argslambda-rs-loggingdemos/physicsChecklist
cargo +nightly fmt --all)cargo clippy --workspace --all-targets -- -D warnings)cargo test --workspace)Testing
Commands run:
Manual verification steps (if applicable):
cargo run -p lambda-demos-physics --bin physics_colliders_2d --features physics-2dthe floor, ramp, walls, and divider
density changes response to the applied impulse
Screenshots/Recordings
Not included in this draft.
Platform Testing
Additional Notes
tests were previously observed failing independently of the collider
simplification work and should be evaluated separately before merge.