-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Merged by Bors] - Fixes Timer Precision Error Causing Panic #2362
[Merged by Bors] - Fixes Timer Precision Error Causing Panic #2362
Conversation
which would imply the panic was at self.set_elapsed(self.elapsed() - self.duration() * self.times_finished); (Specifically the substraction). EDIT Ahhh ok, now I see. The value of elapsed is a result of |
bors try |
tryBuild failed: |
@jacobgardner it looks like you need to run |
@NathanSWard sorry about that. Should be formatted now. |
bors try |
tryBuild succeeded: |
t.tick(duration); | ||
assert_eq!(t.times_finished(), 33); | ||
t.tick(duration); | ||
assert_eq!(t.times_finished(), 33); |
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.
shouldn't the extra tick be on this one?
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.
So my logic was roughly this:
0 + 33.3333 = 33.3333 (Rounds down to 33 times finished, leaving the remainder as .3333)
.3333 + 33.3333 = 33.6666 (Rounds down to 33 again, remainder fo .6666)
.6666 + 33.3333 = 33.9999 (Rounds down last time to 33 with remainder of .9999)
.9999 + 33.3333 = 34.3332 (Rounds down to 34 this time)
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.
It will add the extra tick after the fourth iteration, then it will correctly add it every three iterations... I would have liked it to be every three from the start, but that's probably not possible when using those kind of numbers 🤷
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.
Gotta love floating point numbers 🙃
bors r+ |
# Objective Fixes #2361 ## Solution Uses integer division instead of floating-point which prevents precision errors, I think.
Pull request successfully merged into main. Build succeeded: |
# Objective Fixes bevyengine#2361 ## Solution Uses integer division instead of floating-point which prevents precision errors, I think.
Objective
Fixes #2361
Solution
Uses integer division instead of floating-point which prevents precision errors, I think.