diff options
Diffstat (limited to 'source/blender/blenlib/intern/noise.c')
-rw-r--r-- | source/blender/blenlib/intern/noise.c | 126 |
1 files changed, 64 insertions, 62 deletions
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index 889e336bb52..b47de145e2a 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -319,7 +319,8 @@ static float newPerlin(float x, float y, float z) lerp(u, grad(hash[AB + 1], x, y - 1, z - 1), grad(hash[BB + 1], x - 1, y - 1, z - 1)))); } -/* for use with BLI_gNoise()/BLI_gTurbulence(), returns unsigned improved perlin noise */ +/* for use with BLI_noise_generic_noise()/BLI_noise_generic_turbulence(), returns unsigned improved + * perlin noise */ static float newPerlinU(float x, float y, float z) { return (0.5f + 0.5f * newPerlin(x, y, z)); @@ -329,7 +330,7 @@ static float newPerlinU(float x, float y, float z) /* END OF IMPROVED PERLIN */ /**************************/ -/* Was BLI_hnoise(), removed noisesize, so other functions can call it without scaling. */ +/* Was BLI_noise_hnoise(), removed noisesize, so other functions can call it without scaling. */ static float orgBlenderNoise(float x, float y, float z) { float cn1, cn2, cn3, cn4, cn5, cn6, i; @@ -425,7 +426,7 @@ static float orgBlenderNoiseS(float x, float y, float z) } /* separated from orgBlenderNoise above, with scaling */ -float BLI_hnoise(float noisesize, float x, float y, float z) +float BLI_noise_hnoise(float noisesize, float x, float y, float z) { if (noisesize == 0.0f) { return 0.0f; @@ -437,15 +438,15 @@ float BLI_hnoise(float noisesize, float x, float y, float z) } /* original turbulence functions */ -float BLI_turbulence(float noisesize, float x, float y, float z, int nr) +float BLI_noise_turbulence(float noisesize, float x, float y, float z, int nr) { float s, d = 0.5, div = 1.0; - s = BLI_hnoise(noisesize, x, y, z); + s = BLI_noise_hnoise(noisesize, x, y, z); while (nr > 0) { - s += d * BLI_hnoise(noisesize * d, x, y, z); + s += d * BLI_noise_hnoise(noisesize * d, x, y, z); div += d; d *= 0.5f; @@ -825,14 +826,14 @@ static float noise3_perlin(const float vec[3]) #undef SURVE } -/* for use with BLI_gNoise/gTurbulence, returns signed noise */ +/* for use with BLI_noise_generic_noise/gTurbulence, returns signed noise */ static float orgPerlinNoise(float x, float y, float z) { float v[3] = {x, y, z}; return noise3_perlin(v); } -/* for use with BLI_gNoise/gTurbulence, returns unsigned noise */ +/* for use with BLI_noise_generic_noise/gTurbulence, returns unsigned noise */ static float orgPerlinNoiseU(float x, float y, float z) { float v[3] = {x, y, z}; @@ -841,7 +842,7 @@ static float orgPerlinNoiseU(float x, float y, float z) /* *************** CALL AS: *************** */ -float BLI_hnoisep(float noisesize, float x, float y, float z) +float BLI_noise_hnoisep(float noisesize, float x, float y, float z) { float vec[3]; @@ -915,7 +916,7 @@ static float dist_Minkovsky(float x, float y, float z, float e) /* Not 'pure' Worley, but the results are virtually the same. * Returns distances in da and point coords in pa */ -void BLI_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype) +void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype) { float (*distfunc)(float, float, float, float); switch (dtype) { @@ -1008,39 +1009,39 @@ void BLI_voronoi(float x, float y, float z, float *da, float *pa, float me, int } } -/* returns different feature points for use in BLI_gNoise() */ +/* returns different feature points for use in BLI_noise_generic_noise() */ static float voronoi_F1(float x, float y, float z) { float da[4], pa[12]; - BLI_voronoi(x, y, z, da, pa, 1, 0); + BLI_noise_voronoi(x, y, z, da, pa, 1, 0); return da[0]; } static float voronoi_F2(float x, float y, float z) { float da[4], pa[12]; - BLI_voronoi(x, y, z, da, pa, 1, 0); + BLI_noise_voronoi(x, y, z, da, pa, 1, 0); return da[1]; } static float voronoi_F3(float x, float y, float z) { float da[4], pa[12]; - BLI_voronoi(x, y, z, da, pa, 1, 0); + BLI_noise_voronoi(x, y, z, da, pa, 1, 0); return da[2]; } static float voronoi_F4(float x, float y, float z) { float da[4], pa[12]; - BLI_voronoi(x, y, z, da, pa, 1, 0); + BLI_noise_voronoi(x, y, z, da, pa, 1, 0); return da[3]; } static float voronoi_F1F2(float x, float y, float z) { float da[4], pa[12]; - BLI_voronoi(x, y, z, da, pa, 1, 0); + BLI_noise_voronoi(x, y, z, da, pa, 1, 0); return (da[1] - da[0]); } @@ -1060,35 +1061,35 @@ static float voronoi_Cr(float x, float y, float z) static float voronoi_F1S(float x, float y, float z) { float da[4], pa[12]; - BLI_voronoi(x, y, z, da, pa, 1, 0); + BLI_noise_voronoi(x, y, z, da, pa, 1, 0); return (2.0f * da[0] - 1.0f); } static float voronoi_F2S(float x, float y, float z) { float da[4], pa[12]; - BLI_voronoi(x, y, z, da, pa, 1, 0); + BLI_noise_voronoi(x, y, z, da, pa, 1, 0); return (2.0f * da[1] - 1.0f); } static float voronoi_F3S(float x, float y, float z) { float da[4], pa[12]; - BLI_voronoi(x, y, z, da, pa, 1, 0); + BLI_noise_voronoi(x, y, z, da, pa, 1, 0); return (2.0f * da[2] - 1.0f); } static float voronoi_F4S(float x, float y, float z) { float da[4], pa[12]; - BLI_voronoi(x, y, z, da, pa, 1, 0); + BLI_noise_voronoi(x, y, z, da, pa, 1, 0); return (2.0f * da[3] - 1.0f); } static float voronoi_F1F2S(float x, float y, float z) { float da[4], pa[12]; - BLI_voronoi(x, y, z, da, pa, 1, 0); + BLI_noise_voronoi(x, y, z, da, pa, 1, 0); return (2.0f * (da[1] - da[0]) - 1.0f); } @@ -1127,13 +1128,13 @@ static float BLI_cellNoiseU(float x, float y, float z) } /* idem, signed */ -float BLI_cellNoise(float x, float y, float z) +float BLI_noise_cell(float x, float y, float z) { return (2.0f * BLI_cellNoiseU(x, y, z) - 1.0f); } /* returns a vector/point/color in ca, using point hasharray directly */ -void BLI_cellNoiseV(float x, float y, float z, float ca[3]) +void BLI_noise_cell_v3(float x, float y, float z, float ca[3]) { /* avoid precision issues on unit coordinates */ x = (x + 0.000001f) * 1.00001f; @@ -1154,7 +1155,7 @@ void BLI_cellNoiseV(float x, float y, float z, float ca[3]) /*****************/ /* newnoise: generic noise function for use with different noisebases */ -float BLI_gNoise(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, int hard, int noisebasis) { float (*noisefunc)(float, float, float); @@ -1189,7 +1190,7 @@ float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noise case 0: default: { noisefunc = orgBlenderNoise; - /* add one to make return value same as BLI_hnoise */ + /* add one to make return value same as BLI_noise_hnoise */ x += 1; y += 1; z += 1; @@ -1211,7 +1212,7 @@ float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noise } /* newnoise: generic turbulence function for use with different noisebasis */ -float BLI_gTurbulence( +float BLI_noise_generic_turbulence( float noisesize, float x, float y, float z, int oct, int hard, int noisebasis) { float (*noisefunc)(float, float, float); @@ -1286,7 +1287,7 @@ float BLI_gTurbulence( * ``lacunarity'' is the gap between successive frequencies * ``octaves'' is the number of frequencies in the fBm */ -float BLI_mg_fBm( +float BLI_noise_mg_fbm( float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis) { float (*noisefunc)(float, float, float); @@ -1316,7 +1317,7 @@ float BLI_mg_fBm( noisefunc = voronoi_CrS; break; case 14: - noisefunc = BLI_cellNoise; + noisefunc = BLI_noise_cell; break; case 0: default: { @@ -1357,7 +1358,7 @@ float BLI_mg_fBm( /* this one is in fact rather confusing, * there seem to be errors in the original source code (in all three versions of proc.text&mod), * I modified it to something that made sense to me, so it might be wrong... */ -float BLI_mg_MultiFractal( +float BLI_noise_mg_multi_fractal( float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis) { float (*noisefunc)(float, float, float); @@ -1387,7 +1388,7 @@ float BLI_mg_MultiFractal( noisefunc = voronoi_CrS; break; case 14: - noisefunc = BLI_cellNoise; + noisefunc = BLI_noise_cell; break; case 0: default: { @@ -1423,14 +1424,14 @@ float BLI_mg_MultiFractal( * ``octaves'' is the number of frequencies in the fBm * ``offset'' raises the terrain from `sea level' */ -float BLI_mg_HeteroTerrain(float x, - float y, - float z, - float H, - float lacunarity, - float octaves, - float offset, - int noisebasis) +float BLI_noise_mg_hetero_terrain(float x, + float y, + float z, + float H, + float lacunarity, + float octaves, + float offset, + int noisebasis) { float (*noisefunc)(float, float, float); switch (noisebasis) { @@ -1459,7 +1460,7 @@ float BLI_mg_HeteroTerrain(float x, noisefunc = voronoi_CrS; break; case 14: - noisefunc = BLI_cellNoise; + noisefunc = BLI_noise_cell; break; case 0: default: { @@ -1500,15 +1501,15 @@ float BLI_mg_HeteroTerrain(float x, * H: 0.25 * offset: 0.7 */ -float BLI_mg_HybridMultiFractal(float x, - float y, - float z, - float H, - float lacunarity, - float octaves, - float offset, - float gain, - int noisebasis) +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) { float (*noisefunc)(float, float, float); switch (noisebasis) { @@ -1537,7 +1538,7 @@ float BLI_mg_HybridMultiFractal(float x, noisefunc = voronoi_CrS; break; case 14: - noisefunc = BLI_cellNoise; + noisefunc = BLI_noise_cell; break; case 0: default: { @@ -1584,15 +1585,15 @@ float BLI_mg_HybridMultiFractal(float x, * offset: 1.0 * gain: 2.0 */ -float BLI_mg_RidgedMultiFractal(float x, - float y, - float z, - float H, - float lacunarity, - float octaves, - float offset, - float gain, - int noisebasis) +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) { float (*noisefunc)(float, float, float); switch (noisebasis) { @@ -1621,7 +1622,7 @@ float BLI_mg_RidgedMultiFractal(float x, noisefunc = voronoi_CrS; break; case 14: - noisefunc = BLI_cellNoise; + noisefunc = BLI_noise_cell; break; case 0: default: { @@ -1657,7 +1658,8 @@ float BLI_mg_RidgedMultiFractal(float x, /* "Variable Lacunarity Noise" * A distorted variety of Perlin noise. */ -float BLI_mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nbas2) +float BLI_noise_mg_variable_lacunarity( + float x, float y, float z, float distortion, int nbas1, int nbas2) { float (*noisefunc1)(float, float, float); switch (nbas1) { @@ -1686,7 +1688,7 @@ float BLI_mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int noisefunc1 = voronoi_CrS; break; case 14: - noisefunc1 = BLI_cellNoise; + noisefunc1 = BLI_noise_cell; break; case 0: default: { @@ -1722,7 +1724,7 @@ float BLI_mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int noisefunc2 = voronoi_CrS; break; case 14: - noisefunc2 = BLI_cellNoise; + noisefunc2 = BLI_noise_cell; break; case 0: default: { |