Repository navigation
Conversation
Serialize soft-rigid contact history so restored cloth-and-rigid simulations continue deterministically. Add a failing-before/fixed-after round-trip regression, update native portability goldens, and document the snapshot format change.
This branch has not been deployed
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
RigidPairContacts::softin snapshots instead of dropping its soft-rigid vertex contacts and warm-start impulses during serialization.Why
In #1038, a restored world diverges from its live counterpart when a ball impacts a pinned cloth, despite immediately reserializing to identical bytes. The rigid-only control does not diverge.
RigidPairContacts::softis currently excluded byserde(skip)but is consumed as previous-step state to warm-start the next soft-rigid contact update.The reporter's published JS package and an independent Rust reproduction show 37/160 divergent snapshot steps, starting at k=48; the rigid control shows 0/160. Transferring this one state family to the restored world, or removing it from the live world, eliminates the mismatch in that fixture.
Tests and validation
soft_rigid_cloth_and_ballregression fails on pristine475caa3and passes after the change. It asserts active contact at the snapshot boundary to guard against a vacuous future pass.snapshot_roundtripsuite: 9 passed, 1 existing ignored, 0 failed.snapshot_portabilitytests for 2D and 3D: both original goldens pass on pristine master; both updated goldens pass after the patch.serde-serializecompile checks pass with explicit required dimension/precision features. Formatting andgit diff --checkpass.wasm32-wasip1cross-target portability checks (WASI runner unavailable), full crate suites and other soft–soft/tearing scenarios. Cross-target golden parity must be checked in CI.Snapshot compatibility
This changes the binary snapshot layout, including worlds without active soft bodies. Snapshots written before and after this change are not mutually loadable. Rapier's published snapshots are not documented as stable across engine versions; the format change is explicit in the changelog.
Scope
This addresses the soft–rigid contact reproduction in #1038. It does not claim to fix the separate cross-body overlap/tearing cases reported in the same issue. The PR intentionally does not use
Fixes #1038(which would close the broader issue).