[Bf-blender-cvs] [9daf4a8040d] temp-T96710-pbvh-pixels: Move brush_test from triangles to do_paint_pixels.

Jeroen Bakker noreply at git.blender.org
Fri Apr 15 11:51:45 CEST 2022


Commit: 9daf4a8040d2860479bd09c999327646386d1956
Author: Jeroen Bakker
Date:   Fri Apr 15 08:08:41 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rB9daf4a8040d2860479bd09c999327646386d1956

Move brush_test from triangles to do_paint_pixels.

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

M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/BKE_pbvh_pixels.hh
M	source/blender/blenkernel/intern/pbvh.c
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
M	source/blender/editors/sculpt_paint/sculpt_paint_image.cc

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

diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index cee3b7246a6..bb918fcfdcb 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -308,7 +308,6 @@ void BKE_pbvh_node_fully_unmasked_set(PBVHNode *node, int fully_masked);
 bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node);
 
 void BKE_pbvh_mark_rebuild_pixels(PBVH *pbvh);
-void BKE_pbvh_pixels_free_brush_test(PBVH *pbvh);
 void BKE_pbvh_vert_mark_update(PBVH *pbvh, int index);
 
 void BKE_pbvh_node_get_grids(PBVH *pbvh,
diff --git a/source/blender/blenkernel/BKE_pbvh_pixels.hh b/source/blender/blenkernel/BKE_pbvh_pixels.hh
index 3df78d7cdfb..b2cdb9353e3 100644
--- a/source/blender/blenkernel/BKE_pbvh_pixels.hh
+++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh
@@ -53,12 +53,6 @@ struct Triangles {
   /** Data accessed by the inner loop of the painting brush. */
   Vector<TrianglePaintInput> paint_input;
 
-  /**
-   * For storing brush tests per triangle during painting.
-   * Will be freed after a painting a stroke.
-   */
-  std::vector<bool> brush_test;
-
  public:
   void append(const int3 vert_indices)
   {
@@ -80,18 +74,6 @@ struct Triangles {
     paint_input.clear();
   }
 
-  void init_brush_test()
-  {
-    if (brush_test.size() != size()) {
-      brush_test.resize(size(), false);
-    }
-  }
-
-  void clear_brush_test()
-  {
-    brush_test.resize(0, false);
-  }
-
   uint64_t size() const
   {
     return paint_input.size();
@@ -99,7 +81,7 @@ struct Triangles {
 
   uint64_t mem_size() const
   {
-    return paint_input.size() * sizeof(TrianglePaintInput) + brush_test.size() / 8;
+    return paint_input.size() * sizeof(TrianglePaintInput);
   }
 };
 
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 637c5fb5c2e..e91f360ef22 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1496,16 +1496,6 @@ void BKE_pbvh_update_vertex_data(PBVH *pbvh, int flag)
   }
 }
 
-void BKE_pbvh_pixels_free_brush_test(PBVH *pbvh)
-{
-  for (int n = 0; n < pbvh->totnode; n++) {
-    PBVHNode *node = &pbvh->nodes[n];
-    if (node->flag & PBVH_Leaf && node->pixels.node_data != NULL) {
-      pbvh_pixels_free_brush_test(node);
-    }
-  }
-}
-
 static void pbvh_faces_node_visibility_update(PBVH *pbvh, PBVHNode *node)
 {
   MVert *mvert;
diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc
index 576fb5504e7..52f16cdb3fa 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@ -410,11 +410,4 @@ void pbvh_pixels_free(PBVHNode *node)
   MEM_delete(node_data);
   node->pixels.node_data = nullptr;
 }
-
-void pbvh_pixels_free_brush_test(PBVHNode *node)
-{
-  NodeData *node_data = static_cast<NodeData *>(node->pixels.node_data);
-  BLI_assert(node_data);
-  node_data->triangles.clear_brush_test();
-}
 }
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 89b387359de..bbbed32e316 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5213,10 +5213,6 @@ void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType up
     }
   }
 
-  if (update_flags & SCULPT_FREE_BRUSH_TEST) {
-    BKE_pbvh_pixels_free_brush_test(ss->pbvh);
-  }
-
   if (update_flags & SCULPT_UPDATE_COORDS) {
     BKE_pbvh_update_bounds(ss->pbvh, PBVH_UpdateOriginalBB);
 
@@ -5423,7 +5419,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
   }
   else if (brush->sculpt_tool == SCULPT_TOOL_PAINT) {
     if (SCULPT_use_image_paint_brush(&tool_settings->paint_mode, ob)) {
-      SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_IMAGE | SCULPT_FREE_BRUSH_TEST);
+      SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_IMAGE);
     }
   }
   else {
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 9a7463b7157..3839c0e71e4 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -47,7 +47,6 @@ typedef enum SculptUpdateType {
   SCULPT_UPDATE_VISIBILITY = 1 << 2,
   SCULPT_UPDATE_COLOR = 1 << 3,
   SCULPT_UPDATE_IMAGE = 1 << 4,
-  SCULPT_FREE_BRUSH_TEST = 1 << 5,
 } SculptUpdateType;
 
 typedef struct SculptCursorGeometryInfo {
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
index 963e84168e0..3030b6674c0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
@@ -256,9 +256,11 @@ template<typename ImageBuffer> class PaintingKernel {
   }
 };
 
-static void update_triangle_brush_test(SculptSession *ss, Triangles &triangles, const MVert *mvert)
+static std::vector<bool> init_triangle_brush_test(SculptSession *ss,
+                                                  Triangles &triangles,
+                                                  const MVert *mvert)
 {
-  triangles.init_brush_test();
+  std::vector<bool> brush_test(triangles.size());
   SculptBrushTest test;
   SCULPT_brush_test_init(ss, &test);
   float3 brush_min_bounds(test.location[0] - test.radius,
@@ -281,9 +283,10 @@ static void update_triangle_brush_test(SculptSession *ss, Triangles &triangles,
       triangle_max_bounds.y = max_ff(triangle_max_bounds.y, pos.y);
       triangle_max_bounds.z = max_ff(triangle_max_bounds.z, pos.z);
     }
-    triangles.brush_test[triangle_index] = isect_aabb_aabb_v3(
+    brush_test[triangle_index] = isect_aabb_aabb_v3(
         brush_min_bounds, brush_max_bounds, triangle_min_bounds, triangle_max_bounds);
   }
+  return brush_test;
 }
 
 static void do_paint_pixels(void *__restrict userdata,
@@ -300,7 +303,7 @@ static void do_paint_pixels(void *__restrict userdata,
   const int thread_id = BLI_task_parallel_thread_id(tls);
   MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss);
 
-  update_triangle_brush_test(ss, node_data.triangles, mvert);
+  std::vector<bool> brush_test = init_triangle_brush_test(ss, node_data.triangles, mvert);
 
   PaintingKernel<ImageBufferFloat4> kernel_float4(ss, brush, thread_id, mvert);
   PaintingKernel<ImageBufferByte4> kernel_byte4(ss, brush, thread_id, mvert);
@@ -326,7 +329,7 @@ static void do_paint_pixels(void *__restrict userdata,
         }
 
         for (const PackedPixelRow &pixel_row : tile_data.pixel_rows) {
-          if (!node_data.triangles.brush_test[pixel_row.triangle_index]) {
+          if (!brush_test[pixel_row.triangle_index]) {
             continue;
           }
           bool pixels_painted = false;



More information about the Bf-blender-cvs mailing list