Files
smc-luanti-ide-helper/classes/VoxelArea.lua
Van 5d3804168b Position edits (#7)
* Moving annotations for vector classes and positions: `core_namespace.lua` -> `classes/vector.lua`. Rethinking position annotations

* Replacing float positions with integer positions where required (voxel manipulator, node coordinates, etc.). Adding missing annotations to the position parameters of core methods

* Fix position annotations in noises classes

* remove alias `MapPosition2d`

* Review fixes
2026-02-13 12:09:24 +03:00

90 lines
3.1 KiB
Lua

--- @meta
--- @class VoxelArea
--- A helper class for voxel areas.
--- It can be created via `VoxelArea(pmin, pmax)` or
--- `VoxelArea:new({MinEdge = pmin, MaxEdge = pmax})`.
--- The coordinates are *inclusive*, like most other things in Luanti.
---
--- @field MinEdge MapPosition
--- @field MaxEdge MapPosition
--- @field ystride integer
--- @field zstride integer
VoxelArea = {}
--- The coordinates are *inclusive*, like most other things in Luanti.
---
--- Also you can create an instance via `VoxelArea(pmin, pmax)`
---
--- @param cuboid { MinEdge: MapPosition, MaxEdge: MapPosition }
--- @return VoxelArea
function VoxelArea:new(cuboid) end
--- returns a 3D vector containing the size of the area formed by `MinEdge` and `MaxEdge`.
--- @return IntegerPosition
function VoxelArea:getExtent() end
--- returns the volume of the area formed by `MinEdge` and `MaxEdge`.
--- @return integer
function VoxelArea:getVolume() end
--- returns the index of an absolute position in a flat array starting at `1`.
--- * `x`, `y` and `z` must be integers to avoid an incorrect index result.
--- * The position (x, y, z) is not checked for being inside the area volume,
--- being outside can cause an incorrect index result.
--- * Useful for things like `VoxelManip`, raw Schematic specifiers,
--- `PerlinNoiseMap:get2d`/`3dMap`, and so on.
--- @param x integer
--- @param y integer
--- @param z integer
--- @return integer
function VoxelArea:index(x, y, z) end
--- same functionality as `index(x, y, z)` but takes a vector.
--- * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
--- is not checked for being inside the area volume.
--- @param position MapPosition
--- @return integer
function VoxelArea:indexp(position) end
--- returns the absolute position vector corresponding to index `i`.
--- @param i integer
--- @return MapPosition
function VoxelArea:position(i) end
--- check if (`x`,`y`,`z`) is inside area formed by `MinEdge` and `MaxEdge`.
--- @param x integer
--- @param y integer
--- @param z integer
--- @return boolean
function VoxelArea:contains(x, y, z) end
--- check if Position(`x`,`y`,`z`) is inside area formed by `MinEdge` and `MaxEdge`.
--- @param position MapPosition
--- @return boolean
function VoxelArea:containsp(position) end
--- same as `:containsp()`, except takes an index `i`
--- @param i integer
--- @return boolean
function VoxelArea:containsi(i) end
--- returns an iterator that returns indices.
--- * from (`min_x`,`min_y`,`min_z`) to (`max_x`,`max_y`,`max_z`) in the order of `[z [y [x]]]`.
--- @param min_x integer
--- @param min_y integer
--- @param min_z integer
--- @param max_x integer
--- @param max_y integer
--- @param max_z integer
--- @return fun(tbl: table<integer, integer>): integer, integer
function VoxelArea:iter(min_x, min_y, min_z, max_x, max_y, max_z) end
--- returns an iterator that returns indices.
--- * from (`min_x`,`min_y`,`min_z`) to (`max_x`,`max_y`,`max_z`) in the order of `[z [y [x]]]`.
--- @param min_pos MapPosition
--- @param max_pos MapPosition
--- @return fun(tbl: table<integer, integer>): integer, integer
function VoxelArea:iterp(min_pos, max_pos) end