building-blocks 0.2.1

Data types, collections, and algorithms for working with maps on 2D and 3D integer lattices. Commonly known as voxel data.
Documentation

Building Blocks

Crates.io Docs.rs license Crates.io Discord

Building Blocks is a voxel library for real-time applications.

Meshing

Supported use cases include:

  • memory-efficient storage of voxel maps
  • voxel map serialization
  • generating meshes
    • isosurface
    • cubic / blocky
    • height maps
  • accelerated spatial queries
    • ray casting
    • range queries
  • procedural generation
    • sampling signed distance fields
    • generating height maps from fractal noise (TODO)
  • pathfinding

Short Code Example

The code below samples a signed distance field and generates a mesh from it.

use building_blocks::{
    prelude::*,
    mesh::{SurfaceNetsBuffer, surface_nets},
    procgen::signed_distance_fields::sphere,
};

let center = PointN([25.0; 3]);
let radius = 10.0;
let sphere_sdf = sphere(center, radius);

let extent = Extent3i::from_min_and_shape(PointN([0; 3]), PointN([50; 3]));
let mut samples = Array3::fill_with(extent, &sphere_sdf);

let mut mesh_buffer = SurfaceNetsBuffer::new();
surface_nets(&samples, samples.extent(), &mut mesh_buffer);

Learning

The current best way to learn about the library is to read the documentation and examples.

For the latest stable docs, look here.

For the latest unstable docs, clone the repo and run

cargo doc --open --all-features

There is plentiful documentation with examples.

Take a look in the examples/ directory to see how Building Blocks can be used in real applications.

To run the benchmarks (using the "criterion" crate), go to the root of a crate and run cargo bench.

To learn more about the motivations behind the library's design, read about our design philosophy and architecture.

Development

We prioritize work according to the project board.

If you'd like to make a contribution, please first read the contribution guidelines.