Skip to main content

weld

Function weld 

Source
pub fn weld(tx: &mut Transaction<'_>, tolerance: f32) -> Result<WeldReport>
Expand description

Merges vertices at most tolerance apart (local units).

Vertices are grouped through chains of pairs within the tolerance; each group keeps its smallest id at its original position. Triangles are rewritten to the kept ids, those that thereby get a repeated id are removed, and so are all vertices no triangle uses afterwards, including ones that were unused before. Tolerance 0 merges exact duplicates only. A vertex with a non-finite coordinate is never merged. No vertex is created.

On a mesh with UVs (Mesh::uvs), a pair also needs equal UVs (within 1e-6 per component) to merge, so the two sides of a UV seam stay apart and every kept vertex keeps its own UV. Without UVs nothing changes.

Rewiring can make two triangles share a vertex set, or give an edge a third triangle; run remove_degenerate() afterwards to drop duplicates.

ยงErrors

OpsError::InvalidInput when tolerance is negative, NaN or infinite; OpsError::Store when memory runs out.