[Bf-blender-cvs] [cb22eae31bb] sculpt-dev: sculpt-dev: fix hide bugs and a compiler error

Joseph Eagar noreply at git.blender.org
Mon Oct 17 09:48:53 CEST 2022


Commit: cb22eae31bb1fb751c24450db1be716287ef9818
Author: Joseph Eagar
Date:   Mon Oct 17 00:48:36 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rBcb22eae31bb1fb751c24450db1be716287ef9818

sculpt-dev: fix hide bugs and a compiler error

===================================================================

M	source/blender/blenkernel/intern/paint.cc
M	source/blender/editors/sculpt_paint/paint_hide.c
M	source/blender/editors/sculpt_paint/sculpt.c

===================================================================

diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc
index c8602b74e3c..11c4f3b8c15 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -2794,7 +2794,7 @@ static void init_sculptvert_layer_faces(SculptSession *ss, PBVH *pbvh, int totve
     MV_ADD_FLAG(mv, SCULPTVERT_NEED_VALENCE | SCULPTVERT_NEED_DISK_SORT);
     mv->stroke_id = -1;
 
-    PBVHVertRef vertex = {.i = i};
+    PBVHVertRef vertex = {i};
 
     BKE_sculpt_boundary_flag_update(ss, vertex);
 
@@ -2826,7 +2826,7 @@ static void init_sculptvert_layer_grids(SculptSession *ss, PBVH *pbvh, int totve
     MV_ADD_FLAG(mv, SCULPTVERT_NEED_VALENCE | SCULPTVERT_NEED_DISK_SORT);
     mv->stroke_id = -1;
 
-    PBVHVertRef vertex = {.i = i};
+    PBVHVertRef vertex = {i};
 
     BKE_sculpt_boundary_flag_update(ss, vertex);
     BKE_pbvh_update_vert_boundary_grids(pbvh, ss->subdiv_ccg, vertex);
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index 7b5a24c3a35..edaf94c7c82 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -223,17 +223,13 @@ static void partialvis_update_bmesh_verts(BMesh *bm,
   TGSET_ITER_END
 }
 
-static void partialvis_update_bmesh_faces(TableGSet *faces)
+static void partialvis_update_bmesh_faces(TableGSet *faces, int cd_hide_poly)
 {
   BMFace *f;
-
+  
   TGSET_ITER (f, faces) {
-    if (paint_is_bmesh_face_hidden(f)) {
-      BM_elem_flag_enable(f, BM_ELEM_HIDDEN);
-    }
-    else {
-      BM_elem_flag_disable(f, BM_ELEM_HIDDEN);
-    }
+    bool hidden = paint_is_bmesh_face_hidden(f);
+    BM_ELEM_CD_SET_BOOL(f, cd_hide_poly, hidden);
   }
   TGSET_ITER_END
 }
@@ -261,7 +257,7 @@ static void partialvis_update_bmesh(Object *ob,
   partialvis_update_bmesh_verts(bm, other, action, area, planes, &any_changed, &any_visible);
 
   /* Finally loop over node faces and tag the ones that are fully hidden. */
-  partialvis_update_bmesh_faces(faces);
+  partialvis_update_bmesh_faces(faces, ob->sculpt->attrs.hide_poly->bmesh_cd_offset);
 
   if (any_changed) {
     BKE_pbvh_node_mark_rebuild_draw(node);
@@ -340,6 +336,8 @@ static int hide_show_exec(bContext *C, wmOperator *op)
   clip_planes_from_rect(C, depsgraph, clip_planes, &rect);
 
   pbvh = BKE_sculpt_object_pbvh_ensure(depsgraph, ob);
+  BKE_sculpt_hide_poly_ensure(ob);
+
   BLI_assert(ob->sculpt->pbvh == pbvh);
 
   get_pbvh_nodes(pbvh, &nodes, &totnode, clip_planes, area);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 66a1c802d88..d5c915651a3 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -810,6 +810,11 @@ void SCULPT_face_visibility_all_invert(SculptSession *ss)
 
 void SCULPT_face_visibility_all_set(SculptSession *ss, bool visible)
 {
+  if (visible && !ss->attrs.hide_poly) {
+    /* This case is allowed. */
+    return;
+  }
+
   switch (BKE_pbvh_type(ss->pbvh)) {
     case PBVH_FACES:
     case PBVH_GRIDS:
@@ -822,7 +827,7 @@ void SCULPT_face_visibility_all_set(SculptSession *ss, bool visible)
       for (int i = 0; i < ss->totfaces; i++) {
         PBVHFaceRef face = BKE_pbvh_index_to_face(ss->pbvh, i);
 
-        *(bool *)BKE_sculpt_face_attr_get(face, ss->attrs.hide_poly) = visible;
+        *(bool *)BKE_sculpt_face_attr_get(face, ss->attrs.hide_poly) = !visible;
       }
   }
 }
@@ -1202,6 +1207,8 @@ void SCULPT_visibility_sync_all_from_faces(Object *ob)
 
       if (!ss->attrs.hide_poly) {
         BM_ITER_MESH (f, &iter, ss->bm, BM_FACES_OF_MESH) {
+          BM_elem_flag_disable(f, BM_ELEM_HIDDEN);
+
           BMLoop *l = f->l_first;
           do {
             BM_elem_flag_disable(l->v, BM_ELEM_HIDDEN);
@@ -1226,9 +1233,12 @@ void SCULPT_visibility_sync_all_from_faces(Object *ob)
       /* Unhide verts and edges attached to visible faces. */
       BM_ITER_MESH (f, &iter, ss->bm, BM_FACES_OF_MESH) {
         if (BM_ELEM_CD_GET_BOOL(f, cd_hide_poly)) {
+          BM_elem_flag_enable(f, BM_ELEM_HIDDEN);
           continue;
         }
 
+        BM_elem_flag_disable(f, BM_ELEM_HIDDEN);
+
         BMLoop *l = f->l_first;
         do {
           BM_elem_flag_disable(l->v, BM_ELEM_HIDDEN);



More information about the Bf-blender-cvs mailing list