Browse Source

Merge pull request #275 from plasmacel/master

add explicit matrix conversion operators to quat #275
Christophe Riccio 11 years ago
parent
commit
3c0b3c4009
2 changed files with 17 additions and 1 deletions
  1. 5 1
      glm/gtc/quaternion.hpp
  2. 12 0
      glm/gtc/quaternion.inl

+ 5 - 1
glm/gtc/quaternion.hpp

@@ -102,7 +102,11 @@ namespace glm
 			template <typename U, precision Q>
 			template <typename U, precision Q>
 			GLM_FUNC_DECL tquat(tquat<U, Q> const & q);
 			GLM_FUNC_DECL tquat(tquat<U, Q> const & q);
 #		endif
 #		endif
-
+		
+		// explicit conversion operators
+		GLM_FUNC_DECL explicit operator tmat3x3<T, P>();
+		GLM_FUNC_DECL explicit operator tmat4x4<T, P>();
+		
 		/// Create a quaternion from two normalized axis
 		/// Create a quaternion from two normalized axis
 		/// 
 		/// 
 		/// @param u A first normalized axis
 		/// @param u A first normalized axis

+ 12 - 0
glm/gtc/quaternion.inl

@@ -172,6 +172,18 @@ namespace detail
 	{
 	{
 		*this = quat_cast(m);
 		*this = quat_cast(m);
 	}
 	}
+	
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tquat<T, P>::operator tmat3x3<T, P>()
+	{
+		return mat3_cast(*this);
+	}
+	
+	template <typename T, precision P>	
+	GLM_FUNC_QUALIFIER tquat<T, P>::operator tmat4x4<T, P>()
+	{
+		return mat4_cast(*this);
+	}
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_QUALIFIER tquat<T, P> conjugate(tquat<T, P> const & q)
 	GLM_FUNC_QUALIFIER tquat<T, P> conjugate(tquat<T, P> const & q)