feat(lambda-rs): Add 2d collision events #201
Merged
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.