[Bf-blender-cvs] [94500c8a13c] temp-T97352-3d-texturing-seam-bleeding-b2: Fix: Missing updates for multires sculpting

Hans Goudey noreply at git.blender.org
Tue Sep 20 10:32:09 CEST 2022


Commit: 94500c8a13c96b6db41c781299bec52496658b27
Author: Hans Goudey
Date:   Fri Sep 16 14:29:37 2022 -0500
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB94500c8a13c96b6db41c781299bec52496658b27

Fix: Missing updates for multires sculpting

Caused by ee23f0f3fb58ce56, which removed the update tag when entering
sculpt mode, and by b5f7af31d6d474c, which made these layers lazily
created, so they weren't always available at the start of a stroke. Now
update the evaluated mesh/multires CCG as necessary. Some updates
could potentially avoided when switching modes in the future, but for
now do it all the time.

Fixes T101116
Also fixes a crash when painting multires mask for the first time

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

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

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

diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc
index 22f5b4d54c6..887ae1c8121 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -2042,6 +2042,8 @@ int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
         }
       }
     }
+    /* The evaluated multires CCG must be updated to contain the new data. */
+    DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
 
     ret |= SCULPT_MASK_LAYER_CALC_LOOP;
   }
@@ -2049,6 +2051,8 @@ int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
   /* Create vertex paint mask layer if there isn't one already. */
   if (!paint_mask) {
     CustomData_add_layer(&me->vdata, CD_PAINT_MASK, CD_SET_DEFAULT, nullptr, me->totvert);
+    /* The evaluated mesh must be updated to contain the new data. */
+    DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
     ret |= SCULPT_MASK_LAYER_CALC_VERT;
   }
 
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 53f65960ede..1f64a2445aa 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3301,15 +3301,6 @@ static void do_brush_action(Sculpt *sd,
     BKE_pbvh_ensure_node_loops(ss->pbvh);
   }
 
-  if (SCULPT_tool_is_mask(brush->sculpt_tool)) {
-    MultiresModifierData *mmd = BKE_sculpt_multires_active(ss->scene, ob);
-    BKE_sculpt_mask_layers_ensure(ob, mmd);
-  }
-  if (SCULPT_tool_is_face_sets(brush->sculpt_tool)) {
-    Mesh *mesh = BKE_object_get_original_mesh(ob);
-    ss->face_sets = BKE_sculpt_face_sets_ensure(mesh);
-  }
-
   /* Build a list of all nodes that are potentially within the brush's area of influence */
 
   if (SCULPT_tool_needs_all_pbvh_nodes(brush)) {
@@ -5582,11 +5573,20 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent
 
   Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
   Brush *brush = BKE_paint_brush(&sd->paint);
+  SculptSession *ss = ob->sculpt;
 
   if (SCULPT_tool_is_paint(brush->sculpt_tool) &&
       !SCULPT_handles_colors_report(ob->sculpt, op->reports)) {
     return OPERATOR_CANCELLED;
   }
+  if (SCULPT_tool_is_mask(brush->sculpt_tool)) {
+    MultiresModifierData *mmd = BKE_sculpt_multires_active(ss->scene, ob);
+    BKE_sculpt_mask_layers_ensure(ob, mmd);
+  }
+  if (SCULPT_tool_is_face_sets(brush->sculpt_tool)) {
+    Mesh *mesh = BKE_object_get_original_mesh(ob);
+    ss->face_sets = BKE_sculpt_face_sets_ensure(mesh);
+  }
 
   stroke = paint_stroke_new(C,
                             op,
diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c
index 39c77129f0e..0731e54d533 100644
--- a/source/blender/editors/sculpt_paint/sculpt_ops.c
+++ b/source/blender/editors/sculpt_paint/sculpt_ops.c
@@ -309,6 +309,9 @@ static void sculpt_init_session(Main *bmain, Depsgraph *depsgraph, Scene *scene,
   ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
   ob->sculpt->mode_type = OB_MODE_SCULPT;
 
+  /* Necessary to make multires displacement immediately visible. */
+  DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+
   BKE_scene_graph_evaluated_ensure(depsgraph, bmain);
 
   /* This function expects a fully evaluated depsgraph. */



More information about the Bf-blender-cvs mailing list