diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-20 01:27:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-20 01:27:24 +0400 |
commit | d91deb9e97d38fe3d2220255bbbc72ee1eee1124 (patch) | |
tree | 5d1b3bb1ca371210567080cc916e1a7788cb0459 /source/blender/bmesh | |
parent | 9b5151dbdcedf8e18ac23cbf25e5efa787f6d0a1 (diff) |
bmesh inset:
option to inset boundaries.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 5 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_inset.c | 24 |
2 files changed, 23 insertions, 6 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 73425613453..7230e1d24fa 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1085,8 +1085,9 @@ static BMOpDefine bmo_inset_def = { "inset", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ - {BMO_OP_SLOT_BOOL, "use_even_offset"}, /* type of thickness calculation */ - {BMO_OP_SLOT_BOOL, "use_relative_offset"}, /* type of thickness calculation */ + {BMO_OP_SLOT_BOOL, "use_boundary"}, + {BMO_OP_SLOT_BOOL, "use_even_offset"}, + {BMO_OP_SLOT_BOOL, "use_relative_offset"}, {BMO_OP_SLOT_FLT, "thickness"}, {0} /* null-terminating sentine */}, bmo_inset_exec, diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index ac4ecbfa640..6898f93e94c 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -60,6 +60,7 @@ static void edge_loop_tangent(BMEdge *e, BMLoop *e_loop, float r_no[3]) void bmo_inset_exec(BMesh *bm, BMOperator *op) { + const int use_boundary = BMO_slot_bool_get(op, "use_boundary"); const int use_even_offset = BMO_slot_bool_get(op, "use_even_offset"); const int use_even_boundry = use_even_offset; /* could make own option */ const int use_relative_offset = BMO_slot_bool_get(op, "use_relative_offset"); @@ -83,8 +84,13 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) /* fill in array and initialize tagging */ BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { BMLoop *la, *lb; - if ((BM_edge_loop_pair(e, &la, &lb)) && - (BM_elem_flag_test(la->f, BM_ELEM_TAG) != BM_elem_flag_test(lb->f, BM_ELEM_TAG))) + + if ( + /* tag if boundary is enabled */ + (use_boundary && BM_edge_is_boundary(e) && BM_elem_flag_test(e->l->f, BM_ELEM_TAG)) || + + /* tag if edge is an interior edge inbetween a tagged and untagged face */ + ((BM_edge_loop_pair(e, &la, &lb)) && (BM_elem_flag_test(la->f, BM_ELEM_TAG) != BM_elem_flag_test(lb->f, BM_ELEM_TAG)))) { /* tag */ BM_elem_flag_enable(e->v1, BM_ELEM_TAG); @@ -122,8 +128,13 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) for (i = 0, es = edge_info; i < edge_info_len; i++, es++) { BMLoop *l, *la, *lb; - BM_edge_loop_pair(es->e_old, &la, &lb); /* we know this will succeed, already checked above */ - l = BM_elem_flag_test(la->f, BM_ELEM_TAG) ? la : lb; + if (BM_edge_loop_pair(es->e_old, &la, &lb)) { + l = BM_elem_flag_test(la->f, BM_ELEM_TAG) ? la : lb; + } + else { + l = es->e_old->l; /* must be a boundary */ + } + /* run the separate arg */ bmesh_edge_separate(bm, es->e_old, l); @@ -132,6 +143,11 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) es->e_new = l->e; edge_loop_tangent(es->e_new, l, es->no); + + if (es->e_new == es->e_old) { /* happens on boundary edges */ + es->e_old = BM_edge_create(bm, es->e_new->v1, es->e_new->v2, es->e_new, FALSE); + } + /* store index back to original in 'edge_info' */ BM_elem_index_set(es->e_new, i); BM_elem_flag_enable(es->e_new, BM_ELEM_TAG); |