[Bf-blender-cvs] [15f2a51] master: Solve threading conflict when calculating smooth normals

Sergey Sharybin noreply at git.blender.org
Wed Nov 2 15:11:50 CET 2016


Commit: 15f2a5123256482c15815ea3385eb0a9f7e10bbb
Author: Sergey Sharybin
Date:   Wed Nov 2 15:09:32 2016 +0100
Branches: master
https://developer.blender.org/rB15f2a5123256482c15815ea3385eb0a9f7e10bbb

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!

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

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 fa113ef..016c9c8 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;
 		}
 	}




More information about the Bf-blender-cvs mailing list