-
-
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
Fixed floating point issue in find() of animation. #23632
Conversation
scene/resources/animation.cpp
Outdated
@@ -1469,7 +1469,7 @@ int Animation::_find(const Vector<K> &p_keys, float p_time) const { | |||
|
|||
middle = (low + high) / 2; | |||
|
|||
if (p_time == keys[middle].time) { //match | |||
if (Math::absf(p_time - keys[middle].time) < CMP_EPSILON) { //match |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use Math::abs
directly, I don't think absf
and absd
are meant to be used directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused, Math::absf
is used a bunch in this file, see line 1704, 1718, 1675...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably by oversight, Math::abs
already calls Math::absf
or Math::absd
internally, so unless you want to make 100% that it will be float and never double, Math::abs
should be used.
$ rg "Math::abs[^df]" | wc -l
145
$ rg "Math::abs[df]" | wc -l
14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allright, fixed.
Thanks! |
Thanks so much guys for a quick resolution. This one has been a thorn in our side lately. |
I've added this to #18992 |
Fixes #23504