Uh oh!
There was an error while loading. Please reload this page.
feat(lambda-rs): Add 2d collision events - #201
Conversation
✅ Coverage Report📊 View Full HTML Report (download artifact) Overall Coverage
Changed Files in This PR
PR Files Coverage: 81.64% (3153/3862 lines) Generated by cargo-llvm-cov · Latest main coverage Last updated: 2026-04-03 19:19:18 UTC · Commit: |
There was a problem hiding this comment.
Pull request overview
Adds 2D collision queries, collision filtering, and post-step collision start/end events to the physics-2d feature, including backend Rapier support plus docs, tests, and a new demo/tutorial to validate and illustrate the intended gameplay-facing workflow.
Changes:
- Extend
lambda-rspublic 2D physics API with collision events, collision filters, and point/AABB/raycast queries. - Implement Rapier-backed event aggregation (body-pair scoped), collision group/mask filtering, and live-collider spatial queries in
lambda-rs-platform. - Add integration tests, a new demo binary, and accompanying specs/tutorial documentation.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/tutorials/README.md | Adds the new collision-events tutorial entry and updates index metadata/changelog. |
| docs/tutorials/physics/basics/collision-events-2d.md | New tutorial describing the collision events demo and usage pattern. |
| docs/specs/README.md | Adds the collision queries/events spec entry and updates metadata/changelog. |
| docs/specs/physics/collision-queries-and-events-2d.md | New spec defining 2D collision queries/events/filtering contract. |
| docs/features.md | Updates physics-2d feature documentation to include queries/events/filtering. |
| demos/physics/Cargo.toml | Registers the new physics_collision_events_2d demo binary. |
| demos/physics/src/bin/physics_collision_events_2d.rs | New demo showcasing start/end events and tint changes while in contact. |
| crates/lambda-rs/tests/physics_2d/mod.rs | Wires new physics-2d test modules (events/filters/queries). |
| crates/lambda-rs/tests/physics_2d/collision_events.rs | New integration tests for event start/end, queue draining, and compound-body dedup. |
| crates/lambda-rs/tests/physics_2d/collision_filters.rs | New integration tests validating group/mask collision filtering. |
| crates/lambda-rs/tests/physics_2d/queries.rs | New integration tests for point/AABB/raycast queries and dedup behavior. |
| crates/lambda-rs/src/physics/rigid_body_2d.rs | Adds internal constructor for rebuilding public handles from backend slot ids. |
| crates/lambda-rs/src/physics/mod.rs | Adds public types (CollisionEvent/Kind, CollisionFilter, RaycastHit) and world query/event APIs. |
| crates/lambda-rs/src/physics/collider_2d.rs | Adds per-collider collision filter configuration and forwards it to the backend. |
| crates/lambda-rs-platform/src/physics/mod.rs | Re-exports new backend-neutral event/query payload types. |
| crates/lambda-rs-platform/src/physics/rapier2d.rs | Implements filtering, live-collider queries, and aggregated body-pair collision event collection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Add 2D collision queries, collision filtering, and collision start/end events
to the
physics-2dfeature.Related Issues
Changes
lambda-rs:CollisionEventKindCollisionEventCollisionFilterRaycastHitPhysicsWorld2D::collision_events()PhysicsWorld2D::query_point()PhysicsWorld2D::query_aabb()PhysicsWorld2D::raycast()Collider2DBuilder::with_collision_filter()lambda-rs-platformRapier integration for:Startedcollision eventsEndedcollision eventsbe reconstructed as stable
RigidBody2Dhandlesdemos/physics/src/bin/physics_collision_events_2d.rsdocs/features.mdupdate forphysics-2dType of Change
Affected Crates
lambda-rslambda-rs-platformlambda-rs-argslambda-rs-loggingdemos/physics,docs/specs,docs/tutorialsChecklist
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_collision_events_2d.Startedevent being logged.Spacewhile the ball is grounded to apply the launch impulse.Endedevent, and theball tint returning to its non-contact state.
Screenshots/Recordings
Not included. The main visual change is the new
physics_collision_events_2ddemo.Platform Testing
Additional Notes
first simulation step.
collision_events()is a post-step drain rather than a callback system,which keeps gameplay logic outside backend simulation execution.