diff options
author | Campbell Barton <campbell@blender.org> | 2022-02-01 07:37:14 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-02-01 07:37:14 +0300 |
commit | 120deaac5babbce9625541f470ce3e4d5363c996 (patch) | |
tree | cfb17260b222f61e0efebdc0fa983df7772e08f2 /source | |
parent | 64264a496dae2a756826b5e15aa21f463513553c (diff) | |
parent | c8814fb6103f2e028c857872f4f0eb613ef75db9 (diff) |
Merge branch 'blender-v3.1-release'
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 1926bbcda02..bfedd4d3f49 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -1007,6 +1007,28 @@ typedef struct PBVHUpdateData { bool show_sculpt_face_sets; } PBVHUpdateData; +static void pbvh_update_normals_clear_task_cb(void *__restrict userdata, + const int n, + const TaskParallelTLS *__restrict UNUSED(tls)) +{ + PBVHUpdateData *data = userdata; + PBVH *pbvh = data->pbvh; + PBVHNode *node = data->nodes[n]; + float(*vnors)[3] = data->vnors; + + if (node->flag & PBVH_UpdateNormals) { + const int *verts = node->vert_indices; + const int totvert = node->uniq_verts; + for (int i = 0; i < totvert; i++) { + const int v = verts[i]; + const MVert *mvert = &pbvh->verts[v]; + if (mvert->flag & ME_VERT_PBVH_UPDATE) { + zero_v3(vnors[v]); + } + } + } +} + static void pbvh_update_normals_accum_task_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls)) @@ -1107,6 +1129,8 @@ static void pbvh_faces_update_normals(PBVH *pbvh, PBVHNode **nodes, int totnode) TaskParallelSettings settings; BKE_pbvh_parallel_range_settings(&settings, true, totnode); + /* Zero normals before accumulation. */ + BLI_task_parallel_range(0, totnode, &data, pbvh_update_normals_clear_task_cb, &settings); BLI_task_parallel_range(0, totnode, &data, pbvh_update_normals_accum_task_cb, &settings); BLI_task_parallel_range(0, totnode, &data, pbvh_update_normals_store_task_cb, &settings); } |