diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-10-12 01:46:50 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-10-15 20:39:11 +0300 |
commit | ef5f3070315ea130479c1c646ef889c98825b475 (patch) | |
tree | 1051df86e857bcbbbcb16766145b32f5ea4f8977 /source/blender/editors/sculpt_paint/sculpt.c | |
parent | 750e4e1158bb1bd40c1724e24693cb22c6910f86 (diff) |
Sculpt: Use mpoly flags to sync Face Sets visibility
Previously, all Face Set visibility logic was using mvert flags directly
to store the visibility state on the vertices while sculpting. As Face
Sets are a poly attribute, it is much simpler to use mpoly flags and let
BKE_mesh_flush_hidden_from_polys handle the vertex visibility, even for
Multires.
Now all operators that update the Face Set visibility state will always
copy the visibility to the mesh (using poly flags) and the grids, all
using the same code.
This should fix a lot of visibility glitches and bugs like the following:
- Sculpt visibility reset when changing multires levels.
- Multires visibility not updating in edit mode.
- Single face visibible when surrounded by visibile face set, even when
the face set was hidden.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D9175
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 20 |
1 files changed, 10 insertions, 10 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. */ |