0XDE57 / SpaceProject

An arcadey physics based top-down 2D, procedurally generated asteroid miner sandbox game using libGDX.
Apache License 2.0
38 stars 9 forks source link

"warning: broken physics ahead" -> deep space travel #5

Open 0XDE57 opened 1 year ago

0XDE57 commented 1 year ago

Large world space coordinates will introduce inaccuracy, courtesy of floating point arithmetic rounding: epsilon.

Floating point errors in deep space caused by large world coordinates and small frame times is affecting movement physics and rendering. Meaning the deeper in space we go, the more "stuff" begins to break.

According to the documentation: Caution: Box2D works best with world sizes less than 2 kilometers. Use b2World::ShiftOrigin to support larger worlds.

The universe by contrast, is a little bit bigger than 2km....

To solve this we can use a local coordinate system and a large global coordinate system. see: 'Floating Origin' -> b2World::ShiftOrigin

0XDE57 commented 1 year ago

https://randomascii.wordpress.com/2012/02/13/dont-store-that-in-a-float/ https://www.youtube.com/watch?v=mXTxQko-JH0&t=4m18s