martini_rtin
A Rust port of the RTIN (Right-Triangulated Irregular Network) algorithm previously implemented as Mapbox's Awesome Right-Triangulated Irregular Networks, Improved (MARTINI).
It's an experimental library for real-time terrain mesh generation from height data. Given a (2k+1) × (2k+1) terrain grid, it generates a hierarchy of triangular meshes of varying level of detail in milliseconds. A work in progress.
Based on the paper "Right-Triangulated Irregular Networks" by Will Evans et. al. (1997) and inspired by Mapbox's Martini library.

Features
- Fast terrain mesh generation from height data
- Configurable level of detail based on error tolerance
- Memory-efficient hierarchical mesh representation
- No unsafe code
Usage
Add this to your Cargo.toml:
[]
= "0.2.0"
Example
use Martini;
// Create a mesh generator for a 257x257 grid (2^8 + 1)
let martini = with_capacity;
// Generate terrain data (flat array of height values)
let terrain: = .map.collect;
// Create a tile from the terrain data
let tile = martini.create_tile;
// Generate a mesh with maximum error of 1.0
let = tile.get_mesh;
println!;
Algorithm
The RTIN algorithm works by:
- Building a hierarchy of right triangles from the terrain grid
- Computing approximation errors for each triangle level
- Generating meshes by recursively subdividing triangles that exceed the error threshold
This approach allows for efficient level-of-detail mesh generation suitable for real-time applications.
Grid Size Requirements
The grid size must be of the form 2^n + 1 (e.g., 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025).
Performance
The algorithm is designed for real-time use and can generate meshes from large terrain grids in milliseconds.
License
ISC