[Bf-blender-cvs] [af1f0e166df] temp-T96710-pbvh-pixels: Correct region tagging.

Jeroen Bakker noreply at git.blender.org
Mon Apr 11 11:19:41 CEST 2022


Commit: af1f0e166df7793e96259f83478d00b9871708f2
Author: Jeroen Bakker
Date:   Mon Apr 11 11:19:35 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rBaf1f0e166df7793e96259f83478d00b9871708f2

Correct region tagging.

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

M	source/blender/blenkernel/intern/pbvh_pixels.cc
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h

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

diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc
index 84e6d5842e2..5f7b6639dd5 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@ -371,6 +371,7 @@ static void update_pixels(PBVH *pbvh,
     return;
   }
   TIMEIT_START(update_pixels);
+  printf(" - updating %ld nodes\n", nodes_to_update.size());
 
   MLoopUV *ldata_uv = static_cast<MLoopUV *>(CustomData_get_layer(ldata, CD_MLOOPUV));
   if (ldata_uv == nullptr) {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index e306ae962d5..2439ef08c5f 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2776,11 +2776,6 @@ static void sculpt_pbvh_update_pixels(SculptSession *ss, Object *ob)
     return;
   }
 
-  // If image is different than previous the PBVH should be tagged to fully rebuild the pixels.
-  // If any image tile image has a different resolution
-  // If uvmap changes.
-  // If other uvmap is selected.
-
   BKE_pbvh_build_pixels(ss->pbvh,
                         ss->pmap,
                         mesh->mpoly,
@@ -5104,6 +5099,15 @@ void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags)
     multires_mark_as_modified(depsgraph, ob, MULTIRES_COORDS_MODIFIED);
   }
 
+  if ((update_flags & SCULPT_UPDATE_IMAGE) != 0) {
+    ED_region_tag_redraw(region);
+    if ((update_flags == SCULPT_UPDATE_IMAGE)) {
+      /* Early exit when only need to update the images. We don't want to tag any geometry updates
+       * that would rebuilt the PBVH. */
+      return;
+    }
+  }
+
   DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
 
   /* Only current viewport matters, slower update for all viewports will
@@ -5183,6 +5187,16 @@ void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType up
         }
       }
     }
+
+    if (update_flags & SCULPT_UPDATE_IMAGE) {
+      LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+        SpaceLink *sl = area->spacedata.first;
+        if (sl->spacetype != SPACE_IMAGE) {
+          continue;
+        }
+        ED_area_tag_redraw_regiontype(area, RGN_TYPE_WINDOW);
+      }
+    }
   }
 
   if (update_flags & SCULPT_UPDATE_COORDS) {
@@ -5325,7 +5339,12 @@ static void sculpt_stroke_update_step(bContext *C,
     SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK);
   }
   else if (ELEM(brush->sculpt_tool, SCULPT_TOOL_PAINT, SCULPT_TOOL_SMEAR)) {
-    SCULPT_flush_update_step(C, SCULPT_UPDATE_COLOR);
+    if (SCULPT_use_image_paint_brush(sd, ob)) {
+      SCULPT_flush_update_step(C, SCULPT_UPDATE_IMAGE);
+    }
+    else {
+      SCULPT_flush_update_step(C, SCULPT_UPDATE_COLOR);
+    }
   }
   else {
     SCULPT_flush_update_step(C, SCULPT_UPDATE_COORDS);
@@ -5380,6 +5399,11 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
   if (brush->sculpt_tool == SCULPT_TOOL_MASK) {
     SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK);
   }
+  else if (brush->sculpt_tool == SCULPT_TOOL_PAINT) {
+    if (SCULPT_use_image_paint_brush(sd, ob)) {
+      SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_IMAGE);
+    }
+  }
   else {
     SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_COORDS);
   }
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index dceac7940c8..5fdd748a60d 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -45,6 +45,7 @@ typedef enum SculptUpdateType {
   SCULPT_UPDATE_MASK = 1 << 1,
   SCULPT_UPDATE_VISIBILITY = 1 << 2,
   SCULPT_UPDATE_COLOR = 1 << 3,
+  SCULPT_UPDATE_IMAGE = 1 << 4,
 } SculptUpdateType;
 
 typedef struct SculptCursorGeometryInfo {



More information about the Bf-blender-cvs mailing list