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_face_set.cc | |
parent | d42f882343c74afbc3e136d437887d0a39eedc3c (diff) |
Sculpt: implement Reveal All for PBVH_BMESH
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_face_set.cc')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_face_set.cc | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index 79c1304eee5..34717888966 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -833,8 +833,51 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op) SculptSession *ss = ob->sculpt; Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - /* Dyntopo not supported. */ + Mesh *mesh = BKE_object_get_original_mesh(ob); + + BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, false); + + /* Dyntopo not supported except for SCULPT_FACE_SET_VISIBILITY_SHOW_ALL. */ if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { + if (ss->pbvh && ss->bm && + RNA_enum_get(op->ptr, "mode") == SCULPT_FACE_SET_VISIBILITY_SHOW_ALL) { + PBVHNode **nodes; + int totnode; + + BKE_pbvh_search_gather(ss->pbvh, nullptr, nullptr, &nodes, &totnode); + + if (!totnode) { + return OPERATOR_CANCELLED; + } + + SCULPT_undo_push_begin(ob, op); + SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_COORDS); + + for (int i = 0; i < totnode; i++) { + BKE_pbvh_node_mark_update_visibility(nodes[i]); + } + + BMIter iter; + BMFace *f; + BMVert *v; + const int cd_mask = CustomData_get_offset(&ss->bm->vdata, CD_PAINT_MASK); + + BM_ITER_MESH (v, &iter, ss->bm, BM_VERTS_OF_MESH) { + BM_log_vert_before_modified(ss->bm_log, v, cd_mask); + } + BM_ITER_MESH (f, &iter, ss->bm, BM_FACES_OF_MESH) { + BM_log_face_modified(ss->bm_log, f); + } + + SCULPT_face_visibility_all_set(ss, true); + SCULPT_visibility_sync_all_from_faces(ob); + + SCULPT_undo_push_end(ob); + MEM_SAFE_FREE(nodes); + + return OPERATOR_FINISHED; + } + return OPERATOR_CANCELLED; } @@ -842,10 +885,6 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - Mesh *mesh = BKE_object_get_original_mesh(ob); - - BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, false); - const int tot_vert = SCULPT_vertex_count_get(ss); const int mode = RNA_enum_get(op->ptr, "mode"); const int active_face_set = SCULPT_active_face_set_get(ss); |