Skip to content

Commit

Permalink
Add option 'eased' to NoiseParams
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Robbins <kde.psych@gmail.com>
  • Loading branch information
SmallJoker authored and Zeno- committed Nov 13, 2014
1 parent b57478b commit 874109c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
13 changes: 13 additions & 0 deletions doc/lua_api.txt
Expand Up @@ -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
}
4 changes: 3 additions & 1 deletion src/noise.h
Expand Up @@ -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_;
}
};

Expand Down
1 change: 1 addition & 0 deletions src/script/common/c_content.cpp
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/script/lua_api/l_noise.cpp
Expand Up @@ -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++) {
Expand All @@ -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;
Expand Down

0 comments on commit 874109c

Please sign in to comment.