|
Blender V4.5
|
#include <cmath>#include <cstdlib>#include <cstring>#include <ctime>#include <random>#include "MEM_guardedalloc.h"#include "BLI_bitmap.h"#include "BLI_compiler_compat.h"#include "BLI_math_vector.h"#include "BLI_noise.h"#include "BLI_rand.h"#include "BLI_rand.hh"#include "BLI_sys_types.h"#include "BLI_threads.h"#include "BLI_strict_flags.h"Go to the source code of this file.
Classes | |
| struct | RNG |
| struct | RNG_THREAD_ARRAY |
Namespaces | |
| namespace | blender |
Macros | |
| #define | hash BLI_noise_hash_uchar_512 |
Functions | |
| RNG * | BLI_rng_new (uint seed) |
| RNG * | BLI_rng_new_srandom (uint seed) |
| void | BLI_rng_free (RNG *rng) |
| void | BLI_rng_seed (RNG *rng, uint seed) |
| void | BLI_rng_srandom (RNG *rng, uint seed) |
| void | BLI_rng_get_char_n (RNG *rng, char *bytes, size_t bytes_len) |
| int | BLI_rng_get_int (RNG *rng) |
| uint | BLI_rng_get_uint (RNG *rng) |
| double | BLI_rng_get_double (RNG *rng) |
| float | BLI_rng_get_float (RNG *rng) |
| void | BLI_rng_get_tri_sample_float_v2 (RNG *rng, const float v1[2], const float v2[2], const float v3[2], float r_pt[2]) |
| void | BLI_rng_shuffle_array (RNG *rng, void *data, uint elem_size_i, uint elem_num) |
| void | BLI_rng_shuffle_bitmap (RNG *rng, BLI_bitmap *bitmap, uint bits_num) |
| void | BLI_rng_skip (RNG *rng, int n) |
| float | BLI_hash_frand (uint seed) |
| void | BLI_array_randomize (void *data, uint elem_size, uint elem_num, uint seed) |
| void | BLI_bitmap_randomize (BLI_bitmap *bitmap, uint bits_num, uint seed) |
| RNG_THREAD_ARRAY * | BLI_rng_threaded_new () |
| void | BLI_rng_threaded_free (RNG_THREAD_ARRAY *rngarr) |
| int | BLI_rng_thread_rand (RNG_THREAD_ARRAY *rngarr, int thread) |
| BLI_INLINE double | halton_ex (double invprimes, double *offset) |
| void | BLI_halton_1d (uint prime, double offset, int n, double *r) |
| void | BLI_halton_2d (const uint prime[2], double offset[2], int n, double *r) |
| void | BLI_halton_3d (const uint prime[3], double offset[3], int n, double *r) |
| BLI_INLINE double | radical_inverse (uint n) |
| void | BLI_hammersley_1d (uint n, double *r) |
| #define hash BLI_noise_hash_uchar_512 |
| void BLI_array_randomize | ( | void * | data, |
| unsigned int | elem_size, | ||
| unsigned int | elem_num, | ||
| 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 156 of file rand.cc.
References BLI_array_randomize(), BLI_rng_seed(), BLI_rng_shuffle_array(), and data.
Referenced by BLI_array_randomize(), BLI_rng_shuffle_bitmap(), edbm_select_random_exec(), lattice_select_random_exec(), modify_mesh(), blender::ed::object::object_select_random_exec(), psys_thread_context_init_distribute(), random_heap_helper(), random_heap_reinsert_helper(), random_heapsimple_helper(), and testbuffer_list_data_randomize().
| void BLI_bitmap_randomize | ( | BLI_bitmap * | bitmap, |
| uint | bits_num, | ||
| uint | seed ) |
Definition at line 164 of file rand.cc.
References BLI_bitmap_randomize(), BLI_rng_seed(), and BLI_rng_shuffle_bitmap().
Referenced by BLI_bitmap_randomize(), BLI_rng_shuffle_bitmap(), and curve_select_random_exec().
| void BLI_halton_1d | ( | unsigned int | prime, |
| double | offset, | ||
| int | n, | ||
| double * | r ) |
Return the _n_th number of the given low-discrepancy sequence.
Definition at line 226 of file rand.cc.
References BLI_halton_1d(), and halton_ex().
Referenced by BLI_halton_1d(), and BLI_rng_shuffle_bitmap().
| void BLI_halton_2d | ( | const uint | prime[2], |
| double | offset[2], | ||
| int | n, | ||
| double * | r ) |
Definition at line 237 of file rand.cc.
References BLI_halton_2d(), halton_ex(), and i.
Referenced by blender::draw::gpencil::Instance::antialiasing_sample_get(), BLI_halton_2d(), BLI_rng_shuffle_bitmap(), blender::deform_drawing(), and blender::eevee::Sampling::step().
| void BLI_halton_3d | ( | const uint | prime[3], |
| double | offset[3], | ||
| int | n, | ||
| double * | r ) |
Definition at line 250 of file rand.cc.
References BLI_halton_3d(), halton_ex(), and i.
Referenced by BLI_halton_3d(), BLI_rng_shuffle_bitmap(), blender::get_rand_matrix(), blender::modify_stroke_random(), and blender::eevee::Sampling::step().
| void BLI_hammersley_1d | ( | uint | n, |
| double * | r ) |
Definition at line 281 of file rand.cc.
References BLI_hammersley_1d(), and radical_inverse().
Referenced by BLI_hammersley_1d(), BLI_rng_shuffle_bitmap(), and hammersley_create().
| float BLI_hash_frand | ( | unsigned int | seed | ) |
Return a pseudo-random (hash) float from an integer value
Definition at line 148 of file rand.cc.
References BLI_hash_frand(), BLI_rng_get_float(), and BLI_rng_srandom().
Referenced by BLI_hash_frand(), BLI_rng_shuffle_bitmap(), and modify_mesh().
| void BLI_rng_free | ( | RNG * | rng | ) |
Definition at line 53 of file rand.cc.
References BLI_rng_free().
Referenced by array_store_test_random_data_rle_encode(), array_store_test_random_span_rle_encode(), BKE_brush_system_exit(), BKE_effectors_free(), BKE_mesh_remap_calc_faces_from_mesh(), BKE_particle_init_rng(), BLI_jitter_init(), BLI_rng_free(), bmo_subdivide_edges_exec(), brush_add(), brush_add_count_iter_free(), cloth_build_springs(), createFacepa(), distribute_simple_children(), do_map(), dynamics_step(), find_nearest_points_test(), hammersley_create(), init_keys(), init_mv_jit(), int4_ghash_tests(), int4_map_tests(), make_duplis_particle_system(), modify_mesh(), multi_small_ghash_tests(), Freestyle::Noise::Noise(), particles_fluid_step(), PE_free_random_generator(), blender::ed::transform::postTrans(), psys_tasks_free(), psys_thread_context_init_distribute(), randint_ghash_tests(), randint_map_tests(), random_chunk_generate(), random_chunk_mutate_helper(), random_data_mutate_helper(), select_random_exec(), select_random_metaelems_exec(), sort_bmelem_flag(), utf8_as_char32_test_at_buffer_size(), and blender::geometry::ParamHandle::~ParamHandle().
| void BLI_rng_get_char_n | ( | RNG * | rng, |
| char * | bytes, | ||
| size_t | bytes_len ) |
Definition at line 68 of file rand.cc.
References BLI_rng_get_char_n(), blender::RandomNumberGenerator::get_bytes(), and RNG::rng.
| double BLI_rng_get_double | ( | struct RNG * | rng | ) |
Definition at line 83 of file rand.cc.
References BLI_rng_get_double(), blender::RandomNumberGenerator::get_double(), and RNG::rng.
Referenced by BLI_jitter_init(), BLI_rng_get_char_n(), BLI_rng_get_double(), hammersley_create(), and particles_fluid_step().
| float BLI_rng_get_float | ( | struct RNG * | rng | ) |
Definition at line 88 of file rand.cc.
References BLI_rng_get_float(), blender::RandomNumberGenerator::get_float(), and RNG::rng.
Referenced by basic_force_cb(), BKE_brush_jitter_pos(), BKE_brush_randomize_texture_coords(), BKE_particle_init_rng(), BLI_hash_frand(), BLI_rng_get_char_n(), BLI_rng_get_float(), bmo_subdivide_edges_exec(), boid_body(), brush_add_count_iter(), brush_cut(), blender::ed::transform::calculatePropRatio(), collision_response(), createFacepa(), distribute_children_exec(), distribute_from_faces_exec(), distribute_from_volume_exec(), distribute_simple_children(), find_internal_spring_target_vertex(), init_mv_jit(), blender::geometry::p_chart_stretch_minimize(), psys_thread_context_init_distribute(), rng_v3_round(), rule_average_speed(), rule_avoid_collision(), rule_fight(), select_random_exec(), select_random_metaelems_exec(), sort_bmelem_flag(), weightvg_do_map(), and wind_func().
| int BLI_rng_get_int | ( | RNG * | rng | ) |
Definition at line 73 of file rand.cc.
References BLI_rng_get_int(), blender::RandomNumberGenerator::get_int32(), and RNG::rng.
Referenced by array_store_test_random_span_rle_encode(), BKE_particle_init_rng(), BLI_rng_get_char_n(), BLI_rng_get_int(), BLI_rng_thread_rand(), make_duplis_particle_system(), multi_small_ghash_tests(), Freestyle::Noise::Noise(), and wind_func().
| void BLI_rng_get_tri_sample_float_v2 | ( | struct RNG * | rng, |
| const float | v1[2], | ||
| const float | v2[2], | ||
| const float | v3[2], | ||
| float | r_pt[2] ) |
Generate a random point inside given tri.
Definition at line 93 of file rand.cc.
References BLI_rng_get_tri_sample_float_v2(), copy_v2_v2(), blender::RandomNumberGenerator::get_triangle_sample(), RNG::rng, and v2.
Referenced by BKE_mesh_remap_calc_faces_from_mesh(), BLI_rng_get_char_n(), and BLI_rng_get_tri_sample_float_v2().
Definition at line 78 of file rand.cc.
References BLI_rng_get_uint(), blender::RandomNumberGenerator::get_uint32(), and RNG::rng.
Referenced by BLI_rng_get_char_n(), BLI_rng_get_uint(), BLI_rng_shuffle_array(), BLI_rng_shuffle_bitmap(), init_keys(), int4_ghash_tests(), int4_map_tests(), multi_small_ghash_tests_one(), rand_range_i(), randint_ghash_tests(), randint_map_tests(), and testbuffer_list_state_random_data().
Definition at line 39 of file rand.cc.
References BLI_rng_new(), RNG::rng, and blender::RandomNumberGenerator::seed().
Referenced by array_store_test_random_data_rle_encode(), array_store_test_random_span_rle_encode(), BKE_brush_system_init(), BKE_mesh_remap_calc_faces_from_mesh(), BLI_jitter_init(), BLI_rng_new(), blender::ed::transform::calculatePropRatio(), find_nearest_points_test(), hammersley_create(), init_keys(), init_mv_jit(), int4_ghash_tests(), int4_map_tests(), multi_small_ghash_tests(), Freestyle::Noise::Noise(), PE_create_random_generator(), precalculate_effector(), psys_task_init_distribute(), psys_task_init_path(), randint_ghash_tests(), randint_map_tests(), random_chunk_generate(), random_chunk_mutate_helper(), random_data_mutate_helper(), utf8_as_char32_test_at_buffer_size(), and blender::geometry::uv_parametrizer_stretch_begin().
A version of BLI_rng_new that hashes the seed.
Definition at line 46 of file rand.cc.
References BLI_rng_new_srandom(), RNG::rng, and blender::RandomNumberGenerator::seed_random().
Referenced by BKE_particle_init_rng(), BLI_rng_new_srandom(), bmo_subdivide_edges_exec(), brush_add(), brush_add_count_iter(), cloth_build_springs(), createFacepa(), distribute_simple_children(), do_map(), dynamics_step(), make_duplis_particle_system(), modify_mesh(), particles_fluid_step(), psys_thread_context_init_distribute(), select_random_exec(), select_random_metaelems_exec(), and sort_bmelem_flag().
Definition at line 58 of file rand.cc.
References BLI_rng_seed(), RNG::rng, and blender::RandomNumberGenerator::seed().
Referenced by BLI_array_randomize(), BLI_bitmap_randomize(), and BLI_rng_seed().
Definition at line 99 of file rand.cc.
References BLI_rng_get_uint(), BLI_rng_shuffle_array(), data, free(), and i.
| void BLI_rng_shuffle_bitmap | ( | RNG * | rng, |
| BLI_bitmap * | bitmap, | ||
| uint | bits_num ) |
Definition at line 123 of file rand.cc.
References BLI_BITMAP_SET, BLI_BITMAP_TEST, BLI_rng_get_uint(), BLI_rng_shuffle_bitmap(), and i.
| void BLI_rng_skip | ( | struct RNG * | rng, |
| int | n ) |
Note that skipping is as slow as generating n numbers! Simulate getting n random values.
Definition at line 141 of file rand.cc.
References BLI_rng_skip(), RNG::rng, and blender::RandomNumberGenerator::skip().
Referenced by BLI_rng_shuffle_bitmap(), BLI_rng_skip(), distribute_children_exec(), distribute_from_faces_exec(), distribute_from_verts_exec(), distribute_from_volume_exec(), exec_distribute_child(), and exec_distribute_parent().
Use a hash table to create better seed.
Definition at line 63 of file rand.cc.
References BLI_rng_srandom(), RNG::rng, and blender::RandomNumberGenerator::seed_random().
Referenced by BKE_brush_system_init(), BLI_hash_frand(), BLI_rng_srandom(), and BLI_rng_threaded_new().
| int BLI_rng_thread_rand | ( | RNG_THREAD_ARRAY * | rngarr, |
| int | thread ) |
Definition at line 195 of file rand.cc.
References BLI_rng_get_int(), BLI_rng_thread_rand(), and RNG_THREAD_ARRAY::rng_tab.
Referenced by BLI_rng_shuffle_bitmap(), BLI_rng_thread_rand(), and texnoise().
| void BLI_rng_threaded_free | ( | RNG_THREAD_ARRAY * | rngarr | ) |
Definition at line 190 of file rand.cc.
References BLI_rng_threaded_free().
Referenced by BLI_rng_shuffle_bitmap(), BLI_rng_threaded_free(), and RE_texture_rng_exit().
| RNG_THREAD_ARRAY * BLI_rng_threaded_new | ( | void | ) |
array versions for thread safe random generation
Definition at line 178 of file rand.cc.
References BLENDER_MAX_THREADS, BLI_rng_srandom(), BLI_rng_threaded_new(), i, and RNG_THREAD_ARRAY::rng_tab.
Referenced by BLI_rng_shuffle_bitmap(), BLI_rng_threaded_new(), and RE_texture_rng_init().
| BLI_INLINE double halton_ex | ( | double | invprimes, |
| double * | offset ) |
Definition at line 204 of file rand.cc.
References BLI_INLINE, e, fabs(), and halton_ex().
Referenced by BLI_halton_1d(), BLI_halton_2d(), BLI_halton_3d(), and halton_ex().
| BLI_INLINE double radical_inverse | ( | uint | n | ) |
Definition at line 266 of file rand.cc.
References BLI_INLINE, and radical_inverse().
Referenced by BLI_hammersley_1d(), and radical_inverse().