[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28377] trunk/blender/source/blender/ modifiers/intern/MOD_meshdeform.c: Mesh Deform Modifier: should have included this in last commit.

Brecht Van Lommel brecht at blender.org
Fri Apr 23 13:27:50 CEST 2010


Revision: 28377
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28377
Author:   blendix
Date:     2010-04-23 13:27:50 +0200 (Fri, 23 Apr 2010)

Log Message:
-----------
Mesh Deform Modifier: should have included this in last commit.

Modified Paths:
--------------
    trunk/blender/source/blender/modifiers/intern/MOD_meshdeform.c

Modified: trunk/blender/source/blender/modifiers/intern/MOD_meshdeform.c
===================================================================
--- trunk/blender/source/blender/modifiers/intern/MOD_meshdeform.c	2010-04-23 11:19:06 UTC (rev 28376)
+++ trunk/blender/source/blender/modifiers/intern/MOD_meshdeform.c	2010-04-23 11:27:50 UTC (rev 28377)
@@ -58,8 +58,9 @@
 {
 	MeshDeformModifierData *mmd = (MeshDeformModifierData*) md;
 
-	if(mmd->bindweights) MEM_freeN(mmd->bindweights);
-	if(mmd->bindcos) MEM_freeN(mmd->bindcos);
+	if(mmd->bindinfluences) MEM_freeN(mmd->bindinfluences);
+	if(mmd->bindoffsets) MEM_freeN(mmd->bindoffsets);
+	if(mmd->bindcagecos) MEM_freeN(mmd->bindcagecos);
 	if(mmd->dyngrid) MEM_freeN(mmd->dyngrid);
 	if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences);
 	if(mmd->dynverts) MEM_freeN(mmd->dynverts);
@@ -170,7 +171,7 @@
 }
 
 static void meshdeformModifier_do(
-				  ModifierData *md, Object *ob, DerivedMesh *dm,
+	  ModifierData *md, Object *ob, DerivedMesh *dm,
 	  float (*vertexCos)[3], int numVerts)
 {
 	MeshDeformModifierData *mmd = (MeshDeformModifierData*) md;
@@ -180,11 +181,13 @@
 	MDeformVert *dvert = NULL;
 	MDeformWeight *dw;
 	MVert *cagemvert;
+	MDefInfluence *influences;
+	int *offsets;
 	float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4];
-	float weight, totweight, fac, co[3], *weights, (*dco)[3], (*bindcos)[3];
+	float weight, totweight, fac, co[3], (*dco)[3], (*bindcagecos)[3];
 	int a, b, totvert, totcagevert, defgrp_index;
 	
-	if(!mmd->object || (!mmd->bindcos && !mmd->bindfunc))
+	if(!mmd->object || (!mmd->bindcagecos && !mmd->bindfunc))
 		return;
 	
 	/* get cage derivedmesh */
@@ -216,7 +219,7 @@
 	copy_m3_m4(icagemat, iobmat);
 
 	/* bind weights if needed */
-	if(!mmd->bindcos) {
+	if(!mmd->bindcagecos) {
 		static int recursive = 0;
 
 		/* progress bar redraw can make this recursive .. */
@@ -231,15 +234,16 @@
 	totvert= numVerts;
 	totcagevert= cagedm->getNumVerts(cagedm);
 
-	if(mmd->totvert!=totvert || mmd->totcagevert!=totcagevert || !mmd->bindcos) {
+	if(mmd->totvert!=totvert || mmd->totcagevert!=totcagevert || !mmd->bindcagecos) {
 		cagedm->release(cagedm);
 		return;
 	}
 	
 	/* setup deformation data */
 	cagemvert= cagedm->getVertArray(cagedm);
-	weights= mmd->bindweights;
-	bindcos= (float(*)[3])mmd->bindcos;
+	influences= mmd->bindinfluences;
+	offsets= mmd->bindoffsets;
+	bindcagecos= (float(*)[3])mmd->bindcagecos;
 
 	dco= MEM_callocN(sizeof(*dco)*totcagevert, "MDefDco");
 	for(a=0; a<totcagevert; a++) {
@@ -249,7 +253,7 @@
 		if(G.rt != 527) {
 			mul_m4_v3(mmd->bindmat, co);
 			/* compute difference with world space bind coord */
-			sub_v3_v3v3(dco[a], co, bindcos[a]);
+			sub_v3_v3v3(dco[a], co, bindcagecos[a]);
 		}
 		else
 			copy_v3_v3(dco[a], co);
@@ -296,9 +300,9 @@
 			totweight= 0.0f;
 			co[0]= co[1]= co[2]= 0.0f;
 
-			for(a=0; a<totcagevert; a++) {
-				weight= weights[a + b*totcagevert];
-				madd_v3_v3fl(co, dco[a], weight);
+			for(a=offsets[b]; a<offsets[b+1]; a++) {
+				weight= influences[a].weight;
+				madd_v3_v3fl(co, dco[influences[a].vertex], weight);
 				totweight += weight;
 			}
 		}





More information about the Bf-blender-cvs mailing list