Skip to content
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

Merged
merged 1 commit into from
Nov 10, 2018
Merged

Fixed floating point issue in find() of animation. #23632

merged 1 commit into from
Nov 10, 2018

Conversation

Piet-G
Copy link
Contributor

@Piet-G Piet-G commented Nov 10, 2018

Fixes #23504

@@ -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
Copy link
Member

@akien-mga akien-mga Nov 10, 2018

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.

Copy link
Contributor Author

@Piet-G Piet-G Nov 10, 2018

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...

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allright, fixed.

@akien-mga akien-mga added this to the 3.1 milestone Nov 10, 2018
@akien-mga akien-mga merged commit c3023e8 into godotengine:master Nov 10, 2018
@akien-mga
Copy link
Member

Thanks!

@ghost
Copy link

ghost commented Nov 11, 2018

Thanks so much guys for a quick resolution. This one has been a thorn in our side lately.

@aaronfranke
Copy link
Member

I've added this to #18992

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants