Browse Source

Fixed error: comparing floating point with == or != is unsafe

Groove 7 years ago
parent
commit
f9dc1d587f

+ 2 - 2
test/core/core_type_mat2x3.cpp

@@ -24,8 +24,8 @@ static int test_operators()
 	glm::mat2x3 o = m / x;
 	glm::mat2x3 p = x * m;
 	glm::mat2x3 q = m * x;
-	bool R = m != q;
-	bool S = m == l;
+	bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
+	bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
 
 	return (S && !R) ? 0 : 1;
 }

+ 2 - 2
test/core/core_type_mat2x4.cpp

@@ -25,8 +25,8 @@ static int test_operators()
 	glm::mat2x4 o = m / x;
 	glm::mat2x4 p = x * m;
 	glm::mat2x4 q = m * x;
-	bool R = m != q;
-	bool S = m == l;
+	bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
+	bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
 
 	return (S && !R) ? 0 : 1;
 }

+ 2 - 2
test/core/core_type_mat3x2.cpp

@@ -24,8 +24,8 @@ static bool test_operators()
 	glm::mat3x2 o = m / x;
 	glm::mat3x2 p = x * m;
 	glm::mat3x2 q = m * x;
-	bool R = m != q;
-	bool S = m == l;
+	bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
+	bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
 
 	return (S && !R) ? 0 : 1;
 }

+ 2 - 2
test/core/core_type_mat3x3.cpp

@@ -51,8 +51,8 @@ static int test_operators()
 	glm::mat3x3 o = m / x;
 	glm::mat3x3 p = x * m;
 	glm::mat3x3 q = m * x;
-	bool R = m != q;
-	bool S = m == l;
+	bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
+	bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
 
 	return (S && !R) ? 0 : 1;
 }

+ 2 - 2
test/core/core_type_mat3x4.cpp

@@ -25,8 +25,8 @@ static bool test_operators()
 	glm::mat3x4 o = m / x;
 	glm::mat3x4 p = x * m;
 	glm::mat3x4 q = m * x;
-	bool R = m != q;
-	bool S = m == l;
+	bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
+	bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
 
 	return (S && !R) ? 0 : 1;
 }

+ 2 - 2
test/core/core_type_mat4x2.cpp

@@ -24,8 +24,8 @@ static int test_operators()
 	glm::mat4x2 o = m / x;
 	glm::mat4x2 p = x * m;
 	glm::mat4x2 q = m * x;
-	bool R = m != q;
-	bool S = m == l;
+	bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
+	bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
 
 	return (S && !R) ? 0 : 1;
 }

+ 2 - 2
test/core/core_type_mat4x3.cpp

@@ -24,8 +24,8 @@ static int test_operators()
 	glm::mat4x3 o = m / x;
 	glm::mat4x3 p = x * m;
 	glm::mat4x3 q = m * x;
-	bool R = m != q;
-	bool S = m == l;
+	bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
+	bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
 
 	return (S && !R) ? 0 : 1;
 }

+ 2 - 2
test/core/core_type_mat4x4.cpp

@@ -72,8 +72,8 @@ static bool test_operators()
 	glm::mat4x4 o = m / x;
 	glm::mat4x4 p = x * m;
 	glm::mat4x4 q = m * x;
-	bool R = m != q;
-	bool S = m == l;
+	bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
+	bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
 
 	return (S && !R) ? 0 : 1;
 }