Add option 'eased' to NoiseParams

Signed-off-by: Craig Robbins <kde.psych@gmail.com>
master
SmallJoker 2014-11-12 21:11:40 +01:00 committed by Craig Robbins
parent b57478b93b
commit 874109c520
4 changed files with 19 additions and 3 deletions

View File

@ -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
}

View File

@ -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_;
}
};

View File

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

View File

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