freezy / VisualPinball.Engine

:video_game: Visual Pinball Engine for Unity
https://docs.visualpinball.org
GNU General Public License v3.0
396 stars 62 forks source link

Remove DOTS in favor of Jobs+Burst. #459

Closed freezy closed 10 months ago

freezy commented 10 months ago

So, DOTS v1.0 came out earlier this year. There are two major things that changed:

Dynamically creating a sub scene when importing a table seems impossible. Dynamically adding entities to the sub scene without the hybrid renderer (now "Entities Graphics") also seemed impossible. Baking wouldn't be available when loading a table during runtime.

There are probably workarounds for all of this, but DOTS didn't seem a right fit since quite a while, for the following reasons:

Enter the post-DOTS era. The physics loop is now one single bursted job. Data is still packed into structs and available through a PhysicsState that is passed to the systems that need access to it. Everything is passed by reference, so data is not copied between functions. This turned out to be very fast:

image 13k colliders at 0.2ms per frame.

https://github.com/freezy/VisualPinball.Engine/assets/70426/185e32bb-7b86-4060-a5a7-d972fa9410bf

60k colliders at 1ms per frame.

This was also the opportunity to replace VPX's octree with a faster and easier to use implementation by bartofzo. Tree creation is also insanely fast, allowing us now to introduce dynamic colliders. This will first be dynamic toggles, with the goal of making them fully dynamic, including velocities.

TODO before merge