diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-19 13:47:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-19 13:47:32 +0400 |
commit | 305da3a743d3b214668608cb0551cccf228caaed (patch) | |
tree | e9d9cf151807e70aad56ed3422a69a722c5d0c50 /source/blender/bmesh | |
parent | 543bf45ef049fdcef2fdef8a751901478f04c9bd (diff) |
bmesh inset:
fix hole when 2+ faces a vert but no edges (would make a hole), now splice the verts back together.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.h | 3 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_inset.c | 39 |
3 files changed, 33 insertions, 13 deletions
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index af87de2ec6f..c1814b0ae96 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -1704,7 +1704,7 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) * * \return Success */ -static int bm_vert_splice(BMesh *bm, BMVert *v, BMVert *vtarget) +int BM_vert_splice(BMesh *bm, BMVert *v, BMVert *vtarget) { BMEdge *e; BMLoop *l; @@ -2006,7 +2006,7 @@ BMVert *bmesh_urmv_loop(BMesh *bm, BMLoop *sl) /* And then glue the rest back together */ for (i = 1; i < len - 1; i++) { - bm_vert_splice(bm, vtar[i], vtar[0]); + BM_vert_splice(bm, vtar[i], vtar[0]); } } } diff --git a/source/blender/bmesh/intern/bmesh_core.h b/source/blender/bmesh/intern/bmesh_core.h index e10222dc29a..34947923572 100644 --- a/source/blender/bmesh/intern/bmesh_core.h +++ b/source/blender/bmesh/intern/bmesh_core.h @@ -40,8 +40,9 @@ void BM_face_kill(BMesh *bm, BMFace *f); void BM_edge_kill(BMesh *bm, BMEdge *e); void BM_vert_kill(BMesh *bm, BMVert *v); -int BM_edge_splice(BMesh *bm, BMEdge *e, BMEdge *etarget); int bmesh_edge_separate(BMesh *bm, BMEdge *e, BMLoop *l_sep); +int BM_edge_splice(BMesh *bm, BMEdge *e, BMEdge *etarget); +int BM_vert_splice(BMesh *bm, BMVert *v, BMVert *vtarget); int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len); diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index 148fe97f49c..ac4ecbfa640 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -56,9 +56,6 @@ static void edge_loop_tangent(BMEdge *e, BMLoop *e_loop, float r_no[3]) * - separate these edges and tag vertices, set their index to point to the original edge. * - build faces between old/new edges. * - inset the new edges into their faces. - * - * TODO - * - close tares when 2 corners touch. */ void bmo_inset_exec(BMesh *bm, BMOperator *op) @@ -174,7 +171,11 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) /* comment the first part because we know this verts in a tagged face */ if (/* v->e && */BM_elem_flag_test(v, BM_ELEM_TAG)) { BMVert **vout; - int r_vout_len = 0; + int r_vout_len; + BMVert *v_glue = NULL; + + /* disable touching twice, this _will_ happen if the flags not disabled */ + BM_elem_flag_disable(v, BM_ELEM_TAG); bmesh_vert_separate(bm, v, &vout, &r_vout_len); v = NULL; /* don't use again */ @@ -183,25 +184,20 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) BMVert *v_split = vout[k]; /* only to avoid vout[k] all over */ /* need to check if this vertex is from a */ - BMIter itersub; int vert_edge_tag_tot = 0; int vecpair[2]; /* find adjacent */ - BM_ITER(e, &itersub, bm, BM_EDGES_OF_VERT, v_split) { + BM_ITER(e, &iter, bm, BM_EDGES_OF_VERT, v_split) { if (BM_edge_is_boundary(e) && /* this will be true because bmesh_edge_separate() has run */ BM_elem_flag_test(e, BM_ELEM_TAG) && BM_elem_flag_test(e->l->f, BM_ELEM_TAG)) { - /* disable touching twice, this _will_ happen if the flags not disabled */ - BM_elem_flag_disable(v_split, BM_ELEM_TAG); - if (vert_edge_tag_tot < 2) { vecpair[vert_edge_tag_tot] = BM_elem_index_get(e); BLI_assert(vecpair[vert_edge_tag_tot] != -1); } - // BM_elem_flag_disable(e, BM_ELEM_SMOOTH); // testing only vert_edge_tag_tot++; } } @@ -311,6 +307,29 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) /* apply the offset */ madd_v3_v3fl(v_split->co, tvec, thickness); } + + /* this saves expensive/slow glue check for common cases */ + if (r_vout_len > 2) { + int ok = TRUE; + /* last step, NULL this vertex if has a tagged face */ + BM_ITER(f, &iter, bm, BM_FACES_OF_VERT, v_split) { + if (BM_elem_flag_test(f, BM_ELEM_TAG)) { + ok = FALSE; + break; + } + } + + if (ok) { + if (v_glue == NULL) { + v_glue = v_split; + } + else { + BM_vert_splice(bm, v_split, v_glue); + } + } + } + /* end glue */ + } MEM_freeN(vout); } |