Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606@gmail.com>2019-10-02 17:51:57 +0300
committerPablo Dobarro <pablodp606@gmail.com>2019-10-02 17:58:53 +0300
commita1f16ba67fc2decb3fdb755531aafa9043c046a7 (patch)
tree8a2f5932c2aa34fc50eedd17cd262dc8128b7cd5 /source/blender/editors
parent02ad256f9aaf032bcac93b5c4c60ef7a9003a8bf (diff)
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
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c69
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h1
2 files changed, 18 insertions, 52 deletions
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];