diff options
author | arkology <43543909+arkology@users.noreply.github.com> | 2024-11-04 17:23:03 +0300 |
---|---|---|
committer | arkology <43543909+arkology@users.noreply.github.com> | 2024-11-14 20:20:20 +0300 |
commit | d692b7bddeaacf93a06a08a516d8b61cf58085ce (patch) | |
tree | dc646e035adb702b83e367e06958dea662943f2c /scene/gui/texture_progress_bar.cpp | |
parent | 0f5f3bc9546b46b2029fc8896dc859697f1eab97 (diff) | |
download | redot-engine-d692b7bddeaacf93a06a08a516d8b61cf58085ce.tar.gz |
Improve set_radial_initial_angle by removing loops
Replace two while loops with fposmodp.
Document radial_initial_angle wrapping.
Add testcases for set_radial_initial_angle()
Diffstat (limited to 'scene/gui/texture_progress_bar.cpp')
-rw-r--r-- | scene/gui/texture_progress_bar.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/scene/gui/texture_progress_bar.cpp b/scene/gui/texture_progress_bar.cpp index 4ad56d21d3..24c68e0188 100644 --- a/scene/gui/texture_progress_bar.cpp +++ b/scene/gui/texture_progress_bar.cpp @@ -608,11 +608,10 @@ int TextureProgressBar::get_fill_mode() { } void TextureProgressBar::set_radial_initial_angle(float p_angle) { - while (p_angle > 360) { - p_angle -= 360; - } - while (p_angle < 0) { - p_angle += 360; + ERR_FAIL_COND_MSG(!Math::is_finite(p_angle), "Angle is non-finite."); + + if (p_angle < 0.0 || p_angle > 360.0) { + p_angle = Math::fposmodp(p_angle, 360.0f); } if (rad_init_angle == p_angle) { |