diff options
Diffstat (limited to 'source/blender/bmesh/operators')
-rw-r--r-- | source/blender/bmesh/operators/bmo_create.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_edgesplit.c | 134 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_extrude.c | 47 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_join_triangles.c | 4 |
4 files changed, 28 insertions, 159 deletions
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c index aa69806fb37..2ea5914ca92 100644 --- a/source/blender/bmesh/operators/bmo_create.c +++ b/source/blender/bmesh/operators/bmo_create.c @@ -578,7 +578,7 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) //rotsys_fill_faces(bm, edata, vdata); #if 0 - /* create visualizing geometr */ + /* create visualizing geometry */ BMVert *lastv; BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { BMVert *v2; diff --git a/source/blender/bmesh/operators/bmo_edgesplit.c b/source/blender/bmesh/operators/bmo_edgesplit.c index 9e9e4b8c962..b4b50a60877 100644 --- a/source/blender/bmesh/operators/bmo_edgesplit.c +++ b/source/blender/bmesh/operators/bmo_edgesplit.c @@ -22,152 +22,32 @@ /** \file blender/bmesh/operators/bmo_edgesplit.c * \ingroup bmesh + * + * Just a wrapper around #BM_mesh_edgesplit */ -#include "MEM_guardedalloc.h" - #include "BLI_utildefines.h" #include "bmesh.h" +#include "tools/bmesh_edgesplit.h" #include "intern/bmesh_operators_private.h" /* own include */ -enum { - EDGE_SEAM = 1 -}; - -enum { - VERT_SEAM = 2 -}; - -/** - * Remove the EDGE_SEAM flag for edges we cant split - * - * un-tag edges not connected to other tagged edges, - * unless they are on a boundary - */ -static void bm_edgesplit_validate_seams(BMesh *bm, BMOperator *op) -{ - BMOIter siter; - BMIter iter; - BMEdge *e; - - unsigned char *vtouch; - unsigned char *vt; - - BM_mesh_elem_index_ensure(bm, BM_VERT); - - vtouch = MEM_callocN(sizeof(char) * bm->totvert, __func__); - - /* tag all boundary verts so as not to untag an edge which is inbetween only 2 faces [] */ - BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { - - /* unrelated to flag assignment in this function - since this is the - * only place we loop over all edges, disable tag */ - BM_elem_flag_disable(e, BM_ELEM_INTERNAL_TAG); - - if (e->l == NULL) { - BMO_elem_flag_disable(bm, e, EDGE_SEAM); - } - else if (BM_edge_is_boundary(e)) { - vt = &vtouch[BM_elem_index_get(e->v1)]; if (*vt < 2) (*vt)++; - vt = &vtouch[BM_elem_index_get(e->v2)]; if (*vt < 2) (*vt)++; - - /* while the boundary verts need to be tagged, - * the edge its self can't be split */ - BMO_elem_flag_disable(bm, e, EDGE_SEAM); - } - } - - /* single marked edges unconnected to any other marked edges - * are illegal, go through and unmark them */ - BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { - /* lame, but we don't want the count to exceed 255, - * so just count to 2, its all we need */ - unsigned char *vt; - vt = &vtouch[BM_elem_index_get(e->v1)]; if (*vt < 2) (*vt)++; - vt = &vtouch[BM_elem_index_get(e->v2)]; if (*vt < 2) (*vt)++; - } - BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { - if (vtouch[BM_elem_index_get(e->v1)] == 1 && - vtouch[BM_elem_index_get(e->v2)] == 1) - { - BMO_elem_flag_disable(bm, e, EDGE_SEAM); - } - } - - MEM_freeN(vtouch); -} /* keep this operator fast, its used in a modifier */ void bmo_split_edges_exec(BMesh *bm, BMOperator *op) { - BMOIter siter; - BMEdge *e; const int use_verts = BMO_slot_bool_get(op->slots_in, "use_verts"); - BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_SEAM); + BMO_slot_buffer_hflag_enable(bm, op->slots_in, "edges", BM_EDGE, BM_ELEM_TAG, FALSE); if (use_verts) { /* this slows down the operation but its ok because the modifier doesn't use */ - BMO_slot_buffer_flag_enable(bm, op->slots_in, "verts", BM_VERT, VERT_SEAM); - - /* prevent one edge having both verts unflagged - * we could alternately disable these edges, either way its a corner case. - * - * This is needed so we don't split off the edge but then none of its verts which - * would leave a duplicate edge. - */ - BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { - if (UNLIKELY((BMO_elem_flag_test(bm, e->v1, VERT_SEAM) == FALSE && - (BMO_elem_flag_test(bm, e->v2, VERT_SEAM) == FALSE)))) - { - BMO_elem_flag_enable(bm, e->v1, VERT_SEAM); - BMO_elem_flag_enable(bm, e->v2, VERT_SEAM); - } - } + BMO_slot_buffer_hflag_enable(bm, op->slots_in, "verts", BM_VERT, BM_ELEM_TAG, FALSE); } - bm_edgesplit_validate_seams(bm, op); - - BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { - if (BMO_elem_flag_test(bm, e, EDGE_SEAM)) { - /* this flag gets copied so we can be sure duplicate edges get it too (important) */ - BM_elem_flag_enable(e, BM_ELEM_INTERNAL_TAG); - - /* keep splitting until each loop has its own edge */ - do { - bmesh_edge_separate(bm, e, e->l); - } while (!BM_edge_is_boundary(e)); - - BM_elem_flag_enable(e->v1, BM_ELEM_TAG); - BM_elem_flag_enable(e->v2, BM_ELEM_TAG); - } - } - - if (use_verts) { - BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { - if (BMO_elem_flag_test(bm, e->v1, VERT_SEAM) == FALSE) { - BM_elem_flag_disable(e->v1, BM_ELEM_TAG); - } - if (BMO_elem_flag_test(bm, e->v2, VERT_SEAM) == FALSE) { - BM_elem_flag_disable(e->v2, BM_ELEM_TAG); - } - } - } - - BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { - if (BMO_elem_flag_test(bm, e, EDGE_SEAM)) { - if (BM_elem_flag_test(e->v1, BM_ELEM_TAG)) { - BM_elem_flag_disable(e->v1, BM_ELEM_TAG); - bmesh_vert_separate(bm, e->v1, NULL, NULL); - } - if (BM_elem_flag_test(e->v2, BM_ELEM_TAG)) { - BM_elem_flag_disable(e->v2, BM_ELEM_TAG); - bmesh_vert_separate(bm, e->v2, NULL, NULL); - } - } - } + /* this is where everything happens */ + BM_mesh_edgesplit(bm, use_verts, TRUE); BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_INTERNAL_TAG); } diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 065a1b57737..bf3bafc57fb 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -600,39 +600,31 @@ static void solidify_add_thickness(BMesh *bm, const float dist) float *vert_accum = vert_angles + bm->totvert; int i, index; - /* array for passing verts to angle_poly_v3 */ - float **verts = NULL; - BLI_array_staticdeclare(verts, BM_DEFAULT_NGON_STACK_SIZE); - /* array for receiving angles from angle_poly_v3 */ - float *face_angles = NULL; - BLI_array_staticdeclare(face_angles, BM_DEFAULT_NGON_STACK_SIZE); - BM_mesh_elem_index_ensure(bm, BM_VERT); BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - if (!BMO_elem_flag_test(bm, f, FACE_MARK)) { - continue; - } + if (BMO_elem_flag_test(bm, f, FACE_MARK)) { - BLI_array_grow_items(verts, f->len); - BM_ITER_ELEM_INDEX (l, &loopIter, f, BM_LOOPS_OF_FACE, i) { - verts[i] = l->v->co; - } + /* array for passing verts to angle_poly_v3 */ + float *face_angles = BLI_array_alloca(face_angles, f->len); + /* array for receiving angles from angle_poly_v3 */ + float **verts = BLI_array_alloca(verts, f->len); - BLI_array_grow_items(face_angles, f->len); - angle_poly_v3(face_angles, (const float **)verts, f->len); + BM_ITER_ELEM_INDEX (l, &loopIter, f, BM_LOOPS_OF_FACE, i) { + verts[i] = l->v->co; + } - i = 0; - BM_ITER_ELEM (l, &loopIter, f, BM_LOOPS_OF_FACE) { - v = l->v; - index = BM_elem_index_get(v); - vert_accum[index] += face_angles[i]; - vert_angles[index] += shell_angle_to_dist(angle_normalized_v3v3(v->no, f->no)) * face_angles[i]; - i++; - } + angle_poly_v3(face_angles, (const float **)verts, f->len); - BLI_array_empty(verts); - BLI_array_empty(face_angles); + i = 0; + BM_ITER_ELEM (l, &loopIter, f, BM_LOOPS_OF_FACE) { + v = l->v; + index = BM_elem_index_get(v); + vert_accum[index] += face_angles[i]; + vert_angles[index] += shell_angle_to_dist(angle_normalized_v3v3(v->no, f->no)) * face_angles[i]; + i++; + } + } } BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { @@ -643,9 +635,6 @@ static void solidify_add_thickness(BMesh *bm, const float dist) } MEM_freeN(vert_angles); - - BLI_array_free(verts); - BLI_array_free(face_angles); } void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op) diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c index 1e18a83a0a0..45ecdee014e 100644 --- a/source/blender/bmesh/operators/bmo_join_triangles.c +++ b/source/blender/bmesh/operators/bmo_join_triangles.c @@ -331,13 +331,13 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) } } - /* if l isn't NULL, we broke out of the loo */ + /* if l isn't NULL, we broke out of the loop */ if (l) { break; } } - /* if i isn't 2, we broke out of that loo */ + /* if i isn't 2, we broke out of that loop */ if (i != 2) { continue; } |