From ebfedd20b290e356f35eb1fcbcb5ddfb8e8bf0a9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 4 Dec 2007 12:39:27 +0000 Subject: [PATCH] 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. --- source/blender/blenkernel/intern/modifier.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index df2baefac81..efad06adcf3 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -6367,18 +6367,16 @@ static void meshdeformModifier_do( 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 @@ static void meshdeformModifier_do( dco= MEM_callocN(sizeof(*dco)*totcagevert, "MDefDco"); for(a=0; aobject->obmat, co); + Mat4MulVecfl(mmd->bindmat, co); + /* compute different with world space bind coord */ VECSUB(dco[a], co, bindcos[a]); } @@ -6449,6 +6449,7 @@ static void meshdeformModifier_do( } 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);