diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-09-28 04:29:16 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-09-28 13:29:52 +0300 |
commit | 2c7365aec7d8fc4b8b1ab748887d43e8076d899f (patch) | |
tree | 06f2193a95046011d900985b3643bdbbf977c59f /source | |
parent | 5bace9f5ddb146537425c2a6f918c1057662a002 (diff) |
Fix unnecessary use of atomics in PBVH normal update
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 636a5c62e4d..c17c28fa110 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -1059,11 +1059,12 @@ static void pbvh_update_normals_store_task_cb(void *__restrict userdata, const int v = verts[i]; MVert *mvert = &bvh->verts[v]; - /* mvert is shared between nodes, hence between threads. */ - if (atomic_fetch_and_and_char(&mvert->flag, (char)~ME_VERT_PBVH_UPDATE) & - ME_VERT_PBVH_UPDATE) { + /* No atomics necessary because we are iterating over uniq_verts only, + * so we know only this thread will handle this vertex. */ + if (mvert->flag & ME_VERT_PBVH_UPDATE) { normalize_v3(vnors[v]); normal_float_to_short_v3(mvert->no, vnors[v]); + mvert->flag &= ~ME_VERT_PBVH_UPDATE; } } |