Browse Source

Optimized Quaternion vector rotation #205

Christophe Riccio 11 years ago
parent
commit
4da58d88d4
2 changed files with 5 additions and 9 deletions
  1. 4 9
      glm/gtc/quaternion.inl
  2. 1 0
      readme.txt

+ 4 - 9
glm/gtc/quaternion.inl

@@ -302,16 +302,11 @@ namespace detail
 		detail::tvec3<T, P> const & v
 	)
 	{
-		T Two(2);
+		detail::tvec3<T, P> u(q.x, q.y, q.z);
+		detail::tvec3<T, P> uv(glm::cross(u, v) * q.w);
+		detail::tvec3<T, P> uuv(glm::cross(u, uv));
 
-		detail::tvec3<T, P> uv, uuv;
-		detail::tvec3<T, P> QuatVector(q.x, q.y, q.z);
-		uv = glm::cross(QuatVector, v);
-		uuv = glm::cross(QuatVector, uv);
-		uv *= (Two * q.w);
-		uuv *= Two;
-
-		return v + uv + uuv;
+		return v + (uv + uuv) * static_cast<float>(2);
 	}
 
 	template <typename T, precision P>

+ 1 - 0
readme.txt

@@ -44,6 +44,7 @@ GLM 0.9.5.4: 2014-0X-XX
 - Fixed GTX_color_space - saturation #195
 - Fixed glm::isinf and glm::isnan for with Android NDK 9d #191
 - Fixed builtin GLM_ARCH_SSE4 #204
+- Optimized Quaternion vector rotation #205
 
 ================================================================================
 GLM 0.9.5.3: 2014-04-02