From 874109c5201c3deed49bc9eb98352e816c271d50 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Wed, 12 Nov 2014 21:11:40 +0100 Subject: [PATCH] Add option 'eased' to NoiseParams Signed-off-by: Craig Robbins --- doc/lua_api.txt | 13 +++++++++++++ src/noise.h | 4 +++- src/script/common/c_content.cpp | 1 + src/script/lua_api/l_noise.cpp | 4 ++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 698efbe8a..e4a016b1a 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -2796,3 +2796,16 @@ ParticleSpawner definition (add_particlespawner) playername = "singleplayer" ^ Playername is optional, if specified spawns particle only on the player's client } + +NoiseParams definition (PerlinNoiseMap) +{ + offset = 0, + scale = 0, + spread = 0, + seed = 0, + octaves = 0, + ^ A higher value will result in more details, this means more operations + persist = 0, + eased = false + ^ Whether it should create curves in 3D perlin maps +} diff --git a/src/noise.h b/src/noise.h index 00d3612af..398052837 100644 --- a/src/noise.h +++ b/src/noise.h @@ -73,11 +73,12 @@ struct NoiseParams { int seed; int octaves; float persist; + bool eased; NoiseParams() {} NoiseParams(float offset_, float scale_, v3f spread_, - int seed_, int octaves_, float persist_) + int seed_, int octaves_, float persist_, bool eased_=false) { offset = offset_; scale = scale_; @@ -85,6 +86,7 @@ struct NoiseParams { seed = seed_; octaves = octaves_; persist = persist_; + eased = eased_; } }; diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 0e1e608c4..1972c40e0 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -1000,6 +1000,7 @@ bool read_noiseparams_nc(lua_State *L, int index, NoiseParams *np) np->persist = getfloatfield_default(L, index, "persist", 0.0); np->seed = getintfield_default(L, index, "seed", 0); np->octaves = getintfield_default(L, index, "octaves", 0); + np->eased = getboolfield_default(L, index, "eased", false); lua_getfield(L, index, "spread"); np->spread = read_v3f(L, -1); diff --git a/src/script/lua_api/l_noise.cpp b/src/script/lua_api/l_noise.cpp index 263ecfd69..4f230b76e 100644 --- a/src/script/lua_api/l_noise.cpp +++ b/src/script/lua_api/l_noise.cpp @@ -190,7 +190,7 @@ int LuaPerlinNoiseMap::l_get3dMap(lua_State *L) v3f p = read_v3f(L, 2); Noise *n = o->noise; - n->perlinMap3D(p.X, p.Y, p.Z); + n->perlinMap3D(p.X, p.Y, p.Z, n->np->eased); lua_newtable(L); for (int z = 0; z != n->sz; z++) { @@ -216,7 +216,7 @@ int LuaPerlinNoiseMap::l_get3dMap_flat(lua_State *L) v3f p = read_v3f(L, 2); Noise *n = o->noise; - n->perlinMap3D(p.X, p.Y, p.Z); + n->perlinMap3D(p.X, p.Y, p.Z, n->np->eased); int maplen = n->sx * n->sy * n->sz;