Bläddra i källkod

Merge branch '0.9.2' of ssh://ogl-math.git.sourceforge.net/gitroot/ogl-math/ogl-math into 0.9.2

Christophe Riccio 14 år sedan
förälder
incheckning
5d2350f7c8

+ 1 - 1
doc/gtxModules.doxy

@@ -452,7 +452,7 @@
 **/
 
 /*!
-	\defgroup gtx_vector_access GLM_GTX_vector_angle: Vector access
+	\defgroup gtx_vector_access GLM_GTX_vector_access: Vector access
 	\ingroup gtx
 	
 	\brief Function to set values to vectors

+ 0 - 3
glm/core/setup.hpp

@@ -135,13 +135,10 @@
 // G++
 #elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__)
 #   if defined (__llvm__)
-#       pragma message("LLVM")
 #       define GLM_COMPILER_GCC_EXTRA GLM_COMPILER_GCC_LLVM
 #   elif defined (__clang__)
-#       pragma message("CLANG")
 #       define GLM_COMPILER_GCC_EXTRA GLM_COMPILER_GCC_CLANG
 #   else
-#       pragma message("GCC")
 #       define GLM_COMPILER_GCC_EXTRA 0
 #   endif
 #

+ 37 - 1
glm/gtc/half_float.hpp

@@ -343,7 +343,7 @@ namespace half_float ///< GLM_GTC_half_float extension: Add support for half pre
 	/// 2 * 2 matrix of half-precision floating-point numbers.
 	/// From GLM_GTC_half_float extension.
 	typedef detail::tmat2x2<detail::thalf>	hmat2;
-
+    
 	/// 3 * 3 matrix of half-precision floating-point numbers.
 	/// From GLM_GTC_half_float extension.
 	typedef detail::tmat3x3<detail::thalf>	hmat3;
@@ -352,6 +352,42 @@ namespace half_float ///< GLM_GTC_half_float extension: Add support for half pre
 	/// From GLM_GTC_half_float extension.
 	typedef detail::tmat4x4<detail::thalf>	hmat4;
 
+	/// 2 * 2 matrix of half-precision floating-point numbers.
+	/// From GLM_GTC_half_float extension.
+	typedef detail::tmat2x2<detail::thalf>	hmat2x2;
+    
+	/// 2 * 3 matrix of half-precision floating-point numbers.
+	/// From GLM_GTC_half_float extension.
+	typedef detail::tmat2x3<detail::thalf>	hmat2x3;
+    
+	/// 2 * 4 matrix of half-precision floating-point numbers.
+	/// From GLM_GTC_half_float extension.
+	typedef detail::tmat2x4<detail::thalf>	hmat2x4;
+
+	/// 3 * 2 matrix of half-precision floating-point numbers.
+	/// From GLM_GTC_half_float extension.
+	typedef detail::tmat3x2<detail::thalf>	hmat3x2;
+    
+	/// 3 * 3 matrix of half-precision floating-point numbers.
+	/// From GLM_GTC_half_float extension.
+	typedef detail::tmat3x3<detail::thalf>	hmat3x3;
+    
+	/// 3 * 4 matrix of half-precision floating-point numbers.
+	/// From GLM_GTC_half_float extension.
+	typedef detail::tmat3x4<detail::thalf>	hmat3x4;
+
+	/// 4 * 2 matrix of half-precision floating-point numbers.
+	/// From GLM_GTC_half_float extension.
+	typedef detail::tmat4x2<detail::thalf>	hmat4x2;    
+
+	/// 4 * 3 matrix of half-precision floating-point numbers.
+	/// From GLM_GTC_half_float extension.
+	typedef detail::tmat4x3<detail::thalf>	hmat4x3;
+    
+	/// 4 * 4 matrix of half-precision floating-point numbers.
+	/// From GLM_GTC_half_float extension.
+	typedef detail::tmat4x4<detail::thalf>	hmat4x4;
+    
 	/// @}
 
 }// namespace half_float

+ 6 - 1
glm/gtc/quaternion.hpp

@@ -74,6 +74,11 @@ namespace detail
 	detail::tquat<T> operator- (
 		detail::tquat<T> const & q);
 
+	template <typename T> 
+	detail::tquat<T> operator+ ( 
+		detail::tquat<T> const & q, 
+		detail::tquat<T> const & p); 
+
 	template <typename T> 
 	detail::tquat<T> operator* ( 
 		detail::tquat<T> const & q, 
@@ -154,7 +159,7 @@ namespace quaternion ///< GLM_GTC_quaternion extension: Quaternion types and fun
 	detail::tquat<T> mix(
 		detail::tquat<T> const & x, 
 		detail::tquat<T> const & y, 
-		typename detail::tquat<T>::value_type const & a);
+		T const & a);
 		
 	//! Returns the q conjugate. 
 	//! From GLM_GTC_quaternion extension.

+ 14 - 14
glm/gtc/quaternion.inl

@@ -147,20 +147,6 @@ namespace detail{
     //////////////////////////////////////////////////////////////
     // tquat<valType> external operators
 
-    template <typename T> 
-    GLM_FUNC_QUALIFIER detail::tquat<T> operator*
-    ( 
-        detail::tquat<T> const & q, 
-        detail::tquat<T> const & p
-    ) 
-    { 
-        return detail::tquat<T>(
-            q.w + p.w,
-            q.x + p.x,
-            q.y + p.y,
-            q.z + p.z);
-    } 
-
 	template <typename T>
 	GLM_FUNC_QUALIFIER detail::tquat<T> operator- 
 	(
@@ -170,6 +156,20 @@ namespace detail{
 		return detail::tquat<T>(-q.w, -q.x, -q.y, -q.z);
 	}
 
+	template <typename T> 
+	GLM_FUNC_QUALIFIER detail::tquat<T> operator+
+	( 
+		detail::tquat<T> const & q, 
+		detail::tquat<T> const & p
+	) 
+	{ 
+        return detail::tquat<T>(
+            q.w + p.w,
+	        q.x + p.x,
+	        q.y + p.y,
+	        q.z + p.z);
+	} 
+
 	template <typename T> 
 	GLM_FUNC_QUALIFIER detail::tquat<T> operator*
 	( 

+ 1 - 1
glm/gtx/quaternion.inl

@@ -149,7 +149,7 @@ namespace quaternion
 		detail::tquat<T> const & x
 	)
     {
-        return acos(x.w) * T(2);
+        return glm::degrees(acos(x.w) * T(2));
     }
 
     template <typename T> 

+ 5 - 4
test/gtc/gtc_quaternion.cpp

@@ -23,11 +23,12 @@ int test_quat_slerp()
 {
     int Error = 0;
     
-    glm::quat A(0.0f, glm::vec3(0, 0, 1));
-    glm::quat B(90.0f, glm::vec3(0, 0, 1));
+    glm::quat A(glm::vec3(0, 0, 1));
+    glm::quat B(glm::vec3(0, 1, 0));
     glm::quat C = glm::mix(A, B, 0.5f);
-    
-    Error += C != glm::quat(45.f, glm::vec3(0, 0, 1)) ? 0 : 1;
+    glm::quat D(glm::normalize(glm::vec3(0, 1, 1)));
+
+    Error += C == D ? 0 : 1;
 
     return Error;
 }

+ 24 - 6
test/gtx/gtx_quaternion.cpp

@@ -11,31 +11,48 @@
 #include <glm/gtx/quaternion.hpp>
 #include <glm/gtx/epsilon.hpp>
 
+int test_quat_angleAxis()
+{
+	int Error = 0;
+
+	glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1));
+	glm::quat B = glm::angleAxis(90.0f, glm::vec3(0, 0, 1));
+    glm::quat C = glm::mix(A, B, 0.5f);
+    glm::quat D = glm::angleAxis(45.0f, glm::vec3(0, 0, 1));
+
+    Error += glm::equalEpsilon(C.x, D.x, 0.01f) ? 0 : 1;
+	Error += glm::equalEpsilon(C.y, D.y, 0.01f) ? 0 : 1;
+	Error += glm::equalEpsilon(C.z, D.z, 0.01f) ? 0 : 1;
+	Error += glm::equalEpsilon(C.w, D.w, 0.01f) ? 0 : 1;
+
+	return Error;
+}
+
 int test_quat_angle()
 {
     int Error = 0;
     
     {
-        glm::quat Q(45.0f, glm::vec3(0, 0, 1));
+        glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 1));
         glm::quat N = glm::normalize(Q);
         float L = glm::length(N);
-        Error += L == 1.0f ? 0 : 1;
+        Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1;
         float A = glm::angle(N);
         Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1;
     }
     {
-        glm::quat Q(45.0f, glm::vec3(0, 0, 2));
+        glm::quat Q = glm::angleAxis(45.0f, glm::normalize(glm::vec3(0, 1, 1)));
         glm::quat N = glm::normalize(Q);
         float L = glm::length(N);
-        Error += L == 1.0f ? 0 : 1;
+        Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1;
         float A = glm::angle(N);
         Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1;
     }
     {
-        glm::quat Q(45.0f, glm::vec3(1, 2, 3));
+        glm::quat Q = glm::angleAxis(45.0f, glm::normalize(glm::vec3(1, 2, 3)));
         glm::quat N = glm::normalize(Q);
         float L = glm::length(N);
-        Error += L == 1.0f ? 0 : 1;
+        Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1;
         float A = glm::angle(N);
         Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1;
     }
@@ -48,6 +65,7 @@ int main()
 	int Error = 0;
     
     Error += test_quat_angle();
+	Error += test_quat_angleAxis();
 
 	return Error;
 }