Daniele Bartolini пре 10 година
родитељ
комит
25efb1277c

+ 1 - 3
src/core/math/intersection.cpp

@@ -147,10 +147,8 @@ bool plane_3_intersection(const Plane& p1, const Plane& p2, const Plane& p3, Vec
 
 	float den = -dot(cross(n1, n2), n3);
 
-	if (equals(den, (float)0.0))
-	{
+	if (fequal(den, 0.0f))
 		return false;
-	}
 
 	Vector3 res = p1.d * cross(n2, n3) + p2.d * cross(n3, n1) + p3.d * cross(n1, n2);
 	ip = res / den;

+ 1 - 1
src/core/math/math_utils.h

@@ -19,7 +19,7 @@ const float TWO_PI            = PI * 2.0f;
 const float HALF_PI           = PI * 0.5f;
 const float FLOAT_PRECISION   = 1.0e-7f;
 
-inline bool equals(float a, float b, float precision = FLOAT_PRECISION)
+inline bool fequal(float a, float b, float precision = FLOAT_PRECISION)
 {
 	return ((b <= (a + precision)) && (b >= (a - precision)));
 }

+ 1 - 1
src/core/math/plane.h

@@ -35,7 +35,7 @@ namespace plane
 	{
 		const float len = length(p.n);
 
-		if (equals(len, 0.0f))
+		if (fequal(len, 0.0f))
 			return p;
 
 		const float inv_len = 1.0f / len;

+ 1 - 1
src/core/math/vector2.h

@@ -101,7 +101,7 @@ inline Vector2 operator/(Vector2 a, float k)
 /// Returns true whether the vectors @a a and @a b are equal.
 inline bool operator==(const Vector2& a, const Vector2& b)
 {
-	return equals(a.x, b.x) && equals(a.y, b.y);
+	return fequal(a.x, b.x) && fequal(a.y, b.y);
 }
 
 /// Returns the dot product between the vectors @a a and @a b.

+ 1 - 1
src/core/math/vector3.h

@@ -117,7 +117,7 @@ inline Vector3 operator/(Vector3 a, float k)
 /// Returns true whether the vectors @a a and @a b are equal.
 inline bool operator==(const Vector3& a, const Vector3& b)
 {
-	return equals(a.x, b.x) && equals(a.y, b.y) && equals(a.z, b.z);
+	return fequal(a.x, b.x) && fequal(a.y, b.y) && fequal(a.z, b.z);
 }
 
 /// Returns the dot product between the vectors @a a and @a b.

+ 4 - 1
src/core/math/vector4.h

@@ -131,7 +131,10 @@ inline Vector4 operator/(Vector4 a, float k)
 /// Returns true whether the vectors @a a and @a b are equal.
 inline bool operator==(const Vector4& a, const Vector4& b)
 {
-	return equals(a.x, b.x) && equals(a.y, b.y) && equals(a.z, b.z) && equals(a.w, b.w);
+	return fequal(a.x, b.x)
+		&& fequal(a.y, b.y)
+		&& fequal(a.z, b.z)
+		&& fequal(a.w, b.w);
 }
 
 /// Returns the dot product between the vectors @a a and @a b.