ide-helper: improve VoxelArea annotation: add types.

This commit is contained in:
alek13
2025-05-11 23:04:32 +03:00
parent 2acd74b3cf
commit bb1a27f946

View File

@@ -5,41 +5,65 @@
--- The coordinates are *inclusive*, like most other things in Minetest. --- The coordinates are *inclusive*, like most other things in Minetest.
VoxelArea = {} VoxelArea = {}
--- The coordinates are *inclusive*, like most other things in Minetest.
---
--- Also you can create an instance via `VoxelArea(pmin, pmax)`
---
--- @param cuboid { MinEdge: any, MaxEdge: any } --- @param cuboid { MinEdge: any, MaxEdge: any }
function VoxelArea:new(cuboid) end function VoxelArea:new(cuboid) end
--- returns a 3D vector containing the size of the area formed by --- returns a 3D vector containing the size of the area formed by `MinEdge` and `MaxEdge`.
--- `MinEdge` and `MaxEdge`. --- @return Position
function VoxelArea:getExtent() end function VoxelArea:getExtent() end
--- returns the volume of the area formed by `MinEdge` and --- returns the volume of the area formed by `MinEdge` and `MaxEdge`.
--- `MaxEdge`. --- @return number
function VoxelArea:getVolume() end function VoxelArea:getVolume() end
--- returns the index of an absolute position in a flat array --- returns the index of an absolute position in a flat array starting at `1`.
--- starting at `1`.
--- * `x`, `y` and `z` must be integers to avoid an incorrect index result. --- * `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, --- * The position (x, y, z) is not checked for being inside the area volume,
--- being outside can cause an incorrect index result. --- being outside can cause an incorrect index result.
--- * Useful for things like `VoxelManip`, raw Schematic specifiers, --- * Useful for things like `VoxelManip`, raw Schematic specifiers,
--- `PerlinNoiseMap:get2d`/`3dMap`, and so on. --- `PerlinNoiseMap:get2d`/`3dMap`, and so on.
--- @param x number
--- @param y number
--- @param z number
--- @return number
function VoxelArea:index(x, y, z) end function VoxelArea:index(x, y, z) end
--- same functionality as `index(x, y, z)` but takes a vector. --- 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` --- * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
--- is not checked for being inside the area volume. --- is not checked for being inside the area volume.
function VoxelArea:indexp(p) end --- @param position Position
--- returns the absolute position vector corresponding to index --- @return number
--- `i`. function VoxelArea:indexp(position) end
--- returns the absolute position vector corresponding to index `i`.
--- @param i number
--- @return Position
function VoxelArea:position(i) end function VoxelArea:position(i) end
--- check if (`x`,`y`,`z`) is inside area formed by --- check if (`x`,`y`,`z`) is inside area formed by `MinEdge` and `MaxEdge`.
--- `MinEdge` and `MaxEdge`. --- @param x number
--- @param y number
--- @param z number
--- @return boolean
function VoxelArea:contains(x, y, z) end function VoxelArea:contains(x, y, z) end
--- same as above, except takes a vector --- check if Position(`x`,`y`,`z`) is inside area formed by `MinEdge` and `MaxEdge`.
function VoxelArea:containsp(p) end --- @param position Position
--- @return boolean
function VoxelArea:containsp(position) end
--- same as above, except takes an index `i` --- same as above, except takes an index `i`
function VoxelArea:containsi(i) end function VoxelArea:containsi(i) end
--- returns an iterator that returns --- returns an iterator that returns indices.
--- indices. --- * from (`min_x`,`min_y`,`min_z`) to (`max_x`,`max_y`,`max_z`) in the order of `[z [y [x]]]`.
--- * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of --- @param min_x number
--- `[z [y [x]]]`. --- @param min_y number
function VoxelArea:iter(minx, miny, minz, maxx, maxy, maxz) end --- @param min_z number
--- same as above, except takes a vector --- @param max_x number
function VoxelArea:iterp(minp, maxp) end --- @param max_y number
--- @param max_z number
--- @return fun(tbl: table<number, number>): number, number
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 Position
--- @param max_pos Position
--- @return fun(tbl: table<number, number>): number, number
function VoxelArea:iterp(min_pos, max_pos) end