diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-12 15:20:21 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-12 15:30:50 +0300 |
commit | 49b39ea851be0ca82da675dea5971185e297df47 (patch) | |
tree | 43091c0d4b9457761989ca523de7ea1eb0218236 /source | |
parent | cb409bb219d701af68381eeb2aa4bc027322857d (diff) |
Duplication: Use local RNG
Makes generation safe for threading.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/object_dupli.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index e9b1e79dc67..73e7041fda8 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -836,6 +836,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem float (*obmat)[4]; int a, b, hair = 0; int totpart, totchild, totcollection = 0 /*, pa_num */; + RNG *rng; int no_draw_flag = PARS_UNEXIST; @@ -857,7 +858,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem totpart = psys->totpart; totchild = psys->totchild; - BLI_srandom((unsigned int)(31415926 + psys->seed)); + rng = BLI_rng_new_srandom(31415926u + (unsigned int)psys->seed); if ((for_render || part->draw_as == PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { ParticleSimulationData sim = {NULL}; @@ -992,7 +993,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem /* for collections, pick the object based on settings */ if (part->draw & PART_DRAW_RAND_GR) - b = BLI_rand() % totcollection; + b = BLI_rng_get_int(rng) % totcollection; else b = a % totcollection; @@ -1131,6 +1132,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem end_latt_deform(psys->lattice_deform_data); psys->lattice_deform_data = NULL; } + + BLI_rng_free(rng); } static void make_duplis_particles(const DupliContext *ctx) |