From 57e6ea071dfff00cbed6c5f484bb4f42c60cfefe Mon Sep 17 00:00:00 2001 From: Jesse Talavera-Greenberg Date: Mon, 5 Oct 2015 19:31:17 -0400 Subject: [PATCH] Add simdMat4 static constants - Tests, too --- glm/gtx/simd_mat4.hpp | 5 +++++ glm/gtx/simd_mat4.inl | 5 +++++ test/gtx/gtx_simd_mat4.cpp | 12 +++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/glm/gtx/simd_mat4.hpp b/glm/gtx/simd_mat4.hpp index 04198333..e1567610 100644 --- a/glm/gtx/simd_mat4.hpp +++ b/glm/gtx/simd_mat4.hpp @@ -83,6 +83,11 @@ namespace detail static GLM_RELAXED_CONSTEXPR precision prec = defaultp; # endif//GLM_META_PROG_HELPERS +# ifdef GLM_STATIC_CONST_MEMBERS + static const type ZERO; + static const type IDENTITY; +# endif + GLM_FUNC_DECL length_t length() const; fvec4SIMD Data[4]; diff --git a/glm/gtx/simd_mat4.inl b/glm/gtx/simd_mat4.inl index 13dcb20f..9b48289f 100644 --- a/glm/gtx/simd_mat4.inl +++ b/glm/gtx/simd_mat4.inl @@ -61,6 +61,11 @@ GLM_FUNC_QUALIFIER fvec4SIMD const & fmat4x4SIMD::operator[] return this->Data[i]; } +#ifdef GLM_STATIC_CONST_MEMBERS + const fmat4x4SIMD fmat4x4SIMD::ZERO(0); + const fmat4x4SIMD fmat4x4SIMD::IDENTITY(1); +#endif + ////////////////////////////////////////////////////////////// // Constructors diff --git a/test/gtx/gtx_simd_mat4.cpp b/test/gtx/gtx_simd_mat4.cpp index 11230466..dce607b6 100644 --- a/test/gtx/gtx_simd_mat4.cpp +++ b/test/gtx/gtx_simd_mat4.cpp @@ -29,6 +29,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// +#define GLM_STATIC_CONST_MEMBERS #include #include #include @@ -252,6 +253,15 @@ int test_compute_gtx() return 0; } +int test_static_const() { + int Error(0); + + Error += glm::simdMat4(1) == glm::simdMat4::IDENTITY ? 0 : 1; + Error += glm::simdMat4(0) == glm::simdMat4::ZERO ? 0 : 1; + + return Error; +} + int main() { int Error = 0; @@ -313,7 +323,7 @@ int main() Error += test_compute_glm(); Error += test_compute_gtx(); - + Error += test_static_const(); float Det = glm::determinant(glm::simdMat4(1.0)); Error += Det == 1.0f ? 0 : 1;