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