From 40a5ed791df248c5cb3d19f714dde67cd8c91458 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Mon, 25 Jul 2005 20:33:10 +0000 Subject: - 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. --- source/blender/blenlib/BLI_rand.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'source/blender/blenlib/BLI_rand.h') 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 -- cgit v1.2.3