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/modifiers/intern/MOD_explode.c | |
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/modifiers/intern/MOD_explode.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_explode.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 638f8f0ae01..f0eb113e46f 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -104,6 +104,7 @@ static void createFacepa(ExplodeModifierData *emd, MVert *mvert = NULL; ParticleData *pa; KDTree *tree; + RNG *rng; float center[3], co[3]; int *facepa = NULL, *vertpa = NULL, totvert = 0, totface = 0, totpart = 0; int i, p, v1, v2, v3, v4 = 0; @@ -114,7 +115,7 @@ static void createFacepa(ExplodeModifierData *emd, totvert = dm->getNumVerts(dm); totpart = psmd->psys->totpart; - BLI_srandom(psys->seed); + rng = BLI_rng_new_srandom(psys->seed); if (emd->facepa) MEM_freeN(emd->facepa); @@ -136,7 +137,7 @@ static void createFacepa(ExplodeModifierData *emd, if (dvert) { const int defgrp_index = emd->vgroup - 1; for (i = 0; i < totvert; i++, dvert++) { - float val = BLI_frand(); + float val = BLI_rng_get_float(rng); val = (1.0f - emd->protect) * val + emd->protect * 0.5f; if (val < defvert_find_weight(dvert, defgrp_index)) vertpa[i] = -1; @@ -182,6 +183,8 @@ static void createFacepa(ExplodeModifierData *emd, if (vertpa) MEM_freeN(vertpa); BLI_kdtree_free(tree); + + BLI_rng_free(rng); } static int edgecut_get(EdgeHash *edgehash, unsigned int v1, unsigned int v2) |