-
-
Notifications
You must be signed in to change notification settings - Fork 22k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use doubles for time in many other places #51294
Conversation
Needs a rebase. |
fc2e853
to
84f7209
Compare
Thanks! |
@aaronfranke I'm fixing a PR regarding cumulative time to use doubles as well, and I noticed the binding of both |
@MohammadKhashashneh Are you referring to this? BIND_VMETHOD(MethodInfo(Variant::BOOL, "_physics_process", PropertyInfo(Variant::FLOAT, "delta")));
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_process", PropertyInfo(Variant::FLOAT, "delta"))); It's a bit confusing, but |
indeed! |
@MohammadKhashashneh Yes. Variant only has 64-bit floats and ints, and this is what is bound and used in GDScript and other languages. If other sizes are used internally (such as C++ |
@aaronfranke well noted, thank you |
Follow-up to #38880 and a subset of #21922 split into its own PR for easier reviewing.
Single-precision floats should never be used for time, because it fails after a few days as errors accumulate over time. With doubles, this code should work for about 4.7 million years before failing, assuming 60 FPS.
Unlike #38880 which aims to solve a specific problem (#38878), this PR is just broadly replacing
float
withdouble
in time APIs. This should not impact performance on 64-bit systems (or extremely little), the main downside is slightly increased memory usage.An alternative implementation would be to use
real_t
, in which case this code would only work for more than a few days if Godot was also using doubles for vectors, though I think it's better to use doubles for time always.