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()
This commit is contained in:
arkology
2024-11-04 17:23:03 +03:00
parent 0f5f3bc954
commit d692b7bdde
4 changed files with 98 additions and 5 deletions

View File

@@ -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) {