[Bf-blender-cvs] [ee57ac8abfe] blender-v3.2-release: Fix T99196: sculpt_update_object calls paint updates for nonpaint tools

Joseph Eagar noreply at git.blender.org
Fri Jul 15 15:04:21 CEST 2022


Commit: ee57ac8abfe4c7b88e510d31aab965bbea082f1e
Author: Joseph Eagar
Date:   Wed Jun 29 23:31:08 2022 -0700
Branches: blender-v3.2-release
https://developer.blender.org/rBee57ac8abfe4c7b88e510d31aab965bbea082f1e

Fix T99196: sculpt_update_object calls paint updates for nonpaint tools

Specifically BKE_texpaint_slots_refresh_object was being called, which
causes cycles to reset at strange times (like moving the mouse cursor
in pose, boundary and various other tools).

This (along with some code that checks if the pbvh pixels need
to be rebuilt) is only run if is_paint_mode (which used to be
needs_colors) is true.

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

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

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

diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 322e7deb86a..00f362f17a8 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1770,28 +1770,31 @@ static void sculpt_update_object(Depsgraph *depsgraph,
     }
   }
 
-  /*
-   * We should rebuild the PBVH_pixels when painting canvas changes.
-   *
-   * The relevant changes are stored/encoded in the paint canvas key.
-   * These include the active uv map, and resolutions.
-   */
-  if (U.experimental.use_sculpt_texture_paint && ss->pbvh) {
-    char *paint_canvas_key = BKE_paint_canvas_key_get(&scene->toolsettings->paint_mode, ob);
-    if (ss->last_paint_canvas_key == NULL || !STREQ(paint_canvas_key, ss->last_paint_canvas_key)) {
-      MEM_SAFE_FREE(ss->last_paint_canvas_key);
-      ss->last_paint_canvas_key = paint_canvas_key;
-      BKE_pbvh_mark_rebuild_pixels(ss->pbvh);
-    }
-    else {
-      MEM_freeN(paint_canvas_key);
+  if (is_paint_tool) {
+    /*
+     * We should rebuild the PBVH_pixels when painting canvas changes.
+     *
+     * The relevant changes are stored/encoded in the paint canvas key.
+     * These include the active uv map, and resolutions.
+     */
+    if (U.experimental.use_sculpt_texture_paint && ss->pbvh) {
+      char *paint_canvas_key = BKE_paint_canvas_key_get(&scene->toolsettings->paint_mode, ob);
+      if (ss->last_paint_canvas_key == NULL ||
+          !STREQ(paint_canvas_key, ss->last_paint_canvas_key)) {
+        MEM_SAFE_FREE(ss->last_paint_canvas_key);
+        ss->last_paint_canvas_key = paint_canvas_key;
+        BKE_pbvh_mark_rebuild_pixels(ss->pbvh);
+      }
+      else {
+        MEM_freeN(paint_canvas_key);
+      }
     }
-  }
 
-  /* We could be more precise when we have access to the active tool. */
-  const bool use_paint_slots = (ob->mode & OB_MODE_SCULPT) != 0;
-  if (use_paint_slots) {
-    BKE_texpaint_slots_refresh_object(scene, ob);
+    /* We could be more precise when we have access to the active tool. */
+    const bool use_paint_slots = (ob->mode & OB_MODE_SCULPT) != 0;
+    if (use_paint_slots) {
+      BKE_texpaint_slots_refresh_object(scene, ob);
+    }
   }
 }
 
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc
index d4888bbe29c..08b2bff8d9b 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.cc
+++ b/source/blender/editors/sculpt_paint/paint_vertex.cc
@@ -1190,12 +1190,12 @@ static void vertex_paint_init_session(Depsgraph *depsgraph,
   BLI_assert(ob->sculpt == nullptr);
   ob->sculpt = (SculptSession *)MEM_callocN(sizeof(SculptSession), "sculpt session");
   ob->sculpt->mode_type = object_mode;
-  BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, false);
+  BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, true);
 }
 
 static void vwpaint_init_stroke(Depsgraph *depsgraph, Object *ob)
 {
-  BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, false);
+  BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, true);
   SculptSession *ss = ob->sculpt;
 
   /* Ensure ss->cache is allocated.  It will mostly be initialized in
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 967a13badd4..f41b1e49ed8 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5055,7 +5055,8 @@ static void sculpt_brush_stroke_init(bContext *C, wmOperator *op)
   /* CTX_data_ensure_evaluated_depsgraph should be used at the end to include the updates of
    * earlier steps modifying the data. */
   Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
-  BKE_sculpt_update_object_for_edit(depsgraph, ob, need_pmap, need_mask, needs_colors);
+  BKE_sculpt_update_object_for_edit(
+      depsgraph, ob, need_pmap, need_mask, SCULPT_tool_is_paint(brush->sculpt_tool));
 
   ED_paint_tool_update_sticky_shading_color(C, ob);
 }



More information about the Bf-blender-cvs mailing list