-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Vector elements sometimes return incorrect comparison results. #43476
Comments
I think that's expected, |
Ohh, I think that might also be why I was seeing some ghost noise in the Master audio bus after setting it's volume to '0.0'. I think this casting precision issue should be documented, or at least hinted at in the |
I believe we should a warning in GDScript for these cases, since floating point comparison can always be problematic. The |
Floating point comparisons are only expected to be problematic after performing (different) calculations not assignments. This problem is due to inconsistent use of data types and implicit casts between I think we should stick with one floating point representation, to make sure things are consistent. Lines 109 to 113 in f733746
|
This is the exact same issue as #30426. This happens because A similar issue can be found at #17971, and like that issue, this is a duplicate of godotengine/godot-proposals#892... unless @vnen wants to add a warning to GDScript for this, in which case we can leave this open to track that. |
Although this also applies to equality, the issue is more about greater than reporting incorrectly. The specific use case I have is detecting whether an object has moved right from its current position. If I try store the x position in a variable, and then check whether the current x position has increased, I get the wrong result if it hasn't changed. I understand the root cause of the problem, and I accept there are workarounds, but it doesn't change the fact that we shouldn't be using different data types within the engine for storing the user's floating point variables. It causes unnecessary surprises that are difficult to troubleshoot through no fault on the user's part. |
@madmiraal I did some extra work recently for getting double support working, and now it compiles and runs: Here is a link to a Linux debug build with doubles enabled. It's held together by duct tape and prayers, for example it can't open 3D models or SCN files because there is a size mismatch, but in its current state it does run your test code successfully. |
Many errors in collisions or vector positions ocur because the Vector3 not store the right values, see this bugs report: godotengine/godot#43476 If some explanation is given in the documentation will help people avoid many time lost trying find the bug, and discovering that Godot like imprecise numbers to calculate position.
Godot version:
master a7d610d
3.2.3.beta1
OS/device including version:
Ubuntu 20.10
Issue description:
Sometimes, when comparing the element of a vector to the value that it has been assigned, the comparison fails.
Steps to reproduce:
Set an element of a
Vector
to 0.1 compare the element to 0.1:Output:
This does not happen when comparing two variables or two
Vector
elements, which suggests that the problem lies with the underlying primitive data types being different.Minimal reproduction project:
FloatComparisonError.zip
The text was updated successfully, but these errors were encountered: