From 81ed43373ffee58db8494c38a51aa8956cb346ac Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 30 Sep 2013 03:50:40 +0200 Subject: [PATCH] Fixed mat4 initializer list contructors --- glm/core/type_mat4x4.hpp | 5 ++--- glm/core/type_mat4x4.inl | 15 ++++++++------- glm/core/type_vec4.hpp | 2 +- glm/core/type_vec4.inl | 2 +- test/core/core_type_mat4x4.cpp | 18 +++++++++++------- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/glm/core/type_mat4x4.hpp b/glm/core/type_mat4x4.hpp index daadc1db..02b24fad 100644 --- a/glm/core/type_mat4x4.hpp +++ b/glm/core/type_mat4x4.hpp @@ -91,10 +91,9 @@ namespace detail #if(GLM_HAS_INITIALIZER_LISTS) template - GLM_FUNC_DECL tmat4x4(std::initializer_list const & m); + GLM_FUNC_DECL tmat4x4(std::initializer_list m); - template - GLM_FUNC_DECL tmat4x4(std::initializer_list > const & m); + GLM_FUNC_DECL tmat4x4(std::initializer_list > m); #endif//GLM_HAS_INITIALIZER_LISTS ////////////////////////////////////// diff --git a/glm/core/type_mat4x4.inl b/glm/core/type_mat4x4.inl index 28045567..17e4136d 100644 --- a/glm/core/type_mat4x4.inl +++ b/glm/core/type_mat4x4.inl @@ -177,19 +177,20 @@ namespace detail #if(GLM_HAS_INITIALIZER_LISTS) template template - GLM_FUNC_QUALIFIER tmat4x4::tmat4x4(std::initializer_list const & m) + GLM_FUNC_QUALIFIER tmat4x4::tmat4x4(std::initializer_list m) { assert(m.size() >= this->length()); - this->value[0] = reinterpret_cast const &>(m.begin()[0]); - this->value[1] = reinterpret_cast const &>(m.begin()[4]); - this->value[2] = reinterpret_cast const &>(m.begin()[8]); - this->value[3] = reinterpret_cast const &>(m.begin()[12]); + typename std::initializer_list::iterator p = m.begin(); + + this->value[0] = tvec4(*(p + 0), *(p + 1), *(p + 2), *(p + 3)); + this->value[1] = tvec4(*(p + 4), *(p + 5), *(p + 6), *(p + 7)); + this->value[2] = tvec4(*(p + 8), *(p + 9), *(p + 10), *(p + 11)); + this->value[3] = tvec4(*(p + 12), *(p + 13), *(p + 14), *(p + 15)); } template - template - GLM_FUNC_QUALIFIER tmat4x4::tmat4x4(std::initializer_list > const & m) + GLM_FUNC_QUALIFIER tmat4x4::tmat4x4(std::initializer_list > m) { this->value[0] = m.begin()[0]; this->value[1] = m.begin()[1]; diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index 9f4f07b2..354a5102 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -111,7 +111,7 @@ namespace detail #if(GLM_HAS_INITIALIZER_LISTS) template - GLM_FUNC_DECL tvec4(std::initializer_list const & v); + GLM_FUNC_DECL tvec4(std::initializer_list l); #endif//GLM_HAS_INITIALIZER_LISTS ////////////////////////////////////// diff --git a/glm/core/type_vec4.inl b/glm/core/type_vec4.inl index 78410301..6ea27f71 100644 --- a/glm/core/type_vec4.inl +++ b/glm/core/type_vec4.inl @@ -83,7 +83,7 @@ namespace detail #if(GLM_HAS_INITIALIZER_LISTS) template template - GLM_FUNC_QUALIFIER tvec4::tvec4(std::initializer_list const & v) : + GLM_FUNC_QUALIFIER tvec4::tvec4(std::initializer_list v) : x(static_cast(v.begin()[0])), y(static_cast(v.begin()[1])), z(static_cast(v.begin()[2])), diff --git a/test/core/core_type_mat4x4.cpp b/test/core/core_type_mat4x4.cpp index 2b443756..b42b1183 100644 --- a/test/core/core_type_mat4x4.cpp +++ b/test/core/core_type_mat4x4.cpp @@ -131,10 +131,10 @@ int test_ctr() glm::mat4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; glm::mat4 m2{ - glm::vec4{0, 1, 2, 3}, - glm::vec4{4, 5, 6, 7}, - glm::vec4{8, 9, 10, 11}, - glm::vec4{12, 13, 14, 15}}; + {0, 1, 2, 3}, + {4, 5, 6, 7}, + {8, 9, 10, 11}, + {12, 13, 14, 15}}; /* std::initializer_list m3{ @@ -145,8 +145,12 @@ int test_ctr() */ //glm::mat4 m4{m3}; -/* - std::vector v{ + std::vector v1{ + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} + }; + + std::vector v2{ { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, @@ -160,7 +164,7 @@ int test_ctr() { 12, 13, 14, 15 } } }; -*/ + #endif//GLM_HAS_INITIALIZER_LISTS return Error;