diff options
author | Daniel Dunbar <daniel@zuster.org> | 2005-07-26 00:33:10 +0400 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2005-07-26 00:33:10 +0400 |
commit | 40a5ed791df248c5cb3d19f714dde67cd8c91458 (patch) | |
tree | b727cdf6f96c36c99401f6ac5c27c64bdcab6ade /source/blender/blenlib/BLI_rand.h | |
parent | cb988ff8a9c9df1d1e85c5ec1296857ffcb06dbd (diff) |
- added RNG abstract random object rng_{new/free/seed/get{Int,Double,Float}}
to avoid use of global generator. at the moment the renderer owns the
number generator and this is important for retaining render consistency.
Diffstat (limited to 'source/blender/blenlib/BLI_rand.h')
-rw-r--r-- | source/blender/blenlib/BLI_rand.h | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h index c352016ff53..5168d4b9fea 100644 --- a/source/blender/blenlib/BLI_rand.h +++ b/source/blender/blenlib/BLI_rand.h @@ -36,6 +36,21 @@ #ifndef BLI_RAND_H #define BLI_RAND_H + /* RNG is just an abstract random number generator + * type that avoids using globals, otherwise identical + * to BLI_rand functions below. + */ +struct RNG; + +struct RNG* rng_new (unsigned int seed); +void rng_free (struct RNG* rng); + +void rng_seed (struct RNG* rng, unsigned int seed); +int rng_getInt (struct RNG* rng); +double rng_getDouble (struct RNG* rng); +float rng_getFloat (struct RNG* rng); +void rng_shuffleArray(struct RNG *rng, void *data, int elemSize, int numElems); + /** Seed the random number generator */ void BLI_srand (unsigned int seed); @@ -55,17 +70,10 @@ float BLI_frand (void); */ void BLI_fillrand (void *addr, int len); - /** Stores the BLI randum number generator state - * into the buffer in @a loc_r. - */ -void BLI_storerand (unsigned int loc_r[2]); - - /** Retores the BLI randum number generator state - * from the buffer in @a loc. + /** Shuffle an array randomly using the given seed. + * contents. This routine does not use nor modify + * the state of the BLI random number generator. */ -void BLI_restorerand (unsigned int loc[2]); - - /** Shuffle an array randomly using the given seed. */ void BLI_array_randomize (void *data, int elemSize, int numElems, unsigned int seed); #endif |