Blender V2.61 - r43446
Typedefs | Functions

BLI_rand.h File Reference

Random number functions. More...

Go to the source code of this file.

Typedefs

typedef struct RNG RNG

Functions

struct RNGrng_new (unsigned int seed)
void rng_free (struct RNG *rng)
void rng_seed (struct RNG *rng, unsigned int seed)
void rng_srandom (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)
void rng_skip (struct RNG *rng, int n)
void BLI_srand (unsigned int seed)
void BLI_srandom (unsigned int seed)
int BLI_rand (void)
double BLI_drand (void)
float BLI_frand (void)
void BLI_fillrand (void *addr, int len)
void BLI_array_randomize (void *data, int elemSize, int numElems, unsigned int seed)
void BLI_thread_srandom (int thread, unsigned int seed)
int BLI_thread_rand (int thread)
float BLI_thread_frand (int thread)

Detailed Description

Random number functions.

Definition in file BLI_rand.h.


Typedef Documentation

typedef struct RNG RNG

Definition at line 41 of file BLI_rand.h.


Function Documentation

void BLI_array_randomize ( void *  data,
int  elemSize,
int  numElems,
unsigned int  seed 
)

Shuffle an array randomly using the given seed. contents. This routine does not use nor modify the state of the BLI random number generator.

Definition at line 178 of file rand.c.

References rng_seed(), and rng_shuffleArray().

Referenced by applyModifier(), distribute_threads_init_data(), isb_add_samples(), and isb_add_samples_transp().

double BLI_drand ( void  )

Return a pseudo-random number N where 0.0<=N<1.0

Definition at line 159 of file rand.c.

References rng_getDouble().

Referenced by alter_co(), BLI_initjit(), hashvert_flag(), and RE_make_stars().

void BLI_fillrand ( void *  addr,
int  len 
)

Fills a block of memory starting at addr and extending len bytes with pseudo-random contents. This routine does not use nor modify the state of the BLI random number generator.

Definition at line 169 of file rand.c.

References p, PIL_check_seconds_timer(), rng_getInt(), and rng_seed().

float BLI_frand ( void  )
int BLI_rand ( void  )

Return a pseudo-random number N where 0<=N<(2^31)

Definition at line 154 of file rand.c.

References rng_getInt().

Referenced by calculatePropRatio(), defocus_blur(), new_particle_duplilist(), select_random_metaelems_exec(), selectrandom_curve(), selectrandom_mesh(), texnoise(), and weightvg_do_map().

void BLI_srand ( unsigned int  seed)
void BLI_srandom ( unsigned int  seed)
float BLI_thread_frand ( int  thread)

Return a pseudo-random number N where 0.0f<=N<1.0f Allows up to BLENDER_MAX_THREADS threads to address

Definition at line 207 of file rand.c.

References rng_getFloat().

Referenced by give_jitter_plane(), QMC_initPixel(), sphere_sampler(), vol_get_transmittance(), and volumeintegrate().

int BLI_thread_rand ( int  thread)

Return a pseudo-random number N where 0<=N<(2^31) Allows up to BLENDER_MAX_THREADS threads to address

Definition at line 202 of file rand.c.

References rng_getInt().

void BLI_thread_srandom ( int  thread,
unsigned int  seed 
)

Better seed for the random number generator, using noise.c hash[] Allows up to BLENDER_MAX_THREADS threads to address

Definition at line 190 of file rand.c.

References BLENDER_MAX_THREADS, hash, rng_getInt(), and rng_seed().

Referenced by shadeDA_tile(), strand_shade_point(), zbufshade_sss_tile(), and zbufshade_tile().

void rng_free ( struct RNG rng)
double rng_getDouble ( struct RNG rng)

Definition at line 101 of file rand.c.

References rng_getInt().

Referenced by BLI_drand(), and hammersley_create().

float rng_getFloat ( struct RNG rng)
int rng_getInt ( struct RNG rng)
struct RNG* rng_new ( unsigned int  seed) [read]
void rng_seed ( struct RNG rng,
unsigned int  seed 
)

Definition at line 81 of file rand.c.

References LOWSEED, and RNG::X.

Referenced by BLI_array_randomize(), BLI_fillrand(), BLI_srand(), BLI_thread_srandom(), rng_new(), and rng_srandom().

void rng_shuffleArray ( struct RNG rng,
void *  data,
int  elemSize,
int  numElems 
)

Definition at line 111 of file rand.c.

References addon::engine::free(), i, and rng_getInt().

Referenced by BLI_array_randomize().

void rng_skip ( struct RNG rng,
int  n 
)

Note that skipping is as slow as generating n numbers!

Definition at line 130 of file rand.c.

References i, and rng_getInt().

Referenced by distribute_threads_exec(), and distribute_threads_exec_cb().

void rng_srandom ( struct RNG rng,
unsigned int  seed 
)

Definition at line 86 of file rand.c.

References hash, rng_getInt(), and rng_seed().

Referenced by BLI_srandom(), and precalculate_effector().