Skip to content

refactor(lambda-rs-platform): split rapier2d implementation across multiple #202

Merged
vmarcella merged 1 commit intomainfrom
vmarcella/refactor-rapier2d
Apr 3, 2026
Merged

refactor(lambda-rs-platform): split rapier2d implementation across multiple #202
vmarcella merged 1 commit intomainfrom
vmarcella/refactor-rapier2d

Conversation

@vmarcella
Copy link
Copy Markdown
Member

Summary

Refactor the internal lambda-rs-platform 2D Rapier backend from a single
large source file into a rapier2d module. This keeps the
existing backend behavior and public exports unchanged while making the code
easier to navigate and maintain.

Related Issues

N/A

Changes

  • Replace crates/lambda-rs-platform/src/physics/rapier2d.rs with a
    folder-backed module at crates/lambda-rs-platform/src/physics/rapier2d/.
  • Keep the existing physics::rapier2d module path and PhysicsBackend2D
    exports stable through rapier2d/mod.rs.
  • Split the backend implementation by responsibility:
    • rigid_bodies.rs
    • colliders.rs
    • queries.rs
    • simulation.rs
    • helpers.rs
    • tests.rs
  • Move the existing unit tests into tests.rs without changing their
    assertions or backend semantics.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (updates to docs, specs, tutorials, or comments)
  • Refactor (code change that neither fixes a bug nor adds a feature)
  • Performance (change that improves performance)
  • Test (adding or updating tests)
  • Build/CI (changes to build process or CI configuration)

Affected Crates

  • lambda-rs
  • lambda-rs-platform
  • lambda-rs-args
  • lambda-rs-logging
  • Other:

Checklist

  • Code follows the repository style guidelines (cargo +nightly fmt --all)
  • Code passes clippy (cargo clippy --workspace --all-targets -- -D warnings)
  • Tests pass (cargo test --workspace)
  • New code includes appropriate documentation
  • Public API changes are documented
  • Breaking changes are noted in this PR description

Testing

Commands run:

cargo +nightly fmt --all
cargo test -p lambda-rs-platform rapier2d -- --nocapture
cargo test -p lambda-rs-platform --features physics-2d --lib physics::rapier2d -- --nocapture

Manual verification steps (if applicable):

Screenshots/Recordings

N/A

Platform Testing

  • macOS
  • Windows
  • Linux

Additional Notes

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

✅ Coverage Report

📊 View Full HTML Report (download artifact)

Overall Coverage

Metric Value
Total Line Coverage 72.95%
Lines Covered 13964 / 19143

Changed Files in This PR

File Coverage Lines
crates/lambda-rs-platform/src/physics/rapier2d.rs N/A (no coverage data)
crates/lambda-rs-platform/src/physics/rapier2d/colliders.rs 97.17% 240/247
crates/lambda-rs-platform/src/physics/rapier2d/helpers.rs 89.61% 207/231
crates/lambda-rs-platform/src/physics/rapier2d/mod.rs 0.00% 0/24
crates/lambda-rs-platform/src/physics/rapier2d/queries.rs 90.70% 78/86
crates/lambda-rs-platform/src/physics/rapier2d/rigid_bodies.rs 96.73% 266/275
crates/lambda-rs-platform/src/physics/rapier2d/simulation.rs 93.40% 99/106
crates/lambda-rs-platform/src/physics/rapier2d/tests.rs N/A (no coverage data)

PR Files Coverage: 91.84% (890/969 lines)


Generated by cargo-llvm-cov · Latest main coverage

Last updated: 2026-04-03 20:50:34 UTC · Commit: 3e1358e

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the lambda-rs-platform Rapier-backed 2D physics backend by splitting the former single rapier2d.rs implementation into a folder-backed physics::rapier2d module, keeping the module path and public exports stable while improving navigability and maintainability.

Changes:

  • Replaced crates/lambda-rs-platform/src/physics/rapier2d.rs with crates/lambda-rs-platform/src/physics/rapier2d/ and a mod.rs entrypoint.
  • Split backend implementation across focused submodules (rigid_bodies, colliders, queries, simulation, helpers).
  • Moved existing unit tests into rapier2d/tests.rs without changing assertions/semantics.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/lambda-rs-platform/src/physics/rapier2d/mod.rs New module entrypoint preserving public types/exports and wiring submodules.
crates/lambda-rs-platform/src/physics/rapier2d/rigid_bodies.rs Rigid body creation/state/force APIs extracted into a dedicated module.
crates/lambda-rs-platform/src/physics/rapier2d/colliders.rs Collider creation/attachment and debug slot validation extracted.
crates/lambda-rs-platform/src/physics/rapier2d/queries.rs Point/AABB/raycast query helpers extracted.
crates/lambda-rs-platform/src/physics/rapier2d/simulation.rs Stepping and collision event aggregation extracted.
crates/lambda-rs-platform/src/physics/rapier2d/helpers.rs Shared helper functions extracted (validation, friction encoding, contact selection, etc.).
crates/lambda-rs-platform/src/physics/rapier2d/tests.rs Unit tests moved from the old monolithic file into a module test file.
crates/lambda-rs-platform/src/physics/rapier2d.rs Removed monolithic backend source file (superseded by folder-backed module).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vmarcella vmarcella merged commit 4313b4b into main Apr 3, 2026
14 checks passed
@vmarcella vmarcella deleted the vmarcella/refactor-rapier2d branch April 3, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants