Blender V5.0
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
11
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: A noise basis string.\n" \
150 " :type noise_basis: Literal['BLENDER', 'PERLIN_ORIGINAL', 'PERLIN_NEW', " \
151 "'VORONOI_F1', 'VORONOI_F2', " \
152 "'VORONOI_F3', 'VORONOI_F4', 'VORONOI_F2F1', 'VORONOI_CRACKLE', " \
153 "'CELLNOISE'].\n"
154
155#define BPY_NOISE_METRIC_ENUM_DOC \
156 " :arg distance_metric: A distance metric string.\n" \
157 " :type distance_metric: Literal['DISTANCE', 'DISTANCE_SQUARED', 'MANHATTAN', " \
158 "'CHEBYCHEV', " \
159 "'MINKOVSKY', 'MINKOVSKY_HALF', 'MINKOVSKY_FOUR'].\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 = (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 = (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/*------------------------------------------------------------*/
278/* Python Functions */
279/*------------------------------------------------------------*/
280
282 /* Wrap. */
283 M_Noise_random_doc,
284 ".. function:: random()\n"
285 "\n"
286 " Returns a random number in the range [0, 1).\n"
287 "\n"
288 " :return: The random number.\n"
289 " :rtype: float\n");
290static PyObject *M_Noise_random(PyObject * /*self*/)
291{
292 return PyFloat_FromDouble(frand());
293}
294
296 /* Wrap. */
297 M_Noise_random_unit_vector_doc,
298 ".. function:: random_unit_vector(*, size=3)\n"
299 "\n"
300 " Returns a unit vector with random entries.\n"
301 "\n"
302 " :arg size: The size of the vector to be produced, in the range [2, 4].\n"
303 " :type size: int\n"
304 " :return: The random unit vector.\n"
305 " :rtype: :class:`mathutils.Vector`\n");
306static PyObject *M_Noise_random_unit_vector(PyObject * /*self*/, PyObject *args, PyObject *kw)
307{
308 static const char *kwlist[] = {"size", nullptr};
309 float vec[4] = {0.0f, 0.0f, 0.0f, 0.0f};
310 float norm = 2.0f;
311 int vec_num = 3;
312
313 if (!PyArg_ParseTupleAndKeywords(args, kw, "|$i:random_unit_vector", (char **)kwlist, &vec_num))
314 {
315 return nullptr;
316 }
317
318 if (vec_num > 4 || vec_num < 2) {
319 PyErr_SetString(PyExc_ValueError, "Vector(): invalid size");
320 return nullptr;
321 }
322
323 while (norm == 0.0f || norm > 1.0f) {
324 rand_vn(vec, vec_num);
325 norm = normalize_vn(vec, vec_num);
326 }
327
328 return Vector_CreatePyObject(vec, vec_num, nullptr);
329}
330
332 /* Wrap. */
333 M_Noise_random_vector_doc,
334 ".. function:: random_vector(*, size=3)\n"
335 "\n"
336 " Returns a vector with random entries in the range (-1, 1).\n"
337 "\n"
338 " :arg size: The size of the vector to be produced.\n"
339 " :type size: int\n"
340 " :return: The random vector.\n"
341 " :rtype: :class:`mathutils.Vector`\n");
342static PyObject *M_Noise_random_vector(PyObject * /*self*/, PyObject *args, PyObject *kw)
343{
344 static const char *kwlist[] = {"size", nullptr};
345 float *vec = nullptr;
346 int vec_num = 3;
347
348 if (!PyArg_ParseTupleAndKeywords(args, kw, "|$i:random_vector", (char **)kwlist, &vec_num)) {
349 return nullptr;
350 }
351
352 if (vec_num < 2) {
353 PyErr_SetString(PyExc_ValueError, "Vector(): invalid size");
354 return nullptr;
355 }
356
357 vec = PyMem_New(float, vec_num);
358
359 rand_vn(vec, vec_num);
360
361 return Vector_CreatePyObject_alloc(vec, vec_num, nullptr);
362}
363
365 /* Wrap. */
366 M_Noise_seed_set_doc,
367 ".. function:: seed_set(seed, /)\n"
368 "\n"
369 " Sets the random seed used for random_unit_vector, and random.\n"
370 "\n"
371 " :arg seed: Seed used for the random generator.\n"
372 " When seed is zero, the current time will be used instead.\n"
373 " :type seed: int\n");
374static PyObject *M_Noise_seed_set(PyObject * /*self*/, PyObject *args)
375{
376 int s;
377 if (!PyArg_ParseTuple(args, "i:seed_set", &s)) {
378 return nullptr;
379 }
380 setRndSeed(s);
381 Py_RETURN_NONE;
382}
383
385 /* Wrap. */
386 M_Noise_noise_doc,
387 ".. function:: noise(position, /, *, noise_basis='PERLIN_ORIGINAL')\n"
388 "\n"
389 " Returns noise value from the noise basis at the position specified.\n"
390 "\n"
391 " :arg position: The position to evaluate the selected noise function.\n"
392 " :type position: :class:`mathutils.Vector`\n" BPY_NOISE_BASIS_ENUM_DOC
393 " :return: The noise value.\n"
394 " :rtype: float\n");
395static PyObject *M_Noise_noise(PyObject * /*self*/, PyObject *args, PyObject *kw)
396{
397 static const char *kwlist[] = {"", "noise_basis", nullptr};
398 PyObject *value;
399 float vec[3];
400 const char *noise_basis_str = nullptr;
401 int noise_basis_enum = DEFAULT_NOISE_TYPE;
402
403 if (!PyArg_ParseTupleAndKeywords(
404 args, kw, "O|$s:noise", (char **)kwlist, &value, &noise_basis_str))
405 {
406 return nullptr;
407 }
408
409 if (!noise_basis_str) {
410 /* pass through */
411 }
412 else if (PyC_FlagSet_ValueFromID(bpy_noise_types, noise_basis_str, &noise_basis_enum, "noise") ==
413 -1)
414 {
415 return nullptr;
416 }
417
418 if (mathutils_array_parse(vec, 3, 3, value, "noise: invalid 'position' arg") == -1) {
419 return nullptr;
420 }
421
422 return PyFloat_FromDouble(
423 (2.0f * BLI_noise_generic_noise(1.0f, vec[0], vec[1], vec[2], false, noise_basis_enum) -
424 1.0f));
425}
426
428 /* Wrap. */
429 M_Noise_noise_vector_doc,
430 ".. function:: noise_vector(position, /, *, noise_basis='PERLIN_ORIGINAL')\n"
431 "\n"
432 " Returns the noise vector from the noise basis at the specified position.\n"
433 "\n"
434 " :arg position: The position to evaluate the selected noise function.\n"
435 " :type position: :class:`mathutils.Vector`\n" BPY_NOISE_BASIS_ENUM_DOC
436 " :return: The noise vector.\n"
437 " :rtype: :class:`mathutils.Vector`\n");
438static PyObject *M_Noise_noise_vector(PyObject * /*self*/, PyObject *args, PyObject *kw)
439{
440 static const char *kwlist[] = {"", "noise_basis", nullptr};
441 PyObject *value;
442 float vec[3], r_vec[3];
443 const char *noise_basis_str = nullptr;
444 int noise_basis_enum = DEFAULT_NOISE_TYPE;
445
446 if (!PyArg_ParseTupleAndKeywords(
447 args, kw, "O|$s:noise_vector", (char **)kwlist, &value, &noise_basis_str))
448 {
449 return nullptr;
450 }
451
452 if (!noise_basis_str) {
453 /* pass through */
454 }
456 bpy_noise_types, noise_basis_str, &noise_basis_enum, "noise_vector") == -1)
457 {
458 return nullptr;
459 }
460
461 if (mathutils_array_parse(vec, 3, 3, value, "noise_vector: invalid 'position' arg") == -1) {
462 return nullptr;
463 }
464
465 noise_vector(vec[0], vec[1], vec[2], noise_basis_enum, r_vec);
466
467 return Vector_CreatePyObject(r_vec, 3, nullptr);
468}
469
471 /* Wrap. */
472 M_Noise_turbulence_doc,
473 ".. function:: turbulence(position, octaves, hard, /, *, "
474 "noise_basis='PERLIN_ORIGINAL', amplitude_scale=0.5, frequency_scale=2.0)\n"
475 "\n"
476 " Returns the turbulence value from the noise basis at the specified position.\n"
477 "\n"
478 " :arg position: The position to evaluate the selected noise function.\n"
479 " :type position: :class:`mathutils.Vector`\n"
480 " :arg octaves: The number of different noise frequencies used.\n"
481 " :type octaves: int\n"
482 " :arg hard: Specifies whether returned turbulence is hard (sharp transitions) or "
483 "soft (smooth transitions).\n"
484 " :type hard: bool\n" BPY_NOISE_BASIS_ENUM_DOC
485 " :arg amplitude_scale: The amplitude scaling factor.\n"
486 " :type amplitude_scale: float\n"
487 " :arg frequency_scale: The frequency scaling factor\n"
488 " :type frequency_scale: float\n"
489 " :return: The turbulence value.\n"
490 " :rtype: float\n");
491static PyObject *M_Noise_turbulence(PyObject * /*self*/, PyObject *args, PyObject *kw)
492{
493 static const char *kwlist[] = {
494 "", "", "", "noise_basis", "amplitude_scale", "frequency_scale", nullptr};
495 PyObject *value;
496 float vec[3];
497 const char *noise_basis_str = nullptr;
498 int oct, hd, noise_basis_enum = DEFAULT_NOISE_TYPE;
499 float as = 0.5f, fs = 2.0f;
500
501 if (!PyArg_ParseTupleAndKeywords(args,
502 kw,
503 "Oii|$sff:turbulence",
504 (char **)kwlist,
505 &value,
506 &oct,
507 &hd,
508 &noise_basis_str,
509 &as,
510 &fs))
511 {
512 return nullptr;
513 }
514
515 if (!noise_basis_str) {
516 /* pass through */
517 }
519 bpy_noise_types, noise_basis_str, &noise_basis_enum, "turbulence") == -1)
520 {
521 return nullptr;
522 }
523
524 if (mathutils_array_parse(vec, 3, 3, value, "turbulence: invalid 'position' arg") == -1) {
525 return nullptr;
526 }
527
528 return PyFloat_FromDouble(turb(vec[0], vec[1], vec[2], oct, hd, noise_basis_enum, as, fs));
529}
530
532 /* Wrap. */
533 M_Noise_turbulence_vector_doc,
534 ".. function:: turbulence_vector(position, octaves, hard, /, *, "
535 "noise_basis='PERLIN_ORIGINAL', amplitude_scale=0.5, frequency_scale=2.0)\n"
536 "\n"
537 " Returns the turbulence vector from the noise basis at the specified position.\n"
538 "\n"
539 " :arg position: The position to evaluate the selected noise function.\n"
540 " :type position: :class:`mathutils.Vector`\n"
541 " :arg octaves: The number of different noise frequencies used.\n"
542 " :type octaves: int\n"
543 " :arg hard: Specifies whether returned turbulence is hard (sharp transitions) or "
544 "soft (smooth transitions).\n"
545 " :type hard: bool\n" BPY_NOISE_BASIS_ENUM_DOC
546 " :arg amplitude_scale: The amplitude scaling factor.\n"
547 " :type amplitude_scale: float\n"
548 " :arg frequency_scale: The frequency scaling factor\n"
549 " :type frequency_scale: float\n"
550 " :return: The turbulence vector.\n"
551 " :rtype: :class:`mathutils.Vector`\n");
552static PyObject *M_Noise_turbulence_vector(PyObject * /*self*/, PyObject *args, PyObject *kw)
553{
554 static const char *kwlist[] = {
555 "", "", "", "noise_basis", "amplitude_scale", "frequency_scale", nullptr};
556 PyObject *value;
557 float vec[3], r_vec[3];
558 const char *noise_basis_str = nullptr;
559 int oct, hd, noise_basis_enum = DEFAULT_NOISE_TYPE;
560 float as = 0.5f, fs = 2.0f;
561
562 if (!PyArg_ParseTupleAndKeywords(args,
563 kw,
564 "Oii|$sff:turbulence_vector",
565 (char **)kwlist,
566 &value,
567 &oct,
568 &hd,
569 &noise_basis_str,
570 &as,
571 &fs))
572 {
573 return nullptr;
574 }
575
576 if (!noise_basis_str) {
577 /* pass through */
578 }
580 bpy_noise_types, noise_basis_str, &noise_basis_enum, "turbulence_vector") == -1)
581 {
582 return nullptr;
583 }
584
585 if (mathutils_array_parse(vec, 3, 3, value, "turbulence_vector: invalid 'position' arg") == -1) {
586 return nullptr;
587 }
588
589 vTurb(vec[0], vec[1], vec[2], oct, hd, noise_basis_enum, as, fs, r_vec);
590
591 return Vector_CreatePyObject(r_vec, 3, nullptr);
592}
593
594/* F. Kenton Musgrave's fractal functions */
596 /* Wrap. */
597 M_Noise_fractal_doc,
598 ".. function:: fractal(position, H, lacunarity, octaves, /, *, "
599 "noise_basis='PERLIN_ORIGINAL')\n"
600 "\n"
601 " Returns the fractal Brownian motion (fBm) noise value from the noise basis at the "
602 "specified position.\n"
603 "\n"
604 " :arg position: The position to evaluate the selected noise function.\n"
605 " :type position: :class:`mathutils.Vector`\n"
606 " :arg H: The fractal increment factor.\n"
607 " :type H: float\n"
608 " :arg lacunarity: The gap between successive frequencies.\n"
609 " :type lacunarity: float\n"
610 " :arg octaves: The number of different noise frequencies used.\n"
611 " :type octaves: int\n" BPY_NOISE_BASIS_ENUM_DOC
612 " :return: The fractal Brownian motion noise value.\n"
613 " :rtype: float\n");
614static PyObject *M_Noise_fractal(PyObject * /*self*/, PyObject *args, PyObject *kw)
615{
616 static const char *kwlist[] = {"", "", "", "", "noise_basis", nullptr};
617 PyObject *value;
618 float vec[3];
619 const char *noise_basis_str = nullptr;
620 float H, lac, oct;
621 int noise_basis_enum = DEFAULT_NOISE_TYPE;
622
623 if (!PyArg_ParseTupleAndKeywords(
624 args, kw, "Offf|$s:fractal", (char **)kwlist, &value, &H, &lac, &oct, &noise_basis_str))
625 {
626 return nullptr;
627 }
628
629 if (!noise_basis_str) {
630 /* pass through */
631 }
633 bpy_noise_types, noise_basis_str, &noise_basis_enum, "fractal") == -1)
634 {
635 return nullptr;
636 }
637
638 if (mathutils_array_parse(vec, 3, 3, value, "fractal: invalid 'position' arg") == -1) {
639 return nullptr;
640 }
641
642 return PyFloat_FromDouble(
643 BLI_noise_mg_fbm(vec[0], vec[1], vec[2], H, lac, oct, noise_basis_enum));
644}
645
647 /* Wrap. */
648 M_Noise_multi_fractal_doc,
649 ".. function:: multi_fractal(position, H, lacunarity, octaves, /, *, "
650 "noise_basis='PERLIN_ORIGINAL')\n"
651 "\n"
652 " Returns multifractal noise value from the noise basis at the specified position.\n"
653 "\n"
654 " :arg position: The position to evaluate the selected noise function.\n"
655 " :type position: :class:`mathutils.Vector`\n"
656 " :arg H: The fractal increment factor.\n"
657 " :type H: float\n"
658 " :arg lacunarity: The gap between successive frequencies.\n"
659 " :type lacunarity: float\n"
660 " :arg octaves: The number of different noise frequencies used.\n"
661 " :type octaves: int\n" BPY_NOISE_BASIS_ENUM_DOC
662 " :return: The multifractal noise value.\n"
663 " :rtype: float\n");
664static PyObject *M_Noise_multi_fractal(PyObject * /*self*/, PyObject *args, PyObject *kw)
665{
666 static const char *kwlist[] = {"", "", "", "", "noise_basis", nullptr};
667 PyObject *value;
668 float vec[3];
669 const char *noise_basis_str = nullptr;
670 float H, lac, oct;
671 int noise_basis_enum = DEFAULT_NOISE_TYPE;
672
673 if (!PyArg_ParseTupleAndKeywords(args,
674 kw,
675 "Offf|$s:multi_fractal",
676 (char **)kwlist,
677 &value,
678 &H,
679 &lac,
680 &oct,
681 &noise_basis_str))
682 {
683 return nullptr;
684 }
685
686 if (!noise_basis_str) {
687 /* pass through */
688 }
690 bpy_noise_types, noise_basis_str, &noise_basis_enum, "multi_fractal") == -1)
691 {
692 return nullptr;
693 }
694
695 if (mathutils_array_parse(vec, 3, 3, value, "multi_fractal: invalid 'position' arg") == -1) {
696 return nullptr;
697 }
698
699 return PyFloat_FromDouble(
700 BLI_noise_mg_multi_fractal(vec[0], vec[1], vec[2], H, lac, oct, noise_basis_enum));
701}
702
704 /* Wrap. */
705 M_Noise_variable_lacunarity_doc,
706 ".. function:: variable_lacunarity(position, distortion, /, *, "
707 "noise_type1='PERLIN_ORIGINAL', noise_type2='PERLIN_ORIGINAL')\n"
708 "\n"
709 " Returns variable lacunarity noise value, a distorted variety of noise, from "
710 "noise type 1 distorted by noise type 2 at the specified position.\n"
711 "\n"
712 " :arg position: The position to evaluate the selected noise function.\n"
713 " :type position: :class:`mathutils.Vector`\n"
714 " :arg distortion: The amount of distortion.\n"
715 " :type distortion: float\n"
716 " :arg noise_type1: A noise type string.\n"
717 " :type noise_type1: Literal['BLENDER', 'PERLIN_ORIGINAL', 'PERLIN_NEW', "
718 "'VORONOI_F1', 'VORONOI_F2', "
719 "'VORONOI_F3', 'VORONOI_F4', 'VORONOI_F2F1', 'VORONOI_CRACKLE', "
720 "'CELLNOISE'].\n"
721 " :arg noise_type2: A noise type string.\n"
722 " :type noise_type2: Literal['BLENDER', 'PERLIN_ORIGINAL', 'PERLIN_NEW', "
723 "'VORONOI_F1', 'VORONOI_F2', "
724 "'VORONOI_F3', 'VORONOI_F4', 'VORONOI_F2F1', 'VORONOI_CRACKLE', "
725 "'CELLNOISE'].\n"
726 " :return: The variable lacunarity noise value.\n"
727 " :rtype: float\n");
728static PyObject *M_Noise_variable_lacunarity(PyObject * /*self*/, PyObject *args, PyObject *kw)
729{
730 static const char *kwlist[] = {"", "", "noise_type1", "noise_type2", nullptr};
731 PyObject *value;
732 float vec[3];
733 const char *noise_type1_str = nullptr, *noise_type2_str = nullptr;
734 float d;
735 int noise_type1_enum = DEFAULT_NOISE_TYPE, noise_type2_enum = DEFAULT_NOISE_TYPE;
736
737 if (!PyArg_ParseTupleAndKeywords(args,
738 kw,
739 "Of|$ss:variable_lacunarity",
740 (char **)kwlist,
741 &value,
742 &d,
743 &noise_type1_str,
744 &noise_type2_str))
745 {
746 return nullptr;
747 }
748
749 if (!noise_type1_str) {
750 /* pass through */
751 }
753 bpy_noise_types, noise_type1_str, &noise_type1_enum, "variable_lacunarity") == -1)
754 {
755 return nullptr;
756 }
757
758 if (!noise_type2_str) {
759 /* pass through */
760 }
762 bpy_noise_types, noise_type2_str, &noise_type2_enum, "variable_lacunarity") == -1)
763 {
764 return nullptr;
765 }
766
767 if (mathutils_array_parse(vec, 3, 3, value, "variable_lacunarity: invalid 'position' arg") == -1)
768 {
769 return nullptr;
770 }
771
772 return PyFloat_FromDouble(BLI_noise_mg_variable_lacunarity(
773 vec[0], vec[1], vec[2], d, noise_type1_enum, noise_type2_enum));
774}
775
777 /* Wrap. */
778 M_Noise_hetero_terrain_doc,
779 ".. function:: hetero_terrain(position, H, lacunarity, octaves, offset, /, *, "
780 "noise_basis='PERLIN_ORIGINAL')\n"
781 "\n"
782 " Returns the heterogeneous terrain value from the noise basis at the specified position.\n"
783 "\n"
784 " :arg position: The position to evaluate the selected noise function.\n"
785 " :type position: :class:`mathutils.Vector`\n"
786 " :arg H: The fractal dimension of the roughest areas.\n"
787 " :type H: float\n"
788 " :arg lacunarity: The gap between successive frequencies.\n"
789 " :type lacunarity: float\n"
790 " :arg octaves: The number of different noise frequencies used.\n"
791 " :type octaves: int\n"
792 " :arg offset: The height of the terrain above 'sea level'.\n"
793 " :type offset: float\n" BPY_NOISE_BASIS_ENUM_DOC
794 " :return: The heterogeneous terrain value.\n"
795 " :rtype: float\n");
796static PyObject *M_Noise_hetero_terrain(PyObject * /*self*/, PyObject *args, PyObject *kw)
797{
798 static const char *kwlist[] = {"", "", "", "", "", "noise_basis", nullptr};
799 PyObject *value;
800 float vec[3];
801 const char *noise_basis_str = nullptr;
802 float H, lac, oct, ofs;
803 int noise_basis_enum = DEFAULT_NOISE_TYPE;
804
805 if (!PyArg_ParseTupleAndKeywords(args,
806 kw,
807 "Offff|$s:hetero_terrain",
808 (char **)kwlist,
809 &value,
810 &H,
811 &lac,
812 &oct,
813 &ofs,
814 &noise_basis_str))
815 {
816 return nullptr;
817 }
818
819 if (!noise_basis_str) {
820 /* pass through */
821 }
823 bpy_noise_types, noise_basis_str, &noise_basis_enum, "hetero_terrain") == -1)
824 {
825 return nullptr;
826 }
827
828 if (mathutils_array_parse(vec, 3, 3, value, "hetero_terrain: invalid 'position' arg") == -1) {
829 return nullptr;
830 }
831
832 return PyFloat_FromDouble(
833 BLI_noise_mg_hetero_terrain(vec[0], vec[1], vec[2], H, lac, oct, ofs, noise_basis_enum));
834}
835
837 /* Wrap. */
838 M_Noise_hybrid_multi_fractal_doc,
839 ".. function:: hybrid_multi_fractal(position, H, lacunarity, octaves, offset, gain, /, *, "
840 "noise_basis='PERLIN_ORIGINAL')\n"
841 "\n"
842 " Returns hybrid multifractal value from the noise basis at the specified position.\n"
843 "\n"
844 " :arg position: The position to evaluate the selected noise function.\n"
845 " :type position: :class:`mathutils.Vector`\n"
846 " :arg H: The fractal dimension of the roughest areas.\n"
847 " :type H: float\n"
848 " :arg lacunarity: The gap between successive frequencies.\n"
849 " :type lacunarity: float\n"
850 " :arg octaves: The number of different noise frequencies used.\n"
851 " :type octaves: int\n"
852 " :arg offset: The height of the terrain above 'sea level'.\n"
853 " :type offset: float\n"
854 " :arg gain: Scaling applied to the values.\n"
855 " :type gain: float\n" BPY_NOISE_BASIS_ENUM_DOC
856 " :return: The hybrid multifractal value.\n"
857 " :rtype: float\n");
858static PyObject *M_Noise_hybrid_multi_fractal(PyObject * /*self*/, PyObject *args, PyObject *kw)
859{
860 static const char *kwlist[] = {"", "", "", "", "", "", "noise_basis", nullptr};
861 PyObject *value;
862 float vec[3];
863 const char *noise_basis_str = nullptr;
864 float H, lac, oct, ofs, gn;
865 int noise_basis_enum = DEFAULT_NOISE_TYPE;
866
867 if (!PyArg_ParseTupleAndKeywords(args,
868 kw,
869 "Offfff|$s:hybrid_multi_fractal",
870 (char **)kwlist,
871 &value,
872 &H,
873 &lac,
874 &oct,
875 &ofs,
876 &gn,
877 &noise_basis_str))
878 {
879 return nullptr;
880 }
881
882 if (!noise_basis_str) {
883 /* pass through */
884 }
886 bpy_noise_types, noise_basis_str, &noise_basis_enum, "hybrid_multi_fractal") == -1)
887 {
888 return nullptr;
889 }
890
891 if (mathutils_array_parse(vec, 3, 3, value, "hybrid_multi_fractal: invalid 'position' arg") ==
892 -1)
893 {
894 return nullptr;
895 }
896
897 return PyFloat_FromDouble(BLI_noise_mg_hybrid_multi_fractal(
898 vec[0], vec[1], vec[2], H, lac, oct, ofs, gn, noise_basis_enum));
899}
900
902 /* Wrap. */
903 M_Noise_ridged_multi_fractal_doc,
904 ".. function:: ridged_multi_fractal(position, H, lacunarity, octaves, offset, gain, /, *, "
905 "noise_basis='PERLIN_ORIGINAL')\n"
906 "\n"
907 " Returns ridged multifractal value from the noise basis at the specified position.\n"
908 "\n"
909 " :arg position: The position to evaluate the selected noise function.\n"
910 " :type position: :class:`mathutils.Vector`\n"
911 " :arg H: The fractal dimension of the roughest areas.\n"
912 " :type H: float\n"
913 " :arg lacunarity: The gap between successive frequencies.\n"
914 " :type lacunarity: float\n"
915 " :arg octaves: The number of different noise frequencies used.\n"
916 " :type octaves: int\n"
917 " :arg offset: The height of the terrain above 'sea level'.\n"
918 " :type offset: float\n"
919 " :arg gain: Scaling applied to the values.\n"
920 " :type gain: float\n" BPY_NOISE_BASIS_ENUM_DOC
921 " :return: The ridged multifractal value.\n"
922 " :rtype: float\n");
923static PyObject *M_Noise_ridged_multi_fractal(PyObject * /*self*/, PyObject *args, PyObject *kw)
924{
925 static const char *kwlist[] = {"", "", "", "", "", "", "noise_basis", nullptr};
926 PyObject *value;
927 float vec[3];
928 const char *noise_basis_str = nullptr;
929 float H, lac, oct, ofs, gn;
930 int noise_basis_enum = DEFAULT_NOISE_TYPE;
931
932 if (!PyArg_ParseTupleAndKeywords(args,
933 kw,
934 "Offfff|$s:ridged_multi_fractal",
935 (char **)kwlist,
936 &value,
937 &H,
938 &lac,
939 &oct,
940 &ofs,
941 &gn,
942 &noise_basis_str))
943 {
944 return nullptr;
945 }
946
947 if (!noise_basis_str) {
948 /* pass through */
949 }
951 bpy_noise_types, noise_basis_str, &noise_basis_enum, "ridged_multi_fractal") == -1)
952 {
953 return nullptr;
954 }
955
956 if (mathutils_array_parse(vec, 3, 3, value, "ridged_multi_fractal: invalid 'position' arg") ==
957 -1)
958 {
959 return nullptr;
960 }
961
962 return PyFloat_FromDouble(BLI_noise_mg_ridged_multi_fractal(
963 vec[0], vec[1], vec[2], H, lac, oct, ofs, gn, noise_basis_enum));
964}
965
967 /* Wrap. */
968 M_Noise_voronoi_doc,
969 ".. function:: voronoi(position, /, *, distance_metric='DISTANCE', exponent=2.5)\n"
970 "\n"
971 " Returns a list of distances to the four closest features and their locations.\n"
972 "\n"
973 " :arg position: The position to evaluate the selected noise function.\n"
974 " :type position: :class:`mathutils.Vector`\n" BPY_NOISE_METRIC_ENUM_DOC
975 " :arg exponent: The exponent for Minkowski distance metric.\n"
976 " :type exponent: float\n"
977 " :return: A list of distances to the four closest features and their locations.\n"
978 " :rtype: list[list[float] | list[:class:`mathutils.Vector`]]\n");
979static PyObject *M_Noise_voronoi(PyObject * /*self*/, PyObject *args, PyObject *kw)
980{
981 static const char *kwlist[] = {"", "distance_metric", "exponent", nullptr};
982 PyObject *value;
983 PyObject *list;
984 PyObject *ret;
985 float vec[3];
986 const char *metric_str = nullptr;
987 float da[4], pa[12];
988 int metric_enum = DEFAULT_METRIC_TYPE;
989 float me = 2.5f; /* default minkowski exponent */
990
991 int i;
992
993 if (!PyArg_ParseTupleAndKeywords(
994 args, kw, "O|$sf:voronoi", (char **)kwlist, &value, &metric_str, &me))
995 {
996 return nullptr;
997 }
998
999 if (!metric_str) {
1000 /* pass through */
1001 }
1002 else if (PyC_FlagSet_ValueFromID(bpy_noise_metrics, metric_str, &metric_enum, "voronoi") == -1) {
1003 return nullptr;
1004 }
1005
1006 if (mathutils_array_parse(vec, 3, 3, value, "voronoi: invalid 'position' arg") == -1) {
1007 return nullptr;
1008 }
1009
1010 list = PyList_New(4);
1011
1012 BLI_noise_voronoi(vec[0], vec[1], vec[2], da, pa, me, metric_enum);
1013
1014 for (i = 0; i < 4; i++) {
1015 PyObject *v = Vector_CreatePyObject(pa + 3 * i, 3, nullptr);
1016 PyList_SET_ITEM(list, i, v);
1017 }
1018
1019 ret = Py_BuildValue("[[ffff]O]", da[0], da[1], da[2], da[3], list);
1020 Py_DECREF(list);
1021 return ret;
1022}
1023
1025 /* Wrap. */
1026 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");
1035static PyObject *M_Noise_cell(PyObject * /*self*/, PyObject *args)
1036{
1037 PyObject *value;
1038 float vec[3];
1039
1040 if (!PyArg_ParseTuple(args, "O:cell", &value)) {
1041 return nullptr;
1042 }
1043
1044 if (mathutils_array_parse(vec, 3, 3, value, "cell: invalid 'position' arg") == -1) {
1045 return nullptr;
1046 }
1047
1048 return PyFloat_FromDouble(BLI_noise_cell(vec[0], vec[1], vec[2]));
1049}
1050
1052 /* Wrap. */
1053 M_Noise_cell_vector_doc,
1054 ".. function:: cell_vector(position, /)\n"
1055 "\n"
1056 " Returns cell noise vector at the specified position.\n"
1057 "\n"
1058 " :arg position: The position to evaluate the selected noise function.\n"
1059 " :type position: :class:`mathutils.Vector`\n"
1060 " :return: The cell noise vector.\n"
1061 " :rtype: :class:`mathutils.Vector`\n");
1062static PyObject *M_Noise_cell_vector(PyObject * /*self*/, PyObject *args)
1063{
1064 PyObject *value;
1065 float vec[3], r_vec[3];
1066
1067 if (!PyArg_ParseTuple(args, "O:cell_vector", &value)) {
1068 return nullptr;
1069 }
1070
1071 if (mathutils_array_parse(vec, 3, 3, value, "cell_vector: invalid 'position' arg") == -1) {
1072 return nullptr;
1073 }
1074
1075 BLI_noise_cell_v3(vec[0], vec[1], vec[2], r_vec);
1076 return Vector_CreatePyObject(r_vec, 3, nullptr);
1077}
1078
1079#ifdef __GNUC__
1080# ifdef __clang__
1081# pragma clang diagnostic push
1082# pragma clang diagnostic ignored "-Wcast-function-type"
1083# else
1084# pragma GCC diagnostic push
1085# pragma GCC diagnostic ignored "-Wcast-function-type"
1086# endif
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#ifdef __GNUC__
1141# ifdef __clang__
1142# pragma clang diagnostic pop
1143# else
1144# pragma GCC diagnostic pop
1145# endif
1146#endif
1147
1149 /* Wrap. */
1150 M_Noise_doc,
1151 "The Blender noise module.");
1152static PyModuleDef M_Noise_module_def = {
1153 /*m_base*/ PyModuleDef_HEAD_INIT,
1154 /*m_name*/ "mathutils.noise",
1155 /*m_doc*/ M_Noise_doc,
1156 /*m_size*/ 0,
1157 /*m_methods*/ M_Noise_methods,
1158 /*m_slots*/ nullptr,
1159 /*m_traverse*/ nullptr,
1160 /*m_clear*/ nullptr,
1161 /*m_free*/ nullptr,
1162};
1163
1164/*----------------------------MODULE INIT-------------------------*/
1165
1167{
1168 PyObject *submodule = PyModule_Create(&M_Noise_module_def);
1169
1170 /* use current time as seed for random number generator by default */
1171 setRndSeed(0);
1172
1173 return submodule;
1174}
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.cc:1391
float BLI_noise_mg_multi_fractal(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
Definition noise_c.cc: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.cc:1535
float BLI_noise_mg_variable_lacunarity(float x, float y, float z, float distortion, int nbas1, int nbas2)
Definition noise_c.cc:1606
float BLI_noise_cell(float x, float y, float z)
Definition noise_c.cc:1126
float BLI_noise_generic_noise(float noisesize, float x, float y, float z, bool hard, int noisebasis)
Definition noise_c.cc:1153
void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype)
Definition noise_c.cc:915
float BLI_noise_mg_fbm(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
Definition noise_c.cc:1272
void BLI_noise_cell_v3(float x, float y, float z, float r_ca[3])
Definition noise_c.cc: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.cc: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
nullptr float
#define out
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
Definition mathutils.cc:96
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 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[]
PyDoc_STRVAR(M_Noise_random_doc, ".. function:: random()\n" "\n" " Returns a random number in the range [0, 1).\n" "\n" " :return: The random number.\n" " :rtype: float\n")
#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)
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 int left
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 N
#define H(x, y, z)
int PyC_FlagSet_ValueFromID(const PyC_FlagSet *item, const char *identifier, int *r_value, const char *error_prefix)
Py_DECREF(oname)
return ret
#define fabsf
i
Definition text_draw.cc:230