[Bf-blender-cvs] [1052497aad5] blender-v2.79a-release: Fix possible concurency issue in mesh normals computation.

Bastien Montagne noreply at git.blender.org
Wed Jan 31 12:48:30 CET 2018


Commit: 1052497aad51871b5a99f7ca06e48beb5c3e5037
Author: Bastien Montagne
Date:   Wed Jan 31 12:30:39 2018 +0100
Branches: blender-v2.79a-release
https://developer.blender.org/rB1052497aad51871b5a99f7ca06e48beb5c3e5037

Fix possible concurency issue in mesh normals computation.

Failure in own code from last December, thanks @sergey for finding it.

To be backported to 2.79a.

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

M	source/blender/blenkernel/intern/mesh_evaluate.c

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

diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index ce62e29eaa3..280b4f76ac4 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -247,13 +247,6 @@ static void mesh_calc_normals_poly_prepare_cb(void *userdata, const int pidx)
 	}
 }
 
-static void mesh_calc_normals_poly_accum_cb(void *userdata, const int lidx)
-{
-	MeshCalcNormalsData *data = userdata;
-
-	add_v3_v3(data->vnors[data->mloop[lidx].v], data->lnors_weighted[lidx]);
-}
-
 static void mesh_calc_normals_poly_finalize_cb(void *userdata, const int vidx)
 {
 	MeshCalcNormalsData *data = userdata;
@@ -312,7 +305,11 @@ void BKE_mesh_calc_normals_poly(
 	BLI_task_parallel_range(0, numPolys, &data, mesh_calc_normals_poly_prepare_cb, do_threaded);
 
 	/* Actually accumulate weighted loop normals into vertex ones. */
-	BLI_task_parallel_range(0, numLoops, &data, mesh_calc_normals_poly_accum_cb, do_threaded);
+	/* Unfortunately, not possible to thread that (not in a reasonable, totally lock- and barrier-free fashion),
+	 * since several loops will point to the same vertex... */
+	for (int lidx = 0; lidx < numLoops; lidx++) {
+		add_v3_v3(vnors[mloop[lidx].v], data.lnors_weighted[lidx]);
+	}
 
 	/* Normalize and validate computed vertex normals. */
 	BLI_task_parallel_range(0, numVerts, &data, mesh_calc_normals_poly_finalize_cb, do_threaded);



More information about the Bf-blender-cvs mailing list