From 08444518e62b4c7154c1428c33adab842774aa30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Fri, 7 Mar 2014 10:25:56 +0100 Subject: Removing ParticleSystem->frand arrays to avoid memory corruption issues in threaded depgraph updates and effector list construction. Gathering effectors during depgraph updates will call the psys_check_enabled function. This in turn contained a DNA alloc call for the psys->frand RNG arrays, which is really bad because data must be immutable during these effector constructions. To avoid such allocs the frand array is now global for all particle systems. To avoid correlation of pseudo-random numbers the psys->seed value is complemented with random offset and multiplier for the actual float array. This is not ideal, but work sufficiently well (given that random numbers were already really limited and show repetition quite easily for particle counts > PSYS_FRAND_COUNT). --- source/blender/render/intern/source/convertblender.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/render') diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index a9e83e65455..833acb68a7c 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1579,8 +1579,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem pa_size = pa->size; - r_tilt = 2.0f*(PSYS_FRAND(a) - 0.5f); - r_length = PSYS_FRAND(a+1); + r_tilt = 2.0f*(psys_frand(psys, a) - 0.5f); + r_length = psys_frand(psys, a+1); if (path_nbr) { cache = psys->pathcache[a]; @@ -1604,8 +1604,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem pa_time = psys_get_child_time(psys, cpa, cfra, &pa_birthtime, &pa_dietime); pa_size = psys_get_child_size(psys, cpa, cfra, &pa_time); - r_tilt = 2.0f*(PSYS_FRAND(a + 21) - 0.5f); - r_length = PSYS_FRAND(a + 22); + r_tilt = 2.0f*(psys_frand(psys, a + 21) - 0.5f); + r_length = psys_frand(psys, a + 22); num = cpa->num; -- cgit v1.2.3