Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#797 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
javascript, rust
Lĩnh vực
game-dev

Hướng nghiên cứu

Tái hiện vấn đề với @dimforge/rapier2d-compat 0.14.0 bằng cách khôi phục cùng một snapshot của World, sau đó áp dụng rigidBody.setRotation hoặc collider.setRotationWrtParent trước khi chạy các lần mô phỏng lặp lại. So sánh kết quả với trường hợp chỉ khôi phục snapshot và kiểm tra hành vi của các phương thức này cũng như World.restoreSnapshot. Được xem là hoàn tất khi kết quả giống hệt nhau giữa các lần chạy và hành vi nhất quán với restriction của collider đã được tài liệu hóa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
5.8k
Fork
401
Merge trung bình
1 ngày 13 giờ
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dimforge/rapier

Tất cả issue của dimforge/rapier

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.