[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57901] trunk/blender: Bugfix [#35936] Can 't create new vertex group when using Ctrl G menu

Joshua Leung aligorith at gmail.com
Mon Jul 1 15:02:54 CEST 2013


Revision: 57901
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57901
Author:   aligorith
Date:     2013-07-01 13:02:53 +0000 (Mon, 01 Jul 2013)
Log Message:
-----------
Bugfix [#35936] Can't create new vertex group when using Ctrl G menu

This was caused by r.57812

There were two problems here:
  1) vertex_group_vert_select_unlocked_poll()  had faulty logic which meant that
it always failed when there were no vgroups present yet - the final return
always just fell through
  2) Since the "Assign to New Groups" option was actually implemented using the
same operator as "Assign to Active Group" (just with an extra parameter set), if
the active group was locked, it was not possible to "Assign to New Group" (even
though a new group would not be locked).

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py
    trunk/blender/release/scripts/startup/bl_ui/space_view3d.py
    trunk/blender/source/blender/editors/object/object_intern.h
    trunk/blender/source/blender/editors/object/object_ops.c
    trunk/blender/source/blender/editors/object/object_vgroup.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py	2013-07-01 11:00:22 UTC (rev 57900)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py	2013-07-01 13:02:53 UTC (rev 57901)
@@ -215,7 +215,7 @@
             row = layout.row()
 
             sub = row.row(align=True)
-            sub.operator("object.vertex_group_assign", text="Assign").new = False
+            sub.operator("object.vertex_group_assign", text="Assign")
             sub.operator("object.vertex_group_remove_from", text="Remove")
 
             sub = row.row(align=True)

Modified: trunk/blender/release/scripts/startup/bl_ui/space_view3d.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_view3d.py	2013-07-01 11:00:22 UTC (rev 57900)
+++ trunk/blender/release/scripts/startup/bl_ui/space_view3d.py	2013-07-01 13:02:53 UTC (rev 57901)
@@ -1312,13 +1312,13 @@
         layout = self.layout
 
         layout.operator_context = 'EXEC_AREA'
-        layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
+        layout.operator("object.vertex_group_assign_new")
 
         ob = context.active_object
         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
             if ob.vertex_groups.active:
                 layout.separator()
-                layout.operator("object.vertex_group_assign", text="Assign to Active Group").new = False
+                layout.operator("object.vertex_group_assign", text="Assign to Active Group")
                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").use_all_groups = False
                 layout.operator("object.vertex_group_remove_from", text="Remove from All").use_all_groups = True
                 layout.separator()

Modified: trunk/blender/source/blender/editors/object/object_intern.h
===================================================================
--- trunk/blender/source/blender/editors/object/object_intern.h	2013-07-01 11:00:22 UTC (rev 57900)
+++ trunk/blender/source/blender/editors/object/object_intern.h	2013-07-01 13:02:53 UTC (rev 57901)
@@ -203,6 +203,7 @@
 void OBJECT_OT_vertex_group_add(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_group_remove(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_group_assign(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_assign_new(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_group_remove_from(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_group_select(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_group_deselect(struct wmOperatorType *ot);

Modified: trunk/blender/source/blender/editors/object/object_ops.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_ops.c	2013-07-01 11:00:22 UTC (rev 57900)
+++ trunk/blender/source/blender/editors/object/object_ops.c	2013-07-01 13:02:53 UTC (rev 57901)
@@ -175,6 +175,7 @@
 	WM_operatortype_append(OBJECT_OT_vertex_group_add);
 	WM_operatortype_append(OBJECT_OT_vertex_group_remove);
 	WM_operatortype_append(OBJECT_OT_vertex_group_assign);
+	WM_operatortype_append(OBJECT_OT_vertex_group_assign_new);
 	WM_operatortype_append(OBJECT_OT_vertex_group_remove_from);
 	WM_operatortype_append(OBJECT_OT_vertex_group_select);
 	WM_operatortype_append(OBJECT_OT_vertex_group_deselect);

Modified: trunk/blender/source/blender/editors/object/object_vgroup.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_vgroup.c	2013-07-01 11:00:22 UTC (rev 57900)
+++ trunk/blender/source/blender/editors/object/object_vgroup.c	2013-07-01 13:02:53 UTC (rev 57901)
@@ -2993,7 +2993,7 @@
 			return !(dg->flag & DG_LOCK_WEIGHT);
 		}
 	}
-	return 0;
+	return 1;
 }
 
 static int vertex_group_vert_select_mesh_poll(bContext *C)
@@ -3080,10 +3080,7 @@
 {
 	ToolSettings *ts = CTX_data_tool_settings(C);
 	Object *ob = ED_object_context(C);
-
-	if (RNA_boolean_get(op->ptr, "new"))
-		ED_vgroup_add(ob);
-
+	
 	vgroup_assign_verts(ob, ts->vgroup_weight);
 	DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 	WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -3094,9 +3091,9 @@
 void OBJECT_OT_vertex_group_assign(wmOperatorType *ot)
 {
 	/* identifiers */
-	ot->name = "Assign Vertex Group";
+	ot->name = "Assign to Vertex Group";
 	ot->idname = "OBJECT_OT_vertex_group_assign";
-	ot->description = "Assign the selected vertices to the active (or a new) vertex group";
+	ot->description = "Assign the selected vertices to the active vertex group";
 	
 	/* api callbacks */
 	ot->poll = vertex_group_vert_select_unlocked_poll;
@@ -3107,11 +3104,37 @@
 	 * isn't stored in local edit mode stack and toggling "new" property will
 	 * lead to creating plenty of new vertex groups (see [#29527], sergey) */
 	ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO;
+}
 
-	/* properties */
-	RNA_def_boolean(ot->srna, "new", 0, "New", "Assign vertex to new vertex group");
+/* NOTE: just a wrapper around vertex_group_assign_exec(), except we add these to a new group */
+static int vertex_group_assign_new_exec(bContext *C, wmOperator *op)
+{
+	/* create new group... */
+	Object *ob = ED_object_context(C);
+	ED_vgroup_add(ob);
+	
+	/* assign selection to new group */
+	return vertex_group_assign_exec(C, op);
 }
 
+void OBJECT_OT_vertex_group_assign_new(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Assign to New Group";
+	ot->idname = "OBJECT_OT_vertex_group_assign_new";
+	ot->description = "Assign the selected vertices to a new vertex group";
+	
+	/* api callbacks */
+	ot->poll = vertex_group_vert_select_poll;
+	ot->exec = vertex_group_assign_new_exec;
+	
+	/* flags */
+	/* redo operator will fail in this case because vertex group assignment
+	 * isn't stored in local edit mode stack and toggling "new" property will
+	 * lead to creating plenty of new vertex groups (see [#29527], sergey) */
+	ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO;
+}
+
 static int vertex_group_remove_from_exec(bContext *C, wmOperator *op)
 {
 	const bool use_all_groups = RNA_boolean_get(op->ptr, "use_all_groups");




More information about the Bf-blender-cvs mailing list