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!
This commit is contained in:
Sergey Sharybin 2016-11-02 15:09:32 +01:00
parent dac5438562
commit 15f2a51232
1 changed files with 4 additions and 1 deletions

View File

@ -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;
}
}