stbvox_make_mesh function

  1. @Native<Int Function(Pointer<stbvox_mesh_maker>)>(ffi.Pointer<stbvox_mesh_maker>)>()
int stbvox_make_mesh(
  1. Pointer<stbvox_mesh_maker> mm
)

This sets the range of values in the 3D array for the voxels that the mesh generator will convert. The lower values are inclusive, the higher values are exclusive, so (0,0,0) to (16,16,16) generates mesh data associated with voxels up to (15,15,15) but no higher.

The mesh generate generates faces at the boundary between open space and solid space but associates them with the solid space, so if (15,0,0) is open and (16,0,0) is solid, then the mesh will contain the boundary between them if x0 <= 16 and x1 > 16.

Note that the mesh generator will access array elements 1 beyond the limits set in these parameters. For example, if you set the limits to be (0,0,0) and (16,16,16), then the generator will access all of the voxels between (-1,-1,-1) and (16,16,16), including (16,16,16). You may have to do pointer arithmetic to make it work.

For example, caveview processes mesh chunks that are 32x32x16, but it does this using input buffers that are 34x34x18.

The lower limits are x0 >= 0, y0 >= 0, and z0 >= 0.

The upper limits are mode dependent, but all the current methods are limited to x1 < 127, y1 < 127, z1 < 255. Note that these are not powers of two; if you want to use power-of-two chunks (to make it efficient to decide which chunk a coordinate falls in), you're limited to at most x1=64, y1=64, z1=128. For classic Minecraft-style worlds with limited vertical extent, I recommend using a single chunk for the entire height, which limits the height to 255 blocks (one less than Minecraft), and only chunk the map in X & Y.

Implementation

@ffi.Native<ffi.Int Function(ffi.Pointer<stbvox_mesh_maker>)>()
external int stbvox_make_mesh(ffi.Pointer<stbvox_mesh_maker> mm);