[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35759] trunk/blender/source/blender/ blenkernel/intern/constraint.c: Bugfix:

Joshua Leung aligorith at gmail.com
Fri Mar 25 00:34:44 CET 2011


Revision: 35759
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35759
Author:   aligorith
Date:     2011-03-24 23:34:43 +0000 (Thu, 24 Mar 2011)
Log Message:
-----------
Bugfix:
[#25725] Transform bone constraint & 'local with parent' as owners
space
[#26014] ChildOf Bone Constrain (influence) works in wrong workspace

Moved the influence calculation stuff outside of the space conversions
(i.e. so that it is done in worldspace only) fixes these problems,
which seem to arise when a constraint doesn't work in worldspace AND
doesn't need to apply inverse correct for this space conversion when
it's done, hence resulting in mismatch between spaces for old and new
matrices resulting in all the weird behaviour.

Patch to fix this from Jahka. Cheers!

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	2011-03-24 21:07:54 UTC (rev 35758)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2011-03-24 23:34:43 UTC (rev 35759)
@@ -4465,9 +4465,11 @@
 		 */
 		enf = con->enforce;
 		
+		/* make copy of worldspace matrix pre-constraint for use with blending later */
+		copy_m4_m4(oldmat, cob->matrix);
+		
 		/* move owner matrix into right space */
 		constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace);
-		copy_m4_m4(oldmat, cob->matrix);
 		
 		/* prepare targets for constraint solving */
 		if (cti->get_constraint_targets) {
@@ -4503,16 +4505,20 @@
 			cti->flush_constraint_targets(con, &targets, 1);
 		}
 		
-		/* Interpolate the enforcement, to blend result of constraint into final owner transform */
+		/* move owner back into worldspace for next constraint/other business */
+		if ((con->flag & CONSTRAINT_SPACEONCE) == 0) 
+			constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, con->ownspace, CONSTRAINT_SPACE_WORLD);
+			
+		/* Interpolate the enforcement, to blend result of constraint into final owner transform 
+		 * 	- all this happens in worldspace to prevent any weirdness creeping in ([#26014] and [#25725]),
+		 *	  since some constraints may not convert the solution back to the input space before blending
+		 *	  but all are guaranteed to end up in good "worldspace" result
+		 */
 		/* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka */
 		if (enf < 1.0) {
 			float solution[4][4];
 			copy_m4_m4(solution, cob->matrix);
 			blend_m4_m4m4(cob->matrix, oldmat, solution, enf);
 		}
-		
-		/* move owner back into worldspace for next constraint/other business */
-		if ((con->flag & CONSTRAINT_SPACEONCE) == 0) 
-			constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, con->ownspace, CONSTRAINT_SPACE_WORLD);
 	}
 }




More information about the Bf-blender-cvs mailing list