Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Loss of determinism when using collider.setRotationWrtParent or rigidBody.setRotation

Aperta
#797 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
javascript, rust
Ambito
game-dev

Direzione di ricerca

Riproduci il problema con @dimforge/rapier2d-compat 0.14.0 ripristinando lo stesso snapshot di World, quindi applicando rigidBody.setRotation o collider.setRotationWrtParent prima di eseguire simulazioni ripetute. Confronta i risultati con il solo ripristino dello snapshot e analizza il comportamento di questi metodi e di World.restoreSnapshot. Il lavoro è completo quando i risultati sono identici tra le esecuzioni e il comportamento è coerente con la restrizione documentata di collider.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I have observed that the Rapier.js physics simulation loses determinism when using the collider.setRotationWrtParent and rigidBody.setRotation methods. Specifically, even when starting from the same initial state (restored via World.restoreSnapshot), the simulation outcomes differ every time these methods are applied. This behavior does not occur when only restoring the world snapshot without applying these methods.

Steps to Reproduce
  1. Restore the world from a snapshot:
 const world = RAPIER.World.restoreSnapshot(base64ToUint8Array(worldData.world));
  1. Apply one of the following methods:
  • For a rigid body:
const rigidBody = world.rigidBodies.get(rigidBodyHandle);
rigidBody.setRotation(0); // Breaks determinism
  • For a collider:
const collider = world.colliders.get(colliderHandle);
collider.setRotationWrtParent(0); // also breaks determinism, even when the collider is already attached to a rigid body. This behavior contradicts the documentation, which states: "Does nothing if this collider isn't attached to a rigid-body." However, based on my observations, the method appears to have an effect even when the collider is attached, potentially introducing non-deterministic behavior.
  1. Run the simulation multiple times and observe that the results differ each time.
Expected Behavior

The simulation should produce identical results every time it is run from the same initial state, regardless of whether collider.setRotationWrtParent or rigidBody.setRotation is used.

Actual Behavior

When collider.setRotationWrtParent or rigidBody.setRotation is called, the simulation outcomes vary between runs, breaking determinism.

Environment
  • Rapier.js version: @dimforge/rapier2d-compat 0.14.0
  • Browser: Chrome 132.0.6834.162 (Official Build) (x86_64)
  • Operating System: macOS
Additional Notes

It seems that these methods might introduce non-deterministic behavior due to floating-point precision issues or internal state changes that are not synchronized properly. This could be related to how the physics engine handles rotations internally.

Lingua principale
Rust
Stelle
5.9k
Fork
401
Merge medio
3h 47m
PR unite (30g)
11

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dimforge/rapier

Tutte le issue di dimforge/rapier

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.