Fun with 32-bit math at solar system scale; avoiding 64-bit/32-bit round trips in v0.2 #29
charliewhitfield
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I can't resist posting this image, taken while trying to solve high resolution orbit/trajectory lines. These were previously offset (at best) when zoomed in to small objects. I thought we were doing 64-bit math here but there was a hidden 64-bit/32-bit round trip.
In v0.2, I've reworked IVOrbtit and other API to try to avoid accidents like this. All API is now focused around 64-bit math using
PackedFloat64Arrayas standard input/output for position, state, etc. Vector3 is still available from specific getters that always have "vector" in their name. The latter are needed for graphics, but can only be for distant objects or must be already "localized" (incorporating large offsets).Note that compiling Godot for 64-bit would have solved above (making Vector3, Basis, etc., into 64-bit) but it does not solve the harder 32-bit rendering problems. Those would still need to be solved with origin-shifting, farwarp, etc. And then the Core plugin would be much harder to use by external projects.
Instead of doing that, we segregate "orbit-quality" math to
floatandPackedFloat64Array. To make that easier we provide rotations and other "Basis" and "Vector" math in in our own IVMath64. 32-bit Vector3 is still used for graphics, but we're careful to generate those after astronomical offsets are subtracted out in 64-bit. That solves the graphic line problem in the image above.All reactions