diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-05-22 08:58:34 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-05-22 08:58:34 +0400 |
commit | 07ffd9c79089d200544fde120d18f7c2cd861c08 (patch) | |
tree | 5cddc8d7cfeca7bca266b91757698677b8a21639 /source/blender/editors/mesh/editmesh_select.c | |
parent | 6ce67a8eab884c69837381fb55f6ec86d5614cef (diff) |
Fix T40309: Select inner region 'bigger' failed with equal regions
Diffstat (limited to 'source/blender/editors/mesh/editmesh_select.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 15bfeea8918..3334f5bbb11 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -3187,6 +3187,11 @@ static int loop_find_region(BMLoop *l, int flag, continue; BM_ITER_ELEM (l2, &liter2, l1->e, BM_LOOPS_OF_EDGE) { + /* avoids finding same region twice + * (otherwise) the logic works fine without */ + if (BM_elem_flag_test(l2->f, BM_ELEM_TAG)) { + continue; + } if (BLI_smallhash_haskey(fhash, (uintptr_t)l2->f)) continue; @@ -3216,21 +3221,22 @@ static int verg_radial(const void *va, const void *vb) return 0; } +/** + * This function leaves faces tagged which are apart of the new region. + * + * \note faces already tagged are ignored, to avoid finding the same regions twice: + * important when we have regions with equal face counts, see: T40309 + */ static int loop_find_regions(BMEditMesh *em, const bool selbigger) { SmallHash visithash; BMIter iter; const int edges_len = em->bm->totedgesel; BMEdge *e, **edges; - BMFace *f; int count = 0, i; BLI_smallhash_init_ex(&visithash, edges_len); edges = MEM_mallocN(sizeof(*edges) * edges_len, __func__); - - BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { - BM_elem_flag_disable(f, BM_ELEM_TAG); - } i = 0; BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { @@ -3310,13 +3316,14 @@ static int edbm_loop_to_region_exec(bContext *C, wmOperator *op) const bool select_bigger = RNA_boolean_get(op->ptr, "select_bigger"); int a, b; + /* find the set of regions with smallest number of total faces */ + BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, false); a = loop_find_regions(em, select_bigger); b = loop_find_regions(em, !select_bigger); - - if ((a <= b) ^ select_bigger) { - loop_find_regions(em, select_bigger); - } + + BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, false); + loop_find_regions(em, ((a <= b) != select_bigger) ? select_bigger : !select_bigger); EDBM_flag_disable_all(em, BM_ELEM_SELECT); |