Blender  V2.93
rand.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #include <cmath>
25 #include <cstdlib>
26 #include <cstring>
27 #include <ctime>
28 
29 #include "MEM_guardedalloc.h"
30 
31 #include "BLI_math.h"
32 #include "BLI_rand.h"
33 #include "BLI_rand.hh"
34 #include "BLI_threads.h"
35 
36 /* defines BLI_INLINE */
37 #include "BLI_compiler_compat.h"
38 
39 #include "BLI_strict_flags.h"
40 #include "BLI_sys_types.h"
41 
42 extern "C" unsigned char BLI_noise_hash_uchar_512[512]; /* noise.c */
43 #define hash BLI_noise_hash_uchar_512
44 
48 struct RNG {
50 
51  MEM_CXX_CLASS_ALLOC_FUNCS("RNG")
52 };
53 
54 RNG *BLI_rng_new(unsigned int seed)
55 {
56  RNG *rng = new RNG();
57  rng->rng.seed(seed);
58  return rng;
59 }
60 
65 {
66  RNG *rng = new RNG();
67  rng->rng.seed_random(seed);
68  return rng;
69 }
70 
72 {
73  return new RNG(*rng);
74 }
75 
76 void BLI_rng_free(RNG *rng)
77 {
78  delete rng;
79 }
80 
81 void BLI_rng_seed(RNG *rng, unsigned int seed)
82 {
83  rng->rng.seed(seed);
84 }
85 
89 void BLI_rng_srandom(RNG *rng, unsigned int seed)
90 {
91  rng->rng.seed_random(seed);
92 }
93 
94 void BLI_rng_get_char_n(RNG *rng, char *bytes, size_t bytes_len)
95 {
96  rng->rng.get_bytes(blender::MutableSpan(bytes, static_cast<int64_t>(bytes_len)));
97 }
98 
100 {
101  return rng->rng.get_int32();
102 }
103 
104 unsigned int BLI_rng_get_uint(RNG *rng)
105 {
106  return rng->rng.get_uint32();
107 }
108 
113 {
114  return rng->rng.get_double();
115 }
116 
121 {
122  return rng->rng.get_float();
123 }
124 
125 void BLI_rng_get_float_unit_v2(RNG *rng, float v[2])
126 {
127  copy_v2_v2(v, rng->rng.get_unit_float2());
128 }
129 
130 void BLI_rng_get_float_unit_v3(RNG *rng, float v[3])
131 {
132  copy_v3_v3(v, rng->rng.get_unit_float3());
133 }
134 
139  RNG *rng, const float v1[2], const float v2[2], const float v3[2], float r_pt[2])
140 {
141  copy_v2_v2(r_pt, rng->rng.get_triangle_sample(v1, v2, v3));
142 }
143 
145  RNG *rng, const float v1[3], const float v2[3], const float v3[3], float r_pt[3])
146 {
147  copy_v3_v3(r_pt, rng->rng.get_triangle_sample_3d(v1, v2, v3));
148 }
149 
150 void BLI_rng_shuffle_array(RNG *rng, void *data, unsigned int elem_size_i, unsigned int elem_tot)
151 {
152  const uint elem_size = elem_size_i;
153  unsigned int i = elem_tot;
154  void *temp;
155 
156  if (elem_tot <= 1) {
157  return;
158  }
159 
160  temp = malloc(elem_size);
161 
162  while (i--) {
163  unsigned int j = BLI_rng_get_uint(rng) % elem_tot;
164  if (i != j) {
165  void *iElem = (unsigned char *)data + i * elem_size_i;
166  void *jElem = (unsigned char *)data + j * elem_size_i;
167  memcpy(temp, iElem, elem_size);
168  memcpy(iElem, jElem, elem_size);
169  memcpy(jElem, temp, elem_size);
170  }
171  }
172 
173  free(temp);
174 }
175 
181 void BLI_rng_skip(RNG *rng, int n)
182 {
183  rng->rng.skip((uint)n);
184 }
185 
186 /***/
187 
188 /* fill an array with random numbers */
189 void BLI_array_frand(float *ar, int count, unsigned int seed)
190 {
191  RNG rng;
192 
193  BLI_rng_srandom(&rng, seed);
194 
195  for (int i = 0; i < count; i++) {
196  ar[i] = BLI_rng_get_float(&rng);
197  }
198 }
199 
200 float BLI_hash_frand(unsigned int seed)
201 {
202  RNG rng;
203 
204  BLI_rng_srandom(&rng, seed);
205  return BLI_rng_get_float(&rng);
206 }
207 
209  unsigned int elem_size,
210  unsigned int elem_tot,
211  unsigned int seed)
212 {
213  RNG rng;
214 
215  BLI_rng_seed(&rng, seed);
216  BLI_rng_shuffle_array(&rng, data, elem_size, elem_tot);
217 }
218 
219 /* ********* for threaded random ************** */
220 
222 
223 void BLI_thread_srandom(int thread, unsigned int seed)
224 {
225  if (thread >= BLENDER_MAX_THREADS) {
226  thread = 0;
227  }
228 
229  BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
231  BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
233  BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
234 }
235 
237 {
238  return BLI_rng_get_int(&rng_tab[thread]);
239 }
240 
242 {
243  return BLI_rng_get_float(&rng_tab[thread]);
244 }
245 
248 };
249 
251 {
252  unsigned int i;
254  "random_array");
255 
256  for (i = 0; i < BLENDER_MAX_THREADS; i++) {
257  BLI_rng_srandom(&rngarr->rng_tab[i], (unsigned int)clock());
258  }
259 
260  return rngarr;
261 }
262 
264 {
265  MEM_freeN(rngarr);
266 }
267 
269 {
270  return BLI_rng_get_int(&rngarr->rng_tab[thread]);
271 }
272 
273 /* ********* Low-discrepancy sequences ************** */
274 
275 /* incremental halton sequence generator, from:
276  * "Instant Radiosity", Keller A. */
277 BLI_INLINE double halton_ex(double invprimes, double *offset)
278 {
279  double e = fabs((1.0 - *offset) - 1e-10);
280 
281  if (invprimes >= e) {
282  double lasth;
283  double h = invprimes;
284 
285  do {
286  lasth = h;
287  h *= invprimes;
288  } while (h >= e);
289 
290  *offset += ((lasth + h) - 1.0);
291  }
292  else {
293  *offset += invprimes;
294  }
295 
296  return *offset;
297 }
298 
299 void BLI_halton_1d(unsigned int prime, double offset, int n, double *r)
300 {
301  const double invprime = 1.0 / (double)prime;
302 
303  *r = 0.0;
304 
305  for (int s = 0; s < n; s++) {
306  *r = halton_ex(invprime, &offset);
307  }
308 }
309 
310 void BLI_halton_2d(const unsigned int prime[2], double offset[2], int n, double *r)
311 {
312  const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]};
313 
314  r[0] = r[1] = 0.0;
315 
316  for (int s = 0; s < n; s++) {
317  for (int i = 0; i < 2; i++) {
318  r[i] = halton_ex(invprimes[i], &offset[i]);
319  }
320  }
321 }
322 
323 void BLI_halton_3d(const unsigned int prime[3], double offset[3], int n, double *r)
324 {
325  const double invprimes[3] = {
326  1.0 / (double)prime[0], 1.0 / (double)prime[1], 1.0 / (double)prime[2]};
327 
328  r[0] = r[1] = r[2] = 0.0;
329 
330  for (int s = 0; s < n; s++) {
331  for (int i = 0; i < 3; i++) {
332  r[i] = halton_ex(invprimes[i], &offset[i]);
333  }
334  }
335 }
336 
337 void BLI_halton_2d_sequence(const unsigned int prime[2], double offset[2], int n, double *r)
338 {
339  const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]};
340 
341  for (int s = 0; s < n; s++) {
342  for (int i = 0; i < 2; i++) {
343  r[s * 2 + i] = halton_ex(invprimes[i], &offset[i]);
344  }
345  }
346 }
347 
348 /* From "Sampling with Hammersley and Halton Points" TT Wong
349  * Appendix: Source Code 1 */
350 BLI_INLINE double radical_inverse(unsigned int n)
351 {
352  double u = 0;
353 
354  /* This reverse the bit-wise representation
355  * around the decimal point. */
356  for (double p = 0.5; n; p *= 0.5, n >>= 1) {
357  if (n & 1) {
358  u += p;
359  }
360  }
361 
362  return u;
363 }
364 
365 void BLI_hammersley_1d(unsigned int n, double *r)
366 {
367  *r = radical_inverse(n);
368 }
369 
370 void BLI_hammersley_2d_sequence(unsigned int n, double *r)
371 {
372  for (unsigned int s = 0; s < n; s++) {
373  r[s * 2 + 0] = (double)(s + 0.5) / (double)n;
374  r[s * 2 + 1] = radical_inverse(s);
375  }
376 }
377 
378 namespace blender {
379 
384 {
385  this->seed(seed + hash[seed & 255]);
386  seed = this->get_uint32();
387  this->seed(seed + hash[seed & 255]);
388  seed = this->get_uint32();
389  this->seed(seed + hash[seed & 255]);
390 }
391 
393 {
394  float a = (float)(M_PI * 2.0) * this->get_float();
395  return {cosf(a), sinf(a)};
396 }
397 
399 {
400  float z = (2.0f * this->get_float()) - 1.0f;
401  float r = 1.0f - z * z;
402  if (r > 0.0f) {
403  float a = (float)(M_PI * 2.0) * this->get_float();
404  r = sqrtf(r);
405  float x = r * cosf(a);
406  float y = r * sinf(a);
407  return {x, y, z};
408  }
409  return {0.0f, 0.0f, 1.0f};
410 }
411 
416 {
417  float u = this->get_float();
418  float v = this->get_float();
419 
420  if (u + v > 1.0f) {
421  u = 1.0f - u;
422  v = 1.0f - v;
423  }
424 
425  float2 side_u = v2 - v1;
426  float2 side_v = v3 - v1;
427 
428  float2 sample = v1;
429  sample += side_u * u;
430  sample += side_v * v;
431  return sample;
432 }
433 
435 {
436  float u = this->get_float();
437  float v = this->get_float();
438 
439  if (u + v > 1.0f) {
440  u = 1.0f - u;
441  v = 1.0f - v;
442  }
443 
444  float3 side_u = v2 - v1;
445  float3 side_v = v3 - v1;
446 
447  float3 sample = v1;
448  sample += side_u * u;
449  sample += side_v * v;
450  return sample;
451 }
452 
454 {
455  constexpr int64_t mask_bytes = 2;
456  constexpr int64_t rand_stride = static_cast<int64_t>(sizeof(x_)) - mask_bytes;
457 
458  int64_t last_len = 0;
459  int64_t trim_len = r_bytes.size();
460 
461  if (trim_len > rand_stride) {
462  last_len = trim_len % rand_stride;
463  trim_len = trim_len - last_len;
464  }
465  else {
466  trim_len = 0;
467  last_len = r_bytes.size();
468  }
469 
470  const char *data_src = (const char *)&x_;
471  int64_t i = 0;
472  while (i != trim_len) {
473  BLI_assert(i < trim_len);
474 #ifdef __BIG_ENDIAN__
475  for (int64_t j = (rand_stride + mask_bytes) - 1; j != mask_bytes - 1; j--)
476 #else
477  for (int64_t j = 0; j != rand_stride; j++)
478 #endif
479  {
480  r_bytes[i++] = data_src[j];
481  }
482  this->step();
483  }
484  if (last_len) {
485  for (int64_t j = 0; j != last_len; j++) {
486  r_bytes[i++] = data_src[j];
487  }
488  }
489 }
490 
491 } // namespace blender
typedef float(TangentPoint)[2]
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define BLI_INLINE
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:116
#define M_PI
Definition: BLI_math_base.h:38
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
Random number functions.
struct RNG RNG
Definition: BLI_rand.h:39
Strict compiler flags for areas of code we want to ensure don't do conversions without us knowing abo...
unsigned int uint
Definition: BLI_sys_types.h:83
#define BLENDER_MAX_THREADS
Definition: BLI_threads.h:35
typedef double(DMatrix)[4][4]
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
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
static unsigned long seed
Definition: btSoftBody.h:39
constexpr int64_t size() const
Definition: BLI_span.hh:524
void get_bytes(MutableSpan< char > r_bytes)
Definition: rand.cc:453
void seed_random(uint32_t seed)
Definition: rand.cc:383
float3 get_triangle_sample_3d(float3 v1, float3 v2, float3 v3)
Definition: rand.cc:434
float2 get_triangle_sample(float2 v1, float2 v2, float2 v3)
Definition: rand.cc:415
void seed(uint32_t seed)
Definition: BLI_rand.hh:44
int count
#define sinf(x)
#define cosf(x)
#define sqrtf(x)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
static unsigned a[3]
Definition: RandGen.cpp:92
static void sample(SocketReader *reader, int x, int y, float color[4])
float BLI_rng_get_float(RNG *rng)
Definition: rand.cc:120
void BLI_rng_free(RNG *rng)
Definition: rand.cc:76
float BLI_thread_frand(int thread)
Definition: rand.cc:241
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])
Definition: rand.cc:144
void BLI_hammersley_1d(unsigned int n, double *r)
Definition: rand.cc:365
RNG_THREAD_ARRAY * BLI_rng_threaded_new(void)
Definition: rand.cc:250
RNG * BLI_rng_copy(RNG *rng)
Definition: rand.cc:71
int BLI_rng_get_int(RNG *rng)
Definition: rand.cc:99
int BLI_thread_rand(int thread)
Definition: rand.cc:236
BLI_INLINE double radical_inverse(unsigned int n)
Definition: rand.cc:350
#define hash
Definition: rand.cc:43
void BLI_rng_get_float_unit_v3(RNG *rng, float v[3])
Definition: rand.cc:130
void BLI_halton_2d_sequence(const unsigned int prime[2], double offset[2], int n, double *r)
Definition: rand.cc:337
void BLI_array_randomize(void *data, unsigned int elem_size, unsigned int elem_tot, unsigned int seed)
Definition: rand.cc:208
float BLI_hash_frand(unsigned int seed)
Definition: rand.cc:200
void BLI_halton_3d(const unsigned int prime[3], double offset[3], int n, double *r)
Definition: rand.cc:323
void BLI_rng_threaded_free(struct RNG_THREAD_ARRAY *rngarr)
Definition: rand.cc:263
static RNG rng_tab[BLENDER_MAX_THREADS]
Definition: rand.cc:221
int BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread)
Definition: rand.cc:268
void BLI_rng_srandom(RNG *rng, unsigned int seed)
Definition: rand.cc:89
void BLI_halton_2d(const unsigned int prime[2], double offset[2], int n, double *r)
Definition: rand.cc:310
void BLI_rng_get_char_n(RNG *rng, char *bytes, size_t bytes_len)
Definition: rand.cc:94
double BLI_rng_get_double(RNG *rng)
Definition: rand.cc:112
void BLI_rng_skip(RNG *rng, int n)
Definition: rand.cc:181
RNG * BLI_rng_new_srandom(unsigned int seed)
Definition: rand.cc:64
void BLI_rng_shuffle_array(RNG *rng, void *data, unsigned int elem_size_i, unsigned int elem_tot)
Definition: rand.cc:150
void BLI_thread_srandom(int thread, unsigned int seed)
Definition: rand.cc:223
unsigned int BLI_rng_get_uint(RNG *rng)
Definition: rand.cc:104
RNG * BLI_rng_new(unsigned int seed)
Definition: rand.cc:54
void BLI_rng_seed(RNG *rng, unsigned int seed)
Definition: rand.cc:81
void BLI_rng_get_float_unit_v2(RNG *rng, float v[2])
Definition: rand.cc:125
void BLI_halton_1d(unsigned int prime, double offset, int n, double *r)
Definition: rand.cc:299
BLI_INLINE double halton_ex(double invprimes, double *offset)
Definition: rand.cc:277
unsigned char BLI_noise_hash_uchar_512[512]
Definition: rand.cc:42
void BLI_array_frand(float *ar, int count, unsigned int seed)
Definition: rand.cc:189
void BLI_hammersley_2d_sequence(unsigned int n, double *r)
Definition: rand.cc:370
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])
Definition: rand.cc:138
unsigned int uint32_t
Definition: stdint.h:83
__int64 int64_t
Definition: stdint.h:92
RNG rng_tab[BLENDER_MAX_THREADS]
Definition: rand.cc:247
Definition: rand.cc:48
blender::RandomNumberGenerator rng
Definition: rand.cc:49
ccl_device_inline float2 fabs(const float2 &a)