From d122aea865ccc04d7cfc642b0d98a9476cc20a87 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Sun, 1 Mar 2009 08:02:28 +0000 Subject: [PATCH] coded little vert connect tool. connects selected verts within the same face. currently integrated with fkey, along with the simple face merge tool I made too. --- source/blender/bmesh/bmesh_operators.h | 14 +++++++++++++- source/blender/bmesh/intern/bmesh_opdefines.c | 9 +++++++++ .../blender/bmesh/intern/bmesh_operators_private.h | 1 + source/blender/bmesh/operators/dissolveops.c | 1 - source/blender/editors/mesh/editmesh_add.c | 7 ++++++- source/blender/editors/mesh/editmesh_tools.c | 2 +- 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/source/blender/bmesh/bmesh_operators.h b/source/blender/bmesh/bmesh_operators.h index 4af6e89a94c..aaa6e29d79e 100644 --- a/source/blender/bmesh/bmesh_operators.h +++ b/source/blender/bmesh/bmesh_operators.h @@ -151,11 +151,13 @@ int BMO_CatchOpError(BMesh *bm, BMOperator *catchop, int errorcode, char **msg); /*error messages*/ #define BMERR_SELF_INTERSECTING 1 #define BMERR_DISSOLVEDISK_FAILED 2 +#define BMERR_CONNECTVERT_FAILED 3 static char *bmop_error_messages[] = { 0, "Self intersection error", "Could not dissolve vert", + "Could not connect verts", }; /*------------begin operator defines (see bmesh_opdefines.c too)------------*/ @@ -286,9 +288,15 @@ enum { BMOP_EXFACE_TOTSLOT, }; +#define BMOP_CONNECT_VERTS 11 +enum { + BM_CONVERTS_VERTIN, + BM_CONVERTS_EDGEOUT, + BM_CONVERTS_TOTSLOT +}; /*keep this updated!*/ -#define BMOP_TOTAL_OPS 11 +#define BMOP_TOTAL_OPS 12 /*-------------------------------end operator defines-------------------------------*/ extern BMOpDefine *opdefines[]; @@ -307,6 +315,10 @@ void BMOP_DupeFromFlag(struct BMesh *bm, int etypeflag, int flag); void BM_esubdivideflag(struct Object *obedit, struct BMesh *bm, int selflag, float rad, int flag, int numcuts, int seltype); void BM_extrudefaceflag(BMesh *bm, int flag); + +/*these next two return 1 if they did anything, or zero otherwise.*/ int BM_DissolveFaces(struct EditMesh *em, int flag); +/*this doesn't display errors to the user, btw*/ +int BM_ConnectVerts(struct EditMesh *em, int flag); #endif diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 47841c58ef7..082de58d953 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -3,6 +3,14 @@ #include +BMOpDefine def_connectverts = { + {BMOP_OPSLOT_PNT_BUF, + BMOP_OPSLOT_PNT_BUF}, + connectverts_exec, + BM_CONVERTS_TOTSLOT, + 0 +}; + BMOpDefine def_extrudefaceregion = { {BMOP_OPSLOT_PNT_BUF, BMOP_OPSLOT_MAPPING, @@ -108,6 +116,7 @@ BMOpDefine *opdefines[] = { &def_dissolvevertsop, &def_makefgonsop, &def_extrudefaceregion, + &def_connectverts, }; 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 402b3c774ab..372caa67a82 100644 --- a/source/blender/bmesh/intern/bmesh_operators_private.h +++ b/source/blender/bmesh/intern/bmesh_operators_private.h @@ -18,5 +18,6 @@ void dissolvefaces_exec(BMesh *bmesh, BMOperator *op); void dissolveverts_exec(BMesh *bmesh, BMOperator *op); void bmesh_make_fgons_exec(BMesh *bmesh, BMOperator *op); void extrude_edge_context_exec(BMesh *bm, BMOperator *op); +void connectverts_exec(BMesh *bm, BMOperator *op); #endif diff --git a/source/blender/bmesh/operators/dissolveops.c b/source/blender/bmesh/operators/dissolveops.c index c4a59116b00..90d6721e883 100644 --- a/source/blender/bmesh/operators/dissolveops.c +++ b/source/blender/bmesh/operators/dissolveops.c @@ -10,7 +10,6 @@ #include #define FACE_MARK 1 - #define VERT_MARK 1 void dissolvefaces_exec(BMesh *bm, BMOperator *op) diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index d4780927b70..b2b6e855bbd 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -668,7 +668,12 @@ static void addedgeface_mesh(EditMesh *em, wmOperator *op) EditEdge *eed; EditFace *efa; short amount=0; - + + if (em->selectmode & SCE_SELECT_VERTEX) { + /*return if bmesh vert connect does anything.*/ + if (BM_ConnectVerts(em, BM_SELECT)) return; + } + if (em->selectmode & SCE_SELECT_FACE) { /*return if bmesh face dissolve finds stuff to dissolve.*/ diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 7a617e6d340..e026bb8ea88 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2353,7 +2353,7 @@ static void fill_tri_triple(EditMesh *em, EditFace *efa, struct GHash *gh, int n MEM_freeN(innerverts); } -//Next two fill types are for knife exact only and are provided to allow for knifing through vertices +//Next two fill types are for exact only and are provided to allow for knifing through vertices //This means there is no multicut! static void fill_quad_doublevert(EditMesh *em, EditFace *efa, int v1, int v2) { -- 2.28.0