diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-10-24 02:25:57 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-10-24 02:25:59 +0300 |
commit | c052d38d0a59478035151af8c5cf9267c7414933 (patch) | |
tree | 705040d044542eee5f396b820fe91a8719a7f2ef /source/blender/editors/lattice | |
parent | ed7f6b511f817d9b93eecb07955a30eb3a5afb87 (diff) |
Multi-Objects: LATTICE_OT_select_ungrouped
I thought about having a single error message, or to use BKE_reportf to just
add the "s". That would be bad for translators, so now we have two
explicit messages.
Diffstat (limited to 'source/blender/editors/lattice')
-rw-r--r-- | source/blender/editors/lattice/editlattice_select.c | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c index 41ed73baf0e..5ff8ae76c3d 100644 --- a/source/blender/editors/lattice/editlattice_select.c +++ b/source/blender/editors/lattice/editlattice_select.c @@ -451,35 +451,51 @@ void LATTICE_OT_select_all(wmOperatorType *ot) static int lattice_select_ungrouped_exec(bContext *C, wmOperator *op) { - Object *obedit = CTX_data_edit_object(C); - Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; - MDeformVert *dv; - BPoint *bp; - int a, tot; + ViewLayer *view_layer = CTX_data_view_layer(C); + uint objects_len; + const bool is_extend = RNA_boolean_get(op->ptr, "extend"); + bool changed = false; - if (BLI_listbase_is_empty(&obedit->defbase) || lt->dvert == NULL) { - BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object"); - return OPERATOR_CANCELLED; - } + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; + MDeformVert *dv; + BPoint *bp; + int a, tot; - if (!RNA_boolean_get(op->ptr, "extend")) { - ED_lattice_flags_set(obedit, 0); - } + if (BLI_listbase_is_empty(&obedit->defbase) || lt->dvert == NULL) { + continue; + } + + if (!is_extend) { + ED_lattice_flags_set(obedit, 0); + } - dv = lt->dvert; - tot = lt->pntsu * lt->pntsv * lt->pntsw; + dv = lt->dvert; + tot = lt->pntsu * lt->pntsv * lt->pntsw; - for (a = 0, bp = lt->def; a < tot; a++, bp++, dv++) { - if (bp->hide == 0) { - if (dv->dw == NULL) { - bp->f1 |= SELECT; + for (a = 0, bp = lt->def; a < tot; a++, bp++, dv++) { + if (bp->hide == 0) { + if (dv->dw == NULL) { + bp->f1 |= SELECT; + } } } - } - DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + changed = true; + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + } + MEM_freeN(objects); + if (!changed) { + BKE_report(op->reports, + RPT_ERROR, + objects_len > 1 ? "No weights/vertex groups on objects" : + "No weights/vertex groups on object"); + return OPERATOR_CANCELLED; + } return OPERATOR_FINISHED; } |