Cleanup: use bool argument in BLI_noise

This commit is contained in:
Campbell Barton 2020-11-06 11:07:18 +11:00
parent 29401f8ca2
commit 4a78a2774b
3 changed files with 13 additions and 10 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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,