diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 7992bca2bfa..0c849595ad1 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -6,6 +6,17 @@ through the code and find all references to them!*/ +BMOpDefine def_edgesplit = { + "edgesplit", + {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, + {BMOP_OPSLOT_INT, "numcuts"}, + {BMOP_OPSLOT_ELEMENT_BUF, "outsplit"}, + {0} /*null-terminating sentinel*/, + }, + esplit_exec, + 0 +}; + BMOpDefine def_mirror = { "mirror", /*maps welded vertices to verts they should weld to.*/ @@ -336,6 +347,7 @@ BMOpDefine *opdefines[] = { &def_removedoubles, &def_finddoubles, &def_mirror, + &def_edgesplit, }; int bmesh_total_ops = (sizeof(opdefines) / sizeof(void*)); diff --git a/source/blender/bmesh/intern/bmesh_operators_private.h b/source/blender/bmesh/intern/bmesh_operators_private.h index 20da32a2fd0..1eeb5e2ba22 100644 --- a/source/blender/bmesh/intern/bmesh_operators_private.h +++ b/source/blender/bmesh/intern/bmesh_operators_private.h @@ -35,5 +35,6 @@ void bmesh_weldverts_exec(BMesh *bm, BMOperator *op); void bmesh_removedoubles_exec(BMesh *bm, BMOperator *op); void bmesh_finddoubles_exec(BMesh *bm, BMOperator *op); void bmesh_mirror_exec(BMesh *bm, BMOperator *op); +void esplit_exec(BMesh *bm, BMOperator *op); #endif diff --git a/source/blender/bmesh/operators/subdivideop.c b/source/blender/bmesh/operators/subdivideop.c index 8482fecb7bb..fbb3b4fb68a 100644 --- a/source/blender/bmesh/operators/subdivideop.c +++ b/source/blender/bmesh/operators/subdivideop.c @@ -593,12 +593,12 @@ subdpattern q_4edge = { }; subdpattern *patterns[] = { - &q_1edge, + //&q_1edge, &q_2edge_op, &q_4edge, &q_3edge, &q_2edge, - &t_1edge, + //&t_1edge, &t_2edge, &t_3edge, }; @@ -822,4 +822,23 @@ void BM_esubdivideflag_conv(Object *obedit,EditMesh *em,int selflag, float rad, MEM_freeN(em2); BM_Free_Mesh(bm); } -#endif \ No newline at end of file +#endif + +void esplit_exec(BMesh *bm, BMOperator *op) +{ + BMOIter siter; + BMEdge *e; + subdparams params; + + params.numcuts = BMO_GetSlot(op, "numcuts")->data.i; + params.op = op; + + /*go through and split edges*/ + BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) { + bm_subdivide_multicut(bm, e, ¶ms, e->v1, e->v2); + } + + BMO_Flag_To_Slot(bm, op, "outsplit", + ELE_SPLIT, BM_ALL); +} + diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 60033b771a2..194a3ea9ebe 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -1355,3 +1355,40 @@ void MESH_OT_vert_connect(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } + +static int editbmesh_edge_split(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + Object *obedit= CTX_data_edit_object(C); + Mesh *me= ((Mesh *)obedit->data); + BMEditMesh *em= ((Mesh *)obedit->data)->edit_btmesh; + BMesh *bm = em->bm; + BMOperator bmop; + int len = 0; + + BMO_InitOpf(bm, &bmop, "edgesplit edges=%he numcuts=%d", BM_SELECT, RNA_int_get(op->ptr,"number_cuts")); + BMO_Exec_Op(bm, &bmop); + len = BMO_GetSlot(&bmop, "outsplit")->len; + BMO_Finish_Op(bm, &bmop); + + DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + + return len ? OPERATOR_FINISHED : OPERATOR_CANCELLED; +} + +void MESH_OT_edge_split(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Edge Split"; + ot->idname= "MESH_OT_edge_split"; + + /* api callbacks */ + ot->exec= editbmesh_edge_split; + ot->poll= ED_operator_editmesh; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_int(ot->srna, "number_cuts", 1, 1, 10, "Number of Cuts", "", 1, INT_MAX); +} diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index a400bac2305..90f4a8855ec 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -295,6 +295,7 @@ void MESH_OT_sticky_remove(struct wmOperatorType *ot); /* ************* bmesh_tools.c ***********/ void MESH_OT_vert_connect(struct wmOperatorType *ot); +void MESH_OT_edge_split(struct wmOperatorType *ot); #endif // MESH_INTERN_H diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 02c1116fc55..4da53ed1822 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -315,6 +315,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_specials); WM_operatortype_append(MESH_OT_vert_connect); + WM_operatortype_append(MESH_OT_edge_split); } /* note mesh keymap also for other space? */ @@ -350,8 +351,9 @@ void ED_keymap_mesh(wmWindowManager *wm) RNA_float_set(WM_keymap_add_item(keymap, "MESH_OT_edges_select_sharp", SKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0)->ptr,"sharpness",135.0); WM_keymap_add_item(keymap, "MESH_OT_vertices_transform_to_sphere", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT , 0); - WM_keymap_add_item(keymap, "MESH_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0); + + WM_keymap_add_item(keymap, "MESH_OT_edge_split", MKEY, KM_PRESS, 0, 0); /* selection mode */ WM_keymap_add_item(keymap, "MESH_OT_selection_type", TABKEY, KM_PRESS, KM_CTRL, 0);