diff options
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d.py | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 39 |
2 files changed, 29 insertions, 14 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 81985b55666..a2d78974aeb 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2734,6 +2734,10 @@ class VIEW3D_MT_object_cleanup(Menu): layout = self.layout layout.operator("object.vertex_group_clean", text="Clean Vertex Group Weights").group_select_mode = 'ALL' + layout.operator("object.vertex_group_limit_total", text="Limit Total Vertex Groups").group_select_mode = 'ALL' + + layout.separator() + layout.operator("object.material_slot_remove_unused", text="Remove Unused Material Slots") diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index a144632fc5f..6d426313b66 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -3716,25 +3716,36 @@ void OBJECT_OT_vertex_group_quantize(wmOperatorType *ot) static int vertex_group_limit_total_exec(bContext *C, wmOperator *op) { - Object *ob = ED_object_context(C); - const int limit = RNA_int_get(op->ptr, "limit"); - eVGroupSelect subset_type = RNA_enum_get(op->ptr, "group_select_mode"); + const eVGroupSelect subset_type = RNA_enum_get(op->ptr, "group_select_mode"); + int remove_multi_count = 0; - int subset_count, vgroup_tot; + uint objects_len; + Object **objects = object_array_for_wpaint(C, &objects_len); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *ob = objects[ob_index]; - const bool *vgroup_validmap = BKE_object_defgroup_subset_from_select_type( - ob, subset_type, &vgroup_tot, &subset_count); - int remove_tot = vgroup_limit_total_subset(ob, vgroup_validmap, vgroup_tot, subset_count, limit); - MEM_freeN((void *)vgroup_validmap); + int subset_count, vgroup_tot; + const bool *vgroup_validmap = BKE_object_defgroup_subset_from_select_type( + ob, subset_type, &vgroup_tot, &subset_count); + const int remove_count = vgroup_limit_total_subset( + ob, vgroup_validmap, vgroup_tot, subset_count, limit); + MEM_freeN((void *)vgroup_validmap); - BKE_reportf( - op->reports, remove_tot ? RPT_INFO : RPT_WARNING, "%d vertex weights limited", remove_tot); + if (remove_count != 0) { + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + } + remove_multi_count += remove_count; + } + MEM_freeN(objects); - if (remove_tot) { - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + if (remove_multi_count) { + BKE_reportf(op->reports, + remove_multi_count ? RPT_INFO : RPT_WARNING, + "%d vertex weights limited", + remove_multi_count); return OPERATOR_FINISHED; } |