diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-12-17 04:52:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-12-17 04:52:36 +0400 |
commit | ad96dacbc5a7cc61ccf74405927847f243a955b5 (patch) | |
tree | a2b78d3b502b99a1c7e59e8400dfd0807a896125 /source/blender/blenlib/intern/rand.c | |
parent | 9276fb479ed1c5b472c5d831f52913157efe9288 (diff) |
style edit only - move parenthesis onto second line of function definition (in keeping with most of blenders code)
also split some long lines in own code.
Diffstat (limited to 'source/blender/blenlib/intern/rand.c')
-rw-r--r-- | source/blender/blenlib/intern/rand.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c index b1b7ebed18e..28dc5a696d5 100644 --- a/source/blender/blenlib/intern/rand.c +++ b/source/blender/blenlib/intern/rand.c @@ -78,11 +78,13 @@ void rng_free(RNG* rng) MEM_freeN(rng); } -void rng_seed(RNG *rng, unsigned int seed) { +void rng_seed(RNG *rng, unsigned int seed) +{ rng->X= (((r_uint64) seed)<<16) | LOWSEED; } -void rng_srandom(RNG *rng, unsigned int seed) { +void rng_srandom(RNG *rng, unsigned int seed) +{ rng_seed(rng, seed + hash[seed & 255]); seed= rng_getInt(rng); rng_seed(rng, seed + hash[seed & 255]); @@ -90,16 +92,19 @@ void rng_srandom(RNG *rng, unsigned int seed) { rng_seed(rng, seed + hash[seed & 255]); } -int rng_getInt(RNG *rng) { +int rng_getInt(RNG *rng) +{ rng->X= (MULTIPLIER*rng->X + ADDEND)&MASK; return (int) (rng->X>>17); } -double rng_getDouble(RNG *rng) { +double rng_getDouble(RNG *rng) +{ return (double) rng_getInt(rng)/0x80000000; } -float rng_getFloat(RNG *rng) { +float rng_getFloat(RNG *rng) +{ return (float) rng_getInt(rng)/0x80000000; } @@ -135,28 +140,34 @@ void rng_skip(RNG *rng, int n) static RNG theBLI_rng = {0}; /* note, this one creates periodical patterns */ -void BLI_srand(unsigned int seed) { +void BLI_srand(unsigned int seed) +{ rng_seed(&theBLI_rng, seed); } /* using hash table to create better seed */ -void BLI_srandom(unsigned int seed) { +void BLI_srandom(unsigned int seed) +{ rng_srandom(&theBLI_rng, seed); } -int BLI_rand(void) { +int BLI_rand(void) +{ return rng_getInt(&theBLI_rng); } -double BLI_drand(void) { +double BLI_drand(void) +{ return rng_getDouble(&theBLI_rng); } -float BLI_frand(void) { +float BLI_frand(void) +{ return rng_getFloat(&theBLI_rng); } -void BLI_fillrand(void *addr, int len) { +void BLI_fillrand(void *addr, int len) +{ RNG rng; unsigned char *p= addr; @@ -188,11 +199,13 @@ void BLI_thread_srandom(int thread, unsigned int seed) rng_seed(&rng_tab[thread], seed + hash[seed & 255]); } -int BLI_thread_rand(int thread) { +int BLI_thread_rand(int thread) +{ return rng_getInt(&rng_tab[thread]); } -float BLI_thread_frand(int thread) { +float BLI_thread_frand(int thread) +{ return rng_getFloat(&rng_tab[thread]); } |