Blender V2.61 - r43446
|
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "PIL_time.h"
#include "BLI_threads.h"
#include "BLI_rand.h"
Go to the source code of this file.
Classes | |
struct | RNG |
Defines | |
#define | MULTIPLIER 0x5DEECE66Dll |
#define | MASK 0x0000FFFFFFFFFFFFll |
#define | ADDEND 0xB |
#define | LOWSEED 0x330E |
Typedefs | |
typedef unsigned long long | r_uint64 |
Functions | |
RNG * | rng_new (unsigned int seed) |
void | rng_free (RNG *rng) |
void | rng_seed (RNG *rng, unsigned int seed) |
void | rng_srandom (RNG *rng, unsigned int seed) |
int | rng_getInt (RNG *rng) |
double | rng_getDouble (RNG *rng) |
float | rng_getFloat (RNG *rng) |
void | rng_shuffleArray (RNG *rng, void *data, int elemSize, int numElems) |
void | rng_skip (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) |
Variables | |
unsigned char | hash [] |
static RNG | theBLI_rng = {0} |
static RNG | rng_tab [BLENDER_MAX_THREADS] |
Definition in file rand.c.
#define ADDEND 0xB |
Definition at line 55 of file rand.c.
Referenced by rng_getInt().
#define LOWSEED 0x330E |
Definition at line 57 of file rand.c.
Referenced by rng_seed().
#define MASK 0x0000FFFFFFFFFFFFll |
Definition at line 52 of file rand.c.
Referenced by rng_getInt().
#define MULTIPLIER 0x5DEECE66Dll |
Definition at line 51 of file rand.c.
Referenced by rng_getInt().
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 | ) |
Return a pseudo-random number N where 0.0f<=N<1.0f
Definition at line 164 of file rand.c.
References rng_getFloat().
Referenced by applyModifier(), basic_force_cb(), boid_body(), brush_add(), brush_cut(), brush_jitter_pos(), calculatePropRatio(), collision_response(), create_dither_context(), createFacepa(), defocus_blur(), distribute_simple_children(), distribute_threads_exec(), distribute_threads_init_data(), init_jitter_plane(), lensDistort(), object_select_random_exec(), psys_create_frand(), RandomSpherical(), rule_average_speed(), rule_avoid_collision(), rule_fight(), sculpt_update_cache_variants(), select_random_metaelems_exec(), selectrandom_curve(), selectrandom_mesh(), sort_faces_exec(), and weightvg_do_map().
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 | ) |
Seed the random number generator
Definition at line 143 of file rand.c.
References rng_seed().
Referenced by BLI_initjit(), calculatePropRatio(), hashvert_flag(), RE_make_stars(), select_random_metaelems_exec(), selectrandom_curve(), selectrandom_mesh(), and weightvg_do_map().
void BLI_srandom | ( | unsigned int | seed | ) |
Better seed for the random number generator, using noise.c hash[]
Definition at line 149 of file rand.c.
References rng_srandom().
Referenced by applyModifier(), brush_add(), createFacepa(), distribute_threads_init_data(), do_render_composite_fields_blur_3d(), dynamics_step(), init_ao_sphere(), init_jitter_plane(), new_particle_duplilist(), ntreeCompositExecTree(), and psys_create_frand().
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 | ( | RNG * | rng | ) |
Definition at line 76 of file rand.c.
References MEM_freeN().
Referenced by free_partdeflect(), hammersley_create(), init_mv_jit(), param_stretch_end(), psys_threads_free(), and render_new_particle_system().
double rng_getDouble | ( | RNG * | rng | ) |
Definition at line 101 of file rand.c.
References rng_getInt().
Referenced by BLI_drand(), and hammersley_create().
float rng_getFloat | ( | RNG * | rng | ) |
Definition at line 106 of file rand.c.
References rng_getInt().
Referenced by BLI_frand(), BLI_thread_frand(), distribute_threads_exec(), init_mv_jit(), p_chart_stretch_minimize(), render_new_particle_system(), and wind_func().
int rng_getInt | ( | RNG * | rng | ) |
Definition at line 95 of file rand.c.
References ADDEND, MASK, MULTIPLIER, and RNG::X.
Referenced by BLI_fillrand(), BLI_rand(), BLI_thread_rand(), BLI_thread_srandom(), rng_getDouble(), rng_getFloat(), rng_shuffleArray(), rng_skip(), rng_srandom(), and wind_func().
RNG* rng_new | ( | unsigned int | seed | ) | [read] |
Definition at line 67 of file rand.c.
References MEM_mallocN(), and rng_seed().
Referenced by distribute_threads_init_data(), hammersley_create(), init_mv_jit(), param_stretch_begin(), precalculate_effector(), psys_threads_init_path(), and render_new_particle_system().
void rng_seed | ( | 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 | ( | 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 | ( | 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().
unsigned char hash[] |
Definition at line 165 of file noise.c.
Referenced by _ehash_insert(), _ehash_lookup(), _ehash_lookupWithPrev(), BLI_edgehash_insert(), BLI_edgehash_lookup_p(), BLI_ghash_haskey(), BLI_ghash_insert(), BLI_ghash_lookup(), BLI_ghash_remove(), BLI_ghashutil_pairhash(), BLI_thread_srandom(), BOP_Mesh::BOP_Mesh(), btAdjustInternalEdgeContacts(), btGetHash(), btHashString::btHashString(), cellnoise(), ED_mesh_mirrtopo_init(), btHashMap< btHashPtr, btPointerUid >::findIndex(), btHashedOverlappingPairCache::findPair(), CacheData::get_filename(), BOP_Mesh::getEdge(), BOP_Mesh::getIndexEdge(), HsiehHash(), btHashMap< btHashPtr, btPointerUid >::insert(), mirrtopo_vert_sort(), newPerlin(), orgBlenderNoise(), path_files_md5_hash(), perlin(), phash(), phash_insert(), phash_lookup(), phash_next(), btConnectivityProcessor::processTriangle(), pyrna_set_to_enum_bitfield(), RE_make_stars(), btHashMap< btHashPtr, btPointerUid >::remove(), btHashedOverlappingPairCache::removeOverlappingPair(), rng_srandom(), sb_detect_aabb_collisionCached(), sb_detect_edge_collisionCached(), sb_detect_face_collisionCached(), sb_detect_face_pointCached(), sb_detect_vertex_collisionCached(), ui_popup_menu_memory(), ui_popup_string_hash(), and BOP_Mesh::~BOP_Mesh().
RNG theBLI_rng = {0} [static] |