diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-20 20:55:47 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-20 20:55:47 +0400 |
commit | b26865ba99a8a9dea483a71b757d9eb2de0f7198 (patch) | |
tree | daca82eebccb3a150920ca9200360f2e35291940 /source/blender/editors/mesh | |
parent | 91dc245f93d38307c586b445b91a49ea6cea32e1 (diff) |
code cleanup: prefer BM_face/edge/vert_select_set() over BM_elem_select_set() when the type is known (saves switch statement check on the type).
Add asserts so the correct types are ensured.
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/editmesh_loopcut.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_rip.c | 12 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 68 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 32 |
4 files changed, 57 insertions, 57 deletions
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index d05bf10e206..45a975e5d52 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -211,7 +211,7 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select) eed = BMW_begin(&walker, startedge); for ( ; eed; eed = BMW_step(&walker)) { - BM_elem_select_set(em->bm, eed, TRUE); + BM_edge_select_set(em->bm, eed, TRUE); } BMW_end(&walker); diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 7333bf9aa49..1e0f0b2579b 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -336,7 +336,7 @@ static void edbm_ripsel_deselect_helper(BMesh *bm, EdgeLoopPair *eloop_pairs, e = (score_a > score_b) ? lp->l_a->e : lp->l_b->e; v_prev = edbm_ripsel_edloop_pair_start_vert(e); for (; e; e = edbm_ripsel_edge_uid_step(e, &v_prev)) { - BM_elem_select_set(bm, e, FALSE); + BM_edge_select_set(bm, e, FALSE); } } } @@ -431,12 +431,12 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event) BMVert **vout; int vout_len; - BM_elem_select_set(bm, v, FALSE); + BM_vert_select_set(bm, v, FALSE); bmesh_vert_separate(bm, v, &vout, &vout_len); if (vout_len < 2) { /* set selection back to avoid active-unselected vertex */ - BM_elem_select_set(bm, v, TRUE); + BM_vert_select_set(bm, v, TRUE); /* should never happen */ BKE_report(op->reports, RPT_ERROR, "Error ripping vertex from faces"); return OPERATOR_CANCELLED; @@ -472,7 +472,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event) /* select the vert from the best region */ v = vout[vi_best]; - BM_elem_select_set(bm, v, TRUE); + BM_vert_select_set(bm, v, TRUE); if (ese.ele) { EDBM_editselection_store(em, &v->head); @@ -541,7 +541,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event) BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { /* disable by default, re-enable winner at end */ - BM_elem_select_set(bm, v, FALSE); + BM_vert_select_set(bm, v, FALSE); BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { /* calculate a point in the face, rather then calculate the middle, @@ -566,7 +566,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, wmEvent *event) } if (v_best) { - BM_elem_select_set(bm, v_best, TRUE); + BM_vert_select_set(bm, v_best, TRUE); if (ese.ele) { EDBM_editselection_store(em, &v_best->head); } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index c20c3e50e67..b6e162cb220 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -95,7 +95,7 @@ void EDBM_select_mirrored(Object *UNUSED(obedit), BMEditMesh *em, int extend) v2 = EDBM_verts_mirror_get(em, v1); if (v2 && !BM_elem_flag_test(v2, BM_ELEM_HIDDEN)) { - BM_elem_select_set(em->bm, v2, TRUE); + BM_vert_select_set(em->bm, v2, TRUE); } } @@ -1166,7 +1166,7 @@ static void edgetag_context_set(BMEditMesh *em, Scene *scene, BMEdge *e, int val switch (scene->toolsettings->edge_mode) { case EDGE_MODE_SELECT: - BM_elem_select_set(em->bm, e, val); + BM_edge_select_set(em->bm, e, val); break; case EDGE_MODE_TAG_SEAM: BM_elem_flag_set(e, BM_ELEM_SEAM, val); @@ -1459,31 +1459,31 @@ int mouse_mesh(bContext *C, const int mval[2], short extend) if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) { EDBM_editselection_store(vc.em, &efa->head); - BM_elem_select_set(vc.em->bm, efa, TRUE); + BM_face_select_set(vc.em->bm, efa, TRUE); } else if (extend) { EDBM_editselection_remove(vc.em, &efa->head); - BM_elem_select_set(vc.em->bm, efa, FALSE); + BM_face_select_set(vc.em->bm, efa, FALSE); } } else if (eed) { if (!BM_elem_flag_test(eed, BM_ELEM_SELECT)) { EDBM_editselection_store(vc.em, &eed->head); - BM_elem_select_set(vc.em->bm, eed, TRUE); + BM_edge_select_set(vc.em->bm, eed, TRUE); } else if (extend) { EDBM_editselection_remove(vc.em, &eed->head); - BM_elem_select_set(vc.em->bm, eed, FALSE); + BM_edge_select_set(vc.em->bm, eed, FALSE); } } else if (eve) { if (!BM_elem_flag_test(eve, BM_ELEM_SELECT)) { EDBM_editselection_store(vc.em, &eve->head); - BM_elem_select_set(vc.em->bm, eve, TRUE); + BM_vert_select_set(vc.em->bm, eve, TRUE); } else if (extend) { EDBM_editselection_remove(vc.em, &eve->head); - BM_elem_select_set(vc.em->bm, eve, FALSE); + BM_vert_select_set(vc.em->bm, eve, FALSE); } } @@ -1554,12 +1554,12 @@ void EDBM_selectmode_set(BMEditMesh *em) else if (em->selectmode & SCE_SELECT_EDGE) { /* deselect vertices, and select again based on edge select */ eve = BM_iter_new(&iter, em->bm, BM_VERTS_OF_MESH, NULL); - for (; eve; eve = BM_iter_step(&iter)) BM_elem_select_set(em->bm, eve, FALSE); + for (; eve; eve = BM_iter_step(&iter)) BM_vert_select_set(em->bm, eve, FALSE); eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL); for (; eed; eed = BM_iter_step(&iter)) { if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { - BM_elem_select_set(em->bm, eed, TRUE); + BM_edge_select_set(em->bm, eed, TRUE); } } @@ -1569,12 +1569,12 @@ void EDBM_selectmode_set(BMEditMesh *em) else if (em->selectmode & SCE_SELECT_FACE) { /* deselect eges, and select again based on face select */ eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL); - for (; eed; eed = BM_iter_step(&iter)) BM_elem_select_set(em->bm, eed, FALSE); + for (; eed; eed = BM_iter_step(&iter)) BM_edge_select_set(em->bm, eed, FALSE); efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL); for (; efa; efa = BM_iter_step(&iter)) { if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) { - BM_elem_select_set(em->bm, efa, TRUE); + BM_face_select_set(em->bm, efa, TRUE); } } } @@ -1595,7 +1595,7 @@ void EDBM_selectmode_convert(BMEditMesh *em, short oldmode, short selectmode) if ((BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))) { - BM_elem_select_set(em->bm, eed, TRUE); + BM_edge_select_set(em->bm, eed, TRUE); } } } @@ -1609,7 +1609,7 @@ void EDBM_selectmode_convert(BMEditMesh *em, short oldmode, short selectmode) l = BM_iter_new(&liter, em->bm, BM_LOOPS_OF_FACE, efa); for (; l; l = BM_iter_step(&liter)) { if (BM_elem_flag_test(l->v, BM_ELEM_SELECT)) { - BM_elem_select_set(em->bm, efa, TRUE); + BM_face_select_set(em->bm, efa, TRUE); break; } } @@ -1628,7 +1628,7 @@ void EDBM_selectmode_convert(BMEditMesh *em, short oldmode, short selectmode) l = BM_iter_new(&liter, em->bm, BM_LOOPS_OF_FACE, efa); for (; l; l = BM_iter_step(&liter)) { if (BM_elem_flag_test(l->v, BM_ELEM_SELECT)) { - BM_elem_select_set(em->bm, efa, TRUE); + BM_face_select_set(em->bm, efa, TRUE); break; } } @@ -1647,7 +1647,7 @@ void EDBM_deselect_by_material(BMEditMesh *em, const short index, const short se if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) continue; if (efa->mat_nr == index) { - BM_elem_select_set(em->bm, efa, select); + BM_face_select_set(em->bm, efa, select); } } } @@ -1671,21 +1671,21 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */ BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) continue; - BM_elem_select_set(em->bm, eve, !BM_elem_flag_test(eve, BM_ELEM_SELECT)); + BM_vert_select_set(em->bm, eve, !BM_elem_flag_test(eve, BM_ELEM_SELECT)); } } else if (em->selectmode & SCE_SELECT_EDGE) { BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) continue; - BM_elem_select_set(em->bm, eed, !BM_elem_flag_test(eed, BM_ELEM_SELECT)); + BM_edge_select_set(em->bm, eed, !BM_elem_flag_test(eed, BM_ELEM_SELECT)); } } else { BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) continue; - BM_elem_select_set(em->bm, efa, !BM_elem_flag_test(efa, BM_ELEM_SELECT)); + BM_face_select_set(em->bm, efa, !BM_elem_flag_test(efa, BM_ELEM_SELECT)); } } @@ -1716,7 +1716,7 @@ int EDBM_select_interior_faces(BMEditMesh *em) } if (ok) { - BM_elem_select_set(bm, efa, TRUE); + BM_face_select_set(bm, efa, TRUE); change = TRUE; } } @@ -1799,7 +1799,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent * e = BMW_begin(&walker, efa); for (; efa; efa = BMW_step(&walker)) { - BM_elem_select_set(bm, efa, sel); + BM_face_select_set(bm, efa, sel); } BMW_end(&walker); } @@ -1821,7 +1821,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent * e = BMW_begin(&walker, eed->v1); for (; e; e = BMW_step(&walker)) { - BM_elem_select_set(bm, e, sel); + BM_edge_select_set(bm, e, sel); } BMW_end(&walker); @@ -1891,7 +1891,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { e = BMW_begin(&walker, efa); for (; efa; efa = BMW_step(&walker)) { - BM_elem_select_set(bm, efa, TRUE); + BM_face_select_set(bm, efa, TRUE); } } } @@ -1916,8 +1916,8 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) if (BM_elem_flag_test(v, BM_ELEM_TAG)) { e = BMW_begin(&walker, v); for (; e; e = BMW_step(&walker)) { - BM_elem_select_set(em->bm, e->v1, TRUE); - BM_elem_select_set(em->bm, e->v2, TRUE); + BM_vert_select_set(em->bm, e->v1, TRUE); + BM_vert_select_set(em->bm, e->v2, TRUE); } } } @@ -2237,7 +2237,7 @@ static int edbm_select_sharp_edges_exec(bContext *C, wmOperator *op) angle = angle_normalized_v3v3(l1->f->no, l2->f->no); if (fabsf(angle) > sharp) { - BM_elem_select_set(em->bm, e, TRUE); + BM_edge_select_set(em->bm, e, TRUE); } } @@ -2296,7 +2296,7 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op) f = stack[i - 1]; i--; - BM_elem_select_set(em->bm, f, TRUE); + BM_face_select_set(em->bm, f, TRUE); BM_elem_flag_enable(f, BM_ELEM_TAG); @@ -2365,13 +2365,13 @@ static int edbm_select_non_manifold_exec(bContext *C, wmOperator *op) BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN) && !BM_vert_is_manifold(v)) { - BM_elem_select_set(em->bm, v, TRUE); + BM_vert_select_set(em->bm, v, TRUE); } } BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN) && !BM_edge_is_manifold(e)) { - BM_elem_select_set(em->bm, e, TRUE); + BM_edge_select_set(em->bm, e, TRUE); } } @@ -2413,7 +2413,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op) if (em->selectmode & SCE_SELECT_VERTEX) { BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BLI_frand() < randfac) { - BM_elem_select_set(em->bm, eve, TRUE); + BM_vert_select_set(em->bm, eve, TRUE); } } EDBM_selectmode_flush(em); @@ -2421,7 +2421,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op) else if (em->selectmode & SCE_SELECT_EDGE) { BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BLI_frand() < randfac) { - BM_elem_select_set(em->bm, eed, TRUE); + BM_edge_select_set(em->bm, eed, TRUE); } } EDBM_selectmode_flush(em); @@ -2429,7 +2429,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op) else { BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BLI_frand() < randfac) { - BM_elem_select_set(em->bm, efa, TRUE); + BM_face_select_set(em->bm, efa, TRUE); } } EDBM_selectmode_flush(em); @@ -2480,14 +2480,14 @@ static int edbm_select_next_loop_exec(bContext *C, wmOperator *UNUSED(op)) BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { if (BM_elem_flag_test(l->v, BM_ELEM_SELECT)) { BM_elem_flag_enable(l->next->v, BM_ELEM_TAG); - BM_elem_select_set(em->bm, l->v, FALSE); + BM_vert_select_set(em->bm, l->v, FALSE); } } } BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { - BM_elem_select_set(em->bm, v, TRUE); + BM_vert_select_set(em->bm, v, TRUE); } } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 2c1c25b2a91..a0fcae860f6 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -191,7 +191,7 @@ static short edbm_extrude_face_indiv(BMEditMesh *em, wmOperator *op, const char BMO_op_exec(em->bm, &bmop); BMO_ITER (f, &siter, em->bm, &bmop, "faceout", BM_FACE) { - BM_elem_select_set(em->bm, f, TRUE); + BM_face_select_set(em->bm, f, TRUE); /* set face vertex normals to face normal */ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { @@ -353,8 +353,8 @@ static short edbm_extrude_vert(Object *obedit, BMEditMesh *em, const char hflag, BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(eed, hflag)) { if (hflag & BM_ELEM_SELECT) { - BM_elem_select_set(em->bm, eed->v1, TRUE); - BM_elem_select_set(em->bm, eed->v2, TRUE); + BM_vert_select_set(em->bm, eed->v1, TRUE); + BM_vert_select_set(em->bm, eed->v2, TRUE); } BM_elem_flag_enable(eed->v1, hflag & ~BM_ELEM_SELECT); @@ -363,7 +363,7 @@ static short edbm_extrude_vert(Object *obedit, BMEditMesh *em, const char hflag, else { if (BM_elem_flag_test(eed->v1, hflag) && BM_elem_flag_test(eed->v2, hflag)) { if (hflag & BM_ELEM_SELECT) { - BM_elem_select_set(em->bm, eed, TRUE); + BM_edge_select_set(em->bm, eed, TRUE); } BM_elem_flag_enable(eed, hflag & ~BM_ELEM_SELECT); @@ -860,7 +860,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent BMO_op_exec(vc.em->bm, &bmop); BMO_ITER (v1, &oiter, vc.em->bm, &bmop, "newvertout", BM_VERT) { - BM_elem_select_set(vc.em->bm, v1, TRUE); + BM_vert_select_set(vc.em->bm, v1, TRUE); } if (!EDBM_op_finish(vc.em, &bmop, op, TRUE)) { @@ -2328,15 +2328,15 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op) switch (mode) { case -1: /* aligned */ if (fabs(ev->co[axis] - value) < limit) - BM_elem_select_set(em->bm, ev, TRUE); + BM_vert_select_set(em->bm, ev, TRUE); break; case 0: /* neg */ if (ev->co[axis] > value) - BM_elem_select_set(em->bm, ev, TRUE); + BM_vert_select_set(em->bm, ev, TRUE); break; case 1: /* pos */ if (ev->co[axis] < value) - BM_elem_select_set(em->bm, ev, TRUE); + BM_vert_select_set(em->bm, ev, TRUE); break; } } @@ -2802,7 +2802,7 @@ static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase, wmO continue; if (!BM_edge_is_wire(e)) { - BM_elem_select_set(em->bm, e, FALSE); + BM_edge_select_set(em->bm, e, FALSE); } } EDBM_op_callf(em, wmop, "del geom=%hvef context=%i", BM_ELEM_SELECT, DEL_EDGES); @@ -2813,7 +2813,7 @@ static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase, wmO continue; if (BM_vert_edge_count(v) != 0) { - BM_elem_select_set(em->bm, v, FALSE); + BM_vert_select_set(em->bm, v, FALSE); } } @@ -2899,7 +2899,7 @@ static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase, wmOper } /* Select the seed explicitly, in case it has no edges */ - BM_elem_select_set(bm, v_seed, TRUE); + BM_vert_select_set(bm, v_seed, TRUE); /* Walk from the single vertex, selecting everything connected * to it */ @@ -2910,8 +2910,8 @@ static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase, wmOper e = BMW_begin(&walker, v_seed); for (; e; e = BMW_step(&walker)) { - BM_elem_select_set(bm, e->v1, TRUE); - BM_elem_select_set(bm, e->v2, TRUE); + BM_vert_select_set(bm, e->v1, TRUE); + BM_vert_select_set(bm, e->v2, TRUE); } BMW_end(&walker); @@ -3487,7 +3487,7 @@ static int edbm_select_by_number_vertices_exec(bContext *C, wmOperator *op) } if (select) { - BM_elem_select_set(em->bm, efa, TRUE); + BM_face_select_set(em->bm, efa, TRUE); } } @@ -3535,7 +3535,7 @@ static int edbm_select_loose_verts_exec(bContext *C, wmOperator *UNUSED(op)) eve; eve = BM_iter_step(&iter)) { if (!eve->e) { - BM_elem_select_set(em->bm, eve, TRUE); + BM_vert_select_set(em->bm, eve, TRUE); } } @@ -3543,7 +3543,7 @@ static int edbm_select_loose_verts_exec(bContext *C, wmOperator *UNUSED(op)) eed; eed = BM_iter_step(&iter)) { if (!eed->l) { - BM_elem_select_set(em->bm, eed, TRUE); + BM_edge_select_set(em->bm, eed, TRUE); } } |