diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-01-31 14:30:39 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-01-31 14:46:06 +0300 |
commit | 1052497aad51871b5a99f7ca06e48beb5c3e5037 (patch) | |
tree | cdab46e90d6be0a0b5139aa8e56af89034447535 /source/blender | |
parent | 567b4fa79412051448fced41d90a55eec729b14c (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_evaluate.c | 13 |
1 files changed, 5 insertions, 8 deletions
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); |