Replace floats with doubles for core implementations like Transform and Vector3

As the title suggests. I want to switch out the default implementations using floats for doubles to aid precision and accuracy over longer distances.

I have considered these other approaches:

  • Keep the main camera and primary object stationary at Origin and have everything else move around. However, I think that would both be messy and less performant.
  • Break up the scene in parts and move the active part, alongside the player to the origin. This is my current preferred approach as it could be much cleaner and will only really affect performance for the single frame where the transfer occurs while maintaining accuracy over a acceptably precise limit. It still would relatively be a pain to maintain and will doubtlessly cause countless bugs as the development progresses.

Thus I consider replacing floats with doubles to be the optimal approach as it would almost square the distance I can accurately calculate for any given precision limit.

On first glance, I don’t think it is directly possible to do(I may be wrong) so and my only bet would be to create a layer where all computations are performed on doubles and Unity is passed a float value cast from this layer to render the frame. This would guarantee consistent computations but the actual viewed result may not be similarly consistent, besides being more memory intensive. So, I actually prefer this less than the second consideration listed above.

I thought I could post this here in case anybody has a better idea or a way to achieved the desired effect.

Any effort is deeply appreciated.

Before you do anything complicated, consider humble Floating Origin method first

Here is a super basic implementation to test it out:
Camera starts shaking after 2 minutes of continuous flying! - #2 by andrew-lukasik
Ofc nowadays you can optimize it considerably with Unity - Scripting API: TransformAccessArray


Btw: More mature version of floating origin was implemented by KSP guys https://www.youtube.com/watch?v=mXTxQko-JH0&ab_channel=Unity

Have you considered DOTS? Unlike UnityEngine.Transform, DOTS allows you to write your own custom transform system from scratch, take a look:

https://docs.unity3d.com/Packages/com.unity.entities@1.2/manual/transforms-custom.html

+ You can really do whatever you need here. I, for example, wrote myself a custom transform system where final rendering float4x4 matrix was computed from astronomical elements directly.
- The downside is that DOTS is more complicated and still far from feature parity with UnityEngine namespace workflows.