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