diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-12 16:26:37 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-12 16:38:29 +0300 |
commit | 8204261edec6b28e3b990e6e66f7bcd4f6ee1886 (patch) | |
tree | 53472aef97fabc92820b7902bf47e634b10f0d14 /source/blender/blenkernel | |
parent | 53a9cde038b52585e98a07548319e0d91a989d2e (diff) |
Particle: Remove global RNG usage from distribution
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/particle_distribute.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c index 6c23036256b..05ce45e3900 100644 --- a/source/blender/blenkernel/intern/particle_distribute.c +++ b/source/blender/blenkernel/intern/particle_distribute.c @@ -433,7 +433,7 @@ static int distribute_binary_search(float *sum, int n, float value) /* the max number if calls to rng_* funcs within psys_thread_distribute_particle * be sure to keep up to date if this changes */ -#define PSYS_RND_DIST_SKIP 2 +#define PSYS_RND_DIST_SKIP 3 /* note: this function must be thread safe, for from == PART_FROM_CHILD */ #define ONLY_WORKING_WITH_PA_VERTS 0 @@ -487,8 +487,10 @@ static void distribute_from_verts_exec(ParticleTask *thread, ParticleData *pa, i } #endif - if (rng_skip_tot > 0) /* should never be below zero */ + BLI_assert(rng_skip_tot > 0); /* should never be below zero */ + if (rng_skip_tot > 0) { BLI_rng_skip(thread->rng, rng_skip_tot); + } } static void distribute_from_faces_exec(ParticleTask *thread, ParticleData *pa, int p) { @@ -528,9 +530,11 @@ static void distribute_from_faces_exec(ParticleTask *thread, ParticleData *pa, i break; } pa->foffset= 0.0f; - - if (rng_skip_tot > 0) /* should never be below zero */ + + BLI_assert(rng_skip_tot > 0); /* should never be below zero */ + if (rng_skip_tot > 0) { BLI_rng_skip(thread->rng, rng_skip_tot); + } } static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa, int p) { @@ -618,13 +622,16 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa, pa->foffset *= ctx->jit[p % (2 * ctx->jitlevel)]; break; case PART_DISTR_RAND: - pa->foffset *= BLI_frand(); + pa->foffset *= BLI_rng_get_float(thread->rng); + rng_skip_tot--; break; } } - if (rng_skip_tot > 0) /* should never be below zero */ + BLI_assert(rng_skip_tot > 0); /* should never be below zero */ + if (rng_skip_tot > 0) { BLI_rng_skip(thread->rng, rng_skip_tot); + } } static void distribute_children_exec(ParticleTask *thread, ChildParticle *cpa, int p) { |