[Bf-blender-cvs] [a1f16ba67fc] master: Use PBVH_FullyMasked flag in mesh filter

Pablo Dobarro noreply at git.blender.org
Wed Oct 2 16:57:16 CEST 2019


Commit: a1f16ba67fc2decb3fdb755531aafa9043c046a7
Author: Pablo Dobarro
Date:   Wed Oct 2 16:51:57 2019 +0200
Branches: master
https://developer.blender.org/rBa1f16ba67fc2decb3fdb755531aafa9043c046a7

Use PBVH_FullyMasked flag in mesh filter

We don't need to filter the fully masked nodes here after adding the flag

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5973

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

M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h

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

diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 19eed2d4ec2..bf10ebe67d1 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -8150,43 +8150,36 @@ static void filter_cache_init_task_cb(void *__restrict userdata,
                                       const TaskParallelTLS *__restrict UNUSED(tls))
 {
   SculptThreadedTaskData *data = userdata;
-  SculptSession *ss = data->ob->sculpt;
   PBVHNode *node = data->nodes[i];
 
-  PBVHVertexIter vd;
-  BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
-  {
-    if (!vd.mask || (vd.mask && *vd.mask < 1.0f)) {
-      data->node_mask[i] = 1;
-    }
-  }
-  BKE_pbvh_vertex_iter_end;
-
-  if (data->node_mask[i] == 1) {
-    sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS);
-  }
+  sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS);
 }
 
 static void sculpt_filter_cache_init(Object *ob, Sculpt *sd)
 {
   SculptSession *ss = ob->sculpt;
   PBVH *pbvh = ob->sculpt->pbvh;
-  PBVHNode **nodes;
-  int totnode;
 
   ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache");
 
   ss->filter_cache->random_seed = rand();
 
+  float center[3] = {0.0f};
   SculptSearchSphereData search_data = {
       .original = true,
-  };
-  BKE_pbvh_search_gather(pbvh, NULL, &search_data, &nodes, &totnode);
+      .center = center,
+      .radius_squared = FLT_MAX,
+      .ignore_fully_masked = true,
 
-  int *node_mask = MEM_callocN((unsigned int)totnode * sizeof(int), "node mask");
+  };
+  BKE_pbvh_search_gather(pbvh,
+                         sculpt_search_sphere_cb,
+                         &search_data,
+                         &ss->filter_cache->nodes,
+                         &ss->filter_cache->totnode);
 
-  for (int i = 0; i < totnode; i++) {
-    BKE_pbvh_node_mark_normals_update(nodes[i]);
+  for (int i = 0; i < ss->filter_cache->totnode; i++) {
+    BKE_pbvh_node_mark_normals_update(ss->filter_cache->nodes[i]);
   }
 
   /* mesh->runtime.subdiv_ccg is not available. Updating of the normals is done during drawing.
@@ -8198,40 +8191,14 @@ static void sculpt_filter_cache_init(Object *ob, Sculpt *sd)
   SculptThreadedTaskData data = {
       .sd = sd,
       .ob = ob,
-      .nodes = nodes,
-      .node_mask = node_mask,
+      .nodes = ss->filter_cache->nodes,
   };
 
   TaskParallelSettings settings;
-  BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
-  BLI_task_parallel_range(0, totnode, &data, filter_cache_init_task_cb, &settings);
-
-  int tot_active_nodes = 0;
-  int active_node_index = 0;
-  PBVHNode **active_nodes;
-
-  /* Count number of PBVH nodes that are not fully masked */
-  for (int i = 0; i < totnode; i++) {
-    if (node_mask[i] == 1) {
-      tot_active_nodes++;
-    }
-  }
-
-  /* Create the final list of nodes that is going to be processed in the filter */
-  active_nodes = MEM_callocN(tot_active_nodes * sizeof(PBVHNode *), "active nodes");
-
-  for (int i = 0; i < totnode; i++) {
-    if (node_mask[i] == 1) {
-      active_nodes[active_node_index] = nodes[i];
-      active_node_index++;
-    }
-  }
-
-  ss->filter_cache->nodes = active_nodes;
-  ss->filter_cache->totnode = tot_active_nodes;
-
-  MEM_SAFE_FREE(nodes);
-  MEM_SAFE_FREE(node_mask);
+  BKE_pbvh_parallel_range_settings(
+      &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode);
+  BLI_task_parallel_range(
+      0, ss->filter_cache->totnode, &data, filter_cache_init_task_cb, &settings);
 }
 
 static void sculpt_filter_cache_free(SculptSession *ss)
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index e9af49a0b5a..cbc13e5f0d2 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -194,7 +194,6 @@ typedef struct SculptThreadedTaskData {
 
   int filter_type;
   float filter_strength;
-  int *node_mask;
 
   /* 0=towards view, 1=flipped */
   float (*area_cos)[3];



More information about the Bf-blender-cvs mailing list