Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

geometry.voxelize

Sample a geometry onto a voxel grid and answer the centres of the cells it occupies as points: the cells its surface passes through, or with solid the cells of its inside too. Each point carries voxelSize and its integer grid coordinate voxel (counted from a corner two cells outside the bounds); the points run with z fastest, then y, then x. Triangles are sampled at half-cell spacing, so a cell the surface only grazes is still found. The points are numbered by id.

Inputs

  • geometry (Geometry). The surface sampled onto the grid. Its bounding box fixes where the grid starts and, when voxelSize is left to derive, how coarse it is.
  • voxelSize (Float, default 0). The width of one cell, in the geometry's own units. At 0 or below it is derived: sixteen cells across the longest side of the bounding box, and never finer than 0.0001.
  • solid (Bool, default false). true fills the inside as well as the shell: the space outside is found by flooding inward from the grid's border, and every cell the flood cannot reach becomes a point, so a closed surface fills through and a surface with a hole in it stays a shell.

Outputs

  • points (Geometry). One point per occupied cell, at its centre.
local cells = g.geometry.voxelize({ geometry = g.mesh.sphere({}), voxelSize = 0.25, solid = true })