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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-16 03:12:40 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-16 03:12:40 +0400
commitafb4b65167165613f177a531bd3d4dcb3649c1c6 (patch)
tree32e1446b5fc3ce8ec00fa0e8b9e0fcb2eedda127 /source/blender/blenkernel/intern/particle.c
parent638b084f824bc345468bc8e02422b5da65a641a7 (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/blenkernel/intern/particle.c')
-rw-r--r--source/blender/blenkernel/intern/particle.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 4e78ab52499..b0ef6715382 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -264,11 +264,12 @@ static void psys_create_frand(ParticleSystem *psys)
{
int i;
float *rand = psys->frand = MEM_callocN(PSYS_FRAND_COUNT * sizeof(float), "particle randoms");
-
- BLI_srandom(psys->seed);
+ RNG *rng = BLI_rng_new_srandom(psys->seed);
for (i = 0; i < 1024; i++, rand++)
- *rand = BLI_frand();
+ *rand = BLI_rng_get_float(rng);
+
+ BLI_rng_free(rng);
}
int psys_check_enabled(Object *ob, ParticleSystem *psys)
{
@@ -3302,8 +3303,11 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
sim.ob = ob;
sim.psys = psys;
sim.psmd = psys_get_modifier(ob, psys);
+ sim.rng = BLI_rng_new(0);
psys_cache_child_paths(&sim, cfra, 1);
+
+ BLI_rng_free(sim.rng);
}
/* clear recalc flag if set here */
@@ -4660,6 +4664,7 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys)
sim.ob = ob;
sim.psys = psys;
sim.psmd = psys_get_modifier(ob, psys);
+ sim.rng = BLI_rng_new(0);
psys->lattice = psys_get_lattice(&sim);
@@ -4687,4 +4692,6 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys)
/* protect the applied shape */
psys->flag |= PSYS_EDITED;
}
+
+ BLI_rng_free(sim.rng);
}