pub type TrimeshBuilderError = TriMeshBuilderError;Expand description
An error indicating an inconsistency when building a triangle mesh collider.
Aliased Type§
pub enum TrimeshBuilderError {
EmptyIndices,
TopologyError(TopologyError),
}Variants§
EmptyIndices
The index buffer is empty (no triangles provided).
A triangle mesh must contain at least one triangle. An empty index buffer is not valid because there’s nothing to render or use for collision detection.
§How to Fix
Ensure your index buffer has at least one triangle:
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
// BAD: No triangles
let empty_indices = vec![];
assert!(TriMesh::new(vertices.clone(), empty_indices).is_err());
// GOOD: At least one triangle
let indices = vec![[0, 1, 2]];
assert!(TriMesh::new(vertices, indices).is_ok());TopologyError(TopologyError)
The mesh topology is invalid.
This wraps a [TopologyError] that provides details about the specific
topology problem. This only occurs when creating a mesh with topology
validation enabled (e.g., TriMeshFlags::HALF_EDGE_TOPOLOGY).
See [TopologyError] for details on specific topology problems and how
to fix them.
§Example
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
// Triangle with duplicate vertices
let bad_indices = vec![[0, 0, 1]];
match TriMesh::with_flags(vertices, bad_indices, TriMeshFlags::HALF_EDGE_TOPOLOGY) {
Err(TriMeshBuilderError::TopologyError(topo_err)) => {
println!("Topology error: {}", topo_err);
// Handle the specific topology issue
}
_ => {}
}