[Bf-blender-cvs] [c8814fb6103] blender-v3.1-release: Fix T95185: Invalid normals after undo in sculpt mode
Campbell Barton
noreply at git.blender.org
Tue Feb 1 05:36:28 CET 2022
Commit: c8814fb6103f2e028c857872f4f0eb613ef75db9
Author: Campbell Barton
Date: Tue Feb 1 13:39:48 2022 +1100
Branches: blender-v3.1-release
https://developer.blender.org/rBc8814fb6103f2e028c857872f4f0eb613ef75db9
Fix T95185: Invalid normals after undo in sculpt mode
Since d9c6ceb3b88b6db87490b08e0089f9a18e6c52d6 partial updates to
normals in sculpt-mode were accumulating into the current normal
instead of a zeroed value.
Zero vertex normal values tagged for calculation before accumulation.
Reviewed By: HooglyBoogly
Ref D13975
===================================================================
M source/blender/blenkernel/intern/pbvh.c
===================================================================
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);
}
More information about the Bf-blender-cvs
mailing list