diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-11-02 22:05:02 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-11-02 22:15:21 +0300 |
commit | 046ec863ffc35e2daae105e4b5911076f1aade1d (patch) | |
tree | 76dcd65109b5e69e8f7e4d3fd391771cb0752064 /source/blender/editors | |
parent | 6bee49eca45eb260e040b24a6fc58810f8a1907b (diff) |
Multi-Objects: MBALL_OT_duplicate_metaelems
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/metaball/mball_edit.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 31942651318..816d91dbad9 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -436,25 +436,34 @@ void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot) /* Duplicate selected MetaElements */ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit = CTX_data_edit_object(C); - MetaBall *mb = (MetaBall *)obedit->data; - MetaElem *ml, *newml; + ViewLayer *view_layer = CTX_data_view_layer(C); + uint objects_len = 0; + 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]; + MetaBall *mb = (MetaBall *)obedit->data; + MetaElem *ml, *newml; - ml = mb->editelems->last; - if (ml) { - while (ml) { - if (ml->flag & SELECT) { - newml = MEM_dupallocN(ml); - BLI_addtail(mb->editelems, newml); - mb->lastelem = newml; - ml->flag &= ~SELECT; + if (!BKE_mball_is_any_selected(mb)) { + continue; + } + + ml = mb->editelems->last; + if (ml) { + while (ml) { + if (ml->flag & SELECT) { + newml = MEM_dupallocN(ml); + BLI_addtail(mb->editelems, newml); + mb->lastelem = newml; + ml->flag &= ~SELECT; + } + ml = ml->prev; } - ml = ml->prev; + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); + DEG_id_tag_update(obedit->data, 0); } - WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); - DEG_id_tag_update(obedit->data, 0); } - + MEM_freeN(objects); return OPERATOR_FINISHED; } |