diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-13 08:02:26 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-13 08:02:26 +0400 |
commit | e9358a38060fefe280018e8ac62e142dabc32a0d (patch) | |
tree | debb573a732f3faee8ff1b253838d569a7b3c609 /source/blender/bmesh | |
parent | 8c70caf9665217554708318362e8a6c8ffef2906 (diff) |
bmesh api changes:
- remove recently added BM_mesh_select_flush_strip(), functions purpose wasn't clear.
- add BM_mesh_elem_hflag_disable_test(), BM_mesh_elem_hflag_enable_test()
to match existing BM_mesh_elem_hflag_enable/disable_all(), these take a hflag to test before editing each element.
This replaces the need for BM_mesh_select_flush_strip().
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.c | 74 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.h | 17 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operators.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_inset.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_subdivide.c | 2 |
5 files changed, 44 insertions, 57 deletions
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 1b80bda318e..3492b4257cb 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -446,47 +446,6 @@ void BM_mesh_select_mode_set(BMesh *bm, int selectmode) } /** - * \brief De-Select, Re-Select elements - * Awkwardly named function - * - * Deselect's one type of elements then re-selects another, - * Use case is to de-select stray edges or verts. - */ -void BM_mesh_select_flush_strip(BMesh *bm, const char htype_desel, const char htype_sel, const char hflag_test) -{ - const char iter_types[3] = {BM_VERTS_OF_MESH, - BM_EDGES_OF_MESH, - BM_FACES_OF_MESH}; - - const char flag_types[3] = {BM_VERT, BM_EDGE, BM_FACE}; - - BMIter iter; - BMElem *ele; - int i; - - for (i = 0; i < 3; i++) { - if (htype_desel & flag_types[i]) { - ele = BM_iter_new(&iter, bm, iter_types[i], NULL); - for ( ; ele; ele = BM_iter_step(&iter)) { - BM_elem_flag_disable(ele, BM_ELEM_SELECT); - } - } - } - - for (i = 0; i < 3; i++) { - if (htype_sel & flag_types[i]) { - ele = BM_iter_new(&iter, bm, iter_types[i], NULL); - for ( ; ele; ele = BM_iter_step(&iter)) { - if (BM_elem_flag_test(ele, hflag_test)) { - BM_elem_select_set(bm, ele, TRUE); - } - } - } - } - -} - -/** * counts number of elements with flag enabled/disabled */ static int bm_mesh_flag_count(BMesh *bm, const char htype, const char hflag, @@ -520,12 +479,12 @@ static int bm_mesh_flag_count(BMesh *bm, const char htype, const char hflag, return tot; } -int BM_mesh_enabled_flag_count(BMesh *bm, const char htype, const char hflag, int respecthide) +int BM_mesh_elem_hflag_count_enabled(BMesh *bm, const char htype, const char hflag, int respecthide) { return bm_mesh_flag_count(bm, htype, hflag, respecthide, TRUE); } -int BM_mesh_disabled_flag_count(BMesh *bm, const char htype, const char hflag, int respecthide) +int BM_mesh_elem_hflag_count_disabled(BMesh *bm, const char htype, const char hflag, int respecthide) { return bm_mesh_flag_count(bm, htype, hflag, respecthide, FALSE); } @@ -813,7 +772,8 @@ void BM_select_history_validate(BMesh *bm) } } -void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag, int respecthide) +void BM_mesh_elem_hflag_disable_test(BMesh *bm, const char htype, const char hflag, + int respecthide, const char hflag_test) { const char iter_types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, @@ -831,7 +791,8 @@ void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag if ((htype == (BM_VERT | BM_EDGE | BM_FACE)) && (hflag == BM_ELEM_SELECT) && - (respecthide == FALSE)) + (respecthide == FALSE) && + (hflag_test == 0)) { /* fast path for deselect all, avoid topology loops * since we know all will be de-selected anyway. */ @@ -852,6 +813,9 @@ void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) { continue; } + if (hflag_test && !BM_elem_flag_test(ele, hflag_test)) { + continue; + } if (hflag & BM_ELEM_SELECT) { BM_elem_select_set(bm, ele, FALSE); @@ -863,7 +827,8 @@ void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag } } -void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag, int respecthide) +void BM_mesh_elem_hflag_enable_test(BMesh *bm, const char htype, const char hflag, + int respecthide, const char hflag_test) { const char iter_types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, @@ -896,6 +861,9 @@ void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag, if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) { continue; } + if (hflag_test && !BM_elem_flag_test(ele, hflag_test)) { + continue; + } if (hflag & BM_ELEM_SELECT) { BM_elem_select_set(bm, ele, TRUE); @@ -906,6 +874,20 @@ void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag, } } +void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, + int respecthide) +{ + /* call with 0 hflag_test */ + BM_mesh_elem_hflag_disable_test(bm, htype, hflag, respecthide, 0); +} + +void BM_mesh_elem_hflag_enable_all(BMesh *bm, const char htype, const char hflag, + int respecthide) +{ + /* call with 0 hflag_test */ + BM_mesh_elem_hflag_enable_test(bm, htype, hflag, respecthide, 0); +} + /***************** Mesh Hiding stuff *********** */ static void vert_flush_hide_set(BMesh *bm, BMVert *v) diff --git a/source/blender/bmesh/intern/bmesh_marking.h b/source/blender/bmesh/intern/bmesh_marking.h index b72b3f73950..73423bc181d 100644 --- a/source/blender/bmesh/intern/bmesh_marking.h +++ b/source/blender/bmesh/intern/bmesh_marking.h @@ -45,8 +45,15 @@ void BM_face_hide_set(BMesh *bm, BMFace *f, int hide); #define BM_elem_select_set(bm, ele, hide) _bm_elem_select_set(bm, &(ele)->head, hide) void _bm_elem_select_set(BMesh *bm, BMHeader *ele, int select); -void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag, int respecthide); -void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag, int respecthide); +void BM_mesh_elem_hflag_enable_test(BMesh *bm, const char htype, const char hflag, + int respecthide, const char hflag_test); +void BM_mesh_elem_hflag_disable_test(BMesh *bm, const char htype, const char hflag, + int respecthide, const char hflag_test); + +void BM_mesh_elem_hflag_enable_all(BMesh *bm, const char htype, const char hflag, + int respecthide); +void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, + int respecthide); /* individual element select functions, BM_elem_select_set is a shortcut for these * that automatically detects which one to use*/ @@ -60,10 +67,8 @@ void BM_mesh_select_mode_flush(BMesh *bm); void BM_mesh_deselect_flush(BMesh *bm); void BM_mesh_select_flush(BMesh *bm); -void BM_mesh_select_flush_strip(BMesh *bm, const char htype_desel, const char htype_sel, const char hflag_test); - -int BM_mesh_enabled_flag_count(BMesh *bm, const char htype, const char hflag, int respecthide); -int BM_mesh_disabled_flag_count(BMesh *bm, const char htype, const char hflag, int respecthide); +int BM_mesh_elem_hflag_count_enabled(BMesh *bm, const char htype, const char hflag, int respecthide); +int BM_mesh_elem_hflag_count_disabled(BMesh *bm, const char htype, const char hflag, int respecthide); /* edit selection stuff */ void BM_active_face_set(BMesh *em, BMFace *f); diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 00292e481b2..a1cdcc65f1c 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -701,9 +701,9 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl BLI_assert(ELEM(TRUE, FALSE, test_for_enabled)); if (test_for_enabled) - totelement = BM_mesh_enabled_flag_count(bm, htype, hflag, TRUE); + totelement = BM_mesh_elem_hflag_count_enabled(bm, htype, hflag, TRUE); else - totelement = BM_mesh_disabled_flag_count(bm, htype, hflag, TRUE); + totelement = BM_mesh_elem_hflag_count_disabled(bm, htype, hflag, TRUE); if (totelement) { BMIter iter; diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index c7f1c4cc35c..61447e98c15 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -123,11 +123,11 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) int i, j, k; if (use_outset == FALSE) { - BM_mesh_elem_flag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); BMO_slot_buffer_hflag_enable(bm, op, "faces", BM_FACE, BM_ELEM_TAG, FALSE); } else { - BM_mesh_elem_flag_enable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_enable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); BMO_slot_buffer_hflag_disable(bm, op, "faces", BM_FACE, BM_ELEM_TAG, FALSE); } diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index b011bb32449..335b0257572 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -1054,7 +1054,7 @@ void BM_mesh_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float s // int i; /* deselect input */ - BM_mesh_elem_flag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); + BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); ele = BMO_iter_new(&iter, bm, &op, "outinner", BM_EDGE|BM_VERT); for ( ; ele; ele = BMO_iter_step(&iter)) { |