[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32404] trunk/blender/source/blender/ editors: [#24045] heat weight fails on specific geometry.

Campbell Barton ideasman42 at gmail.com
Mon Oct 11 02:15:49 CEST 2010


Revision: 32404
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32404
Author:   campbellbarton
Date:     2010-10-11 02:15:49 +0200 (Mon, 11 Oct 2010)

Log Message:
-----------
[#24045] heat weight fails on specific geometry.
The error for heat weighting was only being printed in the console, while the problem remains at least a warning is now given that there was a problem calculating the heat weight.

also fixed a memory leak from the mesh octree not being freed after assigning vertex groups. (ModNode error)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/armature/editarmature.c
    trunk/blender/source/blender/editors/armature/meshlaplacian.c
    trunk/blender/source/blender/editors/armature/meshlaplacian.h
    trunk/blender/source/blender/editors/include/ED_armature.h
    trunk/blender/source/blender/editors/object/object_relations.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c

Modified: trunk/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- trunk/blender/source/blender/editors/armature/editarmature.c	2010-10-10 23:37:25 UTC (rev 32403)
+++ trunk/blender/source/blender/editors/armature/editarmature.c	2010-10-11 00:15:49 UTC (rev 32404)
@@ -4723,7 +4723,7 @@
 	}
 }
 
-void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int mirror)
+void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, Object *par, int heat, int mirror)
 {
 	/* This functions implements the automatic computation of vertex group
 	 * weights, either through envelopes or using a heat equilibrium.
@@ -4870,14 +4870,22 @@
 
 	/* compute the weights based on gathered vertices and bones */
 	if (heat) {
+		const char *error= NULL;
 		heat_bone_weighting(ob, mesh, verts, numbones, dgrouplist, dgroupflip,
-			root, tip, selected);
+			root, tip, selected, &error);
+		
+		if(error) {
+			BKE_report(reports, RPT_WARNING, error);
+		}
 	}
 	else {
 		envelope_bone_weighting(ob, mesh, verts, numbones, bonelist, dgrouplist,
 			dgroupflip, root, tip, selected, mat4_to_scale(par->obmat));
 	}
-	
+
+	/* only generated in some cases but can call anyway */
+	mesh_octree_table(ob, NULL, NULL, 'e');
+
 	/* free the memory allocated */
 	MEM_freeN(bonelist);
 	MEM_freeN(dgrouplist);
@@ -4888,7 +4896,7 @@
 	MEM_freeN(verts);
 }
 
-void create_vgroups_from_armature(Scene *scene, Object *ob, Object *par, int mode, int mirror)
+void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob, Object *par, int mode, int mirror)
 {
 	/* Lets try to create some vertex groups 
 	 * based on the bones of the parent armature.
@@ -4909,7 +4917,7 @@
 		 * that are populated with the vertices for which the
 		 * bone is closest.
 		 */
-		add_verts_to_dgroups(scene, ob, par, (mode == ARM_GROUPS_AUTO), mirror);
+		add_verts_to_dgroups(reports, scene, ob, par, (mode == ARM_GROUPS_AUTO), mirror);
 	}
 } 
 /* ************* Clear Pose *****************************/

Modified: trunk/blender/source/blender/editors/armature/meshlaplacian.c
===================================================================
--- trunk/blender/source/blender/editors/armature/meshlaplacian.c	2010-10-10 23:37:25 UTC (rev 32403)
+++ trunk/blender/source/blender/editors/armature/meshlaplacian.c	2010-10-11 00:15:49 UTC (rev 32404)
@@ -642,13 +642,15 @@
 		return weight;
 }
 
-void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], int *selected)
+void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], int *selected, const char **err_str)
 {
 	LaplacianSystem *sys;
 	MFace *mface;
 	float solution, weight;
 	int *vertsflipped = NULL, *mask= NULL;
 	int a, totface, j, bbone, firstsegment, lastsegment, thrownerror = 0;
+	
+	*err_str= NULL;
 
 	/* count triangles and create mask */
 	if(me->editflag & ME_EDIT_PAINT_MASK)
@@ -760,8 +762,7 @@
 			}
 		}
 		else if(!thrownerror) {
-			error("Bone Heat Weighting:"
-				" failed to find solution for one or more bones");
+			*err_str= "Bone Heat Weighting: failed to find solution for one or more bones";
 			thrownerror= 1;
 			break;
 		}

Modified: trunk/blender/source/blender/editors/armature/meshlaplacian.h
===================================================================
--- trunk/blender/source/blender/editors/armature/meshlaplacian.h	2010-10-10 23:37:25 UTC (rev 32403)
+++ trunk/blender/source/blender/editors/armature/meshlaplacian.h	2010-10-11 00:15:49 UTC (rev 32404)
@@ -66,7 +66,7 @@
 void heat_bone_weighting(struct Object *ob, struct Mesh *me, float (*verts)[3],
 	int numbones, struct bDeformGroup **dgrouplist,
 	struct bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3],
-	int *selected);
+	int *selected, const char **error);
 
 #ifdef RIGID_DEFORM
 /* As-Rigid-As-Possible Deformation */

Modified: trunk/blender/source/blender/editors/include/ED_armature.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_armature.h	2010-10-10 23:37:25 UTC (rev 32403)
+++ trunk/blender/source/blender/editors/include/ED_armature.h	2010-10-11 00:15:49 UTC (rev 32404)
@@ -42,6 +42,7 @@
 struct MeshDeformModifierData;
 struct Object;
 struct RegionView3D;
+struct ReportList;
 struct Scene;
 struct SK_Sketch;
 struct View3D;
@@ -132,7 +133,7 @@
 #define ARM_GROUPS_ENVELOPE	2
 #define ARM_GROUPS_AUTO		3
 
-void create_vgroups_from_armature(struct Scene *scene, struct Object *ob, struct Object *par, int mode, int mirror);
+void create_vgroups_from_armature(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct Object *par, int mode, int mirror);
 
 void auto_align_armature(struct Scene *scene, struct View3D *v3d, short mode);
 void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone); /* if bone is already in list, pass it as param to ignore it */

Modified: trunk/blender/source/blender/editors/object/object_relations.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_relations.c	2010-10-10 23:37:25 UTC (rev 32403)
+++ trunk/blender/source/blender/editors/object/object_relations.c	2010-10-11 00:15:49 UTC (rev 32404)
@@ -641,11 +641,11 @@
 				}
 				else if(pararm && ob->type==OB_MESH && par->type == OB_ARMATURE) {
 					if(partype == PAR_ARMATURE_NAME)
-						create_vgroups_from_armature(scene, ob, par, ARM_GROUPS_NAME, 0);
+						create_vgroups_from_armature(op->reports, scene, ob, par, ARM_GROUPS_NAME, 0);
 					else if(partype == PAR_ARMATURE_ENVELOPE)
-						create_vgroups_from_armature(scene, ob, par, ARM_GROUPS_ENVELOPE, 0);
+						create_vgroups_from_armature(op->reports, scene, ob, par, ARM_GROUPS_ENVELOPE, 0);
 					else if(partype == PAR_ARMATURE_AUTO)
-						create_vgroups_from_armature(scene, ob, par, ARM_GROUPS_AUTO, 0);
+						create_vgroups_from_armature(op->reports, scene, ob, par, ARM_GROUPS_AUTO, 0);
 					
 					/* get corrected inverse */
 					ob->partype= PAROBJECT;

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2010-10-10 23:37:25 UTC (rev 32403)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2010-10-11 00:15:49 UTC (rev 32404)
@@ -1971,7 +1971,7 @@
 	Mesh *me= ob->data;
 	int type= RNA_enum_get(op->ptr, "type");
 
-	create_vgroups_from_armature(scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
+	create_vgroups_from_armature(op->reports, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
 
 	DAG_id_flush_update(&me->id, OB_RECALC_DATA);
 	WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);





More information about the Bf-blender-cvs mailing list