소스 검색

Merge pull request #61812 from Chaosus/fix_wrapf

Rémi Verschelde 3 년 전
부모
커밋
cc6b2f4287
1개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 10 2
      core/math/math_funcs.h

+ 10 - 2
core/math/math_funcs.h

@@ -302,11 +302,19 @@ public:
 	}
 	static _ALWAYS_INLINE_ double wrapf(double value, double min, double max) {
 		double range = max - min;
-		return is_zero_approx(range) ? min : value - (range * Math::floor((value - min) / range));
+		double result = is_zero_approx(range) ? min : value - (range * Math::floor((value - min) / range));
+		if (is_equal_approx(result, max)) {
+			return min;
+		}
+		return result;
 	}
 	static _ALWAYS_INLINE_ float wrapf(float value, float min, float max) {
 		float range = max - min;
-		return is_zero_approx(range) ? min : value - (range * Math::floor((value - min) / range));
+		float result = is_zero_approx(range) ? min : value - (range * Math::floor((value - min) / range));
+		if (is_equal_approx(result, max)) {
+			return min;
+		}
+		return result;
 	}
 
 	static _ALWAYS_INLINE_ float fract(float value) {