diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-03-07 13:25:56 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2014-03-07 14:20:45 +0400 |
commit | 08444518e62b4c7154c1428c33adab842774aa30 (patch) | |
tree | 17a55f7dae3b1b877e3f6a2d3c0a6d6cdd213c46 /source/creator/creator.c | |
parent | 98abc80dcf52e6711d20f7e5738e5a8797567f24 (diff) |
Removing ParticleSystem->frand arrays to avoid memory corruption issues
in threaded depgraph updates and effector list construction.
Gathering effectors during depgraph updates will call the
psys_check_enabled function. This in turn contained a DNA alloc call
for the psys->frand RNG arrays, which is really bad because data must be
immutable during these effector constructions.
To avoid such allocs the frand array is now global for all particle
systems. To avoid correlation of pseudo-random numbers the psys->seed
value is complemented with random offset and multiplier for the actual
float array. This is not ideal, but work sufficiently well (given that
random numbers were already really limited and show repetition quite
easily for particle counts > PSYS_FRAND_COUNT).
Diffstat (limited to 'source/creator/creator.c')
-rw-r--r-- | source/creator/creator.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c index 4aaa2ae32b1..6cf86c42eaf 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -100,6 +100,7 @@ #include "BKE_report.h" #include "BKE_sound.h" #include "BKE_image.h" +#include "BKE_particle.h" #include "IMB_imbuf.h" /* for IMB_init */ @@ -1631,6 +1632,7 @@ int main(int argc, const char **argv) RE_engines_init(); init_nodesystem(); + psys_init_rng(); /* end second init */ |