فهرست منبع

Fixed mat4 initializer list contructors

Christophe Riccio 12 سال پیش
والد
کامیت
81ed43373f
5فایلهای تغییر یافته به همراه23 افزوده شده و 19 حذف شده
  1. 2 3
      glm/core/type_mat4x4.hpp
  2. 8 7
      glm/core/type_mat4x4.inl
  3. 1 1
      glm/core/type_vec4.hpp
  4. 1 1
      glm/core/type_vec4.inl
  5. 11 7
      test/core/core_type_mat4x4.cpp

+ 2 - 3
glm/core/type_mat4x4.hpp

@@ -91,10 +91,9 @@ namespace detail
 
 
 #if(GLM_HAS_INITIALIZER_LISTS)
 #if(GLM_HAS_INITIALIZER_LISTS)
 		template <typename U>
 		template <typename U>
-		GLM_FUNC_DECL tmat4x4(std::initializer_list<U> const & m);
+		GLM_FUNC_DECL tmat4x4(std::initializer_list<U> m);
 
 
-		template <typename U>
-		GLM_FUNC_DECL tmat4x4(std::initializer_list<tvec4<U, P> > const & m);
+		GLM_FUNC_DECL tmat4x4(std::initializer_list<tvec4<T, P> > m);
 #endif//GLM_HAS_INITIALIZER_LISTS
 #endif//GLM_HAS_INITIALIZER_LISTS
 
 
 		//////////////////////////////////////
 		//////////////////////////////////////

+ 8 - 7
glm/core/type_mat4x4.inl

@@ -177,19 +177,20 @@ namespace detail
 #if(GLM_HAS_INITIALIZER_LISTS)
 #if(GLM_HAS_INITIALIZER_LISTS)
 	template <typename T, precision P>
 	template <typename T, precision P>
 	template <typename U>
 	template <typename U>
-	GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4(std::initializer_list<U> const & m)
+	GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4(std::initializer_list<U> m)
 	{
 	{
 		assert(m.size() >= this->length());
 		assert(m.size() >= this->length());
 
 
-		this->value[0] = reinterpret_cast<tvec4<U, P> const &>(m.begin()[0]);
-		this->value[1] = reinterpret_cast<tvec4<U, P> const &>(m.begin()[4]);
-		this->value[2] = reinterpret_cast<tvec4<U, P> const &>(m.begin()[8]);
-		this->value[3] = reinterpret_cast<tvec4<U, P> const &>(m.begin()[12]);
+		typename std::initializer_list<U>::iterator p = m.begin();
+
+		this->value[0] = tvec4<T, P>(*(p +  0), *(p +  1), *(p +  2), *(p +  3));
+		this->value[1] = tvec4<T, P>(*(p +  4), *(p +  5), *(p +  6), *(p +  7));
+		this->value[2] = tvec4<T, P>(*(p +  8), *(p +  9), *(p + 10), *(p + 11));
+		this->value[3] = tvec4<T, P>(*(p + 12), *(p + 13), *(p + 14), *(p + 15));
 	}
 	}
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	template <typename U>
-	GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4(std::initializer_list<tvec4<U, P> > const & m)
+	GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4(std::initializer_list<tvec4<T, P> > m)
 	{
 	{
 		this->value[0] = m.begin()[0];
 		this->value[0] = m.begin()[0];
 		this->value[1] = m.begin()[1];
 		this->value[1] = m.begin()[1];

+ 1 - 1
glm/core/type_vec4.hpp

@@ -111,7 +111,7 @@ namespace detail
 
 
 #if(GLM_HAS_INITIALIZER_LISTS)
 #if(GLM_HAS_INITIALIZER_LISTS)
 		template <typename U>
 		template <typename U>
-		GLM_FUNC_DECL tvec4(std::initializer_list<U> const & v);
+		GLM_FUNC_DECL tvec4(std::initializer_list<U> l);
 #endif//GLM_HAS_INITIALIZER_LISTS
 #endif//GLM_HAS_INITIALIZER_LISTS
 
 
 		//////////////////////////////////////
 		//////////////////////////////////////

+ 1 - 1
glm/core/type_vec4.inl

@@ -83,7 +83,7 @@ namespace detail
 #if(GLM_HAS_INITIALIZER_LISTS)
 #if(GLM_HAS_INITIALIZER_LISTS)
 	template <typename T, precision P>
 	template <typename T, precision P>
 	template <typename U>
 	template <typename U>
-	GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4(std::initializer_list<U> const & v) :
+	GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4(std::initializer_list<U> v) :
 		x(static_cast<T>(v.begin()[0])),
 		x(static_cast<T>(v.begin()[0])),
 		y(static_cast<T>(v.begin()[1])),
 		y(static_cast<T>(v.begin()[1])),
 		z(static_cast<T>(v.begin()[2])),
 		z(static_cast<T>(v.begin()[2])),

+ 11 - 7
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 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
 	
 	
 	glm::mat4 m2{
 	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<glm::mat4> m3{
 	std::initializer_list<glm::mat4> m3{
@@ -145,8 +145,12 @@ int test_ctr()
 */
 */
 	//glm::mat4 m4{m3};
 	//glm::mat4 m4{m3};
 
 
-/*	
-	std::vector<glm::mat4> v{
+	std::vector<glm::mat4> 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<glm::mat4> v2{
 		{
 		{
 			{ 0, 1, 2, 3 },
 			{ 0, 1, 2, 3 },
 			{ 4, 5, 6, 7 },
 			{ 4, 5, 6, 7 },
@@ -160,7 +164,7 @@ int test_ctr()
 			{ 12, 13, 14, 15 }
 			{ 12, 13, 14, 15 }
 		}
 		}
 	};
 	};
-*/
+
 #endif//GLM_HAS_INITIALIZER_LISTS
 #endif//GLM_HAS_INITIALIZER_LISTS
 
 
 	return Error;
 	return Error;