Blender  V3.3
mathutils_noise.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
10 /************************/
11 /* Blender Noise Module */
12 /************************/
13 
14 #include <Python.h>
15 
16 #include "BLI_math.h"
17 #include "BLI_noise.h"
18 #include "BLI_utildefines.h"
19 
20 #include "DNA_texture_types.h"
21 
22 #include "../generic/py_capi_utils.h"
23 
24 #include "mathutils.h"
25 #include "mathutils_noise.h"
26 
27 /*-----------------------------------------*/
28 /* 'mersenne twister' random number generator */
29 
30 /* A C-program for MT19937, with initialization improved 2002/2/10.
31  * Coded by Takuji Nishimura and Makoto Matsumoto.
32  * This is a faster version by taking Shawn Cokus's optimization,
33  * Matthe Bellew's simplification, Isaku Wada's real version.
34  *
35  * Before using, initialize the state by using
36  * `init_genrand(seed)` or `init_by_array(init_key, key_length)`.
37  *
38  * SPDX-License-Identifier: BSD-3-Clause
39  * Copyright 1997-2002 Makoto Matsumoto and Takuji Nishimura, All rights reserved.
40  *
41  * Any feedback is very welcome.
42  * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
43  * email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space). */
44 
45 /* Period parameters */
46 #define N 624
47 #define M 397
48 #define MATRIX_A 0x9908b0dfUL /* constant vector a */
49 #define UMASK 0x80000000UL /* most significant w-r bits */
50 #define LMASK 0x7fffffffUL /* least significant r bits */
51 #define MIXBITS(u, v) (((u)&UMASK) | ((v)&LMASK))
52 #define TWIST(u, v) ((MIXBITS(u, v) >> 1) ^ ((v)&1UL ? MATRIX_A : 0UL))
53 
54 static ulong state[N]; /* The array for the state vector. */
55 static int left = 1;
56 static int initf = 0;
57 static ulong *next;
58 static float state_offset_vector[3 * 3];
59 
60 /* initializes state[N] with a seed */
61 static void init_genrand(ulong s)
62 {
63  int j;
64  state[0] = s & 0xffffffffUL;
65  for (j = 1; j < N; j++) {
66  state[j] = (1812433253UL * (state[j - 1] ^ (state[j - 1] >> 30)) + j);
67  /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier.
68  * In the previous versions, MSBs of the seed affect
69  * only MSBs of the array state[].
70  * 2002/01/09 modified by Makoto Matsumoto. */
71  state[j] &= 0xffffffffUL; /* for >32 bit machines */
72  }
73  left = 1;
74  initf = 1;
75 
76  /* update vector offset */
77  {
78  const ulong *state_offset = &state[N - ARRAY_SIZE(state_offset_vector)];
79  const float range = 32; /* range in both pos/neg direction */
80  for (j = 0; j < ARRAY_SIZE(state_offset_vector); j++, state_offset++) {
81  /* overflow is fine here */
82  state_offset_vector[j] = (float)(int)(*state_offset) * (1.0f / ((float)INT_MAX / range));
83  }
84  }
85 }
86 
87 static void next_state(void)
88 {
89  ulong *p = state;
90  int j;
91 
92  /* If init_genrand() has not been called, a default initial seed is used. */
93  if (initf == 0) {
94  init_genrand(5489UL);
95  }
96 
97  left = N;
98  next = state;
99 
100  for (j = N - M + 1; --j; p++) {
101  *p = p[M] ^ TWIST(p[0], p[1]);
102  }
103 
104  for (j = M; --j; p++) {
105  *p = p[M - N] ^ TWIST(p[0], p[1]);
106  }
107 
108  *p = p[M - N] ^ TWIST(p[0], state[0]);
109 }
110 
111 /*------------------------------------------------------------*/
112 
113 static void setRndSeed(int seed)
114 {
115  if (seed == 0) {
117  }
118  else {
120  }
121 }
122 
123 /* float number in range [0, 1) using the mersenne twister rng */
124 static float frand(void)
125 {
126  ulong y;
127 
128  if (--left == 0) {
129  next_state();
130  }
131  y = *next++;
132 
133  /* Tempering */
134  y ^= (y >> 11);
135  y ^= (y << 7) & 0x9d2c5680UL;
136  y ^= (y << 15) & 0xefc60000UL;
137  y ^= (y >> 18);
138 
139  return (float)y / 4294967296.0f;
140 }
141 
142 /*------------------------------------------------------------*/
143 /* Utility Functions */
144 /*------------------------------------------------------------*/
145 
146 #define BPY_NOISE_BASIS_ENUM_DOC \
147  " :arg noise_basis: Enumerator in ['BLENDER', 'PERLIN_ORIGINAL', 'PERLIN_NEW', " \
148  "'VORONOI_F1', 'VORONOI_F2', " \
149  "'VORONOI_F3', 'VORONOI_F4', 'VORONOI_F2F1', 'VORONOI_CRACKLE', " \
150  "'CELLNOISE'].\n" \
151  " :type noise_basis: string\n"
152 
153 #define BPY_NOISE_METRIC_ENUM_DOC \
154  " :arg distance_metric: Enumerator in ['DISTANCE', 'DISTANCE_SQUARED', 'MANHATTAN', " \
155  "'CHEBYCHEV', " \
156  "'MINKOVSKY', 'MINKOVSKY_HALF', 'MINKOVSKY_FOUR'].\n" \
157  " :type distance_metric: string\n"
158 
159 /* Noise basis enum */
160 #define DEFAULT_NOISE_TYPE TEX_STDPERLIN
161 
163  {TEX_BLENDER, "BLENDER"},
164  {TEX_STDPERLIN, "PERLIN_ORIGINAL"},
165  {TEX_NEWPERLIN, "PERLIN_NEW"},
166  {TEX_VORONOI_F1, "VORONOI_F1"},
167  {TEX_VORONOI_F2, "VORONOI_F2"},
168  {TEX_VORONOI_F3, "VORONOI_F3"},
169  {TEX_VORONOI_F4, "VORONOI_F4"},
170  {TEX_VORONOI_F2F1, "VORONOI_F2F1"},
171  {TEX_VORONOI_CRACKLE, "VORONOI_CRACKLE"},
172  {TEX_CELLNOISE, "CELLNOISE"},
173  {0, NULL},
174 };
175 
176 /* Metric basis enum */
177 #define DEFAULT_METRIC_TYPE TEX_DISTANCE
178 
180  {TEX_DISTANCE, "DISTANCE"},
181  {TEX_DISTANCE_SQUARED, "DISTANCE_SQUARED"},
182  {TEX_MANHATTAN, "MANHATTAN"},
183  {TEX_CHEBYCHEV, "CHEBYCHEV"},
184  {TEX_MINKOVSKY, "MINKOVSKY"},
185  {TEX_MINKOVSKY_HALF, "MINKOVSKY_HALF"},
186  {TEX_MINKOVSKY_FOUR, "MINKOVSKY_FOUR"},
187  {0, NULL},
188 };
189 
190 /* Fills an array of length size with random numbers in the range (-1, 1). */
191 static void rand_vn(float *array_tar, const int size)
192 {
193  float *array_pt = array_tar + (size - 1);
194  int i = size;
195  while (i--) {
196  *(array_pt--) = 2.0f * frand() - 1.0f;
197  }
198 }
199 
200 /* Fills an array of length 3 with noise values */
201 static void noise_vector(float x, float y, float z, int nb, float v[3])
202 {
203  /* Simply evaluate noise at 3 different positions */
204  const float *ofs = state_offset_vector;
205  for (int j = 0; j < 3; j++) {
206  v[j] = (2.0f * BLI_noise_generic_noise(1.0f, x + ofs[0], y + ofs[1], z + ofs[2], false, nb) -
207  1.0f);
208  ofs += 3;
209  }
210 }
211 
212 /* Returns a turbulence value for a given position (x, y, z) */
213 static float turb(
214  float x, float y, float z, int oct, int hard, int nb, float ampscale, float freqscale)
215 {
216  float amp, out, t;
217  int i;
218  amp = 1.0f;
219  out = (float)(2.0f * BLI_noise_generic_noise(1.0f, x, y, z, false, nb) - 1.0f);
220  if (hard) {
221  out = fabsf(out);
222  }
223  for (i = 1; i < oct; i++) {
224  amp *= ampscale;
225  x *= freqscale;
226  y *= freqscale;
227  z *= freqscale;
228  t = (float)(amp * (2.0f * BLI_noise_generic_noise(1.0f, x, y, z, false, nb) - 1.0f));
229  if (hard) {
230  t = fabsf(t);
231  }
232  out += t;
233  }
234  return out;
235 }
236 
237 /* Fills an array of length 3 with the turbulence vector for a given
238  * position (x, y, z) */
239 static void vTurb(float x,
240  float y,
241  float z,
242  int oct,
243  int hard,
244  int nb,
245  float ampscale,
246  float freqscale,
247  float v[3])
248 {
249  float amp, t[3];
250  int i;
251  amp = 1.0f;
252  noise_vector(x, y, z, nb, v);
253  if (hard) {
254  v[0] = fabsf(v[0]);
255  v[1] = fabsf(v[1]);
256  v[2] = fabsf(v[2]);
257  }
258  for (i = 1; i < oct; i++) {
259  amp *= ampscale;
260  x *= freqscale;
261  y *= freqscale;
262  z *= freqscale;
263  noise_vector(x, y, z, nb, t);
264  if (hard) {
265  t[0] = fabsf(t[0]);
266  t[1] = fabsf(t[1]);
267  t[2] = fabsf(t[2]);
268  }
269  v[0] += amp * t[0];
270  v[1] += amp * t[1];
271  v[2] += amp * t[2];
272  }
273 }
274 
275 /*-------------------------DOC STRINGS ---------------------------*/
276 PyDoc_STRVAR(M_Noise_doc, "The Blender noise module");
277 
278 /*------------------------------------------------------------*/
279 /* Python Functions */
280 /*------------------------------------------------------------*/
281 
282 PyDoc_STRVAR(M_Noise_random_doc,
283  ".. function:: random()\n"
284  "\n"
285  " Returns a random number in the range [0, 1).\n"
286  "\n"
287  " :return: The random number.\n"
288  " :rtype: float\n");
289 static PyObject *M_Noise_random(PyObject *UNUSED(self))
290 {
291  return PyFloat_FromDouble(frand());
292 }
293 
294 PyDoc_STRVAR(M_Noise_random_unit_vector_doc,
295  ".. function:: random_unit_vector(size=3)\n"
296  "\n"
297  " Returns a unit vector with random entries.\n"
298  "\n"
299  " :arg size: The size of the vector to be produced, in the range [2, 4].\n"
300  " :type size: int\n"
301  " :return: The random unit vector.\n"
302  " :rtype: :class:`mathutils.Vector`\n");
303 static PyObject *M_Noise_random_unit_vector(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
304 {
305  static const char *kwlist[] = {"size", NULL};
306  float vec[4] = {0.0f, 0.0f, 0.0f, 0.0f};
307  float norm = 2.0f;
308  int vec_num = 3;
309 
310  if (!PyArg_ParseTupleAndKeywords(
311  args, kw, "|$i:random_unit_vector", (char **)kwlist, &vec_num)) {
312  return NULL;
313  }
314 
315  if (vec_num > 4 || vec_num < 2) {
316  PyErr_SetString(PyExc_ValueError, "Vector(): invalid size");
317  return NULL;
318  }
319 
320  while (norm == 0.0f || norm > 1.0f) {
321  rand_vn(vec, vec_num);
322  norm = normalize_vn(vec, vec_num);
323  }
324 
325  return Vector_CreatePyObject(vec, vec_num, NULL);
326 }
327 
328 PyDoc_STRVAR(M_Noise_random_vector_doc,
329  ".. function:: random_vector(size=3)\n"
330  "\n"
331  " Returns a vector with random entries in the range (-1, 1).\n"
332  "\n"
333  " :arg size: The size of the vector to be produced.\n"
334  " :type size: int\n"
335  " :return: The random vector.\n"
336  " :rtype: :class:`mathutils.Vector`\n");
337 static PyObject *M_Noise_random_vector(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
338 {
339  static const char *kwlist[] = {"size", NULL};
340  float *vec = NULL;
341  int vec_num = 3;
342 
343  if (!PyArg_ParseTupleAndKeywords(args, kw, "|$i:random_vector", (char **)kwlist, &vec_num)) {
344  return NULL;
345  }
346 
347  if (vec_num < 2) {
348  PyErr_SetString(PyExc_ValueError, "Vector(): invalid size");
349  return NULL;
350  }
351 
352  vec = PyMem_New(float, vec_num);
353 
354  rand_vn(vec, vec_num);
355 
356  return Vector_CreatePyObject_alloc(vec, vec_num, NULL);
357 }
358 
359 PyDoc_STRVAR(M_Noise_seed_set_doc,
360  ".. function:: seed_set(seed)\n"
361  "\n"
362  " Sets the random seed used for random_unit_vector, and random.\n"
363  "\n"
364  " :arg seed: Seed used for the random generator.\n"
365  " When seed is zero, the current time will be used instead.\n"
366  " :type seed: int\n");
367 static PyObject *M_Noise_seed_set(PyObject *UNUSED(self), PyObject *args)
368 {
369  int s;
370  if (!PyArg_ParseTuple(args, "i:seed_set", &s)) {
371  return NULL;
372  }
373  setRndSeed(s);
374  Py_RETURN_NONE;
375 }
376 
377 PyDoc_STRVAR(M_Noise_noise_doc,
378  ".. function:: noise(position, noise_basis='PERLIN_ORIGINAL')\n"
379  "\n"
380  " Returns noise value from the noise basis at the position specified.\n"
381  "\n"
382  " :arg position: The position to evaluate the selected noise function.\n"
383  " :type position: :class:`mathutils.Vector`\n" BPY_NOISE_BASIS_ENUM_DOC
384  " :return: The noise value.\n"
385  " :rtype: float\n");
386 static PyObject *M_Noise_noise(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
387 {
388  static const char *kwlist[] = {"", "noise_basis", NULL};
389  PyObject *value;
390  float vec[3];
391  const char *noise_basis_str = NULL;
392  int noise_basis_enum = DEFAULT_NOISE_TYPE;
393 
394  if (!PyArg_ParseTupleAndKeywords(
395  args, kw, "O|$s:noise", (char **)kwlist, &value, &noise_basis_str)) {
396  return NULL;
397  }
398 
399  if (!noise_basis_str) {
400  /* pass through */
401  }
402  else if (PyC_FlagSet_ValueFromID(bpy_noise_types, noise_basis_str, &noise_basis_enum, "noise") ==
403  -1) {
404  return NULL;
405  }
406 
407  if (mathutils_array_parse(vec, 3, 3, value, "noise: invalid 'position' arg") == -1) {
408  return NULL;
409  }
410 
411  return PyFloat_FromDouble(
412  (2.0f * BLI_noise_generic_noise(1.0f, vec[0], vec[1], vec[2], false, noise_basis_enum) -
413  1.0f));
414 }
415 
416 PyDoc_STRVAR(M_Noise_noise_vector_doc,
417  ".. function:: noise_vector(position, noise_basis='PERLIN_ORIGINAL')\n"
418  "\n"
419  " Returns the noise vector from the noise basis at the specified position.\n"
420  "\n"
421  " :arg position: The position to evaluate the selected noise function.\n"
422  " :type position: :class:`mathutils.Vector`\n" BPY_NOISE_BASIS_ENUM_DOC
423  " :return: The noise vector.\n"
424  " :rtype: :class:`mathutils.Vector`\n");
425 static PyObject *M_Noise_noise_vector(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
426 {
427  static const char *kwlist[] = {"", "noise_basis", NULL};
428  PyObject *value;
429  float vec[3], r_vec[3];
430  const char *noise_basis_str = NULL;
431  int noise_basis_enum = DEFAULT_NOISE_TYPE;
432 
433  if (!PyArg_ParseTupleAndKeywords(
434  args, kw, "O|$s:noise_vector", (char **)kwlist, &value, &noise_basis_str)) {
435  return NULL;
436  }
437 
438  if (!noise_basis_str) {
439  /* pass through */
440  }
441  else if (PyC_FlagSet_ValueFromID(
442  bpy_noise_types, noise_basis_str, &noise_basis_enum, "noise_vector") == -1) {
443  return NULL;
444  }
445 
446  if (mathutils_array_parse(vec, 3, 3, value, "noise_vector: invalid 'position' arg") == -1) {
447  return NULL;
448  }
449 
450  noise_vector(vec[0], vec[1], vec[2], noise_basis_enum, r_vec);
451 
452  return Vector_CreatePyObject(r_vec, 3, NULL);
453 }
454 
455 PyDoc_STRVAR(M_Noise_turbulence_doc,
456  ".. function:: turbulence(position, octaves, hard, noise_basis='PERLIN_ORIGINAL', "
457  "amplitude_scale=0.5, frequency_scale=2.0)\n"
458  "\n"
459  " Returns the turbulence value from the noise basis at the specified position.\n"
460  "\n"
461  " :arg position: The position to evaluate the selected noise function.\n"
462  " :type position: :class:`mathutils.Vector`\n"
463  " :arg octaves: The number of different noise frequencies used.\n"
464  " :type octaves: int\n"
465  " :arg hard: Specifies whether returned turbulence is hard (sharp transitions) or "
466  "soft (smooth transitions).\n"
467  " :type hard: boolean\n" BPY_NOISE_BASIS_ENUM_DOC
468  " :arg amplitude_scale: The amplitude scaling factor.\n"
469  " :type amplitude_scale: float\n"
470  " :arg frequency_scale: The frequency scaling factor\n"
471  " :type frequency_scale: float\n"
472  " :return: The turbulence value.\n"
473  " :rtype: float\n");
474 static PyObject *M_Noise_turbulence(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
475 {
476  static const char *kwlist[] = {
477  "", "", "", "noise_basis", "amplitude_scale", "frequency_scale", NULL};
478  PyObject *value;
479  float vec[3];
480  const char *noise_basis_str = NULL;
481  int oct, hd, noise_basis_enum = DEFAULT_NOISE_TYPE;
482  float as = 0.5f, fs = 2.0f;
483 
484  if (!PyArg_ParseTupleAndKeywords(args,
485  kw,
486  "Oii|$sff:turbulence",
487  (char **)kwlist,
488  &value,
489  &oct,
490  &hd,
491  &noise_basis_str,
492  &as,
493  &fs)) {
494  return NULL;
495  }
496 
497  if (!noise_basis_str) {
498  /* pass through */
499  }
500  else if (PyC_FlagSet_ValueFromID(
501  bpy_noise_types, noise_basis_str, &noise_basis_enum, "turbulence") == -1) {
502  return NULL;
503  }
504 
505  if (mathutils_array_parse(vec, 3, 3, value, "turbulence: invalid 'position' arg") == -1) {
506  return NULL;
507  }
508 
509  return PyFloat_FromDouble(turb(vec[0], vec[1], vec[2], oct, hd, noise_basis_enum, as, fs));
510 }
511 
512 PyDoc_STRVAR(M_Noise_turbulence_vector_doc,
513  ".. function:: turbulence_vector(position, octaves, hard, "
514  "noise_basis='PERLIN_ORIGINAL', amplitude_scale=0.5, frequency_scale=2.0)\n"
515  "\n"
516  " Returns the turbulence vector from the noise basis at the specified position.\n"
517  "\n"
518  " :arg position: The position to evaluate the selected noise function.\n"
519  " :type position: :class:`mathutils.Vector`\n"
520  " :arg octaves: The number of different noise frequencies used.\n"
521  " :type octaves: int\n"
522  " :arg hard: Specifies whether returned turbulence is hard (sharp transitions) or "
523  "soft (smooth transitions).\n"
524  " :type hard: boolean\n" BPY_NOISE_BASIS_ENUM_DOC
525  " :arg amplitude_scale: The amplitude scaling factor.\n"
526  " :type amplitude_scale: float\n"
527  " :arg frequency_scale: The frequency scaling factor\n"
528  " :type frequency_scale: float\n"
529  " :return: The turbulence vector.\n"
530  " :rtype: :class:`mathutils.Vector`\n");
531 static PyObject *M_Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
532 {
533  static const char *kwlist[] = {
534  "", "", "", "noise_basis", "amplitude_scale", "frequency_scale", NULL};
535  PyObject *value;
536  float vec[3], r_vec[3];
537  const char *noise_basis_str = NULL;
538  int oct, hd, noise_basis_enum = DEFAULT_NOISE_TYPE;
539  float as = 0.5f, fs = 2.0f;
540 
541  if (!PyArg_ParseTupleAndKeywords(args,
542  kw,
543  "Oii|$sff:turbulence_vector",
544  (char **)kwlist,
545  &value,
546  &oct,
547  &hd,
548  &noise_basis_str,
549  &as,
550  &fs)) {
551  return NULL;
552  }
553 
554  if (!noise_basis_str) {
555  /* pass through */
556  }
557  else if (PyC_FlagSet_ValueFromID(
558  bpy_noise_types, noise_basis_str, &noise_basis_enum, "turbulence_vector") == -1) {
559  return NULL;
560  }
561 
562  if (mathutils_array_parse(vec, 3, 3, value, "turbulence_vector: invalid 'position' arg") == -1) {
563  return NULL;
564  }
565 
566  vTurb(vec[0], vec[1], vec[2], oct, hd, noise_basis_enum, as, fs, r_vec);
567 
568  return Vector_CreatePyObject(r_vec, 3, NULL);
569 }
570 
571 /* F. Kenton Musgrave's fractal functions */
573  M_Noise_fractal_doc,
574  ".. function:: fractal(position, H, lacunarity, octaves, noise_basis='PERLIN_ORIGINAL')\n"
575  "\n"
576  " Returns the fractal Brownian motion (fBm) noise value from the noise basis at the "
577  "specified position.\n"
578  "\n"
579  " :arg position: The position to evaluate the selected noise function.\n"
580  " :type position: :class:`mathutils.Vector`\n"
581  " :arg H: The fractal increment factor.\n"
582  " :type H: float\n"
583  " :arg lacunarity: The gap between successive frequencies.\n"
584  " :type lacunarity: float\n"
585  " :arg octaves: The number of different noise frequencies used.\n"
586  " :type octaves: int\n" BPY_NOISE_BASIS_ENUM_DOC
587  " :return: The fractal Brownian motion noise value.\n"
588  " :rtype: float\n");
589 static PyObject *M_Noise_fractal(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
590 {
591  static const char *kwlist[] = {"", "", "", "", "noise_basis", NULL};
592  PyObject *value;
593  float vec[3];
594  const char *noise_basis_str = NULL;
595  float H, lac, oct;
596  int noise_basis_enum = DEFAULT_NOISE_TYPE;
597 
598  if (!PyArg_ParseTupleAndKeywords(args,
599  kw,
600  "Offf|$s:fractal",
601  (char **)kwlist,
602  &value,
603  &H,
604  &lac,
605  &oct,
606  &noise_basis_str)) {
607  return NULL;
608  }
609 
610  if (!noise_basis_str) {
611  /* pass through */
612  }
613  else if (PyC_FlagSet_ValueFromID(
614  bpy_noise_types, noise_basis_str, &noise_basis_enum, "fractal") == -1) {
615  return NULL;
616  }
617 
618  if (mathutils_array_parse(vec, 3, 3, value, "fractal: invalid 'position' arg") == -1) {
619  return NULL;
620  }
621 
622  return PyFloat_FromDouble(
623  BLI_noise_mg_fbm(vec[0], vec[1], vec[2], H, lac, oct, noise_basis_enum));
624 }
625 
627  M_Noise_multi_fractal_doc,
628  ".. function:: multi_fractal(position, H, lacunarity, octaves, "
629  "noise_basis='PERLIN_ORIGINAL')\n"
630  "\n"
631  " Returns multifractal noise value from the noise basis at the specified position.\n"
632  "\n"
633  " :arg position: The position to evaluate the selected noise function.\n"
634  " :type position: :class:`mathutils.Vector`\n"
635  " :arg H: The fractal increment factor.\n"
636  " :type H: float\n"
637  " :arg lacunarity: The gap between successive frequencies.\n"
638  " :type lacunarity: float\n"
639  " :arg octaves: The number of different noise frequencies used.\n"
640  " :type octaves: int\n" BPY_NOISE_BASIS_ENUM_DOC
641  " :return: The multifractal noise value.\n"
642  " :rtype: float\n");
643 static PyObject *M_Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
644 {
645  static const char *kwlist[] = {"", "", "", "", "noise_basis", NULL};
646  PyObject *value;
647  float vec[3];
648  const char *noise_basis_str = NULL;
649  float H, lac, oct;
650  int noise_basis_enum = DEFAULT_NOISE_TYPE;
651 
652  if (!PyArg_ParseTupleAndKeywords(args,
653  kw,
654  "Offf|$s:multi_fractal",
655  (char **)kwlist,
656  &value,
657  &H,
658  &lac,
659  &oct,
660  &noise_basis_str)) {
661  return NULL;
662  }
663 
664  if (!noise_basis_str) {
665  /* pass through */
666  }
667  else if (PyC_FlagSet_ValueFromID(
668  bpy_noise_types, noise_basis_str, &noise_basis_enum, "multi_fractal") == -1) {
669  return NULL;
670  }
671 
672  if (mathutils_array_parse(vec, 3, 3, value, "multi_fractal: invalid 'position' arg") == -1) {
673  return NULL;
674  }
675 
676  return PyFloat_FromDouble(
677  BLI_noise_mg_multi_fractal(vec[0], vec[1], vec[2], H, lac, oct, noise_basis_enum));
678 }
679 
680 PyDoc_STRVAR(M_Noise_variable_lacunarity_doc,
681  ".. function:: variable_lacunarity(position, distortion, "
682  "noise_type1='PERLIN_ORIGINAL', noise_type2='PERLIN_ORIGINAL')\n"
683  "\n"
684  " Returns variable lacunarity noise value, a distorted variety of noise, from "
685  "noise type 1 distorted by noise type 2 at the specified position.\n"
686  "\n"
687  " :arg position: The position to evaluate the selected noise function.\n"
688  " :type position: :class:`mathutils.Vector`\n"
689  " :arg distortion: The amount of distortion.\n"
690  " :type distortion: float\n"
691  " :arg noise_type1: Enumerator in ['BLENDER', 'PERLIN_ORIGINAL', 'PERLIN_NEW', "
692  "'VORONOI_F1', 'VORONOI_F2', "
693  "'VORONOI_F3', 'VORONOI_F4', 'VORONOI_F2F1', 'VORONOI_CRACKLE', "
694  "'CELLNOISE'].\n"
695  " :type noise_type1: string\n"
696  " :arg noise_type2: Enumerator in ['BLENDER', 'PERLIN_ORIGINAL', 'PERLIN_NEW', "
697  "'VORONOI_F1', 'VORONOI_F2', "
698  "'VORONOI_F3', 'VORONOI_F4', 'VORONOI_F2F1', 'VORONOI_CRACKLE', "
699  "'CELLNOISE'].\n"
700  " :type noise_type2: string\n"
701  " :return: The variable lacunarity noise value.\n"
702  " :rtype: float\n");
703 static PyObject *M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
704 {
705  static const char *kwlist[] = {"", "", "noise_type1", "noise_type2", NULL};
706  PyObject *value;
707  float vec[3];
708  const char *noise_type1_str = NULL, *noise_type2_str = NULL;
709  float d;
710  int noise_type1_enum = DEFAULT_NOISE_TYPE, noise_type2_enum = DEFAULT_NOISE_TYPE;
711 
712  if (!PyArg_ParseTupleAndKeywords(args,
713  kw,
714  "Of|$ss:variable_lacunarity",
715  (char **)kwlist,
716  &value,
717  &d,
718  &noise_type1_str,
719  &noise_type2_str)) {
720  return NULL;
721  }
722 
723  if (!noise_type1_str) {
724  /* pass through */
725  }
726  else if (PyC_FlagSet_ValueFromID(
727  bpy_noise_types, noise_type1_str, &noise_type1_enum, "variable_lacunarity") == -1) {
728  return NULL;
729  }
730 
731  if (!noise_type2_str) {
732  /* pass through */
733  }
734  else if (PyC_FlagSet_ValueFromID(
735  bpy_noise_types, noise_type2_str, &noise_type2_enum, "variable_lacunarity") == -1) {
736  return NULL;
737  }
738 
739  if (mathutils_array_parse(vec, 3, 3, value, "variable_lacunarity: invalid 'position' arg") ==
740  -1) {
741  return NULL;
742  }
743 
744  return PyFloat_FromDouble(BLI_noise_mg_variable_lacunarity(
745  vec[0], vec[1], vec[2], d, noise_type1_enum, noise_type2_enum));
746 }
747 
749  M_Noise_hetero_terrain_doc,
750  ".. function:: hetero_terrain(position, H, lacunarity, octaves, offset, "
751  "noise_basis='PERLIN_ORIGINAL')\n"
752  "\n"
753  " Returns the heterogeneous terrain value from the noise basis at the specified position.\n"
754  "\n"
755  " :arg position: The position to evaluate the selected noise function.\n"
756  " :type position: :class:`mathutils.Vector`\n"
757  " :arg H: The fractal dimension of the roughest areas.\n"
758  " :type H: float\n"
759  " :arg lacunarity: The gap between successive frequencies.\n"
760  " :type lacunarity: float\n"
761  " :arg octaves: The number of different noise frequencies used.\n"
762  " :type octaves: int\n"
763  " :arg offset: The height of the terrain above 'sea level'.\n"
764  " :type offset: float\n" BPY_NOISE_BASIS_ENUM_DOC
765  " :return: The heterogeneous terrain value.\n"
766  " :rtype: float\n");
767 static PyObject *M_Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
768 {
769  static const char *kwlist[] = {"", "", "", "", "", "noise_basis", NULL};
770  PyObject *value;
771  float vec[3];
772  const char *noise_basis_str = NULL;
773  float H, lac, oct, ofs;
774  int noise_basis_enum = DEFAULT_NOISE_TYPE;
775 
776  if (!PyArg_ParseTupleAndKeywords(args,
777  kw,
778  "Offff|$s:hetero_terrain",
779  (char **)kwlist,
780  &value,
781  &H,
782  &lac,
783  &oct,
784  &ofs,
785  &noise_basis_str)) {
786  return NULL;
787  }
788 
789  if (!noise_basis_str) {
790  /* pass through */
791  }
792  else if (PyC_FlagSet_ValueFromID(
793  bpy_noise_types, noise_basis_str, &noise_basis_enum, "hetero_terrain") == -1) {
794  return NULL;
795  }
796 
797  if (mathutils_array_parse(vec, 3, 3, value, "hetero_terrain: invalid 'position' arg") == -1) {
798  return NULL;
799  }
800 
801  return PyFloat_FromDouble(
802  BLI_noise_mg_hetero_terrain(vec[0], vec[1], vec[2], H, lac, oct, ofs, noise_basis_enum));
803 }
804 
806  M_Noise_hybrid_multi_fractal_doc,
807  ".. function:: hybrid_multi_fractal(position, H, lacunarity, octaves, offset, gain, "
808  "noise_basis='PERLIN_ORIGINAL')\n"
809  "\n"
810  " Returns hybrid multifractal value from the noise basis at the specified position.\n"
811  "\n"
812  " :arg position: The position to evaluate the selected noise function.\n"
813  " :type position: :class:`mathutils.Vector`\n"
814  " :arg H: The fractal dimension of the roughest areas.\n"
815  " :type H: float\n"
816  " :arg lacunarity: The gap between successive frequencies.\n"
817  " :type lacunarity: float\n"
818  " :arg octaves: The number of different noise frequencies used.\n"
819  " :type octaves: int\n"
820  " :arg offset: The height of the terrain above 'sea level'.\n"
821  " :type offset: float\n"
822  " :arg gain: Scaling applied to the values.\n"
823  " :type gain: float\n" BPY_NOISE_BASIS_ENUM_DOC
824  " :return: The hybrid multifractal value.\n"
825  " :rtype: float\n");
826 static PyObject *M_Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
827 {
828  static const char *kwlist[] = {"", "", "", "", "", "", "noise_basis", NULL};
829  PyObject *value;
830  float vec[3];
831  const char *noise_basis_str = NULL;
832  float H, lac, oct, ofs, gn;
833  int noise_basis_enum = DEFAULT_NOISE_TYPE;
834 
835  if (!PyArg_ParseTupleAndKeywords(args,
836  kw,
837  "Offfff|$s:hybrid_multi_fractal",
838  (char **)kwlist,
839  &value,
840  &H,
841  &lac,
842  &oct,
843  &ofs,
844  &gn,
845  &noise_basis_str)) {
846  return NULL;
847  }
848 
849  if (!noise_basis_str) {
850  /* pass through */
851  }
852  else if (PyC_FlagSet_ValueFromID(
853  bpy_noise_types, noise_basis_str, &noise_basis_enum, "hybrid_multi_fractal") ==
854  -1) {
855  return NULL;
856  }
857 
858  if (mathutils_array_parse(vec, 3, 3, value, "hybrid_multi_fractal: invalid 'position' arg") ==
859  -1) {
860  return NULL;
861  }
862 
863  return PyFloat_FromDouble(BLI_noise_mg_hybrid_multi_fractal(
864  vec[0], vec[1], vec[2], H, lac, oct, ofs, gn, noise_basis_enum));
865 }
866 
868  M_Noise_ridged_multi_fractal_doc,
869  ".. function:: ridged_multi_fractal(position, H, lacunarity, octaves, offset, gain, "
870  "noise_basis='PERLIN_ORIGINAL')\n"
871  "\n"
872  " Returns ridged multifractal value from the noise basis at the specified position.\n"
873  "\n"
874  " :arg position: The position to evaluate the selected noise function.\n"
875  " :type position: :class:`mathutils.Vector`\n"
876  " :arg H: The fractal dimension of the roughest areas.\n"
877  " :type H: float\n"
878  " :arg lacunarity: The gap between successive frequencies.\n"
879  " :type lacunarity: float\n"
880  " :arg octaves: The number of different noise frequencies used.\n"
881  " :type octaves: int\n"
882  " :arg offset: The height of the terrain above 'sea level'.\n"
883  " :type offset: float\n"
884  " :arg gain: Scaling applied to the values.\n"
885  " :type gain: float\n" BPY_NOISE_BASIS_ENUM_DOC
886  " :return: The ridged multifractal value.\n"
887  " :rtype: float\n");
888 static PyObject *M_Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
889 {
890  static const char *kwlist[] = {"", "", "", "", "", "", "noise_basis", NULL};
891  PyObject *value;
892  float vec[3];
893  const char *noise_basis_str = NULL;
894  float H, lac, oct, ofs, gn;
895  int noise_basis_enum = DEFAULT_NOISE_TYPE;
896 
897  if (!PyArg_ParseTupleAndKeywords(args,
898  kw,
899  "Offfff|$s:ridged_multi_fractal",
900  (char **)kwlist,
901  &value,
902  &H,
903  &lac,
904  &oct,
905  &ofs,
906  &gn,
907  &noise_basis_str)) {
908  return NULL;
909  }
910 
911  if (!noise_basis_str) {
912  /* pass through */
913  }
914  else if (PyC_FlagSet_ValueFromID(
915  bpy_noise_types, noise_basis_str, &noise_basis_enum, "ridged_multi_fractal") ==
916  -1) {
917  return NULL;
918  }
919 
920  if (mathutils_array_parse(vec, 3, 3, value, "ridged_multi_fractal: invalid 'position' arg") ==
921  -1) {
922  return NULL;
923  }
924 
925  return PyFloat_FromDouble(BLI_noise_mg_ridged_multi_fractal(
926  vec[0], vec[1], vec[2], H, lac, oct, ofs, gn, noise_basis_enum));
927 }
928 
929 PyDoc_STRVAR(M_Noise_voronoi_doc,
930  ".. function:: voronoi(position, distance_metric='DISTANCE', exponent=2.5)\n"
931  "\n"
932  " Returns a list of distances to the four closest features and their locations.\n"
933  "\n"
934  " :arg position: The position to evaluate the selected noise function.\n"
935  " :type position: :class:`mathutils.Vector`\n" BPY_NOISE_METRIC_ENUM_DOC
936  " :arg exponent: The exponent for Minkowski distance metric.\n"
937  " :type exponent: float\n"
938  " :return: A list of distances to the four closest features and their locations.\n"
939  " :rtype: list of four floats, list of four :class:`mathutils.Vector` types\n");
940 static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
941 {
942  static const char *kwlist[] = {"", "distance_metric", "exponent", NULL};
943  PyObject *value;
944  PyObject *list;
945  PyObject *ret;
946  float vec[3];
947  const char *metric_str = NULL;
948  float da[4], pa[12];
949  int metric_enum = DEFAULT_METRIC_TYPE;
950  float me = 2.5f; /* default minkowski exponent */
951 
952  int i;
953 
954  if (!PyArg_ParseTupleAndKeywords(
955  args, kw, "O|$sf:voronoi", (char **)kwlist, &value, &metric_str, &me)) {
956  return NULL;
957  }
958 
959  if (!metric_str) {
960  /* pass through */
961  }
962  else if (PyC_FlagSet_ValueFromID(bpy_noise_metrics, metric_str, &metric_enum, "voronoi") == -1) {
963  return NULL;
964  }
965 
966  if (mathutils_array_parse(vec, 3, 3, value, "voronoi: invalid 'position' arg") == -1) {
967  return NULL;
968  }
969 
970  list = PyList_New(4);
971 
972  BLI_noise_voronoi(vec[0], vec[1], vec[2], da, pa, me, metric_enum);
973 
974  for (i = 0; i < 4; i++) {
975  PyObject *v = Vector_CreatePyObject(pa + 3 * i, 3, NULL);
976  PyList_SET_ITEM(list, i, v);
977  }
978 
979  ret = Py_BuildValue("[[ffff]O]", da[0], da[1], da[2], da[3], list);
980  Py_DECREF(list);
981  return ret;
982 }
983 
984 PyDoc_STRVAR(M_Noise_cell_doc,
985  ".. function:: cell(position)\n"
986  "\n"
987  " Returns cell noise value at the specified position.\n"
988  "\n"
989  " :arg position: The position to evaluate the selected noise function.\n"
990  " :type position: :class:`mathutils.Vector`\n"
991  " :return: The cell noise value.\n"
992  " :rtype: float\n");
993 static PyObject *M_Noise_cell(PyObject *UNUSED(self), PyObject *args)
994 {
995  PyObject *value;
996  float vec[3];
997 
998  if (!PyArg_ParseTuple(args, "O:cell", &value)) {
999  return NULL;
1000  }
1001 
1002  if (mathutils_array_parse(vec, 3, 3, value, "cell: invalid 'position' arg") == -1) {
1003  return NULL;
1004  }
1005 
1006  return PyFloat_FromDouble(BLI_noise_cell(vec[0], vec[1], vec[2]));
1007 }
1008 
1009 PyDoc_STRVAR(M_Noise_cell_vector_doc,
1010  ".. function:: cell_vector(position)\n"
1011  "\n"
1012  " Returns cell noise vector at the specified position.\n"
1013  "\n"
1014  " :arg position: The position to evaluate the selected noise function.\n"
1015  " :type position: :class:`mathutils.Vector`\n"
1016  " :return: The cell noise vector.\n"
1017  " :rtype: :class:`mathutils.Vector`\n");
1018 static PyObject *M_Noise_cell_vector(PyObject *UNUSED(self), PyObject *args)
1019 {
1020  PyObject *value;
1021  float vec[3], r_vec[3];
1022 
1023  if (!PyArg_ParseTuple(args, "O:cell_vector", &value)) {
1024  return NULL;
1025  }
1026 
1027  if (mathutils_array_parse(vec, 3, 3, value, "cell_vector: invalid 'position' arg") == -1) {
1028  return NULL;
1029  }
1030 
1031  BLI_noise_cell_v3(vec[0], vec[1], vec[2], r_vec);
1032  return Vector_CreatePyObject(r_vec, 3, NULL);
1033 }
1034 
1035 static PyMethodDef M_Noise_methods[] = {
1036  {"seed_set", (PyCFunction)M_Noise_seed_set, METH_VARARGS, M_Noise_seed_set_doc},
1037  {"random", (PyCFunction)M_Noise_random, METH_NOARGS, M_Noise_random_doc},
1038  {"random_unit_vector",
1039  (PyCFunction)M_Noise_random_unit_vector,
1040  METH_VARARGS | METH_KEYWORDS,
1041  M_Noise_random_unit_vector_doc},
1042  {"random_vector",
1043  (PyCFunction)M_Noise_random_vector,
1044  METH_VARARGS | METH_KEYWORDS,
1045  M_Noise_random_vector_doc},
1046  {"noise", (PyCFunction)M_Noise_noise, METH_VARARGS | METH_KEYWORDS, M_Noise_noise_doc},
1047  {"noise_vector",
1048  (PyCFunction)M_Noise_noise_vector,
1049  METH_VARARGS | METH_KEYWORDS,
1050  M_Noise_noise_vector_doc},
1051  {"turbulence",
1052  (PyCFunction)M_Noise_turbulence,
1053  METH_VARARGS | METH_KEYWORDS,
1054  M_Noise_turbulence_doc},
1055  {"turbulence_vector",
1056  (PyCFunction)M_Noise_turbulence_vector,
1057  METH_VARARGS | METH_KEYWORDS,
1058  M_Noise_turbulence_vector_doc},
1059  {"fractal", (PyCFunction)M_Noise_fractal, METH_VARARGS | METH_KEYWORDS, M_Noise_fractal_doc},
1060  {"multi_fractal",
1061  (PyCFunction)M_Noise_multi_fractal,
1062  METH_VARARGS | METH_KEYWORDS,
1063  M_Noise_multi_fractal_doc},
1064  {"variable_lacunarity",
1065  (PyCFunction)M_Noise_variable_lacunarity,
1066  METH_VARARGS | METH_KEYWORDS,
1067  M_Noise_variable_lacunarity_doc},
1068  {"hetero_terrain",
1069  (PyCFunction)M_Noise_hetero_terrain,
1070  METH_VARARGS | METH_KEYWORDS,
1071  M_Noise_hetero_terrain_doc},
1072  {"hybrid_multi_fractal",
1073  (PyCFunction)M_Noise_hybrid_multi_fractal,
1074  METH_VARARGS | METH_KEYWORDS,
1075  M_Noise_hybrid_multi_fractal_doc},
1076  {"ridged_multi_fractal",
1077  (PyCFunction)M_Noise_ridged_multi_fractal,
1078  METH_VARARGS | METH_KEYWORDS,
1079  M_Noise_ridged_multi_fractal_doc},
1080  {"voronoi", (PyCFunction)M_Noise_voronoi, METH_VARARGS | METH_KEYWORDS, M_Noise_voronoi_doc},
1081  {"cell", (PyCFunction)M_Noise_cell, METH_VARARGS, M_Noise_cell_doc},
1082  {"cell_vector", (PyCFunction)M_Noise_cell_vector, METH_VARARGS, M_Noise_cell_vector_doc},
1083  {NULL, NULL, 0, NULL},
1084 };
1085 
1086 static struct PyModuleDef M_Noise_module_def = {
1087  PyModuleDef_HEAD_INIT,
1088  "mathutils.noise", /* m_name */
1089  M_Noise_doc, /* m_doc */
1090  0, /* m_size */
1091  M_Noise_methods, /* m_methods */
1092  NULL, /* m_reload */
1093  NULL, /* m_traverse */
1094  NULL, /* m_clear */
1095  NULL, /* m_free */
1096 };
1097 
1098 /*----------------------------MODULE INIT-------------------------*/
1099 PyMODINIT_FUNC PyInit_mathutils_noise(void)
1100 {
1101  PyObject *submodule = PyModule_Create(&M_Noise_module_def);
1102 
1103  /* use current time as seed for random number generator by default */
1104  setRndSeed(0);
1105 
1106  return submodule;
1107 }
typedef float(TangentPoint)[2]
float normalize_vn(float *array_tar, int size)
Definition: math_vector.c:1016
float BLI_noise_mg_hetero_terrain(float x, float y, float z, float H, float lacunarity, float octaves, float offset, int noisebasis)
Definition: noise.c:1388
float BLI_noise_mg_multi_fractal(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
Definition: noise.c:1329
float BLI_noise_mg_ridged_multi_fractal(float x, float y, float z, float H, float lacunarity, float octaves, float offset, float gain, int noisebasis)
Definition: noise.c:1534
float BLI_noise_mg_variable_lacunarity(float x, float y, float z, float distortion, int nbas1, int nbas2)
Definition: noise.c:1605
float BLI_noise_cell(float x, float y, float z)
Definition: noise.c:1123
float BLI_noise_generic_noise(float noisesize, float x, float y, float z, bool hard, int noisebasis)
Definition: noise.c:1150
void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype)
Definition: noise.c:914
float BLI_noise_mg_fbm(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
Definition: noise.c:1269
void BLI_noise_cell_v3(float x, float y, float z, float r_ca[3])
Definition: noise.c:1128
float BLI_noise_mg_hybrid_multi_fractal(float x, float y, float z, float H, float lacunarity, float octaves, float offset, float gain, int noisebasis)
Definition: noise.c:1458
unsigned long ulong
Definition: BLI_sys_types.h:69
#define ARRAY_SIZE(arr)
#define UNUSED(x)
#define TEX_BLENDER
#define TEX_MINKOVSKY_FOUR
#define TEX_DISTANCE_SQUARED
#define TEX_MINKOVSKY_HALF
#define TEX_STDPERLIN
#define TEX_MINKOVSKY
#define TEX_DISTANCE
#define TEX_VORONOI_CRACKLE
#define TEX_VORONOI_F2F1
#define TEX_VORONOI_F4
#define TEX_VORONOI_F3
#define TEX_NEWPERLIN
#define TEX_CELLNOISE
#define TEX_MANHATTAN
#define TEX_CHEBYCHEV
#define TEX_VORONOI_F1
#define TEX_VORONOI_F2
_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 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 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 t
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
static unsigned long seed
Definition: btSoftBody.h:39
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
Definition: btVector3.h:263
double time
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
Definition: mathutils.c:98
PyObject * Vector_CreatePyObject_alloc(float *vec, const int vec_num, PyTypeObject *base_type)
PyObject * Vector_CreatePyObject(const float *vec, const int vec_num, PyTypeObject *base_type)
#define N
#define TWIST(u, v)
static PyObject * M_Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static float state_offset_vector[3 *3]
static ulong * next
static PyObject * M_Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
#define BPY_NOISE_BASIS_ENUM_DOC
static void setRndSeed(int seed)
static PyObject * M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
#define DEFAULT_METRIC_TYPE
static void vTurb(float x, float y, float z, int oct, int hard, int nb, float ampscale, float freqscale, float v[3])
#define M
#define BPY_NOISE_METRIC_ENUM_DOC
PyDoc_STRVAR(M_Noise_doc, "The Blender noise module")
static PyObject * M_Noise_random_unit_vector(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static void next_state(void)
static PyObject * M_Noise_fractal(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static PyObject * M_Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static PyObject * M_Noise_random_vector(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static PyObject * M_Noise_turbulence(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static PyObject * M_Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static PyObject * M_Noise_random(PyObject *UNUSED(self))
static void noise_vector(float x, float y, float z, int nb, float v[3])
static ulong state[N]
static PyObject * M_Noise_noise(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
#define DEFAULT_NOISE_TYPE
static PyObject * M_Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static float turb(float x, float y, float z, int oct, int hard, int nb, float ampscale, float freqscale)
static PyC_FlagSet bpy_noise_types[]
static PyObject * M_Noise_seed_set(PyObject *UNUSED(self), PyObject *args)
static void init_genrand(ulong s)
static void rand_vn(float *array_tar, const int size)
static PyObject * M_Noise_noise_vector(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static int left
static float frand(void)
static PyObject * M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static int initf
static PyC_FlagSet bpy_noise_metrics[]
PyMODINIT_FUNC PyInit_mathutils_noise(void)
#define H(x, y, z)
#define fabsf(x)
Definition: metal/compat.h:219
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
int PyC_FlagSet_ValueFromID(const PyC_FlagSet *item, const char *identifier, int *r_value, const char *error_prefix)
return ret