From afde3b4645daf3f72666055595814ec49631feed Mon Sep 17 00:00:00 2001 From: Groove Date: Wed, 25 Jul 2018 23:27:57 +0200 Subject: [PATCH] Added identity experiment #765 --- test/gtc/gtc_quaternion.cpp | 60 ++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index be78f198..f1bdf0c1 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -1,6 +1,6 @@ #include -#include -#include +#include +#include #include int test_quat_angle() @@ -319,39 +319,57 @@ static int test_constexpr() using namespace glm; -/* -template class matType> -struct init_mat +enum genTypeEnum { - static matType identity() - { - return matType(1, 0, 0, 0); - } + GENTYPE_VEC, + GENTYPE_MAT, + GENTYPE_QUAT }; -*/ -template -struct init_quat +template +struct genTypeTrait +{}; + +template +struct genTypeTrait > { - static tquat identity() + static const genTypeEnum GENTYPE = GENTYPE_QUAT; +}; + +template +struct genTypeTrait > +{ + static const genTypeEnum GENTYPE = GENTYPE_MAT; +}; + +template +struct init_gentype +{ +}; + +template +struct init_gentype +{ + static genType identity() { - return tquat(1, 0, 0, 0); + return genType(1, 0, 0, 0); } }; template -struct init +struct init_gentype { static genType identity() { - return init_quat::identity(); + return genType(1); } }; template inline genType identity() { - return init::identity(); + //return init_gentype::identity(); + return init_gentype::GENTYPE>::identity(); } int test_identity() @@ -363,6 +381,14 @@ int test_identity() Error += glm::all(glm::equal(Q, glm::quat(1, 0, 0, 0), 0.0001f)) ? 0 : 1; Error += glm::any(glm::notEqual(Q, glm::quat(1, 0, 0, 0), 0.0001f)) ? 1 : 0; + glm::mat4 const M = identity(); + glm::mat4 const N(1.0f); + + Error += glm::all(glm::equal(M[0], N[0], 0.0001f)) ? 0 : 1; + Error += glm::all(glm::equal(M[1], N[1], 0.0001f)) ? 0 : 1; + Error += glm::all(glm::equal(M[2], N[2], 0.0001f)) ? 0 : 1; + Error += glm::all(glm::equal(M[3], N[3], 0.0001f)) ? 0 : 1; + return Error; }