-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
Fixed inspector precision issues when editing floats #25470
Conversation
For some reason the editor limits the precision of all floating-point values, including vectors, matrices, etc. to 3 decimal places after the decimal point (as they all have a step of 0.001). This change gets rid of this artificial limitation at least for the basic types and uniforms. The implementation of step_decimals() is also changed to use log10 instead of a loop, and it will now correctly handle a step size of zero and return maxn while previously it incorrectly returned 0 in this case. Fixes godotengine#18251 (at least).
I know some people will complain after this change that they type e.g. "100.01" in and get "100.0100021362" displayed (due to the precision limitations of FP32), but that's actually good, because you are at least aware of what is the actual value stored in memory. However, without this change you can't even use simple values like 1/16 (0.0625) as values of floats, vector components, etc. because both the displayed and the serialized value gets truncated to 3 decimal digits. |
I'd also note that this change still does not allow being able to use any float value as the maximum number of digits after the decimal point are still limited by |
I see various issues with this PR:
|
Also allow lifting the decimal step formatting with a hint range step of 0. A new `range_step_decimals()` is added for this to avoid breaking compatibility on the general purpose `step_decimals()` (which still returns 0 for an input step of 0). Supersedes godotengine#25470. Partial fix for godotengine#18251.
See #30776. It should achieve most of what this PR attempted to do, without introducing regressions or usability issues. There's only the part about shader hint ranges that I left unmodified for now, as I'm not sure how to handle it. It could default to 0, but as far as I understand that would always take precedence over the configured default float step, so unless another step is specified manually, it would always be 0 / no limit. |
For values which don't have an explicitly defined range and/or step (i.e. unbounded, unrestricted default behavior of floats) thus not having semantics what's the point of having a slider?
That's debatable and one way to fix it is to round the value displayed but not the value stored if user friendliness of this sort is preferred. That I'd say is probably okay, but I disagree with the principle of trying to hide the fact that floating point precision limitations exist at all costs. Even today you can encounter values being snapped to another one when the step is sufficiently small to cause floating point rounding errors, so hiding that fact is not really possible in all cases and I'd argue it's counter-productive. But it's your call as I think this is sort of a positioning question on who are the target audience of the engine.
Thanks, appreciated, personally I don't need it as I forked the code anyway due to this and other issues where I guess my requirements are different to that of majority. Though I agree that some solution to this problem will likely come handy to other users as well.
Huh, really? I thought I tested the precision with all the specific values previously hard-coded in the function, but I may recall it incorrectly. It's been a long time I wrote that code. Still, it should be trivial to fix that using an appropriate scalar. I'll look into it, at least so far it didn't bite me. |
Oh, just one more note on this with respect to my particular requirements. I'm not really looking for more precision by default, but for maximum precision allowed by 32-bit floats, and AFAICT you can't achieve that with a configurable negative-power-of-ten step value, because the value that'd allow full precision is simply itself not representable as a 32-bit float. Right? Edit: If zero is an allowed value for the default step to indicate full precision like it does internally then that resolves the problem. |
I don't have a strong opinion on that one, but that's the way Godot has always worked. Note also that the property hint range is of the form
AFAIK that is what happens already. The editor rounds the issue displayed in the widget, but the value saved in your scene is the original one. Even for your original example in #18251, you were already allowed to input
Zero is an allowed value, yes, that's why I added https://github.com/godotengine/godot/pull/30776/files#diff-422087b7a934519b4112d21b9e9073eeR82 (I didn't want to change the behavior of |
Note that I don't consider #30776 a complete solution for the problems discussed here and in #18251. IMO solving #19242 is really necessary, and this can be done by removing this dependency between range hint and the actual values that can be typed and shown. A good UX would be IMO:
|
Closing as superseded by #30776. I'll link the discussion here in related issues though to keep track of what would be left to do. |
Also allow lifting the decimal step formatting with a hint range step of 0. A new `range_step_decimals()` is added for this to avoid breaking compatibility on the general purpose `step_decimals()` (which still returns 0 for an input step of 0). Supersedes godotengine#25470. Partial fix for godotengine#18251.
Also allow lifting the decimal step formatting with a hint range step of 0. A new `range_step_decimals()` is added for this to avoid breaking compatibility on the general purpose `step_decimals()` (which still returns 0 for an input step of 0). Supersedes godotengine#25470. Partial fix for godotengine#18251.
For some reason the editor limits the precision of all floating-point values,
including vectors, matrices, etc. to 3 decimal places after the decimal point
(as they all have a step of 0.001).
This change gets rid of this artificial limitation at least for the basic
types and uniforms.
The implementation of step_decimals() is also changed to use log10 instead of
a loop, and it will now correctly handle a step size of zero and return maxn
while previously it incorrectly returned 0 in this case.
Fixes #18251 (at least).