diff options
author | Thomas Beck <software@plasmasolutions.de> | 2018-04-19 00:17:52 +0300 |
---|---|---|
committer | Thomas Beck <software@plasmasolutions.de> | 2018-04-19 00:18:08 +0300 |
commit | 1ade0710529de5ca350237c7dac9ebab1741be3c (patch) | |
tree | 68d60d8f7cb6dade8d1cb7d42f7397cda71f8544 /source/blender | |
parent | abeae5d38e40af10d2f83898fa15fdb5ace01ccb (diff) |
Edit Mesh: multi-object duplicate_move support
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 752c6bd2859..d32542e5c25 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -1562,33 +1562,44 @@ void MESH_OT_edge_split(wmOperatorType *ot) static int edbm_duplicate_exec(bContext *C, wmOperator *op) { - Object *ob = CTX_data_edit_object(C); - BMEditMesh *em = BKE_editmesh_from_object(ob); - BMesh *bm = em->bm; - BMOperator bmop; + 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); - EDBM_op_init( - em, &bmop, op, - "duplicate geom=%hvef use_select_history=%b", - BM_ELEM_SELECT, true); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) + { + Object *obedit = objects[ob_index]; + BMEditMesh *em = BKE_editmesh_from_object(obedit); + if (em->bm->totvertsel == 0) { + continue; + } - BMO_op_exec(bm, &bmop); + BMOperator bmop; + BMesh *bm = em->bm; - /* de-select all would clear otherwise */ - BM_SELECT_HISTORY_BACKUP(bm); + EDBM_op_init( + em, &bmop, op, + "duplicate geom=%hvef use_select_history=%b", + BM_ELEM_SELECT, true); - EDBM_flag_disable_all(em, BM_ELEM_SELECT); + BMO_op_exec(bm, &bmop); - BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true); + /* de-select all would clear otherwise */ + BM_SELECT_HISTORY_BACKUP(bm); - /* rebuild editselection */ - BM_SELECT_HISTORY_RESTORE(bm); + EDBM_flag_disable_all(em, BM_ELEM_SELECT); - if (!EDBM_op_finish(em, &bmop, op, true)) { - return OPERATOR_CANCELLED; - } + BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true); - EDBM_update_generic(em, true, true); + /* rebuild editselection */ + BM_SELECT_HISTORY_RESTORE(bm); + + if (!EDBM_op_finish(em, &bmop, op, true)) { + continue; + } + EDBM_update_generic(em, true, true); + } + MEM_freeN(objects); return OPERATOR_FINISHED; } |