diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-10-04 02:12:41 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-10-04 03:19:50 +0300 |
commit | 2cf21604c9130c56021525ed5af3f1fa59dcb19a (patch) | |
tree | 0a945e1d2a27d2d3eb8e8d59d01dde600cc9e958 /source/blender/editors/sculpt_paint/sculpt.c | |
parent | d42f882343c74afbc3e136d437887d0a39eedc3c (diff) |
Sculpt: implement Reveal All for PBVH_BMESH
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 70 |
1 files changed, 66 insertions, 4 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index c9d29b3ceb5..89998f19476 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -419,8 +419,15 @@ void SCULPT_face_visibility_all_invert(SculptSession *ss) ss->hide_poly[i] = !ss->hide_poly[i]; } break; - case PBVH_BMESH: + case PBVH_BMESH: { + BMIter iter; + BMFace *f; + + BM_ITER_MESH (f, &iter, ss->bm, BM_FACES_OF_MESH) { + BM_elem_flag_toggle(f, BM_ELEM_HIDDEN); + } break; + } } } @@ -432,8 +439,15 @@ void SCULPT_face_visibility_all_set(SculptSession *ss, bool visible) BLI_assert(ss->hide_poly != NULL); memset(ss->hide_poly, !visible, sizeof(bool) * ss->totfaces); break; - case PBVH_BMESH: + case PBVH_BMESH: { + BMIter iter; + BMFace *f; + + BM_ITER_MESH (f, &iter, ss->bm, BM_FACES_OF_MESH) { + BM_elem_flag_set(f, BM_ELEM_HIDDEN, !visible); + } break; + } } } @@ -475,8 +489,30 @@ bool SCULPT_vertex_all_faces_visible_get(const SculptSession *ss, PBVHVertRef ve } return true; } - case PBVH_BMESH: + case PBVH_BMESH: { + BMVert *v = (BMVert *)vertex.i; + BMEdge *e = v->e; + + if (!e) { + return true; + } + + do { + BMLoop *l = e->l; + + if (!l) { + continue; + } + + do { + if (BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) { + return false; + } + } while ((l = l->radial_next) != e->l); + } while ((e = BM_DISK_EDGE_NEXT(e, v)) != v->e); + return true; + } case PBVH_GRIDS: { if (!ss->hide_poly) { return true; @@ -603,8 +639,34 @@ void SCULPT_visibility_sync_all_from_faces(Object *ob) BKE_sculpt_sync_face_visibility_to_grids(mesh, ss->subdiv_ccg); break; } - case PBVH_BMESH: + case PBVH_BMESH: { + BMIter iter; + BMVert *v; + BMFace *f; + + /* Hide all verts and edges attached to faces.*/ + BM_ITER_MESH (f, &iter, ss->bm, BM_FACES_OF_MESH) { + BMLoop *l = f->l_first; + do { + BM_elem_flag_enable(l->v, BM_ELEM_HIDDEN); + BM_elem_flag_enable(l->e, BM_ELEM_HIDDEN); + } while ((l = l->next) != f->l_first); + } + + /* Unhide verts and edges attached to visible faces. */ + BM_ITER_MESH (f, &iter, ss->bm, BM_FACES_OF_MESH) { + if (!(BM_elem_flag_test(f, BM_ELEM_HIDDEN))) { + continue; + } + + BMLoop *l = f->l_first; + do { + BM_elem_flag_disable(l->v, BM_ELEM_HIDDEN); + BM_elem_flag_disable(l->e, BM_ELEM_HIDDEN); + } while ((l = l->next) != f->l_first); + } break; + } } } |