28#define hash BLI_noise_hash_uchar_512
36 MEM_CXX_CLASS_ALLOC_FUNCS(
"RNG")
109 RNG *rng,
const float v1[2],
const float v2[2],
const float v3[2],
float r_pt[2])
115 RNG *rng,
const float v1[3],
const float v2[3],
const float v3[3],
float r_pt[3])
126 const uint elem_size = elem_size_i;
128 void *temp = malloc(elem_size);
133 void *iElem = (
uchar *)data + i * elem_size_i;
134 void *jElem = (
uchar *)data + j * elem_size_i;
135 memcpy(temp, iElem, elem_size);
136 memcpy(iElem, jElem, elem_size);
137 memcpy(jElem, temp, elem_size);
175 for (
int i = 0; i <
count; i++) {
264 double e =
fabs((1.0 - *offset) - 1
e-10);
266 if (invprimes >=
e) {
268 double h = invprimes;
275 *offset += ((lasth + h) - 1.0);
278 *offset += invprimes;
286 const double invprime = 1.0 /
double(prime);
290 for (
int s = 0; s < n; s++) {
297 const double invprimes[2] = {1.0 /
double(prime[0]), 1.0 /
double(prime[1])};
301 for (
int s = 0; s < n; s++) {
302 for (
int i = 0; i < 2; i++) {
303 r[i] =
halton_ex(invprimes[i], &offset[i]);
310 const double invprimes[3] = {
313 r[0] = r[1] = r[2] = 0.0;
315 for (
int s = 0; s < n; s++) {
316 for (
int i = 0; i < 3; i++) {
317 r[i] =
halton_ex(invprimes[i], &offset[i]);
324 const double invprimes[2] = {1.0 /
double(prime[0]), 1.0 /
double(prime[1])};
326 for (
int s = 0; s < n; s++) {
327 for (
int i = 0; i < 2; i++) {
328 r[s * 2 + i] =
halton_ex(invprimes[i], &offset[i]);
341 for (
double p = 0.5; n; p *= 0.5, n >>= 1) {
357 for (
uint s = 0; s < n; s++) {
367 std::random_device rd;
368 std::mt19937
e{rd()};
369 std::uniform_int_distribution<uint32_t> dist;
387 const float round_up_probability =
fractf(x);
401 float r = 1.0f -
z *
z;
405 float x = r *
cosf(a);
406 float y = r *
sinf(a);
409 return {0.0f, 0.0f, 1.0f};
452 constexpr int64_t mask_bytes = 2;
458 if (trim_len > rand_stride) {
459 last_len = trim_len % rand_stride;
460 trim_len = trim_len - last_len;
464 last_len = r_bytes.
size();
467 const char *data_src = (
const char *)&x_;
469 while (i != trim_len) {
472 for (
int64_t j = (rand_stride + mask_bytes) - 1; j != mask_bytes - 1; j--)
474 for (
int64_t j = 0; j != rand_stride; j++)
477 r_bytes[i++] = data_src[j];
482 for (
int64_t j = 0; j != last_len; j++) {
483 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])
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define BLENDER_MAX_THREADS
typedef double(DMatrix)[4][4]
Read Guarded memory(de)allocation.
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()
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
MINLINE float fractf(float a)
ccl_device_inline float2 fabs(const float2 a)
void BLI_rng_threaded_free(RNG_THREAD_ARRAY *rngarr)
uint BLI_rng_get_uint(RNG *rng)
void BLI_thread_srandom(int thread, uint seed)
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)
float BLI_thread_frand(int thread)
void BLI_rng_shuffle_array(RNG *rng, void *data, uint elem_size_i, uint elem_num)
void BLI_rng_get_tri_sample_float_v3(RNG *rng, const float v1[3], const float v2[3], const float v3[3], float r_pt[3])
RNG * BLI_rng_copy(const RNG *rng)
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)
int BLI_thread_rand(int thread)
void BLI_rng_get_float_unit_v3(RNG *rng, float v[3])
uchar BLI_noise_hash_uchar_512[512]
BLI_INLINE double radical_inverse(uint n)
void BLI_hammersley_1d(uint n, double *r)
void BLI_rng_seed(RNG *rng, uint seed)
void BLI_hammersley_2d_sequence(uint n, double *r)
static RNG rng_tab[BLENDER_MAX_THREADS]
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_halton_2d_sequence(const uint prime[2], double offset[2], int n, double *r)
void BLI_rng_get_float_unit_v2(RNG *rng, float v[2])
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)
void BLI_array_frand(float *ar, int count, uint seed)
RNG rng_tab[BLENDER_MAX_THREADS]
blender::RandomNumberGenerator rng
ccl_device_inline size_t round_up(size_t x, size_t multiple)