[Bf-blender-cvs] [8442b0ffc1d] master: Fix T101027: Sculpt tools don't respect visibility after recent commit

Hans Goudey noreply at git.blender.org
Tue Sep 13 15:38:07 CEST 2022


Commit: 8442b0ffc1df59cf6e557e7243b9197b2a898aa0
Author: Hans Goudey
Date:   Tue Sep 13 08:35:48 2022 -0500
Branches: master
https://developer.blender.org/rB8442b0ffc1df59cf6e557e7243b9197b2a898aa0

Fix T101027: Sculpt tools don't respect visibility after recent commit

Caused by b5f7af31d6d4, which exposed the fact that the PBVH wasn't
retrieving the updated hide status attributes if they were allocated in
sculpt mode. Previously the attributes were always allocated when
entering sculpt mode.

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

M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/editors/sculpt_paint/paint_hide.c
M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 403f3a31ba0..6a194698bd8 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -491,6 +491,12 @@ void BKE_pbvh_grids_update(PBVH *pbvh,
 void BKE_pbvh_subdiv_cgg_set(PBVH *pbvh, struct SubdivCCG *subdiv_ccg);
 void BKE_pbvh_face_sets_set(PBVH *pbvh, int *face_sets);
 
+/**
+ * If an operation causes the hide status stored in the mesh to change, this must be called
+ * to update the references to those attributes, since they are only added when necessary.
+ */
+void BKE_pbvh_update_hide_attributes_from_mesh(PBVH *pbvh);
+
 void BKE_pbvh_face_sets_color_set(PBVH *pbvh, int seed, int color_default);
 
 void BKE_pbvh_respect_hide_set(PBVH *pbvh, bool respect_hide);
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 2de5c718918..2e273e076d5 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -3247,6 +3247,14 @@ void BKE_pbvh_face_sets_set(PBVH *pbvh, int *face_sets)
   pbvh->face_sets = face_sets;
 }
 
+void BKE_pbvh_update_hide_attributes_from_mesh(PBVH *pbvh)
+{
+  if (pbvh->header.type == PBVH_FACES) {
+    pbvh->hide_vert = CustomData_get_layer_named(&pbvh->mesh->vdata, CD_PROP_BOOL, ".hide_vert");
+    pbvh->hide_poly = CustomData_get_layer_named(&pbvh->mesh->pdata, CD_PROP_BOOL, ".hide_poly");
+  }
+}
+
 void BKE_pbvh_respect_hide_set(PBVH *pbvh, bool respect_hide)
 {
   pbvh->respect_hide = respect_hide;
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index c1289364fb2..2b80c62a0ba 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -383,6 +383,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
    * sculpt but it looks wrong when entering editmode otherwise). */
   if (pbvh_type == PBVH_FACES) {
     BKE_mesh_flush_hidden_from_verts(me);
+    BKE_pbvh_update_hide_attributes_from_mesh(pbvh);
   }
 
   SCULPT_visibility_sync_all_vertex_to_face_sets(ob->sculpt);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 65e69bd8761..089a8a4cb54 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -602,6 +602,7 @@ void SCULPT_visibility_sync_all_face_sets_to_verts(Object *ob)
   switch (BKE_pbvh_type(ss->pbvh)) {
     case PBVH_FACES: {
       BKE_sculpt_sync_face_sets_visibility_to_base_mesh(mesh);
+      BKE_pbvh_update_hide_attributes_from_mesh(ss->pbvh);
       break;
     }
     case PBVH_GRIDS: {



More information about the Bf-blender-cvs mailing list