Fixed matrix comparison as constexpr

This commit is contained in:
Christophe Riccio 2018-08-08 00:17:29 +02:00
parent c1be8bf008
commit cca8569a41
2 changed files with 7 additions and 2 deletions

View File

@ -22,7 +22,7 @@ namespace glm
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)
{
vec<C, bool, Q> Result;
vec<C, bool, Q> Result(true);
for(length_t i = 0; i < C; ++i)
Result[i] = all(equal(a[i], b[i], Epsilon[i]));
return Result;
@ -43,7 +43,7 @@ namespace glm
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)
{
vec<C, bool, Q> Result;
vec<C, bool, Q> Result(true);
for(length_t i = 0; i < C; ++i)
Result[i] = any(notEqual(a[i], b[i], Epsilon[i]));
return Result;

View File

@ -4,6 +4,7 @@
#include <glm/ext/matrix_relational.hpp>
#include <glm/matrix.hpp>
#include <glm/mat4x4.hpp>
#include <glm/vec4.hpp>
#include <vector>
template <typename matType, typename vecType>
@ -174,6 +175,10 @@ static int test_constexpr()
{
#if GLM_HAS_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
return 0;