From e48c5ae8928e3288328e9e0e7ae7be22622889bc Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Tue, 10 Jul 2018 11:52:00 +0200 Subject: [PATCH] More use of initializer lists --- glm/detail/type_mat2x2.hpp | 1 - glm/detail/type_mat2x2.inl | 16 +++++----------- glm/detail/type_mat2x3.hpp | 1 - glm/detail/type_mat2x3.inl | 23 +++++++++++------------ glm/detail/type_mat2x4.inl | 14 ++++---------- glm/detail/type_mat3x2.inl | 15 ++++----------- glm/detail/type_mat3x3.inl | 15 ++++----------- glm/detail/type_mat3x4.inl | 15 ++++----------- glm/detail/type_mat4x2.inl | 16 ++++------------ glm/detail/type_mat4x3.inl | 16 ++++------------ glm/detail/type_mat4x4.inl | 16 ++++------------ test/core/core_type_mat2x2.cpp | 13 +++++++++++-- 12 files changed, 55 insertions(+), 106 deletions(-) diff --git a/glm/detail/type_mat2x2.hpp b/glm/detail/type_mat2x2.hpp index 0c194ae2..38f40f7a 100644 --- a/glm/detail/type_mat2x2.hpp +++ b/glm/detail/type_mat2x2.hpp @@ -35,7 +35,6 @@ namespace glm // -- Constructors -- GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat() GLM_DEFAULT_CTOR; - GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 2, T, Q> const& m) GLM_DEFAULT; template GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 2, T, P> const& m); diff --git a/glm/detail/type_mat2x2.inl b/glm/detail/type_mat2x2.inl index dca6658d..6fab73bb 100644 --- a/glm/detail/type_mat2x2.inl +++ b/glm/detail/type_mat2x2.inl @@ -10,28 +10,22 @@ namespace glm # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 2, T, Q>::mat() +# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS + : value{col_type(1, 0), col_type(0, 1)} +# endif { -# ifdef GLM_FORCE_CTOR_INIT +# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS this->value[0] = col_type(1, 0); this->value[1] = col_type(0, 1); # endif } # endif -# if !GLM_HAS_DEFAULTED_FUNCTIONS - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 2, T, Q>::mat(mat<2, 2, T, Q> const& m) - { - this->value[0] = m.value[0]; - this->value[1] = m.value[1]; - } -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 2, T, Q>::mat(mat<2, 2, T, P> const& m) # if GLM_HAS_INITIALIZER_LISTS - : value{m.value[0], m.value[1]} + : value{m[0], m[1]} # endif { # if !GLM_HAS_INITIALIZER_LISTS diff --git a/glm/detail/type_mat2x3.hpp b/glm/detail/type_mat2x3.hpp index a3a53c8c..17276a0e 100644 --- a/glm/detail/type_mat2x3.hpp +++ b/glm/detail/type_mat2x3.hpp @@ -36,7 +36,6 @@ namespace glm // -- Constructors -- GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat() GLM_DEFAULT_CTOR; - GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 3, T, Q> const& m) GLM_DEFAULT; template GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 3, T, P> const& m); diff --git a/glm/detail/type_mat2x3.inl b/glm/detail/type_mat2x3.inl index 450e67b4..847ca281 100644 --- a/glm/detail/type_mat2x3.inl +++ b/glm/detail/type_mat2x3.inl @@ -8,29 +8,28 @@ namespace glm # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 3, T, Q>::mat() +# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS + : value{col_type(1, 0, 0), col_type(0, 1, 0)} +# endif { -# ifdef GLM_FORCE_CTOR_INIT +# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS this->value[0] = col_type(1, 0, 0); this->value[1] = col_type(0, 1, 0); # endif } # endif -# if !GLM_HAS_DEFAULTED_FUNCTIONS - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 3, T, Q>::mat(mat<2, 3, T, Q> const& m) - { - this->value[0] = m.value[0]; - this->value[1] = m.value[1]; - } -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 3, T, Q>::mat(mat<2, 3, T, P> const& m) +# if GLM_HAS_INITIALIZER_LISTS + : value{m.value[0], m.value[1]} +# endif { - this->value[0] = m.value[0]; - this->value[1] = m.value[1]; +# if !GLM_HAS_INITIALIZER_LISTS + this->value[0] = m.value[0]; + this->value[1] = m.value[1]; +# endif } template diff --git a/glm/detail/type_mat2x4.inl b/glm/detail/type_mat2x4.inl index f95fe140..e8c7be32 100644 --- a/glm/detail/type_mat2x4.inl +++ b/glm/detail/type_mat2x4.inl @@ -8,23 +8,17 @@ namespace glm # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 4, T, Q>::mat() +# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS + : value{col_type(1, 0, 0, 0), col_type(0, 1, 0, 0)} +# endif { -# ifdef GLM_FORCE_CTOR_INIT +# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS this->value[0] = col_type(1, 0, 0, 0); this->value[1] = col_type(0, 1, 0, 0); # endif } # endif -# if !GLM_HAS_DEFAULTED_FUNCTIONS - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 4, T, Q>::mat(mat<2, 4, T, Q> const& m) - { - this->value[0] = m.value[0]; - this->value[1] = m.value[1]; - } -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 4, T, Q>::mat(mat<2, 4, T, P> const& m) diff --git a/glm/detail/type_mat3x2.inl b/glm/detail/type_mat3x2.inl index ea4da70a..b49ee97a 100644 --- a/glm/detail/type_mat3x2.inl +++ b/glm/detail/type_mat3x2.inl @@ -8,8 +8,11 @@ namespace glm # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 2, T, Q>::mat() +# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS + : value{col_type(1, 0), col_type(0, 1), col_type(0, 0)} +# endif { -# ifdef GLM_FORCE_CTOR_INIT +# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS this->value[0] = col_type(1, 0); this->value[1] = col_type(0, 1); this->value[2] = col_type(0, 0); @@ -17,16 +20,6 @@ namespace glm } # endif -# if !GLM_HAS_DEFAULTED_FUNCTIONS - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 2, T, Q>::mat(mat<3, 2, T, Q> const& m) - { - this->value[0] = m.value[0]; - this->value[1] = m.value[1]; - this->value[2] = m.value[2]; - } -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 2, T, Q>::mat(mat<3, 2, T, P> const& m) diff --git a/glm/detail/type_mat3x3.inl b/glm/detail/type_mat3x3.inl index 0547842f..0796c14d 100644 --- a/glm/detail/type_mat3x3.inl +++ b/glm/detail/type_mat3x3.inl @@ -10,8 +10,11 @@ namespace glm # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 3, T, Q>::mat() +# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS + : value{col_type(1, 0, 0), col_type(0, 1, 0), col_type(0, 0, 1)} +# endif { -# ifdef GLM_FORCE_CTOR_INIT +# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS this->value[0] = col_type(1, 0, 0); this->value[1] = col_type(0, 1, 0); this->value[2] = col_type(0, 0, 1); @@ -19,16 +22,6 @@ namespace glm } # endif -# if !GLM_HAS_DEFAULTED_FUNCTIONS - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 3, T, Q>::mat(mat<3, 3, T, Q> const& m) - { - this->value[0] = m.value[0]; - this->value[1] = m.value[1]; - this->value[2] = m.value[2]; - } -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 3, T, Q>::mat(mat<3, 3, T, P> const& m) diff --git a/glm/detail/type_mat3x4.inl b/glm/detail/type_mat3x4.inl index abb6eda2..26a5b0c1 100644 --- a/glm/detail/type_mat3x4.inl +++ b/glm/detail/type_mat3x4.inl @@ -8,8 +8,11 @@ namespace glm # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 4, T, Q>::mat() +# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS + : value{col_type(1, 0, 0, 0), col_type(0, 1, 0, 0), col_type(0, 0, 1, 0)} +# endif { -# ifdef GLM_FORCE_CTOR_INIT +# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS this->value[0] = col_type(1, 0, 0, 0); this->value[1] = col_type(0, 1, 0, 0); this->value[2] = col_type(0, 0, 1, 0); @@ -17,16 +20,6 @@ namespace glm } # endif -# if !GLM_HAS_DEFAULTED_FUNCTIONS - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 4, T, Q>::mat(mat<3, 4, T, Q> const& m) - { - this->value[0] = m.value[0]; - this->value[1] = m.value[1]; - this->value[2] = m.value[2]; - } -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 4, T, Q>::mat(mat<3, 4, T, P> const& m) diff --git a/glm/detail/type_mat4x2.inl b/glm/detail/type_mat4x2.inl index 4d88bb00..7a8a8dcc 100644 --- a/glm/detail/type_mat4x2.inl +++ b/glm/detail/type_mat4x2.inl @@ -8,8 +8,11 @@ namespace glm # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 2, T, Q>::mat() +# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS + : value{col_type(1, 0), col_type(0, 1), col_type(0, 0), col_type(0, 0)} +# endif { -# ifdef GLM_FORCE_CTOR_INIT +# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS this->value[0] = col_type(1, 0); this->value[1] = col_type(0, 1); this->value[2] = col_type(0, 0); @@ -18,17 +21,6 @@ namespace glm } # endif -# if !GLM_HAS_DEFAULTED_FUNCTIONS - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 2, T, Q>::mat(mat<4, 2, T, Q> const& m) - { - this->value[0] = m.value[0]; - this->value[1] = m.value[1]; - this->value[2] = m.value[2]; - this->value[3] = m.value[3]; - } -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 2, T, Q>::mat(mat<4, 2, T, P> const& m) diff --git a/glm/detail/type_mat4x3.inl b/glm/detail/type_mat4x3.inl index cbae8e79..4f299d22 100644 --- a/glm/detail/type_mat4x3.inl +++ b/glm/detail/type_mat4x3.inl @@ -8,8 +8,11 @@ namespace glm # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 3, T, Q>::mat() +# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS + : value{col_type(1, 0, 0), col_type(0, 1, 0), col_type(0, 0, 1), col_type(0, 0, 0)} +# endif { -# ifdef GLM_FORCE_CTOR_INIT +# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS this->value[0] = col_type(1, 0, 0); this->value[1] = col_type(0, 1, 0); this->value[2] = col_type(0, 0, 1); @@ -18,17 +21,6 @@ namespace glm } # endif -# if !GLM_HAS_DEFAULTED_FUNCTIONS - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 3, T, Q>::mat(mat<4, 3, T, Q> const& m) - { - this->value[0] = m.value[0]; - this->value[1] = m.value[1]; - this->value[2] = m.value[2]; - this->value[3] = m.value[3]; - } -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 3, T, Q>::mat(mat<4, 3, T, P> const& m) diff --git a/glm/detail/type_mat4x4.inl b/glm/detail/type_mat4x4.inl index b6311c77..eaa3dd0c 100644 --- a/glm/detail/type_mat4x4.inl +++ b/glm/detail/type_mat4x4.inl @@ -10,8 +10,11 @@ namespace glm # if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT) template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 4, T, Q>::mat() +# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS + : value{col_type(1, 0, 0, 0), col_type(0, 1, 0, 0), col_type(0, 0, 1, 0), col_type(0, 0, 0, 1)} +# endif { -# ifdef GLM_FORCE_CTOR_INIT +# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS this->value[0] = col_type(1, 0, 0, 0); this->value[1] = col_type(0, 1, 0, 0); this->value[2] = col_type(0, 0, 1, 0); @@ -20,17 +23,6 @@ namespace glm } # endif -# if !GLM_HAS_DEFAULTED_FUNCTIONS - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 4, T, Q>::mat(mat<4, 4, T, Q> const& m) - { - this->value[0] = m[0]; - this->value[1] = m[1]; - this->value[2] = m[2]; - this->value[3] = m[3]; - } -# endif//!GLM_HAS_DEFAULTED_FUNCTIONS - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 4, T, Q>::mat(mat<4, 4, T, P> const& m) diff --git a/test/core/core_type_mat2x2.cpp b/test/core/core_type_mat2x2.cpp index 3b1228f1..933ca543 100644 --- a/test/core/core_type_mat2x2.cpp +++ b/test/core/core_type_mat2x2.cpp @@ -57,11 +57,20 @@ int test_inverse() int test_ctr() { - int Error(0); + int Error = 0; + + { + glm::mediump_mat2x2 const A(1.0f); + glm::highp_mat2x2 const B(A); + glm::mediump_mat2x2 const C(B); + + for(glm::length_t i = 0; i < A.length(); ++i) + Error += glm::all(glm::equal(A[i], C[i])) ? 0 : 1; + } #if GLM_HAS_INITIALIZER_LISTS glm::mat2x2 m0( - glm::vec2(0, 1), + glm::vec2(0, 1), glm::vec2(2, 3)); glm::mat2x2 m1{0, 1, 2, 3};