godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.21k stars 21.22k forks source link

Editor Translate Snap Shifted Decimals #77414

Open Naradoxy opened 1 year ago

Naradoxy commented 1 year ago

Godot version

v4.0.stable.official [92bee43ad]

System information

Windows 10, AMD Ryzen 7 3700X 8-Core Processor

Issue description

Editing the grid translate snap number, leaving that scene in the editor, then coming back the number will shift by a small amount. This is in the 3D tab.

Ex: I set it as 0.0005, which shifted to 0.00050000002375 or 0.01 became 0.00999999977648

Steps to reproduce

-Be in the 3D view. -Edit the translate snap in a scene to a specific number (it has to be a floating point number). -Switch scene, then come back. -Open the configure snap menu and see it has slightly shifted (as shown in the examples in Issue desc.).

Minimal reproduction project

N/A

AThousandShips commented 1 year ago

Can you test this on 4.0.3? There's been a lot of bugs fixed since 4.0.0

AThousandShips commented 1 year ago

This is probably due to the way String::num works, the snap values are taken from the string and translated to floats, and then back with the default precision of 14, which adds excessive decimals on a single precision build I suspect, there are a number of precision issues involving strings from floats (also causes #77325, #75615, among others)

Naradoxy commented 1 year ago

This would make sense, thank you for the explanation. I have tested this in v4.0.3.stable.official [5222a99f5] and this issue is still present.