godot
godot copied to clipboard
Fix animation compression going the wrong way
On the compression page break breaks the animation rotates wrongly.
Fixes: https://github.com/godotengine/godot/issues/96882
See also https://stackoverflow.com/a/47190699/381724 discussion about rint() and nearbyint(). Math::fast_ftoi uses rint which appears to be using FE_TONEAREST.
See https://stackoverflow.com/questions/311696/why-does-net-use-bankers-rounding-as-default about discussion about banker's rounding which is FE_TONEAREST.
Video of the mrp of animation compression with the fix applied.
https://youtu.be/b5wAQqX9XsM
I'll rewrite the commit message to be slightly better.
I think this is the right way to go, since it seems right to use round(nearest) at least for bit sampling, and this PR is appropriate as Math::fast_ftoi() is faster than Math::round().
However, note that this fix eliminates glitching, it still causes the stutter in the same as Math::round() as I commented in https://github.com/godotengine/godot/issues/96882#issuecomment-2344978163, and there are still areas that could be improved.
https://github.com/user-attachments/assets/24972a2c-b4ed-4e0d-9ead-e4f044917db4
For example, it might be possible to do something like blending the prev page's last few bits and next page's first few bits when decoding to make it smooth like anti-aliasing.
Or it may simply be that there is still a boundary error lurking somewhere, as I commented in there.
Would it work to use a cubic interpolation for blending the prev page's last few bits and next page's first few bits?
Since this stutter does not occur unless we use a round()(or fast_ftoi()), I would expect that it is a boundary value error due to some boundary being implemented with assuming to floor truncating, but I do not know where that is.
Should this be merged as is, or should some more work be done first to work on the other problem identified?
There is definitely still work to be done, but IMO the stutter still looks better than the glitch, so I think it is acceptable to merge this PR and postpone the work to eliminate the stutter in the later.
Thanks!