summaryrefslogtreecommitdiffstats
path: root/scene/gui
diff options
context:
space:
mode:
authorarkology <43543909+arkology@users.noreply.github.com>2024-11-04 17:23:03 +0300
committerarkology <43543909+arkology@users.noreply.github.com>2024-11-14 20:20:20 +0300
commitd692b7bddeaacf93a06a08a516d8b61cf58085ce (patch)
treedc646e035adb702b83e367e06958dea662943f2c /scene/gui
parent0f5f3bc9546b46b2029fc8896dc859697f1eab97 (diff)
downloadredot-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')
-rw-r--r--scene/gui/texture_progress_bar.cpp9
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) {