30#define hash BLI_noise_hash_uchar_512
38 MEM_CXX_CLASS_ALLOC_FUNCS(
"RNG")
96 RNG *rng,
const float v1[2],
const float v2[2],
const float v3[2],
float r_pt[2])
107 const uint elem_size = elem_size_i;
109 void *temp = malloc(elem_size);
114 void *iElem =
static_cast<uchar *
>(
data) + i * elem_size_i;
115 void *jElem =
static_cast<uchar *
>(
data) + j * elem_size_i;
116 memcpy(temp, iElem, elem_size);
117 memcpy(iElem, jElem, elem_size);
118 memcpy(jElem, temp, elem_size);
208 double e =
fabs((1.0 - *offset) - 1
e-10);
210 if (invprimes >=
e) {
212 double h = invprimes;
219 *offset += ((lasth + h) - 1.0);
222 *offset += invprimes;
230 const double invprime = 1.0 / double(prime);
234 for (
int s = 0; s < n; s++) {
241 const double invprimes[2] = {1.0 / double(prime[0]), 1.0 / double(prime[1])};
245 for (
int s = 0; s < n; s++) {
246 for (
int i = 0; i < 2; i++) {
247 r[i] =
halton_ex(invprimes[i], &offset[i]);
254 const double invprimes[3] = {
255 1.0 / double(prime[0]), 1.0 / double(prime[1]), 1.0 / double(prime[2])};
257 r[0] = r[1] = r[2] = 0.0;
259 for (
int s = 0; s < n; s++) {
260 for (
int i = 0; i < 3; i++) {
261 r[i] =
halton_ex(invprimes[i], &offset[i]);
274 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;
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 =
reinterpret_cast<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)
#define BLENDER_MAX_THREADS
Read Blender memory allocation and freeing.
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
constexpr MutableSpan()=default
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()
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
void free(Subdiv *subdiv)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BLI_halton_2d(const unsigned int prime[2], double offset[2], int n, double *r)
void void BLI_rng_shuffle_bitmap(struct RNG *rng, unsigned int *bitmap, unsigned int bits_num) ATTR_NONNULL(1
double BLI_rng_get_double(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE void copy_v2_v2(float r[2], const float a[2])
float BLI_hash_frand(unsigned int seed) ATTR_WARN_UNUSED_RESULT
struct RNG * BLI_rng_new_srandom(unsigned int seed)
BLI_INLINE double halton_ex(double invprimes, double *offset)
MINLINE float fractf(float a)
void BLI_bitmap_randomize(unsigned int *bitmap, unsigned int bits_num, unsigned int seed) ATTR_NONNULL(1)
ATTR_WARN_UNUSED_RESULT const BMVert * v
int BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread) ATTR_WARN_UNUSED_RESULT
struct RNG * BLI_rng_new(unsigned int seed)
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]) ATTR_NONNULL()
void BLI_array_randomize(void *data, unsigned int elem_size, unsigned int elem_num, unsigned int seed)
void BLI_rng_get_char_n(RNG *rng, char *bytes, size_t bytes_len) ATTR_NONNULL(1
void BLI_halton_1d(unsigned int prime, double offset, int n, double *r)
VecBase< float, 2 > float2
BLI_INLINE double radical_inverse(uint n)
void BLI_rng_seed(struct RNG *rng, unsigned int seed) ATTR_NONNULL(1)
void BLI_halton_3d(const unsigned int prime[3], double offset[3], int n, double *r)
BMesh const char void * data
unsigned int BLI_rng_get_uint(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_rng_srandom(struct RNG *rng, unsigned int seed) ATTR_NONNULL(1)
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
void BLI_rng_shuffle_array(struct RNG *rng, void *data, unsigned int elem_size_i, unsigned int elem_num) ATTR_NONNULL(1
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void int BLI_rng_get_int(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
RNG_THREAD_ARRAY * BLI_rng_threaded_new()
ATTR_WARN_UNUSED_RESULT const BMVert * v2
void void void BLI_rng_skip(struct RNG *rng, int n) ATTR_NONNULL(1)
void BLI_rng_threaded_free(struct RNG_THREAD_ARRAY *rngarr) ATTR_NONNULL(1)
void BLI_hammersley_1d(unsigned int n, double *r)
VecBase< float, 3 > float3
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
std::array< RNG, BLENDER_MAX_THREADS > rng_tab
RandomNumberGenerator rng
ccl_device_inline size_t round_up(const size_t x, const size_t multiple)