[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11913] trunk/blender/source/blender/src/ editarmature.c: apply envelope to weigh group didnt take armature scale into account

Campbell Barton cbarton at metavr.com
Sat Sep 1 22:27:51 CEST 2007


Revision: 11913
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11913
Author:   campbellbarton
Date:     2007-09-01 22:27:50 +0200 (Sat, 01 Sep 2007)

Log Message:
-----------
apply envelope to weigh group didnt take armature scale into account

Modified Paths:
--------------
    trunk/blender/source/blender/src/editarmature.c

Modified: trunk/blender/source/blender/src/editarmature.c
===================================================================
--- trunk/blender/source/blender/src/editarmature.c	2007-09-01 18:50:40 UTC (rev 11912)
+++ trunk/blender/source/blender/src/editarmature.c	2007-09-01 20:27:50 UTC (rev 11913)
@@ -2488,7 +2488,7 @@
 	VECCOPY(verts[index], co);
 }
 
-static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist, bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], int *selected)
+static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist, bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], int *selected, float scale)
 {
 	/* Create vertex group weights from envelopes */
 
@@ -2511,7 +2511,7 @@
 
 			/* store the distance-factor from the vertex to the bone */
 			distance = distfactor_to_bone (verts[i], root[j], tip[j],
-				bone->rad_head, bone->rad_tail, bone->dist);
+				bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
 
 			/* add the vert to the deform group if weight!=0.0 */
 			if (distance!=0.0)
@@ -2653,13 +2653,22 @@
 	}
 
 	/* compute the weights based on gathered vertices and bones */
-	if (heat)
+	if (heat) {
 		heat_bone_weighting(ob, mesh, verts, numbones, dgrouplist, dgroupflip,
 			root, tip, selected);
-	else
+	} else {
+		float scale;
+		float tmp[3] = {1.0, 1.0, 1.0};
+		float mat[3][3];
+		
+		/* scale value from matrix, wont account for non uniform scale but ok */
+		Mat3CpyMat4(mat, ob->obmat);
+		Mat3MulVecfl(mat, tmp);
+		scale = (fabs(tmp[0]) + fabs(tmp[1]) + fabs(tmp[2])) / 3.0f;
+		
 		envelope_bone_weighting(ob, mesh, verts, numbones, bonelist, dgrouplist,
-			dgroupflip, root, tip, selected);
-
+			dgroupflip, root, tip, selected, scale);
+	}
     /* free the memory allocated */
     MEM_freeN(bonelist);
     MEM_freeN(dgrouplist);





More information about the Bf-blender-cvs mailing list