Replace Rapier physics crate with a Jolt-backed jolt_physics crate#39
Open
GuilhermeGSousa wants to merge 3 commits into
Open
Replace Rapier physics crate with a Jolt-backed jolt_physics crate#39GuilhermeGSousa wants to merge 3 commits into
GuilhermeGSousa wants to merge 3 commits into
Conversation
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
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.
Add a new
jolt_physicscrate that implements the same physics API on topof Jolt Physics via the raw
joltc-sysC bindings, wrapped in a thinhand-written safe layer, and remove the old Rapier-based
physicscrate.PhysicsStateowns the Jolt system plus its collision-layer interfaces,freeing the system before the interfaces it references;
PhysicsPipelineowns the temp allocator and job-system thread pool. Both carry justified
unsafe impl Send + Syncbacked by the ECS scheduler's exclusive ResMutaccess guarantee, and free their resources in
Drop.BodyId(u32), so they are naturally Send + Sync.SetShapeinmake_sphere/make_cuboid; parentless cuboids become staticbodies for level geometry.
jolt_physics.Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01J4hfgWjZDvKQk4wiCSKogV