some small edge split related things. now you can split edges (with no additional geometry created) with mkey.

This commit is contained in:
Joseph Eagar
2009-07-17 06:05:09 +00:00
parent b588b65618
commit 6fa67401d8
6 changed files with 76 additions and 4 deletions

View File

@@ -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*));

View File

@@ -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

View File

@@ -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
#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, &params, e->v1, e->v2);
}
BMO_Flag_To_Slot(bm, op, "outsplit",
ELE_SPLIT, BM_ALL);
}

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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);