Edit Mesh: multi-object duplicate_move support

This commit is contained in:
2018-04-18 23:17:52 +02:00
parent abeae5d38e
commit 1ade071052

View File

@@ -1562,33 +1562,44 @@ void MESH_OT_edge_split(wmOperatorType *ot)
static int edbm_duplicate_exec(bContext *C, wmOperator *op) static int edbm_duplicate_exec(bContext *C, wmOperator *op)
{ {
Object *ob = CTX_data_edit_object(C); ViewLayer *view_layer = CTX_data_view_layer(C);
BMEditMesh *em = BKE_editmesh_from_object(ob); uint objects_len = 0;
BMesh *bm = em->bm; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
BMOperator bmop;
EDBM_op_init( for (uint ob_index = 0; ob_index < objects_len; ob_index++)
em, &bmop, op, {
"duplicate geom=%hvef use_select_history=%b", Object *obedit = objects[ob_index];
BM_ELEM_SELECT, true); 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 */ EDBM_op_init(
BM_SELECT_HISTORY_BACKUP(bm); 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 */ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
BM_SELECT_HISTORY_RESTORE(bm);
if (!EDBM_op_finish(em, &bmop, op, true)) { BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
return OPERATOR_CANCELLED;
/* 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);
EDBM_update_generic(em, true, true);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }