Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Tönne <lukas.toenne@gmail.com>2014-03-07 13:25:56 +0400
committerLukas Tönne <lukas.toenne@gmail.com>2014-03-07 14:20:45 +0400
commit08444518e62b4c7154c1428c33adab842774aa30 (patch)
tree17a55f7dae3b1b877e3f6a2d3c0a6d6cdd213c46 /source/blender/blenkernel/intern/boids.c
parent98abc80dcf52e6711d20f7e5738e5a8797567f24 (diff)
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).
Diffstat (limited to 'source/blender/blenkernel/intern/boids.c')
-rw-r--r--source/blender/blenkernel/intern/boids.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index a8d64ea9fb6..157de3e2f1c 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -970,8 +970,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
bbd->wanted_speed = 0.0f;
/* create random seed for every particle & frame */
- rand = (int)(PSYS_FRAND(psys->seed + p) * 1000);
- rand = (int)(PSYS_FRAND((int)bbd->cfra + rand) * 1000);
+ rand = (int)(psys_frand(psys, psys->seed + p) * 1000);
+ rand = (int)(psys_frand(psys, (int)bbd->cfra + rand) * 1000);
set_boid_values(&val, bbd->part->boids, pa);