Skip to content

Preserve soft-rigid warm-start contacts across snapshot restores - #1052

Open
notferdon wants to merge 1 commit into
dimforge:masterfrom
notferdon:ferdon-soft-rigid-snapshot-clean
Open

notferdon wants to merge 1 commit into
dimforge:masterfrom
notferdon:ferdon-soft-rigid-snapshot-clean

Conversation

@notferdon

Copy link
Copy Markdown

Summary

  • Preserve RigidPairContacts::soft in snapshots instead of dropping its soft-rigid vertex contacts and warm-start impulses during serialization.
  • Add the required serialization derives for the nested soft-contact state, without changing the solver's step logic.
  • Add a pinned-cloth/rigid-ball snapshot continuation regression, update the native 2D/3D snapshot portability goldens, and document the snapshot format change.

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::soft is currently excluded by serde(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

  • The new soft_rigid_cloth_and_ball regression fails on pristine 475caa3 and passes after the change. It asserts active contact at the snapshot boundary to guard against a vacuous future pass.
  • The patched 3D snapshot_roundtrip suite: 9 passed, 1 existing ignored, 0 failed.
  • Native snapshot_portability tests for 2D and 3D: both original goldens pass on pristine master; both updated goldens pass after the patch.
  • Focused 2D/3D serde-serialize compile checks pass with explicit required dimension/precision features. Formatting and git diff --check pass.
  • The standalone native harness confirms unchanged no-snapshot cloth/rigid trajectories across the source repair in the tested 160-step cases.
  • Not run locally: wasm32-wasip1 cross-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).

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

No deployments
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.

1 participant