diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint')
4 files changed, 15 insertions, 25 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 4e15728b081..f512da504eb 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -544,22 +544,19 @@ bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set) return true; } -static void sculpt_visibility_sync_face_sets_to_vertex(SculptSession *ss, int index) -{ - SCULPT_vertex_visible_set(ss, index, SCULPT_vertex_any_face_set_visible_get(ss, index)); -} - -void SCULPT_visibility_sync_all_face_sets_to_vertices(SculptSession *ss) +void SCULPT_visibility_sync_all_face_sets_to_vertices(Object *ob) { + SculptSession *ss = ob->sculpt; + Mesh *mesh = BKE_object_get_original_mesh(ob); switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: { - for (int i = 0; i < ss->totvert; i++) { - sculpt_visibility_sync_face_sets_to_vertex(ss, i); - } + BKE_sculpt_sync_face_sets_visibility_to_base_mesh(mesh); break; } case PBVH_GRIDS: { - BKE_pbvh_sync_face_sets_to_grids(ss->pbvh); + BKE_sculpt_sync_face_sets_visibility_to_base_mesh(mesh); + BKE_sculpt_sync_face_sets_visibility_to_grids(mesh, ss->subdiv_ccg); + break; } case PBVH_BMESH: break; @@ -8176,6 +8173,9 @@ void ED_object_sculptmode_enter_ex(Main *bmain, * freed memory. */ BKE_object_free_derived_caches(ob); + /* Copy the current mesh visibility to the Face Sets. */ + BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(me); + sculpt_init_session(depsgraph, scene, ob); /* Mask layer is required. */ diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c index dae4b068e93..152d23dfa5b 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.c +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c @@ -720,7 +720,7 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op) SCULPT_undo_push_end(); /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */ - SCULPT_visibility_sync_all_face_sets_to_vertices(ss); + SCULPT_visibility_sync_all_face_sets_to_vertices(ob); for (int i = 0; i < totnode; i++) { BKE_pbvh_node_mark_update_visibility(nodes[i]); @@ -889,12 +889,6 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op) if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE) { SCULPT_face_sets_visibility_all_set(ss, false); SCULPT_face_set_visibility_set(ss, active_face_set, true); - for (int i = 0; i < tot_vert; i++) { - SCULPT_vertex_visible_set(ss, - i, - SCULPT_vertex_visible_get(ss, i) && - SCULPT_vertex_has_face_set(ss, i, active_face_set)); - } } if (mode == SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE) { @@ -918,7 +912,7 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op) } /* Sync face sets visibility and vertex visibility. */ - SCULPT_visibility_sync_all_face_sets_to_vertices(ss); + SCULPT_visibility_sync_all_face_sets_to_vertices(ob); SCULPT_undo_push_end(); @@ -930,10 +924,6 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op) MEM_SAFE_FREE(nodes); - if (BKE_pbvh_type(pbvh) == PBVH_FACES) { - BKE_mesh_flush_hidden_from_verts(ob->data); - } - ED_region_tag_redraw(region); DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); @@ -1194,7 +1184,7 @@ static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEven SCULPT_undo_push_end(); /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */ - SCULPT_visibility_sync_all_face_sets_to_vertices(ss); + SCULPT_visibility_sync_all_face_sets_to_vertices(ob); for (int i = 0; i < totnode; i++) { BKE_pbvh_node_mark_update_visibility(nodes[i]); diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 1fddfc7d6db..ec4d594293a 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -186,7 +186,7 @@ bool SCULPT_vertex_is_boundary(const SculptSession *ss, const int index); void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible); bool SCULPT_vertex_visible_get(SculptSession *ss, int index); -void SCULPT_visibility_sync_all_face_sets_to_vertices(struct SculptSession *ss); +void SCULPT_visibility_sync_all_face_sets_to_vertices(struct Object *ob); void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss); /* Face Sets API */ diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index c67a3145be8..fa9eb43891c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -647,7 +647,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase BKE_sculpt_update_object_for_edit(depsgraph, ob, true, need_mask, false); - SCULPT_visibility_sync_all_face_sets_to_vertices(ss); + SCULPT_visibility_sync_all_face_sets_to_vertices(ob); BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); |