Skip to content

Commit b29bb11

Browse files
authored
Merge pull request godotengine#70812 from Chaosus/wrapf_optimize
2 parents 5726770 + b28571c commit b29bb11

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

core/math/math_funcs.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,21 @@ class Math {
453453
}
454454
static _ALWAYS_INLINE_ double wrapf(double value, double min, double max) {
455455
double range = max - min;
456-
double result = is_zero_approx(range) ? min : value - (range * Math::floor((value - min) / range));
456+
if (is_zero_approx(range)) {
457+
return min;
458+
}
459+
double result = value - (range * Math::floor((value - min) / range));
457460
if (is_equal_approx(result, max)) {
458461
return min;
459462
}
460463
return result;
461464
}
462465
static _ALWAYS_INLINE_ float wrapf(float value, float min, float max) {
463466
float range = max - min;
464-
float result = is_zero_approx(range) ? min : value - (range * Math::floor((value - min) / range));
467+
if (is_zero_approx(range)) {
468+
return min;
469+
}
470+
float result = value - (range * Math::floor((value - min) / range));
465471
if (is_equal_approx(result, max)) {
466472
return min;
467473
}

0 commit comments

Comments
 (0)