From 4c9a8a91c4988b3567a38af622a3eb0d0ec19f6b Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sun, 17 May 2015 03:38:39 -0400 Subject: SAPI/Noise: Add PerlinNoiseMap:getMapSlice() function This adds the ability to grab 'slices' of noise calculated by PerlinNoiseMap. Retrieving smaller slices of noise from the computation result as needed optimizes memory usage while maintaining a reasonable amount of CPU overhead. --- doc/lua_api.txt | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'doc/lua_api.txt') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index b4a5fa1d8..2acb94a68 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -2640,16 +2640,30 @@ Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` conponent is ommitted for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise `nil` is returned). +For each of the functions with an optional `buffer` parameter: If `buffer` is not +nil, this table will be used to store the result instead of creating a new table. + + #### Methods * `get2dMap(pos)`: returns a `` times `` 2D array of 2D noise with values starting at `pos={x=,y=}` * `get3dMap(pos)`: returns a `` times `` times `` 3D array of 3D noise with values starting at `pos={x=,y=,z=}` -* `get2dMap_flat(pos)`: returns a flat `` element array of 2D noise +* `get2dMap_flat(pos, buffer)`: returns a flat `` element array of 2D noise with values starting at `pos={x=,y=}` - * if the param `buffer` is present, this table will be used to store the result instead -* `get3dMap_flat(pos)`: Same as `get2dMap_flat`, but 3D noise - * if the param `buffer` is present, this table will be used to store the result instead +* `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 + 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})` + 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})` ### `VoxelManip` An interface to the `MapVoxelManipulator` for Lua. -- cgit v1.2.3