Skip to content
Permalink
Browse files

Add option 'eased' to NoiseParams

Signed-off-by: Craig Robbins <kde.psych@gmail.com>
  • Loading branch information
SmallJoker authored and Zeno- committed Nov 13, 2014
1 parent b57478b commit 874109c5201c3deed49bc9eb98352e816c271d50
Showing with 19 additions and 3 deletions.
  1. +13 −0 doc/lua_api.txt
  2. +3 −1 src/noise.h
  3. +1 −0 src/script/common/c_content.cpp
  4. +2 −2 src/script/lua_api/l_noise.cpp
@@ -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
}
@@ -73,18 +73,20 @@ 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_;
spread = spread_;
seed = seed_;
octaves = octaves_;
persist = persist_;
eased = eased_;
}
};

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

0 comments on commit 874109c

Please sign in to comment.