diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-26 02:23:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-26 02:23:40 +0400 |
commit | c65b3b73fd2c0c0011ef36d8fc36301de4a42fe0 (patch) | |
tree | 3a45d161d5814bf403ffa9093a2d417b6f7a960e /source/blender/editors/mesh | |
parent | 72e1316dc4b607440430779d78a26a76a4527c4b (diff) |
bmesh api cleanup
* better type safety for BM_elem_flag_* and BM_elem_index_* functions.
* add BMElem type to be used where BMFace/Edge/Vert/Loop can be interchanged.
* fix bug in select manifold, found when making functions more strict.
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/bmesh_select.c | 34 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_selecthistory.c | 8 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_tools.c | 18 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_utils.c | 12 |
4 files changed, 36 insertions, 36 deletions
diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index ec64caa8253..1bc1ebcd9a7 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -889,18 +889,18 @@ void MESH_OT_select_similar(wmOperatorType *ot) static void walker_select(BMEditMesh *em, int walkercode, void *start, int select) { BMesh *bm = em->bm; - BMHeader *h; + BMElem *ele; BMWalker walker; BMW_init(&walker, bm, walkercode, BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP, BMW_NIL_LAY); - h = BMW_begin(&walker, start); - for ( ; h; h = BMW_step(&walker)) { + ele = BMW_begin(&walker, start); + for ( ; ele; ele = BMW_step(&walker)) { if (!select) { - BM_select_history_remove(bm, h); + BM_select_history_remove(bm, ele); } - BM_elem_select_set(bm, h, select); + BM_elem_select_set(bm, ele, select); } BMW_end(&walker); } @@ -1369,7 +1369,7 @@ static void mouse_mesh_shortest_path(bContext *C, int mval[2]) if (ese && ese->htype == BM_EDGE) { BMEdge *e_act; - e_act = (BMEdge *)ese->data; + e_act = (BMEdge *)ese->ele; if (e_act != e) { if (edgetag_shortest_path(vc.scene, em, e_act, e)) { EDBM_remove_selection(em, e_act); @@ -1999,7 +1999,7 @@ void MESH_OT_select_less(wmOperatorType *ot) are reached is not a multiple of "nth". */ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h_act) { - BMHeader *h; + BMElem *ele; BMesh *bm = em->bm; BMWalker walker; BMIter iter; @@ -2037,10 +2037,10 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h /* Walker restrictions uses BMO flags, not header flags, * so transfer BM_ELEM_SELECT from HFlags onto a BMO flag layer. */ BMO_push(bm, NULL); - BM_ITER(h, &iter, bm, itertype, NULL) { - if (BM_elem_flag_test(h, BM_ELEM_SELECT)) { + BM_ITER(ele, &iter, bm, itertype, NULL) { + if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) { /* BMESH_TODO, don't use 'BM_ELEM_SELECT' here, its a HFLAG only! */ - BMO_elem_flag_enable(bm, (BMElemF *)h, BM_ELEM_SELECT); + BMO_elem_flag_enable(bm, (BMElemF *)ele, BM_ELEM_SELECT); } } @@ -2050,10 +2050,10 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h BMW_NIL_LAY); BLI_assert(walker.order == BMW_BREADTH_FIRST); - for (h = BMW_begin(&walker, h_act); h != NULL; h = BMW_step(&walker)) { + for (ele = BMW_begin(&walker, h_act); ele != NULL; ele = BMW_step(&walker)) { /* Deselect elements that aren't at "nth" depth from active */ if ((offset + BMW_current_depth(&walker)) % nth) { - BM_elem_select_set(bm, h, FALSE); + BM_elem_select_set(bm, ele, FALSE); } } BMW_end(&walker); @@ -2082,13 +2082,13 @@ static void deselect_nth_active(BMEditMesh *em, BMVert **v_p, BMEdge **e_p, BMFa if (ese) { switch(ese->htype) { case BM_VERT: - *v_p = (BMVert *)ese->data; + *v_p = (BMVert *)ese->ele; return; case BM_EDGE: - *e_p = (BMEdge *)ese->data; + *e_p = (BMEdge *)ese->ele; return; case BM_FACE: - *f_p = (BMFace *)ese->data; + *f_p = (BMFace *)ese->ele; return; } } @@ -2356,13 +2356,13 @@ static int select_non_manifold_exec(bContext *C, wmOperator *op) } BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { - if (!BM_elem_flag_test(em->bm, BM_ELEM_HIDDEN) && !BM_vert_is_manifold(em->bm, v)) { + if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN) && !BM_vert_is_manifold(em->bm, v)) { BM_elem_select_set(em->bm, v, TRUE); } } BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { - if (!BM_elem_flag_test(em->bm, BM_ELEM_HIDDEN) && BM_edge_face_count(e) != 2) { + if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN) && BM_edge_face_count(e) != 2) { BM_elem_select_set(em->bm, e, TRUE); } } diff --git a/source/blender/editors/mesh/bmesh_selecthistory.c b/source/blender/editors/mesh/bmesh_selecthistory.c index ed3bd0c8a87..f0c00d0ff07 100644 --- a/source/blender/editors/mesh/bmesh_selecthistory.c +++ b/source/blender/editors/mesh/bmesh_selecthistory.c @@ -53,14 +53,14 @@ void EDBM_editselection_plane(BMEditMesh *em, float *plane, BMEditSelection *ese BM_editselection_plane(em->bm, plane, ese); } -void EDBM_remove_selection(BMEditMesh *em, void *data) +void EDBM_remove_selection(BMEditMesh *em, BMElem *ele) { - BM_select_history_remove(em->bm, data); + BM_select_history_remove(em->bm, ele); } -void EDBM_store_selection(BMEditMesh *em, void *data) +void EDBM_store_selection(BMEditMesh *em, BMElem *ele) { - BM_select_history_store(em->bm, data); + BM_select_history_store(em->bm, ele); } void EDBM_validate_selections(BMEditMesh *em) diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 91aaa36c77d..74ef159b40e 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -1424,7 +1424,7 @@ void MESH_OT_edge_rotate(wmOperatorType *ot) void EDBM_hide_mesh(BMEditMesh *em, int swap) { BMIter iter; - BMHeader *h; + BMElem *ele; int itermode; if (em == NULL) return; @@ -1436,9 +1436,9 @@ void EDBM_hide_mesh(BMEditMesh *em, int swap) else itermode = BM_FACES_OF_MESH; - BM_ITER(h, &iter, em->bm, itermode, NULL) { - if (BM_elem_flag_test(h, BM_ELEM_SELECT) ^ swap) - BM_elem_hide_set(em->bm, h, TRUE); + BM_ITER(ele, &iter, em->bm, itermode, NULL) { + if (BM_elem_flag_test(ele, BM_ELEM_SELECT) ^ swap) + BM_elem_hide_set(em->bm, ele, TRUE); } EDBM_selectmode_flush(em); @@ -1497,7 +1497,7 @@ void EDBM_reveal_mesh(BMEditMesh *em) }; BMIter iter; - BMHeader *ele; + BMElem *ele; int i; /* Use tag flag to remember what was hidden before all is revealed. @@ -2011,11 +2011,11 @@ static int merge_firstlast(BMEditMesh *em, int first, int uvmerge, wmOperator *w /* do sanity check in mergemenu in edit.c ?*/ if (first == 0) { ese = em->bm->selected.last; - mergevert = (BMVert *)ese->data; + mergevert = (BMVert *)ese->ele; } else{ ese = em->bm->selected.first; - mergevert = (BMVert *)ese->data; + mergevert = (BMVert *)ese->ele; } if (!BM_elem_flag_test(mergevert, BM_ELEM_SELECT)) @@ -2270,7 +2270,7 @@ static int select_vertex_path_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_InitOpf(em, &bmop, op, "vertexshortestpath startv=%e endv=%e type=%i", sv->data, ev->data, type); + EDBM_InitOpf(em, &bmop, op, "vertexshortestpath startv=%e endv=%e type=%i", sv->ele, ev->ele, type); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -2739,7 +2739,7 @@ static int select_axis_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else { - BMVert *ev, *act_vert = (BMVert *)ese->data; + BMVert *ev, *act_vert = (BMVert *)ese->ele; BMIter iter; float value = act_vert->co[axis]; float limit = CTX_data_tool_settings(C)->doublimit; // XXX diff --git a/source/blender/editors/mesh/bmesh_utils.c b/source/blender/editors/mesh/bmesh_utils.c index da1904cf11a..96ef8b98bf8 100644 --- a/source/blender/editors/mesh/bmesh_utils.c +++ b/source/blender/editors/mesh/bmesh_utils.c @@ -83,7 +83,7 @@ void EDBM_stats_update(BMEditMesh *em) BM_FACES_OF_MESH}; BMIter iter; - BMHeader *ele; + BMElem *ele; int *tots[3]; int i; @@ -451,24 +451,24 @@ int EDBM_get_actSelection(BMEditMesh *em, BMEditSelection *ese) if (ese_last) { if (ese_last->htype == BM_FACE) { /* if there is an active face, use it over the last selected face */ if (efa) { - ese->data = (void *)efa; + ese->ele = (BMElem *)efa; } else { - ese->data = ese_last->data; + ese->ele = ese_last->ele; } ese->htype = BM_FACE; } else { - ese->data = ese_last->data; + ese->ele = ese_last->ele; ese->htype = ese_last->htype; } } else if (efa) { /* no */ - ese->data = (void *)efa; + ese->ele = (BMElem *)efa; ese->htype = BM_FACE; } else { - ese->data = NULL; + ese->ele = NULL; return 0; } return 1; |