diff options
Diffstat (limited to 'source/blender/bmesh/operators')
-rw-r--r-- | source/blender/bmesh/operators/bmo_bridge.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_connect.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_connect_nonplanar.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_dissolve.c | 68 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_dupe.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_edgenet.c | 8 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_fill_attribute.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_fill_holes.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_inset.c | 1 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_join_triangles.c | 12 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_primitive.c | 12 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_removedoubles.c | 28 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_symmetrize.c | 3 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_triangulate.c | 1 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_utils.c | 1 |
15 files changed, 84 insertions, 62 deletions
diff --git a/source/blender/bmesh/operators/bmo_bridge.c b/source/blender/bmesh/operators/bmo_bridge.c index 9dfbf951fc0..10d15d93995 100644 --- a/source/blender/bmesh/operators/bmo_bridge.c +++ b/source/blender/bmesh/operators/bmo_bridge.c @@ -26,8 +26,6 @@ * Connect verts across faces (splits faces) and bridge tool. */ -#include "MEM_guardedalloc.h" - #include "BLI_math.h" #include "BLI_utildefines.h" #include "BLI_listbase.h" diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index b3a42ba533e..d0f64eb2892 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -26,8 +26,6 @@ * Connect verts across faces (splits faces). */ -#include "MEM_guardedalloc.h" - #include "BLI_math.h" #include "BLI_utildefines.h" #include "BLI_alloca.h" diff --git a/source/blender/bmesh/operators/bmo_connect_nonplanar.c b/source/blender/bmesh/operators/bmo_connect_nonplanar.c index 61085596acc..bd7a625406c 100644 --- a/source/blender/bmesh/operators/bmo_connect_nonplanar.c +++ b/source/blender/bmesh/operators/bmo_connect_nonplanar.c @@ -26,8 +26,6 @@ * Connect verts non-planer faces iteratively (splits faces). */ -#include "MEM_guardedalloc.h" - #include "BLI_math.h" #include "BLI_utildefines.h" #include "BLI_alloca.h" diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index d3c7a6864c3..cf36e88ea98 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -37,14 +37,21 @@ #include "intern/bmesh_operators_private.h" +/* ***_ISGC: mark for garbage-collection */ + #define FACE_MARK 1 #define FACE_ORIG 2 #define FACE_NEW 4 + #define EDGE_MARK 1 #define EDGE_TAG 2 +#define EDGE_ISGC 8 #define VERT_MARK 1 #define VERT_TAG 2 +#define VERT_ISGC 8 + + static bool UNUSED_FUNCTION(check_hole_in_region) (BMesh *bm, BMFace *f) { @@ -232,14 +239,12 @@ cleanup: void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op) { - /* might want to make this an option or mode - campbell */ - /* BMOperator fop; */ BMFace *act_face = bm->act_face; BMOIter eiter; - BMEdge *e; - BMIter viter; - BMVert *v; + BMIter iter; + BMEdge *e, *e_next; + BMVert *v, *v_next; const bool use_verts = BMO_slot_bool_get(op->slots_in, "use_verts"); const bool use_face_split = BMO_slot_bool_get(op->slots_in, "use_face_split"); @@ -247,10 +252,10 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op) if (use_face_split) { BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_TAG); - BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) { - BMIter iter; + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + BMIter itersub; int untag_count = 0; - BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) { + BM_ITER_ELEM (e, &itersub, v, BM_EDGES_OF_VERT) { if (!BMO_elem_flag_test(bm, e, EDGE_TAG)) { untag_count++; } @@ -266,22 +271,34 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op) } if (use_verts) { - BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) { + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { BMO_elem_flag_set(bm, v, VERT_MARK, (BM_vert_edge_count(v) != 2)); } } + /* tag all verts/edges connected to faces */ BMO_ITER (e, &eiter, op->slots_in, "edges", BM_EDGE) { - BMFace *fa, *fb; + BMFace *f_pair[2]; + if (BM_edge_face_pair(e, &f_pair[0], &f_pair[1])) { + unsigned int j; + for (j = 0; j < 2; j++) { + BMLoop *l_first, *l_iter; + l_iter = l_first = BM_FACE_FIRST_LOOP(f_pair[j]); + do { + BMO_elem_flag_enable(bm, l_iter->v, VERT_ISGC); + BMO_elem_flag_enable(bm, l_iter->e, EDGE_ISGC); + } while ((l_iter = l_iter->next) != l_first); + } + } + } + BMO_ITER (e, &eiter, op->slots_in, "edges", BM_EDGE) { + BMFace *fa, *fb; if (BM_edge_face_pair(e, &fa, &fb)) { BMFace *f_new; /* join faces */ - - /* BMESH_TODO - check on delaying edge removal since we may end up removing more than - * one edge, and later reference a removed edge */ - f_new = BM_faces_join_pair(bm, fa, fb, e, true); + f_new = BM_faces_join_pair(bm, fa, fb, e, false); if (f_new) { /* maintain active face */ @@ -292,8 +309,23 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op) } } + /* Cleanup geometry (#BM_faces_join_pair, but it removes geometry we're looping on) + * so do this in a separate pass instead. */ + BM_ITER_MESH_MUTABLE (e, e_next, &iter, bm, BM_EDGES_OF_MESH) { + if ((e->l == NULL) && BMO_elem_flag_test(bm, e, EDGE_ISGC)) { + BM_edge_kill(bm, e); + } + } + BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) { + if ((v->e == NULL) && BMO_elem_flag_test(bm, v, VERT_ISGC)) { + BM_vert_kill(bm, v); + } + } + /* done with cleanup */ + + if (use_verts) { - BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) { + BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) { if (BMO_elem_flag_test(bm, v, VERT_MARK)) { if (BM_vert_edge_count(v) == 2) { BM_vert_collapse_edge(bm, v->e, v, true); @@ -349,7 +381,7 @@ static bool test_extra_verts(BMesh *bm, BMVert *v) void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op) { BMIter iter, fiter; - BMVert *v; + BMVert *v, *v_next; BMFace *f; const bool use_face_split = BMO_slot_bool_get(op->slots_in, "use_face_split"); @@ -361,7 +393,7 @@ void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op) bm_face_split(bm, VERT_MARK); } - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) { if (BMO_elem_flag_test(bm, v, VERT_MARK)) { /* check if it's a two-valence ver */ if (BM_vert_edge_count(v) == 2) { @@ -409,7 +441,7 @@ void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op) } /* clean up any remainin */ - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) { if (BMO_elem_flag_test(bm, v, VERT_MARK)) { if (!BM_vert_dissolve(bm, v)) { BMO_error_raise(bm, op, BMERR_DISSOLVEVERTS_FAILED, NULL); diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index bd2485b92fb..a5c34f7623b 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -26,8 +26,6 @@ * Duplicate, Split, Split operators. */ -#include "MEM_guardedalloc.h" - #include "BLI_math.h" #include "BLI_alloca.h" diff --git a/source/blender/bmesh/operators/bmo_edgenet.c b/source/blender/bmesh/operators/bmo_edgenet.c index c58a11f21ec..de41bc7937d 100644 --- a/source/blender/bmesh/operators/bmo_edgenet.c +++ b/source/blender/bmesh/operators/bmo_edgenet.c @@ -28,13 +28,8 @@ #include "MEM_guardedalloc.h" -#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_array.h" -#include "BLI_alloca.h" -#include "BLI_smallhash.h" -#include "BLI_rand.h" -#include "BLI_heap.h" #include "bmesh.h" #include "bmesh_tools.h" @@ -44,10 +39,7 @@ #define EDGE_MARK 1 #define EDGE_VIS 2 -#define FACE_NEW 1 - #define ELE_NEW 1 -#define ELE_ORIG 4 void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op) { diff --git a/source/blender/bmesh/operators/bmo_fill_attribute.c b/source/blender/bmesh/operators/bmo_fill_attribute.c index f53b4536e44..fa77e6b509c 100644 --- a/source/blender/bmesh/operators/bmo_fill_attribute.c +++ b/source/blender/bmesh/operators/bmo_fill_attribute.c @@ -27,8 +27,6 @@ * Fill in geometry with the attributes of their adjacent data. */ -#include "MEM_guardedalloc.h" - #include "BLI_utildefines.h" #include "BLI_linklist_stack.h" diff --git a/source/blender/bmesh/operators/bmo_fill_holes.c b/source/blender/bmesh/operators/bmo_fill_holes.c index 8160d28d7a7..eadfbdb1aa8 100644 --- a/source/blender/bmesh/operators/bmo_fill_holes.c +++ b/source/blender/bmesh/operators/bmo_fill_holes.c @@ -26,8 +26,6 @@ * Fill boundary edge loop(s) with faces. */ -#include "MEM_guardedalloc.h" - #include "BLI_utildefines.h" #include "bmesh.h" diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index 20cd828af1e..e20556a830d 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -31,7 +31,6 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" -#include "BLI_array.h" #include "BLI_alloca.h" #include "BLI_memarena.h" #include "BKE_customdata.h" diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c index 6d4f257909c..6562f26062f 100644 --- a/source/blender/bmesh/operators/bmo_join_triangles.c +++ b/source/blender/bmesh/operators/bmo_join_triangles.c @@ -203,7 +203,7 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) BMIter iter; BMOIter siter; BMFace *f; - BMEdge *e; + BMEdge *e, *e_next; /* data: edge-to-join, sort_value: error weight */ struct SortPointerByFloat *jedges; unsigned i, totedge; @@ -291,7 +291,7 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) MEM_freeN(jedges); /* join best weighted */ - BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { + BM_ITER_MESH_MUTABLE (e, e_next, &iter, bm, BM_EDGES_OF_MESH) { BMFace *f_new; BMFace *f_a, *f_b; @@ -308,7 +308,7 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) } /* join 2-tri islands */ - BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { + BM_ITER_MESH_MUTABLE (e, e_next, &iter, bm, BM_EDGES_OF_MESH) { if (BMO_elem_flag_test(bm, e, EDGE_MARK)) { BMLoop *l_a, *l_b; BMFace *f_a, *f_b; @@ -326,7 +326,11 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) (BMO_elem_flag_test(bm, l_a->next->e, EDGE_MARK) == false) && (BMO_elem_flag_test(bm, l_a->prev->e, EDGE_MARK) == false) && (BMO_elem_flag_test(bm, l_b->next->e, EDGE_MARK) == false) && - (BMO_elem_flag_test(bm, l_b->prev->e, EDGE_MARK) == false)) + (BMO_elem_flag_test(bm, l_b->prev->e, EDGE_MARK) == false) && + /* check for faces that use same verts, this is supported but raises an error + * and cancels the operation when performed from editmode, since this is only + * two triangles we only need to compare a single vertex */ + (LIKELY(l_a->prev->v != l_b->prev->v))) { BMFace *f_new; f_new = BM_faces_join_pair(bm, f_a, f_b, e, true); diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c index 45653f3411f..6a540928d43 100644 --- a/source/blender/bmesh/operators/bmo_primitive.c +++ b/source/blender/bmesh/operators/bmo_primitive.c @@ -36,7 +36,7 @@ /* ************************ primitives ******************* */ -static float icovert[12][3] = { +static const float icovert[12][3] = { {0.0f, 0.0f, -200.0f}, {144.72f, -105.144f, -89.443f}, {-55.277f, -170.128, -89.443f}, @@ -51,7 +51,7 @@ static float icovert[12][3] = { {0.0f, 0.0f, 200.0f} }; -static short icoface[20][3] = { +static const short icoface[20][3] = { {0, 1, 2}, {1, 0, 5}, {0, 2, 3}, @@ -78,10 +78,10 @@ static short icoface[20][3] = { * this hack is only used so that scons & mingw + split-sources hack works * ------------------------------- start copied code */ /* these are not the monkeys you are looking for */ -static int monkeyo = 4; -static int monkeynv = 271; -static int monkeynf = 250; -static signed char monkeyv[271][3] = { +static const int monkeyo = 4; +static const int monkeynv = 271; +static const int monkeynf = 250; +static const signed char monkeyv[271][3] = { {-71, 21, 98}, {-63, 12, 88}, {-57, 7, 74}, {-82, -3, 79}, {-82, 4, 92}, {-82, 17, 100}, {-92, 21, 102}, {-101, 12, 95}, {-107, 7, 83}, {-117, 31, 84}, {-109, 31, 95}, {-96, 31, 102}, {-92, 42, 102}, diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index 5ab909ffb0c..cc5a635092a 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -354,7 +354,7 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op) BMEdge *e, **edges = NULL; BLI_array_declare(edges); float min[3], max[3], center[3]; - int i, tot; + unsigned int i, tot; BMOpSlot *slot_targetmap; BMO_op_callf(bm, op->flag, "collapse_uvs edges=%s", op, "edges"); @@ -369,6 +369,8 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op) BMW_NIL_LAY); BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { + BMVert *v_tar; + if (!BMO_elem_flag_test(bm, e, EDGE_MARK)) continue; @@ -381,19 +383,29 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op) minmax_v3v3_v3(min, max, e->v1->co); minmax_v3v3_v3(min, max, e->v2->co); + + /* prevent adding to slot_targetmap multiple times */ + BM_elem_flag_disable(e->v1, BM_ELEM_TAG); + BM_elem_flag_disable(e->v2, BM_ELEM_TAG); } mid_v3_v3v3(center, min, max); /* snap edges to a point. for initial testing purposes anyway */ + v_tar = edges[0]->v1; + for (i = 0; i < tot; i++) { - copy_v3_v3(edges[i]->v1->co, center); - copy_v3_v3(edges[i]->v2->co, center); - - if (edges[i]->v1 != edges[0]->v1) - BMO_slot_map_elem_insert(&weldop, slot_targetmap, edges[i]->v1, edges[0]->v1); - if (edges[i]->v2 != edges[0]->v1) - BMO_slot_map_elem_insert(&weldop, slot_targetmap, edges[i]->v2, edges[0]->v1); + unsigned int j; + + for (j = 0; j < 2; j++) { + BMVert *v_src = *((&edges[i]->v1) + j); + + copy_v3_v3(v_src->co, center); + if ((v_src != v_tar) && !BM_elem_flag_test(v_src, BM_ELEM_TAG)) { + BM_elem_flag_enable(v_src, BM_ELEM_TAG); + BMO_slot_map_elem_insert(&weldop, slot_targetmap, v_src, v_tar); + } + } } } diff --git a/source/blender/bmesh/operators/bmo_symmetrize.c b/source/blender/bmesh/operators/bmo_symmetrize.c index 4b538dccb4e..74f880906c0 100644 --- a/source/blender/bmesh/operators/bmo_symmetrize.c +++ b/source/blender/bmesh/operators/bmo_symmetrize.c @@ -26,9 +26,6 @@ * Makes the mesh symmetrical by splitting along an axis and duplicating the geometry. */ - -#include "MEM_guardedalloc.h" - #include "BLI_utildefines.h" #include "BLI_math.h" diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c index 590b5ea97c4..ca45289520b 100644 --- a/source/blender/bmesh/operators/bmo_triangulate.c +++ b/source/blender/bmesh/operators/bmo_triangulate.c @@ -26,7 +26,6 @@ * Triangulate faces, also defines triangle fill. */ -#include "MEM_guardedalloc.h" #include "DNA_listBase.h" #include "BLI_math.h" diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index e23358bf4ff..c89fee71cbc 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -32,7 +32,6 @@ #include "DNA_meshdata_types.h" #include "BLI_math.h" -#include "BLI_heap.h" #include "BLI_alloca.h" #include "BKE_customdata.h" |