diff options
author | kwolekr <kwolekr@minetest.net> | 2014-12-07 21:57:12 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2014-12-07 21:59:32 -0500 |
commit | 2fd3d5202051e03303ac2b8e76976a7c4c8477f3 (patch) | |
tree | c461272b8eef33846cf5773e38c6a8b7716e1d0d /src/noise.h | |
parent | 638f3a8454941d3f561b1834d47fa07a611454a3 (diff) | |
download | minetest-2fd3d5202051e03303ac2b8e76976a7c4c8477f3.tar.gz minetest-2fd3d5202051e03303ac2b8e76976a7c4c8477f3.tar.bz2 minetest-2fd3d5202051e03303ac2b8e76976a7c4c8477f3.zip |
Add flags and lacunarity as new noise parameters
Add 'absolute value' option to noise map functions
Extend persistence modulation to 3D noise
Extend 'eased' option to noise2d_perlin* functions
Some noise.cpp formatting fixups
Diffstat (limited to 'src/noise.h')
-rw-r--r-- | src/noise.h | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/src/noise.h b/src/noise.h index 7d055d2e1..1f7bdbbf4 100644 --- a/src/noise.h +++ b/src/noise.h @@ -28,6 +28,9 @@ #include "debug.h" #include "irr_v3d.h" +#include "util/string.h" + +extern FlagDesc flagdesc_noiseparams[]; class PseudoRandom { @@ -66,6 +69,14 @@ private: int m_next; }; +#define NOISE_FLAG_DEFAULTS 0x01 +#define NOISE_FLAG_EASED 0x02 +#define NOISE_FLAG_ABSVALUE 0x04 + +//// TODO(hmmmm): implement these! +#define NOISE_FLAG_POINTBUFFER 0x08 +#define NOISE_FLAG_SIMPLEX 0x10 + struct NoiseParams { float offset; float scale; @@ -73,20 +84,32 @@ struct NoiseParams { s32 seed; u16 octaves; float persist; - bool eased; - - NoiseParams() {} + float lacunarity; + u32 flags; + + NoiseParams() { + offset = 0.0f; + scale = 1.0f; + spread = v3f(250, 250, 250); + seed = 12345; + octaves = 3; + persist = 0.6f; + lacunarity = 2.0f; + flags = NOISE_FLAG_DEFAULTS; + } - NoiseParams(float offset_, float scale_, v3f spread_, - int seed_, int octaves_, float persist_, bool eased_=false) + NoiseParams(float offset_, float scale_, v3f spread_, s32 seed_, + u16 octaves_, float persist_, float lacunarity_, + u32 flags_=NOISE_FLAG_DEFAULTS) { - offset = offset_; - scale = scale_; - spread = spread_; - seed = seed_; - octaves = octaves_; - persist = persist_; - eased = eased_; + offset = offset_; + scale = scale_; + spread = spread_; + seed = seed_; + octaves = octaves_; + persist = persist_; + lacunarity = lacunarity_; + flags = flags_; } }; @@ -123,10 +146,12 @@ public: void gradientMap3D( float x, float y, float z, float step_x, float step_y, float step_z, - int seed, bool eased=false); - float *perlinMap2D(float x, float y); - float *perlinMap2DModulated(float x, float y, float *persist_map); - float *perlinMap3D(float x, float y, float z, bool eased=false); + int seed); + + float *perlinMap2D(float x, float y, float *persistence_map=NULL); + float *perlinMap3D(float x, float y, float z, float *persistence_map=NULL); + + void updateResults(float g, float *gmap, float *persistence_map, size_t bufsize); void transformNoiseMap(); }; @@ -134,14 +159,14 @@ public: float noise2d(int x, int y, int seed); float noise3d(int x, int y, int z, int seed); -float noise2d_gradient(float x, float y, int seed); +float noise2d_gradient(float x, float y, int seed, bool eased=true); float noise3d_gradient(float x, float y, float z, int seed, bool eased=false); float noise2d_perlin(float x, float y, int seed, - int octaves, float persistence); + int octaves, float persistence, bool eased=true); float noise2d_perlin_abs(float x, float y, int seed, - int octaves, float persistence); + int octaves, float persistence, bool eased=true); float noise3d_perlin(float x, float y, float z, int seed, int octaves, float persistence, bool eased=false); |