Edit Mesh: multi-object split
This commit is contained in:
@@ -5015,22 +5015,33 @@ void MESH_OT_delete_edgeloop(wmOperatorType *ot)
|
|||||||
|
|
||||||
static int edbm_split_exec(bContext *C, wmOperator *op)
|
static int edbm_split_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;
|
||||||
BMOperator bmop;
|
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];
|
||||||
|
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
||||||
|
|
||||||
EDBM_op_init(em, &bmop, op, "split geom=%hvef use_only_faces=%b", BM_ELEM_SELECT, false);
|
if (em->bm->totfacesel == 0) {
|
||||||
BMO_op_exec(em->bm, &bmop);
|
continue;
|
||||||
BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
|
}
|
||||||
BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
|
|
||||||
if (!EDBM_op_finish(em, &bmop, op, true)) {
|
BMOperator bmop;
|
||||||
return OPERATOR_CANCELLED;
|
EDBM_op_init(em, &bmop, op, "split geom=%hvef use_only_faces=%b", BM_ELEM_SELECT, false);
|
||||||
|
BMO_op_exec(em->bm, &bmop);
|
||||||
|
BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
|
||||||
|
BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
|
||||||
|
|
||||||
|
if (!EDBM_op_finish(em, &bmop, op, true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Geometry has changed, need to recalc normals and looptris */
|
||||||
|
EDBM_mesh_normals_update(em);
|
||||||
|
|
||||||
|
EDBM_update_generic(em, true, true);
|
||||||
}
|
}
|
||||||
|
MEM_freeN(objects);
|
||||||
/* Geometry has changed, need to recalc normals and looptris */
|
|
||||||
EDBM_mesh_normals_update(em);
|
|
||||||
|
|
||||||
EDBM_update_generic(em, true, true);
|
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user