godotengine / godot

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

[4.3 stable] Animation player editor: Keys get inserted at wrong timeline positions #97010

Open tufduckhotmailcom opened 4 days ago

tufduckhotmailcom commented 4 days ago

Tested versions

Reproducable in 4.3 stable. Redproducable in 4.4-dev2

System information

Godot v4.3.stable - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce RTX 3070 (NVIDIA; 31.0.15.3623) - Intel(R) Core(TM) i5-4670K CPU @ 3.40GHz (4 Threads)

Issue description

I have an animation with keys every 0.15 seconds. I've noticed that when I click in the animation editor to insert new keys, they don't get added at the right position. Instead of 0.15, 0.3, 0.45 etc. they are always bit off, 0.1429, 0.2857, 0.4286 etc.

I've tried some other snap values. 0.1 works, but for instance 0.6 does not. I click at 0.6 in the timeline and right click "Insert key here", and it is inserted at 0.5.

Steps to reproduce

Create a new project. Add an AnimationPlayer, create an animation track. Set snap length to value 0.15 and click in the editor to add keys. Notice how they are not at the right positions.

Minimal reproduction project (MRP)

Not necessary.

AThousandShips commented 2 days ago

This is likely due to precision issues in floating point values, 0.15 is not a representable value in binary, so it behaves weirdly