Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix timer with zero duration (#8467)
# Objective Timer with zero `Duration` panics at `tick()` because of division by zero. This PR Fixes #8463 . ## Solution - Handle division by zero separately with `checked_div` and `checked_rem`. --- ## Changelog - Replace division with `checked_div`. Set `times_finished_this_tick` to u32::MAX when duration is zero. - Set `elapsed` to `Duration::ZERO` when timer duration is zero. - Set `percent` to `1.0` when duration is zero. - `times_finished_this_tick` is [not used anywhere](https://github.com/bevyengine/bevy/search?q=times_finished_this_tick), that's why this change will not affect other parts of the project. - `times_finished_this_tick` is set to `0` after `reset()` and before first `tick()` call.
- Loading branch information