diff options
author | Jacques Lucke <jacques@blender.org> | 2020-11-19 21:09:24 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-11-19 21:09:24 +0300 |
commit | dca36a8ec922bcce6bc4882cd6cba52792ed56ee (patch) | |
tree | 0216b0fb48b8cd7a82f3775c6310786163d0b3b2 /source/blender/editors | |
parent | e01bf7a92ecad3c64d0b1ae176f402d2638e246c (diff) |
Fix T82769: remove thread local data from PTCacheMem
The issue was that the same point cache was read by multiple
threads at the same time (the same object was evaluated for
render and for the viewport).
Both threads incremented PTCacheMem->cur which lead to the crash.
The fix is to remove the PTCacheMem->cur and store it on the
stack instead. This way every thread has its own cur.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D9606
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 11 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit_undo.c | 11 |
2 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index e6d11398279..25efb210355 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -5200,7 +5200,8 @@ void PE_create_particle_edit( for (pm = cache->mem_cache.first; pm; pm = pm->next) { LOOP_POINTS { - if (BKE_ptcache_mem_pointers_seek(p, pm) == 0) { + void *cur[BPHYS_TOT_DATA]; + if (BKE_ptcache_mem_pointers_seek(p, pm, cur) == 0) { continue; } @@ -5212,12 +5213,12 @@ void PE_create_particle_edit( key = point->keys + point->totkey; } - key->co = pm->cur[BPHYS_DATA_LOCATION]; - key->vel = pm->cur[BPHYS_DATA_VELOCITY]; - key->rot = pm->cur[BPHYS_DATA_ROTATION]; + key->co = cur[BPHYS_DATA_LOCATION]; + key->vel = cur[BPHYS_DATA_VELOCITY]; + key->rot = cur[BPHYS_DATA_ROTATION]; key->ftime = (float)pm->frame; key->time = &key->ftime; - BKE_ptcache_mem_pointers_incr(pm); + BKE_ptcache_mem_pointers_incr(cur); point->totkey++; } diff --git a/source/blender/editors/physics/particle_edit_undo.c b/source/blender/editors/physics/particle_edit_undo.c index a4fcfa93a60..7523571733e 100644 --- a/source/blender/editors/physics/particle_edit_undo.c +++ b/source/blender/editors/physics/particle_edit_undo.c @@ -166,18 +166,19 @@ static void undoptcache_to_editcache(PTCacheUndo *undo, PTCacheEdit *edit) for (i = 0; i < BPHYS_TOT_DATA; i++) { pm->data[i] = MEM_dupallocN(pm->data[i]); } - BKE_ptcache_mem_pointers_init(pm); + void *cur[BPHYS_TOT_DATA]; + BKE_ptcache_mem_pointers_init(pm, cur); LOOP_POINTS { LOOP_KEYS { if ((int)key->ftime == (int)pm->frame) { - key->co = pm->cur[BPHYS_DATA_LOCATION]; - key->vel = pm->cur[BPHYS_DATA_VELOCITY]; - key->rot = pm->cur[BPHYS_DATA_ROTATION]; + key->co = cur[BPHYS_DATA_LOCATION]; + key->vel = cur[BPHYS_DATA_VELOCITY]; + key->rot = cur[BPHYS_DATA_ROTATION]; key->time = &key->ftime; } } - BKE_ptcache_mem_pointers_incr(pm); + BKE_ptcache_mem_pointers_incr(cur); } } } |