[Bf-blender-cvs] [4a78a2774be] master: Cleanup: use bool argument in BLI_noise

Campbell Barton noreply at git.blender.org
Fri Nov 6 02:41:46 CET 2020


Commit: 4a78a2774bee655a54391cc8fafae2d20ead2bb0
Author: Campbell Barton
Date:   Fri Nov 6 11:07:18 2020 +1100
Branches: master
https://developer.blender.org/rB4a78a2774bee655a54391cc8fafae2d20ead2bb0

Cleanup: use bool argument in BLI_noise

===================================================================

M	source/blender/blenlib/BLI_noise.h
M	source/blender/blenlib/intern/noise.c
M	source/blender/python/mathutils/mathutils_noise.c

===================================================================

diff --git a/source/blender/blenlib/BLI_noise.h b/source/blender/blenlib/BLI_noise.h
index 4a41ee68ca9..37afd8ee031 100644
--- a/source/blender/blenlib/BLI_noise.h
+++ b/source/blender/blenlib/BLI_noise.h
@@ -27,7 +27,6 @@
 extern "C" {
 #endif
 
-/* noise.h: */
 float BLI_noise_hnoise(float noisesize, float x, float y, float z);
 float BLI_noise_hnoisep(float noisesize, float x, float y, float z);
 float BLI_noise_turbulence(float noisesize, float x, float y, float z, int nr);
@@ -35,9 +34,9 @@ float BLI_noise_turbulence(float noisesize, float x, float y, float z, int nr);
  * to replace the above BLI_noise_hnoise/p & BLI_noise_turbulence/1.
  * This is done so different noise basis functions can be used */
 float BLI_noise_generic_noise(
-    float noisesize, float x, float y, float z, int hard, int noisebasis);
+    float noisesize, float x, float y, float z, bool hard, int noisebasis);
 float BLI_noise_generic_turbulence(
-    float noisesize, float x, float y, float z, int oct, int hard, int noisebasis);
+    float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis);
 /* newnoise: musgrave functions */
 float BLI_noise_mg_fbm(
     float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis);
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index b47de145e2a..bc8135605a8 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -24,7 +24,9 @@
 #include <math.h>
 
 #include "BLI_compiler_compat.h"
-#include "BLI_noise.h"
+#include "BLI_sys_types.h"
+
+#include "BLI_noise.h" /* Own include. */
 
 /* local */
 static float noise3_perlin(const float vec[3]);
@@ -1155,7 +1157,8 @@ void BLI_noise_cell_v3(float x, float y, float z, float ca[3])
 /*****************/
 
 /* newnoise: generic noise function for use with different noisebases */
-float BLI_noise_generic_noise(float noisesize, float x, float y, float z, int hard, int noisebasis)
+float BLI_noise_generic_noise(
+    float noisesize, float x, float y, float z, bool hard, int noisebasis)
 {
   float (*noisefunc)(float, float, float);
 
@@ -1213,7 +1216,7 @@ float BLI_noise_generic_noise(float noisesize, float x, float y, float z, int ha
 
 /* newnoise: generic turbulence function for use with different noisebasis */
 float BLI_noise_generic_turbulence(
-    float noisesize, float x, float y, float z, int oct, int hard, int noisebasis)
+    float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
 {
   float (*noisefunc)(float, float, float);
   switch (noisebasis) {
diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c
index 61838ade31a..05cd7a12706 100644
--- a/source/blender/python/mathutils/mathutils_noise.c
+++ b/source/blender/python/mathutils/mathutils_noise.c
@@ -246,7 +246,7 @@ static void noise_vector(float x, float y, float z, int nb, float v[3])
   /* Simply evaluate noise at 3 different positions */
   const float *ofs = state_offset_vector;
   for (int j = 0; j < 3; j++) {
-    v[j] = (2.0f * BLI_noise_generic_noise(1.0f, x + ofs[0], y + ofs[1], z + ofs[2], 0, nb) -
+    v[j] = (2.0f * BLI_noise_generic_noise(1.0f, x + ofs[0], y + ofs[1], z + ofs[2], false, nb) -
             1.0f);
     ofs += 3;
   }
@@ -259,7 +259,7 @@ static float turb(
   float amp, out, t;
   int i;
   amp = 1.f;
-  out = (float)(2.0f * BLI_noise_generic_noise(1.f, x, y, z, 0, nb) - 1.0f);
+  out = (float)(2.0f * BLI_noise_generic_noise(1.f, x, y, z, false, nb) - 1.0f);
   if (hard) {
     out = fabsf(out);
   }
@@ -268,7 +268,7 @@ static float turb(
     x *= freqscale;
     y *= freqscale;
     z *= freqscale;
-    t = (float)(amp * (2.0f * BLI_noise_generic_noise(1.f, x, y, z, 0, nb) - 1.0f));
+    t = (float)(amp * (2.0f * BLI_noise_generic_noise(1.f, x, y, z, false, nb) - 1.0f));
     if (hard) {
       t = fabsf(t);
     }
@@ -451,7 +451,8 @@ static PyObject *M_Noise_noise(PyObject *UNUSED(self), PyObject *args, PyObject
   }
 
   return PyFloat_FromDouble(
-      (2.0f * BLI_noise_generic_noise(1.0f, vec[0], vec[1], vec[2], 0, noise_basis_enum) - 1.0f));
+      (2.0f * BLI_noise_generic_noise(1.0f, vec[0], vec[1], vec[2], false, noise_basis_enum) -
+       1.0f));
 }
 
 PyDoc_STRVAR(M_Noise_noise_vector_doc,



More information about the Bf-blender-cvs mailing list