Floating Origin Physics

Amazing @georgie ! Thank you for make it easy for me. Any space game will really benefits from this. I documenting everything to post here my use of Babylon.js to this case. So I’ll update you if I find any bug.

Here is an updated playground of floating origin physics with Physics V2 (Havok) and the new large world rendering feature:

My bad the PG above does not work, it was a special case because the motion was along the Y axis and the bodies had small position values along that axis.

In the following PG, setting the origin shift to be along the Y axis breaks the impulse applied on that axis, while it works if the origin shift is along the X or Z axis:

I will work on a better solution

I guess we still need some origin rebasing to avoid feeding large coordinates in Havok:

Hey @CrashMaster and @Peipol I have added a feature to support floatingorigin in physics without you needing any custom position offsetting before sending values to havok.

The change is available in most recent patch and can be tested with playground, here is an example (built off of your original playground, which if you remove the manual offsetting you can see now works)

Floating Origin Physics with Havok | Babylon.js Playground

Thanks @georgie I’m hopping to return to the development of the space simulator in a few months. Is really nice of you informing us about this updates.

That looks very interesting thank you! This opens possibilities for 1:1 scale orbital mechanics driven by havok among other things :ok_hand:

I wonder if physics bodies can transition from one region to another? What if a spaceship starts in one region and travels to another region, will the collisions work or will the physics body need to be recreated?

@CrashMaster As of today bodies in separate regions will not collide (limitation of current implementation), however we can enhance the feature by adding in dynamic re-regioning so that if a body moves to a location that is outside its region, its world region gets updated.

This will likely come after 9.0 release :slight_smile:

@CrashMaster Alas, I checked in a change to dynamically re-region bodies so that far away objects can still collide, whether by physics simulation bringing them near one another or by manually ‘teleporting’ a body to a new location

So this will be part of the 9.0 release after all! And available in the patch version 8.51.1 (available in ~30 minutes)

Havok + FloatingOrigin: Dynamic re-regioning by georginahalpern · Pull Request #17892 · BabylonJS/Babylon.js

Wow that’s a welcome surprise! Thank you for implementing it so soon :heart: Looks like the remnants of my origin rebasing code are going to the recycler sooner than expected haha