Browse Source

Initializer list experiment

Christophe Riccio 12 năm trước cách đây
mục cha
commit
812ff4fcc8
2 tập tin đã thay đổi với 14 bổ sung13 xóa
  1. 8 8
      glm/core/type_mat4x4.inl
  2. 6 5
      test/core/core_type_mat4x4.cpp

+ 8 - 8
glm/core/type_mat4x4.inl

@@ -181,20 +181,20 @@ namespace detail
 	{
 		assert(m.size() >= this->length());
 
-		this->value[0] = static_cast<tvec4<T, P> >(reinterpret_cast<tvec4<U, P>&>(const_cast<U&>(m.begin()[0])));
-		this->value[1] = static_cast<tvec4<T, P> >(reinterpret_cast<tvec4<U, P>&>(const_cast<U&>(m.begin()[4])));
-		this->value[2] = static_cast<tvec4<T, P> >(reinterpret_cast<tvec4<U, P>&>(const_cast<U&>(m.begin()[8])));
-		this->value[3] = static_cast<tvec4<T, P> >(reinterpret_cast<tvec4<U, P>&>(const_cast<U&>(m.begin()[12])));
+		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]);
 	}
 
 	template <typename T, precision P>
 	template <typename U>
 	GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4(std::initializer_list<tvec4<U, P> > const & m)
 	{
-		this->value[0] = static_cast<tvec4<T, P> >(m.begin()[0]);
-		this->value[1] = static_cast<tvec4<T, P> >(m.begin()[1]);
-		this->value[2] = static_cast<tvec4<T, P> >(m.begin()[2]);
-		this->value[3] = static_cast<tvec4<T, P> >(m.begin()[3]);
+		this->value[0] = m.begin()[0];
+		this->value[1] = m.begin()[1];
+		this->value[2] = m.begin()[2];
+		this->value[3] = m.begin()[3];
 	}
 #endif//GLM_HAS_INITIALIZER_LISTS
 

+ 6 - 5
test/core/core_type_mat4x4.cpp

@@ -131,17 +131,18 @@ 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{
-		{0, 1, 2, 3},
-		{4, 5, 6, 7},
-		{8, 9, 10, 11},
-		{12, 13, 14, 15}};
+		glm::vec4{0, 1, 2, 3},
+		glm::vec4{4, 5, 6, 7},
+		glm::vec4{8, 9, 10, 11},
+		glm::vec4{12, 13, 14, 15}};
 
+/*
 	std::initializer_list<glm::mat4> m3{
 		{0, 1, 2, 3},
 		{4, 5, 6, 7},
 		{8, 9, 10, 11},
 		{12, 13, 14, 15}};
-
+*/
 	//glm::mat4 m4{m3};
 
 /*