| Crates.io | martini_rtin |
| lib.rs | martini_rtin |
| version | 0.2.0 |
| created_at | 2025-10-27 13:15:08.303084+00 |
| updated_at | 2025-10-27 13:15:08.303084+00 |
| description | A Rust implementation of the RTIN algorithm |
| homepage | https://github.com/milkcask/martini_rtin |
| repository | https://github.com/milkcask/martini_rtin |
| max_upload_size | |
| id | 1902883 |
| size | 19,174 |
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.

Add this to your Cargo.toml:
[dependencies]
martini_rtin = "0.2.0"
use martini_rtin::Martini;
// Create a mesh generator for a 257x257 grid (2^8 + 1)
let martini = Martini::with_capacity(257);
// Generate terrain data (flat array of height values)
let terrain: Vec<f32> = (0..257*257).map(|i| {
let x = i % 257;
let y = i / 257;
// Simple sine wave terrain
((x as f32 * 0.1).sin() + (y as f32 * 0.1).sin()) * 10.0
}).collect();
// Create a tile from the terrain data
let tile = martini.create_tile(terrain);
// Generate a mesh with maximum error of 1.0
let (vertices, triangles) = tile.get_mesh(1.0);
println!("Generated {} vertices and {} triangles",
vertices.len(), triangles.len() / 3);
The RTIN algorithm works by:
This approach allows for efficient level-of-detail mesh generation suitable for real-time applications.
The grid size must be of the form 2^n + 1 (e.g., 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025).
The algorithm is designed for real-time use and can generate meshes from large terrain grids in milliseconds.
ISC