[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31096] trunk/blender/source/blender/ blenkernel/intern/lattice.c: Minor cleanup to lattice.c while looking into [#19525] Curve modifier moves mesh geometry first

Campbell Barton ideasman42 at gmail.com
Fri Aug 6 07:19:05 CEST 2010


Revision: 31096
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31096
Author:   campbellbarton
Date:     2010-08-06 07:19:00 +0200 (Fri, 06 Aug 2010)

Log Message:
-----------
Minor cleanup to lattice.c while looking into [#19525] Curve modifier moves mesh geometry first
A subtle change with the curve deform modifier is when a vgroup is used: the mesh bounds were being calculated based on the verts in the group (ignoring their weight).
Now ignore verts weighted at 0.

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

Modified: trunk/blender/source/blender/blenkernel/intern/lattice.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/lattice.c	2010-08-06 04:55:32 UTC (rev 31095)
+++ trunk/blender/source/blender/blenkernel/intern/lattice.c	2010-08-06 05:19:00 UTC (rev 31096)
@@ -175,7 +175,7 @@
 	bp= lt->def;
 	
 	for (i=0; i<lt->pntsu*lt->pntsv*lt->pntsw; i++,bp++) {
-		VECCOPY(bp->vec, vertexCos[i]);
+		copy_v3_v3(bp->vec, vertexCos[i]);
 	}
 
 	MEM_freeN(vertexCos);
@@ -474,7 +474,9 @@
 		invert_m4_m4(par->imat, par->obmat);
 		mul_v3_m4v3(cd->dloc, par->imat, ob->obmat[3]);
 	}
-	else cd->dloc[0]=cd->dloc[1]=cd->dloc[2]= 0.0f;
+	else {
+		cd->dloc[0]=cd->dloc[1]=cd->dloc[2]= 0.0f;
+	}
 	
 	cd->no_rot_axis= 0;
 }
@@ -507,15 +509,15 @@
 			if(ctime < 0.0) {
 				sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec);
 				mul_v3_fl(dvec, ctime*(float)path->len);
-				VECADD(vec, vec, dvec);
-				if(quat) QUATCOPY(quat, path->data[0].quat);
+				add_v3_v3(vec, dvec);
+				if(quat) copy_qt_qt(quat, path->data[0].quat);
 				if(radius) *radius= path->data[0].radius;
 			}
 			else if(ctime > 1.0) {
 				sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec);
 				mul_v3_fl(dvec, (ctime-1.0)*(float)path->len);
-				VECADD(vec, vec, dvec);
-				if(quat) QUATCOPY(quat, path->data[path->len-1].quat);
+				add_v3_v3(vec, dvec);
+				if(quat) copy_qt_qt(quat, path->data[path->len-1].quat);
 				if(radius) *radius= path->data[path->len-1].radius;
 				/* weight - not used but could be added */
 			}
@@ -608,7 +610,7 @@
 			/* this is not exactly the same as 2.4x, since the axis is having rotation removed rather then
 			 * changing the axis before calculating the tilt but serves much the same purpose */
 			float dir_flat[3]={0,0,0}, q[4];
-			VECCOPY(dir_flat, dir);
+			copy_v3_v3(dir_flat, dir);
 			dir_flat[cd->no_rot_axis-1]= 0.0f;
 
 			normalize_v3(dir);
@@ -686,11 +688,11 @@
 		mul_qt_v3(quat, cent);
 
 		/* translation */
-		VECADD(co, cent, loc);
+		add_v3_v3v3(co, cent, loc);
 
 		if(quatp)
-			QUATCOPY(quatp, quat);
-		
+			copy_qt_qt(quatp, quat);
+
 		return 1;
 	}
 	return 0;
@@ -726,48 +728,36 @@
 		use_vgroups = 0;
 	
 	if(vgroup && vgroup[0] && use_vgroups) {
-		bDeformGroup *curdef;
 		Mesh *me= target->data;
-		int index;
-		
-		/* find the group (weak loop-in-loop) */
-		for(index = 0, curdef = target->defbase.first; curdef;
-			curdef = curdef->next, index++)
-			if (!strcmp(curdef->name, vgroup))
-				break;
+		int index= defgroup_name_index(target, vgroup);
 
-		if(curdef && (me->dvert || dm)) {
+		if(index != -1 && (me->dvert || dm)) {
 			MDeformVert *dvert = me->dvert;
 			float vec[3];
-			int j;
+			float weight;
 
 			INIT_MINMAX(cd.dmin, cd.dmax);
 
 			for(a = 0; a < numVerts; a++, dvert++) {
 				if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
-
-				for(j = 0; j < dvert->totweight; j++) {
-					if(dvert->dw[j].def_nr == index) {
-						mul_m4_v3(cd.curvespace, vertexCos[a]);
-						DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax);
-						break;
-					}
+				
+				if(defvert_find_weight(dvert, index) > 0.0f) {
+					mul_m4_v3(cd.curvespace, vertexCos[a]);
+					DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax);
 				}
 			}
 
 			dvert = me->dvert;
 			for(a = 0; a < numVerts; a++, dvert++) {
 				if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
+				
+				weight= defvert_find_weight(dvert, index);
 
-				for(j = 0; j < dvert->totweight; j++) {
-					if(dvert->dw[j].def_nr == index) {
-						VECCOPY(vec, vertexCos[a]);
-						calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
-						interp_v3_v3v3(vertexCos[a], vertexCos[a], vec,
-								 dvert->dw[j].weight);
-						mul_m4_v3(cd.objectspace, vertexCos[a]);
-						break;
-					}
+				if(weight > 0.0f) {
+					copy_v3_v3(vec, vertexCos[a]);
+					calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
+					interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
+					mul_m4_v3(cd.objectspace, vertexCos[a]);
 				}
 			}
 		}
@@ -803,8 +793,8 @@
 	init_curve_deform(cuOb, target, &cd, 0);	/* 0 no dloc */
 	cd.no_rot_axis= no_rot_axis;				/* option to only rotate for XY, for example */
 	
-	VECCOPY(cd.dmin, orco);
-	VECCOPY(cd.dmax, orco);
+	copy_v3_v3(cd.dmin, orco);
+	copy_v3_v3(cd.dmax, orco);
 
 	mul_m4_v3(cd.curvespace, vec);
 	
@@ -973,7 +963,7 @@
 	vertexCos = MEM_mallocN(sizeof(*vertexCos)*numVerts,"lt_vcos");
 	
 	for (i=0; i<numVerts; i++) {
-		VECCOPY(vertexCos[i], lt->def[i].vec);
+		copy_v3_v3(vertexCos[i], lt->def[i].vec);
 	}
 
 	return vertexCos;
@@ -985,7 +975,7 @@
 	int i, numVerts = lt->pntsu*lt->pntsv*lt->pntsw;
 
 	for (i=0; i<numVerts; i++) {
-		VECCOPY(lt->def[i].vec, vertexCos[i]);
+		copy_v3_v3(lt->def[i].vec, vertexCos[i]);
 	}
 }
 





More information about the Bf-blender-cvs mailing list