[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12778] trunk/blender/source/blender/ blenkernel/intern/modifier.c:

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Dec 4 13:39:28 CET 2007


Revision: 12778
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12778
Author:   blendix
Date:     2007-12-04 13:39:27 +0100 (Tue, 04 Dec 2007)

Log Message:
-----------

Mesh Deform Modifier
====================

Bugfix for mdef + groups. The mdef modifier treated the cage object as
a sort of parent, which meant that transforming the cage object also
transformed the mesh. However, this behaviour is different from e.g.
armatures, where transforming the armature object has no effect for
the modifier, but instead this transform is taken into account by the
fact that the armature is usually the parent of the mesh.

For groups and duplis, this basically lead to the parent transform
being applied twice. So, now transforming the cage object will have no
effect, except if you make the cage object the parent of the object.

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

Modified: trunk/blender/source/blender/blenkernel/intern/modifier.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/modifier.c	2007-12-04 11:34:26 UTC (rev 12777)
+++ trunk/blender/source/blender/blenkernel/intern/modifier.c	2007-12-04 12:39:27 UTC (rev 12778)
@@ -6367,18 +6367,16 @@
 			tmpdm->release(tmpdm);
 	}
 	else
-		cagedm= mesh_get_derived_final(mmd->object, CD_MASK_BAREMESH);
+		cagedm= mmd->object->derivedFinal;
 	
-	/* TODO: this could give inifinite loop for circular dependency */
 	if(!cagedm)
 		return;
 
  	/* compute matrices to go in and out of cage object space */
-	Mat4Invert(imat, (mmd->bindcos)? mmd->bindmat: mmd->object->obmat);
+	Mat4Invert(imat, mmd->object->obmat);
 	Mat4MulMat4(cagemat, ob->obmat, imat);
 	Mat4Invert(icagemat, cagemat);
-	Mat4Invert(imat, ob->obmat);
-	Mat3CpyMat4(iobmat, imat);
+	Mat3CpyMat4(iobmat, icagemat);
 
 	/* bind weights if needed */
 	if(!mmd->bindcos)
@@ -6400,8 +6398,10 @@
 
 	dco= MEM_callocN(sizeof(*dco)*totcagevert, "MDefDco");
 	for(a=0; a<totcagevert; a++) {
+		/* get cage vertex in world space with binding transform */
 		VECCOPY(co, cagemvert[a].co);
-		Mat4MulVecfl(mmd->object->obmat, co);
+		Mat4MulVecfl(mmd->bindmat, co);
+		/* compute different with world space bind coord */
 		VECSUB(dco[a], co, bindcos[a]);
 	}
 
@@ -6449,6 +6449,7 @@
 		}
 
 		if(mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
+			/* transform coordinate into cage's local space */
 			VECCOPY(co, vertexCos[b]);
 			Mat4MulVecfl(cagemat, co);
 			totweight= meshdeform_dynamic_bind(mmd, dco, co);





More information about the Bf-blender-cvs mailing list