Expand description
MeshGraph is a halfedge data structure for representing triangle meshes.
This is heavily inspired by SMesh and OpenMesh.
§Features
- Fast spatial queries using parry3d’s Bvh
- High performance using slotmap
- Easy integration with Bevy game engine using the
bevyCargo feature - Good debugging using
rerunCargo feature to enable the Rerun integration - Best in class documentation with illustrations
§Debugging topology corruption
The instrumentation Cargo feature compiles in extra topology probes: chain /
twin / outgoing-list validators that run at the end of every topology op and
report the first op to corrupt the mesh, plus JSON state dump/resume via
MeshGraph::save_state / MeshGraph::load_state. Enabling the feature enables
the probes — there is no second switch to forget — and regular builds compile
none of it.
The validators scan every halfedge at the end of every topology op, so the cost
grows with the mesh: roughly 30 ms per op call on a 250k-halfedge mesh. That is
nothing for the per-stroke *_until_* ops but very noticeable for a host that
calls merge_vertices_one_rings hundreds of times per stroke. The further
extras stay opt-in via the environment:
MESH_GRAPH_STATE_HISTORY_LEN=<n>keeps a ring of the lastnverified mesh states (a full mesh clone per op) and writes it to disk when a probe fires, so the run can be resumed from any state leading up to the corruption. Default0.MESH_GRAPH_HOLE_CHECK=1adds the boundary-delta probe: every probed op must leave the set of open edges exactly as it found it.MESH_GRAPH_TRACE=1records a ring of the structural re-wiring events leading up to a report.
§Usage
use mesh_graph::{MeshGraph, primitives::IcoSphere};
// Create a new mesh
let mesh_graph = MeshGraph::from(IcoSphere { radius: 10.0, subdivisions: 2 });
// Get some vertex ID and its vertex node
let (vertex_id, vertex) = mesh_graph.vertices.iter().next().unwrap();
// Iterate over all outgoing halfedges of the vertex
for halfedge_id in vertex.outgoing_halfedges(&mesh_graph) {
// do sth
}
// Get the position of the vertex
let position = mesh_graph.positions[vertex_id];Check out the crate freestyle-sculpt for a heavy duty example.
§Connectivity
§Halfedge
§Vertex
Modules§
Macros§
Structs§
- AddEdge
- Return value of
add_edge - AddFace
- Return value of several
add_face...methods - AddOr
GetEdge - Return value of
add_or_get_edge - Circular
Halfedges Iterator - Iterator over some halfedges
- Face
- FaceId
- Halfedge
- A directional edge that points from one vertex to another and is (optionally) part of a face. If it’s not part of a face, it’s called a boundary halfedge.
- Halfedge
Id - Hash
Grid - Merge
Vertices OneRing - Mesh
Graph - Halfedge data structure for representing triangle meshes.
- Polygon2
- Polygon3
- Polygon
Id - Selection
- Vertex
- A vertex is an corner point of a face.
- Vertex
Id
Enums§
- Edge
Length Cleanup - The outcome of
MeshGraph::collapse_until_edges_above_min_lengthandMeshGraph::subdivide_until_edges_below_max_length. - Polygon
Terminal