Browse Source

Fixed matrix comparison as constexpr

Christophe Riccio 7 years ago
parent
commit
cca8569a41
2 changed files with 7 additions and 2 deletions
  1. 2 2
      glm/ext/matrix_relational.inl
  2. 5 0
      test/core/core_type_mat4x4.cpp

+ 2 - 2
glm/ext/matrix_relational.inl

@@ -22,7 +22,7 @@ namespace glm
 	template<length_t C, length_t R, typename T, qualifier Q>
 	template<length_t C, length_t R, typename T, qualifier Q>
 	GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<C, bool, Q> equal(mat<C, R, T, Q> const& a, mat<C, R, T, Q> const& b, vec<C, T, Q> const& Epsilon)
 	GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<C, bool, Q> equal(mat<C, R, T, Q> const& a, mat<C, R, T, Q> const& b, vec<C, T, Q> const& Epsilon)
 	{
 	{
-		vec<C, bool, Q> Result;
+		vec<C, bool, Q> Result(true);
 		for(length_t i = 0; i < C; ++i)
 		for(length_t i = 0; i < C; ++i)
 			Result[i] = all(equal(a[i], b[i], Epsilon[i]));
 			Result[i] = all(equal(a[i], b[i], Epsilon[i]));
 		return Result;
 		return Result;
@@ -43,7 +43,7 @@ namespace glm
 	template<length_t C, length_t R, typename T, qualifier Q>
 	template<length_t C, length_t R, typename T, qualifier Q>
 	GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<C, bool, Q> notEqual(mat<C, R, T, Q> const& a, mat<C, R, T, Q> const& b, vec<C, T, Q> const& Epsilon)
 	GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<C, bool, Q> notEqual(mat<C, R, T, Q> const& a, mat<C, R, T, Q> const& b, vec<C, T, Q> const& Epsilon)
 	{
 	{
-		vec<C, bool, Q> Result;
+		vec<C, bool, Q> Result(true);
 		for(length_t i = 0; i < C; ++i)
 		for(length_t i = 0; i < C; ++i)
 			Result[i] = any(notEqual(a[i], b[i], Epsilon[i]));
 			Result[i] = any(notEqual(a[i], b[i], Epsilon[i]));
 		return Result;
 		return Result;

+ 5 - 0
test/core/core_type_mat4x4.cpp

@@ -4,6 +4,7 @@
 #include <glm/ext/matrix_relational.hpp>
 #include <glm/ext/matrix_relational.hpp>
 #include <glm/matrix.hpp>
 #include <glm/matrix.hpp>
 #include <glm/mat4x4.hpp>
 #include <glm/mat4x4.hpp>
+#include <glm/vec4.hpp>
 #include <vector>
 #include <vector>
 
 
 template <typename matType, typename vecType>
 template <typename matType, typename vecType>
@@ -174,6 +175,10 @@ static int test_constexpr()
 {
 {
 #if GLM_HAS_CONSTEXPR
 #if GLM_HAS_CONSTEXPR
 	static_assert(glm::mat4::length() == 4, "GLM: Failed constexpr");
 	static_assert(glm::mat4::length() == 4, "GLM: Failed constexpr");
+	constexpr glm::mat4 A(1.f);
+	constexpr glm::mat4 B(1.f);
+	constexpr glm::bvec4 C = glm::equal(A, B, 0.01f);
+	static_assert(glm::all(C), "GLM: Failed constexpr");
 #endif
 #endif
 
 
 	return 0;
 	return 0;