diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-16 03:12:40 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-16 03:12:40 +0400 |
commit | afb4b65167165613f177a531bd3d4dcb3649c1c6 (patch) | |
tree | 32e1446b5fc3ce8ec00fa0e8b9e0fcb2eedda127 /source/blender/editors/physics | |
parent | 638b084f824bc345468bc8e02422b5da65a641a7 (diff) |
Random number generator: replace a bunch of usage of the global random number
generator with a local one. It's not thread safe and will not give repeatable
results, so in most cases it should not be used.
Also fixes #34992 where the noise texture of a displacement modifier was not
properly random in opengl animation render, because the seed got reset to a
fixed value by an unrelated function while for final render it changed each
frame.
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 4825416f6e9..f12df7aa3dd 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3254,12 +3254,13 @@ static int brush_add(PEData *data, short number) short size= pset->brush[PE_BRUSH_ADD].size; short size2= size*size; DerivedMesh *dm=0; + RNG *rng; invert_m4_m4(imat, ob->obmat); if (psys->flag & PSYS_GLOBAL_HAIR) return 0; - BLI_srandom(psys->seed+data->mval[0]+data->mval[1]); + rng = BLI_rng_new_srandom(psys->seed+data->mval[0]+data->mval[1]); sim.scene= scene; sim.ob= ob; @@ -3281,8 +3282,8 @@ static int brush_add(PEData *data, short number) /* rejection sampling to get points in circle */ while (dmx*dmx + dmy*dmy > size2) { - dmx= (2.0f*BLI_frand() - 1.0f)*size; - dmy= (2.0f*BLI_frand() - 1.0f)*size; + dmx= (2.0f*BLI_rng_get_float(rng) - 1.0f)*size; + dmy= (2.0f*BLI_rng_get_float(rng) - 1.0f)*size; } } else { @@ -3458,6 +3459,8 @@ static int brush_add(PEData *data, short number) if (!psmd->dm->deformedOnly) dm->release(dm); + BLI_rng_free(rng); + return n; } |