diff options
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_mesh.py | 2 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d.py | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 41 |
5 files changed, 37 insertions, 12 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index 655fd4045ee..b6ad14196cd 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -215,7 +215,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel): 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) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 51995ba5012..0eea75e4e64 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1312,13 +1312,13 @@ class VIEW3D_MT_vertex_group(Menu): 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() diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index b3ce9320852..58cca9dca02 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -203,6 +203,7 @@ void CONSTRAINT_OT_followpath_path_animate(struct wmOperatorType *ot); 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); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 356bda109a4..35bfba8b78a 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -175,6 +175,7 @@ void ED_operatortypes_object(void) 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); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index e1a18158c2d..c4fb3188528 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -2993,7 +2993,7 @@ static int vertex_group_vert_select_unlocked_poll(bContext *C) return !(dg->flag & DG_LOCK_WEIGHT); } } - return 0; + return 1; } static int vertex_group_vert_select_mesh_poll(bContext *C) @@ -3080,10 +3080,7 @@ static int vertex_group_assign_exec(bContext *C, wmOperator *op) { 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 @@ static int vertex_group_assign_exec(bContext *C, wmOperator *op) 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,9 +3104,35 @@ void OBJECT_OT_vertex_group_assign(wmOperatorType *ot) * 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) |