diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-25 23:43:51 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-25 23:43:51 +0400 |
commit | 55e68985e7cf868481d3ffcb845f94e3c52a5043 (patch) | |
tree | ee679ecb5c00a258972f6ca0f8ecc1c777695f1f /source/blender/bmesh/operators | |
parent | 0096370db89eaf315a8c75b29076b9b85c83409a (diff) |
bmesh api:
* added BM_elem_flag_set, BMO_elem_flag_set. to avoid 'if(...) enable(); else disable();' all over the place.
* added bmesh_operator_api_inline.c, the header file was getting messy.
Diffstat (limited to 'source/blender/bmesh/operators')
-rw-r--r-- | source/blender/bmesh/operators/bmo_create.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_dissolve.c | 14 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_dupe.c | 9 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_extrude.c | 7 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_primitive.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_removedoubles.c | 6 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_triangulate.c | 3 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_utils.c | 49 |
8 files changed, 48 insertions, 46 deletions
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c index 6ba0c91fb4d..610790393f1 100644 --- a/source/blender/bmesh/operators/bmo_create.c +++ b/source/blender/bmesh/operators/bmo_create.c @@ -1407,6 +1407,8 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op) printf("cannot find nice quad from concave set of vertices\n"); } - if (f) BMO_elem_flag_enable(bm, f, ELE_OUT); + if (f) { + BMO_elem_flag_enable(bm, f, ELE_OUT); + } } } diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 2ee70bb4644..ddef478a4aa 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -88,12 +88,7 @@ void dissolvefaces_exec(BMesh *bm, BMOperator *op) BMVert *v; BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) { - if (BM_vert_edge_count(v) == 2) { - BMO_elem_flag_disable(bm, v, VERT_MARK); - } - else { - BMO_elem_flag_enable(bm, v, VERT_MARK); - } + BMO_elem_flag_set(bm, v, VERT_MARK, (BM_vert_edge_count(v) != 2)); } } @@ -251,12 +246,7 @@ void dissolveedges_exec(BMesh *bm, BMOperator *op) if (use_verts) { BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) { - if (BM_vert_edge_count(v) == 2) { - BMO_elem_flag_disable(bm, v, VERT_MARK); - } - else { - BMO_elem_flag_enable(bm, v, VERT_MARK); - } + BMO_elem_flag_set(bm, v, VERT_MARK, (BM_vert_edge_count(v) != 2)); } } diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index d7626673e43..09b0e2042f4 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -407,7 +407,9 @@ void splitop_exec(BMesh *bm, BMOperator *op) break; } } - if (!found) BMO_elem_flag_enable(bm, e, SPLIT_INPUT); + if (!found) { + BMO_elem_flag_enable(bm, e, SPLIT_INPUT); + } } for (v = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); v; v = BM_iter_step(&iter)) { @@ -419,8 +421,9 @@ void splitop_exec(BMesh *bm, BMOperator *op) break; } } - if (!found) BMO_elem_flag_enable(bm, v, SPLIT_INPUT); - + if (!found) { + BMO_elem_flag_enable(bm, v, SPLIT_INPUT); + } } } diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 2c6a0e0de6a..b194428deba 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -215,7 +215,9 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) } } - if (!found && (rlen > 1)) BMO_elem_flag_enable(bm, e, EXT_DEL); + if (!found && (rlen > 1)) { + BMO_elem_flag_enable(bm, e, EXT_DEL); + } } } @@ -243,8 +245,9 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) } BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { - if (BMO_elem_flag_test(bm, f, EXT_INPUT)) + if (BMO_elem_flag_test(bm, f, EXT_INPUT)) { BMO_elem_flag_enable(bm, f, EXT_DEL); + } } if (delorig) { diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c index e674a3f2856..9cf17490d58 100644 --- a/source/blender/bmesh/operators/bmo_primitive.c +++ b/source/blender/bmesh/operators/bmo_primitive.c @@ -248,7 +248,7 @@ void bmesh_create_grid_exec(BMesh *bm, BMOperator *op) eve = BM_vert_create(bm, vec, NULL); BMO_elem_flag_enable(bm, eve, VERT_MARK); - if (a) { + if (a != 0) { e = BM_edge_create(bm, preveve, eve, NULL, TRUE); BMO_elem_flag_enable(bm, e, EDGE_ORIG); } diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index 2eb1cf7db3e..bd528faa43e 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -124,10 +124,12 @@ void bmesh_weldverts_exec(BMesh *bm, BMOperator *op) if (!v) v = e->v1; if (!v2) v2 = e->v2; - if (v == v2) + if (v == v2) { BMO_elem_flag_enable(bm, e, EDGE_COL); - else if (!BM_edge_exists(v, v2)) + } + else if (!BM_edge_exists(v, v2)) { BM_edge_create(bm, v, v2, e, TRUE); + } BMO_elem_flag_enable(bm, e, ELE_DEL); } diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c index a14af618411..b4ec3d740d4 100644 --- a/source/blender/bmesh/operators/bmo_triangulate.c +++ b/source/blender/bmesh/operators/bmo_triangulate.c @@ -89,8 +89,9 @@ void bmesh_beautify_fill_exec(BMesh *bm, BMOperator *op) BMO_slot_buffer_flag_enable(bm, op, "constrain_edges", EDGE_MARK, BM_EDGE); BMO_ITER(f, &siter, bm, op, "faces", BM_FACE) { - if (f->len == 3) + if (f->len == 3) { BMO_elem_flag_enable(bm, f, FACE_MARK); + } } while (!stop) { diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index d80535efb76..1acdf05ef35 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -170,8 +170,9 @@ static void bmesh_regionextend_extend(BMesh *bm, BMOperator *op, int usefaces) BMO_ITER(f, &siter, bm, op, "geom", BM_FACE) { BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { BM_ITER(f2, &fiter, bm, BM_FACES_OF_EDGE, l->e) { - if (!BMO_elem_flag_test(bm, f2, SEL_ORIG)) + if (!BMO_elem_flag_test(bm, f2, SEL_ORIG)) { BMO_elem_flag_enable(bm, f2, SEL_FLAG); + } } } } @@ -595,21 +596,21 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) for (i = 0; i < num_total; i++) { fm = f_ext[i].f; if (!BMO_elem_flag_test(bm, fm, FACE_MARK) && !BM_elem_flag_test(fm, BM_ELEM_HIDDEN)) { - int cont = 1; - for (idx = 0; idx < num_sels && cont == 1; idx++) { + int cont = TRUE; + for (idx = 0; idx < num_sels && cont == TRUE; idx++) { fs = f_ext[indices[idx]].f; switch (type) { case SIMFACE_MATERIAL: if (fm->mat_nr == fs->mat_nr) { BMO_elem_flag_enable(bm, fm, FACE_MARK); - cont = 0; + cont = FALSE; } break; case SIMFACE_IMAGE: if (f_ext[i].t == f_ext[indices[idx]].t) { BMO_elem_flag_enable(bm, fm, FACE_MARK); - cont = 0; + cont = FALSE; } break; @@ -617,7 +618,7 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) angle = RAD2DEGF(angle_v3v3(fs->no, fm->no)); /* if the angle between the normals -> 0 */ if (angle / 180.0f <= thresh) { BMO_elem_flag_enable(bm, fm, FACE_MARK); - cont = 0; + cont = FALSE; } break; @@ -626,7 +627,7 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) if (angle / 180.0f <= thresh) { /* and dot product difference -> 0 */ if (fabsf(f_ext[i].d - f_ext[indices[idx]].d) <= thresh) { BMO_elem_flag_enable(bm, fm, FACE_MARK); - cont = 0; + cont = FALSE; } } break; @@ -634,14 +635,14 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) case SIMFACE_AREA: if (fabsf(f_ext[i].area - f_ext[indices[idx]].area) <= thresh) { BMO_elem_flag_enable(bm, fm, FACE_MARK); - cont = 0; + cont = FALSE; } break; case SIMFACE_PERIMETER: if (fabsf(f_ext[i].perim - f_ext[indices[idx]].perim) <= thresh) { BMO_elem_flag_enable(bm, fm, FACE_MARK); - cont = 0; + cont = FALSE; } break; } @@ -769,14 +770,14 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) for (i = 0; i < num_total; i++) { e = e_ext[i].e; if (!BMO_elem_flag_test(bm, e, EDGE_MARK) && !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { - int cont = 1; - for (idx = 0; idx < num_sels && cont == 1; idx++) { + int cont = TRUE; + for (idx = 0; idx < num_sels && cont == TRUE; idx++) { es = e_ext[indices[idx]].e; switch (type) { case SIMEDGE_LENGTH: if (fabsf(e_ext[i].length - e_ext[indices[idx]].length) <= thresh) { BMO_elem_flag_enable(bm, e, EDGE_MARK); - cont = 0; + cont = FALSE; } break; @@ -789,14 +790,14 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) if (angle / 90.0f <= thresh) { BMO_elem_flag_enable(bm, e, EDGE_MARK); - cont = 0; + cont = FALSE; } break; case SIMEDGE_FACE: if (e_ext[i].faces == e_ext[indices[idx]].faces) { BMO_elem_flag_enable(bm, e, EDGE_MARK); - cont = 0; + cont = FALSE; } break; @@ -805,12 +806,12 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) if (e_ext[indices[idx]].faces == 2) { if (fabsf(e_ext[i].angle - e_ext[indices[idx]].angle) <= thresh) { BMO_elem_flag_enable(bm, e, EDGE_MARK); - cont = 0; + cont = FALSE; } } } else { - cont = 0; + cont = FALSE; } break; @@ -823,7 +824,7 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) if (c1 && c2 && fabsf(*c1 - *c2) <= thresh) { BMO_elem_flag_enable(bm, e, EDGE_MARK); - cont = 0; + cont = FALSE; } } break; @@ -831,14 +832,14 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) case SIMEDGE_SEAM: if (BM_elem_flag_test(e, BM_ELEM_SEAM) == BM_elem_flag_test(es, BM_ELEM_SEAM)) { BMO_elem_flag_enable(bm, e, EDGE_MARK); - cont = 0; + cont = FALSE; } break; case SIMEDGE_SHARP: if (BM_elem_flag_test(e, BM_ELEM_SMOOTH) == BM_elem_flag_test(es, BM_ELEM_SMOOTH)) { BMO_elem_flag_enable(bm, e, EDGE_MARK); - cont = 0; + cont = FALSE; } break; } @@ -925,22 +926,22 @@ void bmesh_similarverts_exec(BMesh *bm, BMOperator *op) for (i = 0; i < num_total; i++) { v = v_ext[i].v; if (!BMO_elem_flag_test(bm, v, VERT_MARK) && !BM_elem_flag_test(v, BM_ELEM_HIDDEN)) { - int cont = 1; - for (idx = 0; idx < num_sels && cont == 1; idx++) { + int cont = TRUE; + for (idx = 0; idx < num_sels && cont == TRUE; idx++) { vs = v_ext[indices[idx]].v; switch (type) { case SIMVERT_NORMAL: /* compare the angle between the normals */ if (RAD2DEGF(angle_v3v3(v->no, vs->no)) / 180.0f <= thresh) { BMO_elem_flag_enable(bm, v, VERT_MARK); - cont = 0; + cont = FALSE; } break; case SIMVERT_FACE: /* number of adjacent faces */ if (v_ext[i].num_faces == v_ext[indices[idx]].num_faces) { BMO_elem_flag_enable(bm, v, VERT_MARK); - cont = 0; + cont = FALSE; } break; @@ -951,7 +952,7 @@ void bmesh_similarverts_exec(BMesh *bm, BMOperator *op) for (v2 = 0; v2 < v_ext[indices[idx]].dvert->totweight; v2++) { if (v_ext[i].dvert->dw[v1].def_nr == v_ext[indices[idx]].dvert->dw[v2].def_nr) { BMO_elem_flag_enable(bm, v, VERT_MARK); - cont = 0; + cont = FALSE; break; } } |