[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33171] trunk/blender/source/blender/ blenkernel/intern/constraint.c: bugfix for pivot constraint.

Campbell Barton ideasman42 at gmail.com
Fri Nov 19 07:22:05 CET 2010


Revision: 33171
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33171
Author:   campbellbarton
Date:     2010-11-19 07:21:39 +0100 (Fri, 19 Nov 2010)

Log Message:
-----------
bugfix for pivot constraint.
- no rotation resulted in NAN location.
- subtraction of pivot done in wrong order made the constraint give odd results when rotating on more then 1 axis.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/constraint.c

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2010-11-19 04:06:06 UTC (rev 33170)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2010-11-19 06:21:39 UTC (rev 33171)
@@ -3814,7 +3814,6 @@
 
 	/* pivot correction */
 	float axis[3], angle;
-	float dvec[3];
 	
 	/* firstly, check if pivoting should take place based on the current rotation */
 	if (data->rotAxis != PIVOTCON_AXIS_NONE) {
@@ -3861,14 +3860,16 @@
 
 	/* correct the pivot by the rotation axis otherwise the pivot translates when it shouldnt */
 	mat3_to_axis_angle(axis, &angle, rotMat);
-	sub_v3_v3v3(vec, pivot, cob->matrix[3]);
-	project_v3_v3v3(dvec, vec, axis);
-	sub_v3_v3(pivot, dvec);
+	if(angle) {
+		float dvec[3];
+		sub_v3_v3v3(vec, pivot, cob->matrix[3]);
+		project_v3_v3v3(dvec, vec, axis);
+		sub_v3_v3(pivot, dvec);
+	}
 
-
 	/* perform the pivoting... */
 		/* 1. take the vector from owner to the pivot */
-	sub_v3_v3v3(vec, pivot, cob->matrix[3]);
+	sub_v3_v3v3(vec, cob->matrix[3], pivot);
 		/* 2. rotate this vector by the rotation of the object... */
 	mul_m3_v3(rotMat, vec);
 		/* 3. make the rotation in terms of the pivot now */





More information about the Bf-blender-cvs mailing list