[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60695] trunk/blender/source/blender/ blenlib/intern/math_rotation.c: Fix dual quaternion armature deform giving erratic results in some cases.

Brecht Van Lommel brechtvanlommel at pandora.be
Sat Oct 12 02:08:35 CEST 2013


Revision: 60695
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60695
Author:   blendix
Date:     2013-10-12 00:08:34 +0000 (Sat, 12 Oct 2013)
Log Message:
-----------
Fix dual quaternion armature deform giving erratic results in some cases. Bug
was encountered in a Kiribati rig file.

The problem was actually in the matrix to quaternion conversion function. One
problem is that it was using the wrong matrix indices in case of an ill defined
matrix trace. Besides that FLT_EPSILON was too small to detect cases where
float precision becomes a problem.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/math_rotation.c

Modified: trunk/blender/source/blender/blenlib/intern/math_rotation.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_rotation.c	2013-10-12 00:08:33 UTC (rev 60694)
+++ trunk/blender/source/blender/blenlib/intern/math_rotation.c	2013-10-12 00:08:34 UTC (rev 60695)
@@ -286,7 +286,7 @@
 
 	tr = 0.25 * (double)(1.0f + mat[0][0] + mat[1][1] + mat[2][2]);
 
-	if (tr > (double)FLT_EPSILON) {
+	if (tr > (double)1e-6f) {
 		s = sqrt(tr);
 		q[0] = (float)s;
 		s = 1.0 / (4.0 * s);
@@ -300,7 +300,7 @@
 			q[1] = (float)(0.25 * s);
 
 			s = 1.0 / s;
-			q[0] = (float)((double)(mat[2][1] - mat[1][2]) * s);
+			q[0] = (float)((double)(mat[1][2] - mat[2][1]) * s);
 			q[2] = (float)((double)(mat[1][0] + mat[0][1]) * s);
 			q[3] = (float)((double)(mat[2][0] + mat[0][2]) * s);
 		}
@@ -318,7 +318,7 @@
 			q[3] = (float)(0.25 * s);
 
 			s = 1.0 / s;
-			q[0] = (float)((double)(mat[1][0] - mat[0][1]) * s);
+			q[0] = (float)((double)(mat[0][1] - mat[1][0]) * s);
 			q[1] = (float)((double)(mat[2][0] + mat[0][2]) * s);
 			q[2] = (float)((double)(mat[2][1] + mat[1][2]) * s);
 		}




More information about the Bf-blender-cvs mailing list