From 7f162ff4e828deac9883ecb8a81fef4aa28b67fe Mon Sep 17 00:00:00 2001 From: Yuri Kilochek Date: Tue, 26 Dec 2017 19:37:25 +0300 Subject: [PATCH 1/3] Remove redundant specializations of `glm::type>` --- glm/gtx/type_trait.hpp | 138 ++--------------------------------------- 1 file changed, 6 insertions(+), 132 deletions(-) diff --git a/glm/gtx/type_trait.hpp b/glm/gtx/type_trait.hpp index 08dcc1a7..0f14f308 100644 --- a/glm/gtx/type_trait.hpp +++ b/glm/gtx/type_trait.hpp @@ -17,18 +17,7 @@ #endif // Dependency: -#include "../detail/type_vec2.hpp" -#include "../detail/type_vec3.hpp" -#include "../detail/type_vec4.hpp" -#include "../detail/type_mat2x2.hpp" -#include "../detail/type_mat2x3.hpp" -#include "../detail/type_mat2x4.hpp" -#include "../detail/type_mat3x2.hpp" -#include "../detail/type_mat3x3.hpp" -#include "../detail/type_mat3x4.hpp" -#include "../detail/type_mat4x2.hpp" -#include "../detail/type_mat4x3.hpp" -#include "../detail/type_mat4x4.hpp" +#include "../detail/qualifier.hpp" #include "../gtc/quaternion.hpp" #include "../gtx/dual_quaternion.hpp" @@ -64,130 +53,15 @@ namespace glm }; }; - template - struct type > + template + struct type > { static bool const is_vec = false; static bool const is_mat = true; static bool const is_quat = false; - enum - { - components = 2, - cols = 2, - rows = 2 - }; - }; - - template - struct type > - { - static bool const is_vec = false; - static bool const is_mat = true; - static bool const is_quat = false; - enum - { - components = 2, - cols = 2, - rows = 3 - }; - }; - - template - struct type > - { - static bool const is_vec = false; - static bool const is_mat = true; - static bool const is_quat = false; - enum - { - components = 2, - cols = 2, - rows = 4 - }; - }; - - template - struct type > - { - static bool const is_vec = false; - static bool const is_mat = true; - static bool const is_quat = false; - enum - { - components = 3, - cols = 3, - rows = 2 - }; - }; - - template - struct type > - { - static bool const is_vec = false; - static bool const is_mat = true; - static bool const is_quat = false; - enum - { - components = 3, - cols = 3, - rows = 3 - }; - }; - - template - struct type > - { - static bool const is_vec = false; - static bool const is_mat = true; - static bool const is_quat = false; - enum - { - components = 3, - cols = 3, - rows = 4 - }; - }; - - template - struct type > - { - static bool const is_vec = false; - static bool const is_mat = true; - static bool const is_quat = false; - enum - { - components = 4, - cols = 4, - rows = 2 - }; - }; - - template - struct type > - { - static bool const is_vec = false; - static bool const is_mat = true; - static bool const is_quat = false; - enum - { - components = 4, - cols = 4, - rows = 3 - }; - }; - - template - struct type > - { - static bool const is_vec = false; - static bool const is_mat = true; - static bool const is_quat = false; - enum - { - components = 4, - cols = 4, - rows = 4 - }; + static length_t const components = C; + static length_t const cols = C; + static length_t const rows = R; }; template From 1ef3e5a2009a85f44d4ec5a0884ef615e91efc95 Mon Sep 17 00:00:00 2001 From: Yuri Kilochek Date: Tue, 26 Dec 2017 19:42:12 +0300 Subject: [PATCH 2/3] `components`, `cols`, `rows` are no longer defined as members of anonymous enums and are now instead static integral constants of type `glm::length_t` (this appears to be current approach). --- glm/gtx/type_trait.hpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/glm/gtx/type_trait.hpp b/glm/gtx/type_trait.hpp index 0f14f308..637bbd19 100644 --- a/glm/gtx/type_trait.hpp +++ b/glm/gtx/type_trait.hpp @@ -47,10 +47,7 @@ namespace glm static bool const is_vec = true; static bool const is_mat = false; static bool const is_quat = false; - enum - { - components = L - }; + static length_t const components = L; }; template @@ -70,10 +67,7 @@ namespace glm static bool const is_vec = false; static bool const is_mat = false; static bool const is_quat = true; - enum - { - components = 4 - }; + static length_t const components = 4; }; template @@ -82,10 +76,7 @@ namespace glm static bool const is_vec = false; static bool const is_mat = false; static bool const is_quat = true; - enum - { - components = 8 - }; + static length_t const components = 8; }; /// @} From 0afc784511ccd10cd0ede233a44ed8e2757ba1e4 Mon Sep 17 00:00:00 2001 From: Yuri Kilochek Date: Sun, 7 Jan 2018 00:05:12 +0300 Subject: [PATCH 3/3] Add definitions for `glm::type` members, so that they can be used outside of constant expressions. --- glm/gtx/type_trait.inl | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/glm/gtx/type_trait.inl b/glm/gtx/type_trait.inl index e69de29b..1cdf3322 100644 --- a/glm/gtx/type_trait.inl +++ b/glm/gtx/type_trait.inl @@ -0,0 +1,62 @@ +/// @ref gtx_type_trait +/// @file glm/gtx/type_trait.inl + +namespace glm +{ + template + bool const type::is_vec; + template + bool const type::is_mat; + template + bool const type::is_quat; + template + length_t const type::components; + template + length_t const type::cols; + template + length_t const type::rows; + + // vec + template + bool const type >::is_vec; + template + bool const type >::is_mat; + template + bool const type >::is_quat; + template + length_t const type >::components; + + // mat + template + bool const type >::is_vec; + template + bool const type >::is_mat; + template + bool const type >::is_quat; + template + length_t const type >::components; + template + length_t const type >::cols; + template + length_t const type >::rows; + + // tquat + template + bool const type >::is_vec; + template + bool const type >::is_mat; + template + bool const type >::is_quat; + template + length_t const type >::components; + + // tdualquat + template + bool const type >::is_vec; + template + bool const type >::is_mat; + template + bool const type >::is_quat; + template + length_t const type >::components; +}//namespace glm