Skip to content

Commit

Permalink
Fix naming conventions of noise userdata
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Jan 7, 2018
1 parent 9146c6a commit 0a83c42
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
24 changes: 12 additions & 12 deletions doc/lua_api.txt
Expand Up @@ -3893,8 +3893,8 @@ Alternatively with `minetest.get_perlin(seeddiff, octaves, persistence, scale)`
or `minetest.get_perlin(noiseparams)`.

#### Methods
* `get2d(pos)`: returns 2D noise value at `pos={x=,y=}`
* `get3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
* `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
* `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`

### `PerlinNoiseMap`
A fast, bulk perlin noise generator.
Expand All @@ -3911,25 +3911,25 @@ nil, this table will be used to store the result instead of creating a new table


#### Methods
* `get2dMap(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
* `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
with values starting at `pos={x=,y=}`
* `get3dMap(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>` 3D array
* `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>` 3D array
of 3D noise with values starting at `pos={x=,y=,z=}`
* `get2dMap_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element array of 2D noise
* `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element array of 2D noise
with values starting at `pos={x=,y=}`
* `get3dMap_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
* `calc2dMap(pos)`: Calculates the 2d noise map starting at `pos`. The result is stored internally.
* `calc3dMap(pos)`: Calculates the 3d noise map starting at `pos`. The result is stored internally.
* `getMapSlice(slice_offset, slice_size, buffer)`: In the form of an array, returns a slice of the
* `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
* `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result is stored internally.
* `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result is stored internally.
* `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array, returns a slice of the
most recently computed noise results. The result slice begins at coordinates `slice_offset` and
takes a chunk of `slice_size`.
E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer offset y = 20:
`noisevals = noise:getMapSlice({y=20}, {y=2})`
`noisevals = noise:get_map_slice({y=20}, {y=2})`
It is important to note that `slice_offset` offset coordinates begin at 1, and are relative to
the starting position of the most recently calculated noise.
To grab a single vertical column of noise starting at map coordinates x = 1023, y=1000, z = 1000:
`noise:calc3dMap({x=1000, y=1000, z=1000})`
`noisevals = noise:getMapSlice({x=24, z=1}, {x=1, z=1})`
`noise:calc_3d_map({x=1000, y=1000, z=1000})`
`noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`

### `VoxelManip`

Expand Down
36 changes: 18 additions & 18 deletions src/script/lua_api/l_noise.cpp
Expand Up @@ -36,7 +36,7 @@ LuaPerlinNoise::LuaPerlinNoise(NoiseParams *params) :
}


int LuaPerlinNoise::l_get2d(lua_State *L)
int LuaPerlinNoise::l_get_2d(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
LuaPerlinNoise *o = checkobject(L, 1);
Expand All @@ -47,7 +47,7 @@ int LuaPerlinNoise::l_get2d(lua_State *L)
}


int LuaPerlinNoise::l_get3d(lua_State *L)
int LuaPerlinNoise::l_get_3d(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
LuaPerlinNoise *o = checkobject(L, 1);
Expand Down Expand Up @@ -131,8 +131,8 @@ void LuaPerlinNoise::Register(lua_State *L)

const char LuaPerlinNoise::className[] = "PerlinNoise";
const luaL_Reg LuaPerlinNoise::methods[] = {
luamethod(LuaPerlinNoise, get2d),
luamethod(LuaPerlinNoise, get3d),
luamethod_aliased(LuaPerlinNoise, get_2d, get2d),
luamethod_aliased(LuaPerlinNoise, get_3d, get3d),
{0,0}
};

Expand All @@ -159,7 +159,7 @@ LuaPerlinNoiseMap::~LuaPerlinNoiseMap()
}


int LuaPerlinNoiseMap::l_get2dMap(lua_State *L)
int LuaPerlinNoiseMap::l_get_2d_map(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
size_t i = 0;
Expand All @@ -183,7 +183,7 @@ int LuaPerlinNoiseMap::l_get2dMap(lua_State *L)
}


int LuaPerlinNoiseMap::l_get2dMap_flat(lua_State *L)
int LuaPerlinNoiseMap::l_get_2d_map_flat(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;

Expand All @@ -209,7 +209,7 @@ int LuaPerlinNoiseMap::l_get2dMap_flat(lua_State *L)
}


int LuaPerlinNoiseMap::l_get3dMap(lua_State *L)
int LuaPerlinNoiseMap::l_get_3d_map(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
size_t i = 0;
Expand Down Expand Up @@ -240,7 +240,7 @@ int LuaPerlinNoiseMap::l_get3dMap(lua_State *L)
}


int LuaPerlinNoiseMap::l_get3dMap_flat(lua_State *L)
int LuaPerlinNoiseMap::l_get_3d_map_flat(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;

Expand Down Expand Up @@ -269,7 +269,7 @@ int LuaPerlinNoiseMap::l_get3dMap_flat(lua_State *L)
}


int LuaPerlinNoiseMap::l_calc2dMap(lua_State *L)
int LuaPerlinNoiseMap::l_calc_2d_map(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;

Expand All @@ -282,7 +282,7 @@ int LuaPerlinNoiseMap::l_calc2dMap(lua_State *L)
return 0;
}

int LuaPerlinNoiseMap::l_calc3dMap(lua_State *L)
int LuaPerlinNoiseMap::l_calc_3d_map(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;

Expand All @@ -299,7 +299,7 @@ int LuaPerlinNoiseMap::l_calc3dMap(lua_State *L)
}


int LuaPerlinNoiseMap::l_getMapSlice(lua_State *L)
int LuaPerlinNoiseMap::l_get_map_slice(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;

Expand Down Expand Up @@ -389,13 +389,13 @@ void LuaPerlinNoiseMap::Register(lua_State *L)

const char LuaPerlinNoiseMap::className[] = "PerlinNoiseMap";
const luaL_Reg LuaPerlinNoiseMap::methods[] = {
luamethod(LuaPerlinNoiseMap, get2dMap),
luamethod(LuaPerlinNoiseMap, get2dMap_flat),
luamethod(LuaPerlinNoiseMap, calc2dMap),
luamethod(LuaPerlinNoiseMap, get3dMap),
luamethod(LuaPerlinNoiseMap, get3dMap_flat),
luamethod(LuaPerlinNoiseMap, calc3dMap),
luamethod(LuaPerlinNoiseMap, getMapSlice),
luamethod_aliased(LuaPerlinNoiseMap, get_2d_map, get2dMap),
luamethod_aliased(LuaPerlinNoiseMap, get_2d_map_flat, get2dMap_flat),
luamethod_aliased(LuaPerlinNoiseMap, calc_2d_map, calc2dMap),
luamethod_aliased(LuaPerlinNoiseMap, get_3d_map, get3dMap),
luamethod_aliased(LuaPerlinNoiseMap, get_3d_map_flat, get3dMap_flat),
luamethod_aliased(LuaPerlinNoiseMap, calc_3d_map, calc3dMap),
luamethod_aliased(LuaPerlinNoiseMap, get_map_slice, getMapSlice),
{0,0}
};

Expand Down
18 changes: 9 additions & 9 deletions src/script/lua_api/l_noise.h
Expand Up @@ -38,8 +38,8 @@ class LuaPerlinNoise : public ModApiBase
// garbage collector
static int gc_object(lua_State *L);

static int l_get2d(lua_State *L);
static int l_get3d(lua_State *L);
static int l_get_2d(lua_State *L);
static int l_get_3d(lua_State *L);

public:
LuaPerlinNoise(NoiseParams *params);
Expand Down Expand Up @@ -70,14 +70,14 @@ class LuaPerlinNoiseMap : public ModApiBase
// garbage collector
static int gc_object(lua_State *L);

static int l_get2dMap(lua_State *L);
static int l_get2dMap_flat(lua_State *L);
static int l_get3dMap(lua_State *L);
static int l_get3dMap_flat(lua_State *L);
static int l_get_2d_map(lua_State *L);
static int l_get_2d_map_flat(lua_State *L);
static int l_get_3d_map(lua_State *L);
static int l_get_3d_map_flat(lua_State *L);

static int l_calc2dMap(lua_State *L);
static int l_calc3dMap(lua_State *L);
static int l_getMapSlice(lua_State *L);
static int l_calc_2d_map(lua_State *L);
static int l_calc_3d_map(lua_State *L);
static int l_get_map_slice(lua_State *L);

public:
LuaPerlinNoiseMap(NoiseParams *np, s32 seed, v3s16 size);
Expand Down

0 comments on commit 0a83c42

Please sign in to comment.