1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

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
This commit is contained in:
kwolekr 2014-12-07 21:57:12 -05:00
parent 638f3a8454
commit 2fd3d52020
16 changed files with 306 additions and 214 deletions

View file

@ -975,11 +975,11 @@ void luaentity_get(lua_State *L, u16 id)
}
/******************************************************************************/
NoiseParams *read_noiseparams(lua_State *L, int index)
NoiseParams *get_noiseparams(lua_State *L, int index)
{
NoiseParams *np = new NoiseParams;
if (!read_noiseparams_nc(L, index, np)) {
if (!read_noiseparams(L, index, np)) {
delete np;
np = NULL;
}
@ -987,7 +987,7 @@ NoiseParams *read_noiseparams(lua_State *L, int index)
return np;
}
bool read_noiseparams_nc(lua_State *L, int index, NoiseParams *np)
bool read_noiseparams(lua_State *L, int index, NoiseParams *np)
{
if (index < 0)
index = lua_gettop(L) + 1 + index;
@ -995,12 +995,16 @@ bool read_noiseparams_nc(lua_State *L, int index, NoiseParams *np)
if (!lua_istable(L, index))
return false;
np->offset = getfloatfield_default(L, index, "offset", 0.0);
np->scale = getfloatfield_default(L, index, "scale", 0.0);
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);
np->offset = getfloatfield_default(L, index, "offset", 0.0);
np->scale = getfloatfield_default(L, index, "scale", 0.0);
np->persist = getfloatfield_default(L, index, "persist", 0.0);
np->lacunarity = getfloatfield_default(L, index, "lacunarity", 2.0);
np->seed = getintfield_default(L, index, "seed", 0);
np->octaves = getintfield_default(L, index, "octaves", 0);
u32 flags = 0, flagmask = 0;
np->flags = getflagsfield(L, index, "flags", flagdesc_noiseparams,
&flags, &flagmask) ? flags : NOISE_FLAG_DEFAULTS;
lua_getfield(L, index, "spread");
np->spread = read_v3f(L, -1);

View file

@ -147,9 +147,9 @@ bool string_to_enum (const EnumString *spec,
int &result,
const std::string &str);
NoiseParams* read_noiseparams (lua_State *L, int index);
NoiseParams* get_noiseparams (lua_State *L, int index);
bool read_noiseparams_nc (lua_State *L, int index,
bool read_noiseparams (lua_State *L, int index,
NoiseParams *np);
bool get_schematic (lua_State *L, int index,
Schematic *schem,