pub fn weld_indexed(
positions: &[f32],
normals: &[f32],
uvs: Option<&[f32]>,
indices: &[u32],
) -> Option<(Vec<f32>, Vec<f32>, Option<Vec<f32>>, Vec<u32>)>Expand description
Weld positions/normals (3 floats per vertex, equal length), optional
uvs (2 floats per vertex), and remap indices.
Returns Some((positions, normals, uvs, indices)) ONLY when at least two
vertices actually merged; uvs is Some iff the input uvs was, always
1:1 with the welded positions. Returns None when nothing changes — a mesh
that is already welded / all-crease (a swept solid, an indexed mesher, a
flat-shaded cube), OR a malformed input (normals not matching positions,
empty, a UV array not 2-per-vertex, or an out-of-range index). In every
None case the identity remap would reproduce the input byte-for-byte, so
the caller keeps its ORIGINAL buffers and skips the copy: no per-element
reallocation on the (common) already-welded path, and a malformed input
stays invalid-but-present rather than panicking or being re-associated.
Because the decision is purely “did any key collide”, the funnel stays
uniform — no per-geometry-type branching. The weld is idempotent: welding a
welded mesh returns None.