diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-08-13 05:52:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-08-13 05:52:36 +0400 |
commit | 5a9c012d86e900208db09b74aebd0bdd60ec711c (patch) | |
tree | 31cef1dd80dbf37339bad50a470b0cef37aa0e85 /source/blender/bmesh/intern | |
parent | 49411a6e37ce88e644db733621ac2577851a7b7e (diff) |
fix for bug in rip tool, isolated verts would remain selected after ripping.
Diffstat (limited to 'source/blender/bmesh/intern')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.c | 73 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.h | 3 |
2 files changed, 76 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index dfae7251c72..bec301acaa9 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -70,6 +70,79 @@ static void recount_totsels(BMesh *bm) } /** + * \brief Select Mode Clean + * + * Remove isolated selected elements when in a mode doesn't support them. + * eg: in edge-mode a selected vertex must be connected to a selected edge. + * + * \note this could be made apart of #BM_mesh_select_mode_flush_ex + */ +void BM_mesh_select_mode_clean_ex(BMesh *bm, const short selectmode) +{ + if (selectmode & SCE_SELECT_VERTEX) { + /* pass */ + } + else if (selectmode & SCE_SELECT_EDGE) { + BMIter iter; + + if (bm->totvertsel) { + BMVert *v; + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + BM_elem_flag_disable(v, BM_ELEM_SELECT); + } + bm->totvertsel = 0; + } + + if (bm->totedgesel) { + BMEdge *e; + BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { + BM_vert_select_set(bm, e->v1, true); + BM_vert_select_set(bm, e->v2, true); + } + } + } + } + else if (selectmode & SCE_SELECT_FACE) { + BMIter iter; + + if (bm->totvertsel) { + BMVert *v; + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + BM_elem_flag_disable(v, BM_ELEM_SELECT); + } + bm->totvertsel = 0; + } + + if (bm->totedgesel) { + BMEdge *e; + BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { + BM_elem_flag_disable(e, BM_ELEM_SELECT); + } + bm->totedgesel = 0; + } + + if (bm->totfacesel) { + BMFace *f; + BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { + if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { + BMLoop *l_iter, *l_first; + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + BM_edge_select_set(bm, l_iter->e, true); + } while ((l_iter = l_iter->next) != l_first); + } + } + } + } +} + +void BM_mesh_select_mode_clean(BMesh *bm) +{ + BM_mesh_select_mode_clean_ex(bm, bm->selectmode); +} + +/** * \brief Select Mode Flush * * Makes sure to flush selections 'upwards' diff --git a/source/blender/bmesh/intern/bmesh_marking.h b/source/blender/bmesh/intern/bmesh_marking.h index b7040e63458..062de4f69e1 100644 --- a/source/blender/bmesh/intern/bmesh_marking.h +++ b/source/blender/bmesh/intern/bmesh_marking.h @@ -59,6 +59,9 @@ void BM_vert_select_set(BMesh *bm, BMVert *v, const bool select); void BM_edge_select_set(BMesh *bm, BMEdge *e, const bool select); void BM_face_select_set(BMesh *bm, BMFace *f, const bool select); +void BM_mesh_select_mode_clean_ex(BMesh *bm, const short selectmode); +void BM_mesh_select_mode_clean(BMesh *bm); + void BM_mesh_select_mode_set(BMesh *bm, int selectmode); void BM_mesh_select_mode_flush_ex(BMesh *bm, const short selectmode); void BM_mesh_select_mode_flush(BMesh *bm); |