Algorithms for generating triangle meshes from:
- height maps
- signed distance fields
- voxel occupancy grids
All of the algorithms are designed to be used with a ChunkMap, such that each chunk will have its own mesh. In order to
update the mesh for a chunk, you must copy not only the chunk, but also some adjacent points, into an array before running
the meshing algorithm.
An example of updating chunk meshes for a height map is shown below. The same general pattern applies to all meshing algorithms, where you:
- get the desired chunk extent
- pad the extent for a particular meshing algorithm
- copy that extent into an array
- mesh that array
use *;
use *;
use *;
use HashSet;
let chunk_shape = PointN;
let builder = ChunkMapBuilder ;
let mut map = builder.build_with_hash_map_storage;
// ...mutate one or more of the chunks...
let mutated_chunk_keys = ;
// For each mutated chunk, and any adjacent chunk, the mesh will need to be updated.
let mut chunk_keys_to_update: = new;
let offsets = moore_offsets;
for chunk_key in mutated_chunk_keys.into_iter
// Now we generate mesh vertices for each chunk.
for chunk_key in chunk_keys_to_update.into_iter
All of the meshing algorithms are generic enough to work with an array wrapped in a TransformMap.
# use *;
# use *;
# use *;
#
;
let extent = from_min_and_shape;
let array = fill;
let tfm_array = new;
let mut hm_buffer = default;
triangulate_height_map;