[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13421] trunk/blender/source/blender: VertexGroup Editing:

Joshua Leung aligorith at gmail.com
Sun Jan 27 11:34:36 CET 2008


Revision: 13421
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13421
Author:   aligorith
Date:     2008-01-27 11:34:35 +0100 (Sun, 27 Jan 2008)

Log Message:
-----------
VertexGroup Editing:

Added a new option to the "Vertex Groups" menu: "Remove Selected from All Groups". This menu can be accessed using Ctrl-G in EditMode for Meshes and Lattices.

Modified Paths:
--------------
    trunk/blender/source/blender/include/BIF_editdeform.h
    trunk/blender/source/blender/src/editdeform.c

Modified: trunk/blender/source/blender/include/BIF_editdeform.h
===================================================================
--- trunk/blender/source/blender/include/BIF_editdeform.h	2008-01-27 09:39:26 UTC (rev 13420)
+++ trunk/blender/source/blender/include/BIF_editdeform.h	2008-01-27 10:34:35 UTC (rev 13421)
@@ -50,6 +50,7 @@
 void duplicate_defgroup ( struct Object *ob );
 void assign_verts_defgroup (void);
 void remove_verts_defgroup (int allverts);
+void remove_verts_defgroups (int allverts);
 void sel_verts_defgroup (int select);
 
 struct MDeformWeight *get_defweight (struct MDeformVert *dv, int defgroup);

Modified: trunk/blender/source/blender/src/editdeform.c
===================================================================
--- trunk/blender/source/blender/src/editdeform.c	2008-01-27 09:39:26 UTC (rev 13420)
+++ trunk/blender/source/blender/src/editdeform.c	2008-01-27 10:34:35 UTC (rev 13421)
@@ -779,7 +779,7 @@
 	case OB_MESH:
 		for (eve=G.editMesh->verts.first; eve; eve=eve->next){
 			dvert= CustomData_em_get(&G.editMesh->vdata, eve->data, CD_MDEFORMVERT);
-
+		
 			if (dvert && dvert->dw && ((eve->f & 1) || allverts)){
 				for (i=0; i<dvert->totweight; i++){
 					/* Find group */
@@ -825,6 +825,36 @@
 	}
 }
 
+/* Only available in editmode */
+/* removes from all defgroup, if allverts==0 only selected vertices */
+void remove_verts_defgroups(int allverts)
+{
+	Object *ob;
+	int actdef, defCount;
+	
+	if (multires_level1_test()) return;
+
+	ob= G.obedit;
+	if (ob == NULL) return;
+	
+	actdef= ob->actdef;
+	defCount= BLI_countlist(&ob->defbase);
+	
+	if (defCount == 0) {
+		error("Object has no vertex groups");
+		return;
+	}
+	
+	/* To prevent code redundancy, we just use remove_verts_defgroup, but that
+	 * only operates on the active vgroup. So we iterate through all groups, by changing
+	 * active group index
+	 */
+	for (ob->actdef= 1; ob->actdef <= defCount; ob->actdef++)
+		remove_verts_defgroup(allverts);
+		
+	ob->actdef= actdef;
+}
+
 void vertexgroup_select_by_name(Object *ob, char *name)
 {
 	bDeformGroup *curdef;
@@ -859,7 +889,7 @@
 	
 	/* give user choices of adding to current/new or removing from current */
 	if (defCount && ob->actdef)
-		mode = pupmenu("Vertex Groups %t|Add Selected to New Group %x1|Add Selected to Active Group %x2|Remove Selected from Active Group %x3");
+		mode = pupmenu("Vertex Groups %t|Add Selected to New Group %x1|Add Selected to Active Group %x2|Remove Selected from Active Group %x3|Remove Selected from All Groups %x4");
 	else
 		mode= pupmenu("Vertex Groups %t|Add Selected to New Group %x1");
 	
@@ -881,6 +911,11 @@
 			allqueue(REDRAWVIEW3D, 1);
 			BIF_undo_push("Remove from vertex group");
 			break;
+		case 4: /* remove from all groups */
+			remove_verts_defgroups(0);
+			allqueue(REDRAWVIEW3D, 1);
+			BIF_undo_push("Remove from all vertex groups");
+			break;
 	}
 }
 





More information about the Bf-blender-cvs mailing list