Skip to content

Replace Rapier physics crate with a Jolt-backed jolt_physics crate#39

Open
GuilhermeGSousa wants to merge 3 commits into
masterfrom
claude/physics-crate-jolt-backend-sqccpe
Open

Replace Rapier physics crate with a Jolt-backed jolt_physics crate#39
GuilhermeGSousa wants to merge 3 commits into
masterfrom
claude/physics-crate-jolt-backend-sqccpe

Conversation

@GuilhermeGSousa

Copy link
Copy Markdown
Owner

Add a new jolt_physics crate that implements the same physics API on top
of Jolt Physics via the raw joltc-sys C bindings, wrapped in a thin
hand-written safe layer, and remove the old Rapier-based physics crate.

  • Global one-time Jolt init (allocator/factory/types) via OnceLock.
  • PhysicsState owns the Jolt system plus its collision-layer interfaces,
    freeing the system before the interfaces it references; PhysicsPipeline
    owns the temp allocator and job-system thread pool. Both carry justified
    unsafe impl Send + Sync backed by the ECS scheduler's exclusive ResMut
    access guarantee, and free their resources in Drop.
  • Components store a plain BodyId (u32), so they are naturally Send + Sync.
  • Bodies are created with a placeholder shape and given their real shape via
    SetShape in make_sphere/make_cuboid; parentless cuboids become static
    bodies for level geometry.
  • A build script links the C++ standard library that the Jolt archives need.
  • Integration test drops a sphere onto a static floor and asserts it settles.
  • Switch the root crate and the game example over to jolt_physics.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01J4hfgWjZDvKQk4wiCSKogV

claude added 3 commits June 19, 2026 17:33
Add a new `jolt_physics` crate that implements the same physics API on top
of Jolt Physics via the raw `joltc-sys` C bindings, wrapped in a thin
hand-written safe layer, and remove the old Rapier-based `physics` crate.

- Global one-time Jolt init (allocator/factory/types) via OnceLock.
- `PhysicsState` owns the Jolt system plus its collision-layer interfaces,
  freeing the system before the interfaces it references; `PhysicsPipeline`
  owns the temp allocator and job-system thread pool. Both carry justified
  `unsafe impl Send + Sync` backed by the ECS scheduler's exclusive ResMut
  access guarantee, and free their resources in `Drop`.
- Components store a plain `BodyId` (u32), so they are naturally Send + Sync.
- Bodies are created with a placeholder shape and given their real shape via
  `SetShape` in `make_sphere`/`make_cuboid`; parentless cuboids become static
  bodies for level geometry.
- A build script links the C++ standard library that the Jolt archives need.
- Integration test drops a sphere onto a static floor and asserts it settles.
- Switch the root crate and the game example over to `jolt_physics`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4hfgWjZDvKQk4wiCSKogV
A small headless example that drives Jolt directly (no window/GPU): it builds
a static floor and drops two dynamic spheres, advancing the simulation with
PhysicsPipeline and printing each body's height over time. It then verifies
the lower sphere rests on the floor and the upper sphere rests on the lower
one, demonstrating both sphere-vs-floor and sphere-vs-sphere collisions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4hfgWjZDvKQk4wiCSKogV
Replace the headless console example with a minimal windowed scene: a camera,
a light, a static floor, and several dynamic spheres dropped from increasing
heights. The spheres fall under gravity and collide with the floor and each
other via the engine's PhysicsPlugin. All meshes (plane + UV sphere) are
generated in code, so no asset files or build script are needed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4hfgWjZDvKQk4wiCSKogV
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