diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-11-02 17:09:32 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-11-02 17:10:40 +0300 |
commit | 15f2a5123256482c15815ea3385eb0a9f7e10bbb (patch) | |
tree | d335e8310e67acd9e521c05ffdeec267b3018a88 | |
parent | dac543856205a68975cb61b80769574b5986da18 (diff) |
Solve threading conflict when calculating smooth normals
It was possible to have synchronization issues whe naccumulating smooth
normal to a vertex, causing shading artifacts during playback.
Bug found by Dalai, thanks!
-rw-r--r-- | source/blender/blenkernel/intern/mesh_evaluate.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c index fa113ef5eef..016c9c863f0 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.c +++ b/source/blender/blenkernel/intern/mesh_evaluate.c @@ -58,6 +58,7 @@ #include "BLI_strict_flags.h" +#include "atomic_ops.h" #include "mikktspace.h" // #define DEBUG_TIME @@ -236,7 +237,9 @@ static void mesh_calc_normals_poly_accum_task_cb(void *userdata, const int pidx) const float fac = saacos(-dot_v3v3(cur_edge, prev_edge)); /* accumulate */ - madd_v3_v3fl(vnors[ml[i].v], pnor, fac); + for (int k = 3; k--; ) { + atomic_add_fl(&vnors[ml[i].v][k], pnor[k] * fac); + } prev_edge = cur_edge; } } |