diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-10-26 17:01:53 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-10-26 17:04:54 +0300 |
commit | 1cc7d71a0b20fdea9328305e7ed59b0d64a8b8b0 (patch) | |
tree | b4af93832f4a7cfa771146f38adaf62a63277c08 /source/blender/editors | |
parent | 70d73ff5007c817c6c7fedbfceea2fc1641f60b5 (diff) |
Multi-Objects: LATTICE_OT_make_regular
Committing this for the sake of completionism. I'm going to bring this
up for review, I think we may want to revert it.
Fundamentally I'm changing the behaviour of the operator both in object
mode (acting on all selected lattice objects), as well as the edit mode
(acting on all lattices in edit mode, regardless of them having any
selected vertice).
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/lattice/editlattice_tools.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/source/blender/editors/lattice/editlattice_tools.c b/source/blender/editors/lattice/editlattice_tools.c index 4fefe05b799..01211a436a4 100644 --- a/source/blender/editors/lattice/editlattice_tools.c +++ b/source/blender/editors/lattice/editlattice_tools.c @@ -72,22 +72,40 @@ static bool make_regular_poll(bContext *C) static int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob = CTX_data_edit_object(C); - Lattice *lt; + ViewLayer *view_layer = CTX_data_view_layer(C); + const bool is_editmode = CTX_data_edit_object(C) != NULL; + + if (is_editmode) { + uint objects_len; + 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 *ob = objects[ob_index]; + Lattice *lt = ob->data; + + if (lt->editlatt->latt == NULL) { + continue; + } + + BKE_lattice_resize(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); - if (ob) { - lt = ob->data; - BKE_lattice_resize(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + } + MEM_freeN(objects); } else { - ob = CTX_data_active_object(C); - lt = ob->data; - BKE_lattice_resize(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); - } + FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob) { + if (ob->type != OB_LATTICE) { + continue; + } - DEG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + Lattice *lt = ob->data; + BKE_lattice_resize(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + } FOREACH_SELECTED_OBJECT_END; + } return OPERATOR_FINISHED; } |