28#define hash BLI_noise_hash_uchar_512
36 MEM_CXX_CLASS_ALLOC_FUNCS(
"RNG")
94 RNG *rng,
const float v1[2],
const float v2[2],
const float v3[2],
float r_pt[2])
105 const uint elem_size = elem_size_i;
107 void *temp = malloc(elem_size);
112 void *iElem = (
uchar *)
data +
i * elem_size_i;
113 void *jElem = (
uchar *)
data + j * elem_size_i;
114 memcpy(temp, iElem, elem_size);
115 memcpy(iElem, jElem, elem_size);
116 memcpy(jElem, temp, elem_size);
206 double e =
fabs((1.0 - *offset) - 1
e-10);
208 if (invprimes >=
e) {
210 double h = invprimes;
217 *offset += ((lasth + h) - 1.0);
220 *offset += invprimes;
228 const double invprime = 1.0 / double(prime);
232 for (
int s = 0; s < n; s++) {
239 const double invprimes[2] = {1.0 / double(prime[0]), 1.0 / double(prime[1])};
243 for (
int s = 0; s < n; s++) {
244 for (
int i = 0;
i < 2;
i++) {
252 const double invprimes[3] = {
253 1.0 / double(prime[0]), 1.0 / double(prime[1]), 1.0 / double(prime[2])};
255 r[0] = r[1] = r[2] = 0.0;
257 for (
int s = 0; s < n; s++) {
258 for (
int i = 0;
i < 3;
i++) {
272 for (
double p = 0.5; n; p *= 0.5, n >>= 1) {
290 std::random_device rd;
291 std::mt19937
e{rd()};
292 std::uniform_int_distribution<uint32_t> dist;
293 const uint32_t
seed = dist(
e);
310 const float round_up_probability =
fractf(
x);
324 float r = 1.0f -
z *
z;
328 float x = r *
cosf(a);
329 float y = r *
sinf(a);
332 return {0.0f, 0.0f, 1.0f};
375 constexpr int64_t mask_bytes = 2;
381 if (trim_len > rand_stride) {
382 last_len = trim_len % rand_stride;
383 trim_len = trim_len - last_len;
387 last_len = r_bytes.
size();
390 const char *data_src = (
const char *)&x_;
392 while (
i != trim_len) {
396 for (
int64_t j = 0; j != rand_stride; j++) {
397 r_bytes[
i++] = data_src[j];
402 for (
int64_t j = 0; j != last_len; j++) {
403 r_bytes[
i++] = data_src[j];
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_SET(_bitmap, _index, _set)
void BLI_kdtree_nd_ free(KDTree *tree)
MINLINE void copy_v2_v2(float r[2], const float a[2])
#define BLENDER_MAX_THREADS
Read Guarded memory(de)allocation.
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
static unsigned long seed
constexpr int64_t size() const
void get_bytes(MutableSpan< char > r_bytes)
int round_probabilistic(float x)
RandomNumberGenerator(uint32_t seed=0)
void seed_random(uint32_t seed)
float3 get_triangle_sample_3d(float3 v1, float3 v2, float3 v3)
float2 get_triangle_sample(float2 v1, float2 v2, float2 v3)
static RandomNumberGenerator from_random_seed()
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
ccl_device_inline float2 fabs(const float2 a)
VecBase< float, 2 > float2
VecBase< float, 3 > float3
void BLI_rng_threaded_free(RNG_THREAD_ARRAY *rngarr)
uint BLI_rng_get_uint(RNG *rng)
float BLI_rng_get_float(RNG *rng)
void BLI_halton_3d(const uint prime[3], double offset[3], int n, double *r)
void BLI_rng_free(RNG *rng)
void BLI_rng_srandom(RNG *rng, uint seed)
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_halton_2d(const uint prime[2], double offset[2], int n, double *r)
int BLI_rng_get_int(RNG *rng)
BLI_INLINE double radical_inverse(uint n)
void BLI_hammersley_1d(uint n, double *r)
void BLI_rng_seed(RNG *rng, uint seed)
int BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread)
void BLI_rng_get_char_n(RNG *rng, char *bytes, size_t bytes_len)
double BLI_rng_get_double(RNG *rng)
void BLI_rng_skip(RNG *rng, int n)
RNG * BLI_rng_new_srandom(uint seed)
void BLI_halton_1d(uint prime, double offset, int n, double *r)
RNG_THREAD_ARRAY * BLI_rng_threaded_new()
void BLI_array_randomize(void *data, uint elem_size, uint elem_num, uint seed)
BLI_INLINE double halton_ex(double invprimes, double *offset)
RNG * BLI_rng_new(uint seed)
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])
float BLI_hash_frand(uint seed)
void BLI_bitmap_randomize(BLI_bitmap *bitmap, uint bits_num, uint seed)
std::array< RNG, BLENDER_MAX_THREADS > rng_tab
blender::RandomNumberGenerator rng
ccl_device_inline size_t round_up(const size_t x, const size_t multiple)