Pārlūkot izejas kodu

Added C++11 initalizer lists to quaternions

Christophe Riccio 12 gadi atpakaļ
vecāks
revīzija
258361ccd4
2 mainītis faili ar 18 papildinājumiem un 0 dzēšanām
  1. 5 0
      glm/gtc/quaternion.hpp
  2. 13 0
      glm/gtc/quaternion.inl

+ 5 - 0
glm/gtc/quaternion.hpp

@@ -77,6 +77,11 @@ namespace detail
 			T const & y,
 			T const & z);
 
+#if(GLM_HAS_INITIALIZER_LISTS)
+		template <typename U>
+		GLM_FUNC_DECL tquat(std::initializer_list<U> l);
+#endif//GLM_HAS_INITIALIZER_LISTS
+
 		// Convertions
 
 		/// Create a quaternion from two normalized axis

+ 13 - 0
glm/gtc/quaternion.inl

@@ -83,6 +83,19 @@ namespace detail
 		w(w)
 	{}
 
+#if(GLM_HAS_INITIALIZER_LISTS)
+	template <typename T, precision P>
+	template <typename U>
+	GLM_FUNC_QUALIFIER tquat<T, P>::tquat(std::initializer_list<U> l) :
+		x(static_cast<T>(l.begin()[0])),
+		y(static_cast<T>(l.begin()[1])),
+		z(static_cast<T>(l.begin()[2])),
+		w(static_cast<T>(l.begin()[3]))
+	{
+		assert(v.size() >= this->length());
+	}
+#endif//GLM_HAS_INITIALIZER_LISTS
+
 	//////////////////////////////////////////////////////////////
 	// tquat conversions