block-mesh
Fast algorithms for generating voxel block meshes.
Two algorithms are included:
visible_block_faces
: very fast but suboptimal meshesgreedy_quads
: not quite as fast, but far fewer triangles are generated
Benchmarks show that visible_block_faces
generates about 40 million quads per second on a
single core of a 2.5 GHz Intel Core i7. Assuming spherical input data, greedy_quads
can generate a
more optimal version of the same mesh with 1/3 of the quads, but it takes about 3 times longer. To run the benchmarks
yourself, cd bench/ && cargo bench
.
Example Code
use ;
use ;
;
const EMPTY: BoolVoxel = BoolVoxel;
const FULL: BoolVoxel = BoolVoxel;
// A 16^3 chunk with 1-voxel boundary padding.
type ChunkShape = ;
// This chunk will cover just a single octant of a sphere SDF (radius 15).
let mut voxels = ;
for i in 0..SIZE
let mut buffer = new;
greedy_quads;
// Some quads were generated.
assert!;
License: MIT OR Apache-2.0