rapier.js icon indicating copy to clipboard operation
rapier.js copied to clipboard

How to better handle large-scale simulations with huge numeric values

Open ShineLuLu opened this issue 4 months ago • 4 comments

Hi, I'm new to Rapier and really appreciate the great work on this physics engine. I'm currently using Rapier.js in a frontend project for geospatial applications. One issue I’ve run into is that the Earth isn’t flat — gravity direction varies across regions. I handled this by updating the gravity vector dynamically, which works fine. However, another problem is that my data values are typically very large and require high precision. Scaling them down for simulation leads to noticeable precision loss, and I haven’t found a good workaround. I suspect this is because Rapier is optimized for small-scale scenes and uses Float32 internally. Would it be possible to optionally enable Float64 precision, even at the cost of performance? Or are there recommended approaches for handling large-scale simulations accurately? Thanks!

ShineLuLu avatar Sep 28 '25 07:09 ShineLuLu

Hi! While the Rust version of Rapier does have a 64-bits version, we haven’t built bindings for them. Your best alternative would be to have multiple Rapier scenes, each with a different local origin (the local origin being an implicit coordinate system you know your rigid-bodies for that scene are relative to).

sebcrozet avatar Sep 28 '25 09:09 sebcrozet

@sebcrozet Currently, I am indeed doing it this way, but I'm not entirely sure if the physical simulations, such as object collisions across different scenarios, will function properly. If they don't, it could significantly increase the workload to further handle these interactions. Do you have plans to develop a 64-bit version in the future? It would likely be more beneficial for a wider range of applications.

ShineLuLu avatar Sep 28 '25 11:09 ShineLuLu

@ShineLuLu This is currently not planned unless there is a significant increase in demand for it, or if I can get it funded somehow.

sebcrozet avatar Sep 28 '25 12:09 sebcrozet

@sebcrozet Okay, got it. Thank you for your reply.

ShineLuLu avatar Sep 28 '25 15:09 ShineLuLu