Skip to content

Add VoxelArea support #34

@S-S-X

Description

@S-S-X

A helper class for voxel areas.
It can be created via VoxelArea:new{MinEdge = pmin, MaxEdge = pmax}.
The coordinates are inclusive, like most other things in Minetest.

Methods

  • getExtent(): returns a 3D vector containing the size of the area formed by
    MinEdge and MaxEdge.
  • getVolume(): returns the volume of the area formed by MinEdge and
    MaxEdge.
  • index(x, y, z): 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.
  • indexp(p): 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.
  • position(i): returns the absolute position vector corresponding to index
    i.
  • contains(x, y, z): check if (x,y,z) is inside area formed by
    MinEdge and MaxEdge.
  • containsp(p): same as above, except takes a vector
  • containsi(i): same as above, except takes an index i
  • iter(minx, miny, minz, maxx, maxy, maxz): returns an iterator that returns
    indices.
    • from (minx,miny,minz) to (maxx,maxy,maxz) in the order of
      [z [y [x]]].
  • iterp(minp, maxp): same as above, except takes a vector

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestin-latest-dockerIncluded with latest docker images, might not yet be available elsewhere

    Projects

    Status

    In review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions