pub enum TriMeshBuilderError {
EmptyIndices,
TopologyError(TopologyError),
}Expand description
Errors that occur when creating a triangle mesh.
When constructing a TriMesh using TriMesh::new or TriMesh::with_flags,
various validation checks are performed. This error type describes what went wrong.
§Common Usage
let vertices = vec![Point3::origin()];
let indices = vec![]; // Empty!
match TriMesh::new(vertices, indices) {
Err(TriMeshBuilderError::EmptyIndices) => {
println!("Cannot create a mesh with no triangles");
}
Err(TriMeshBuilderError::TopologyError(topo_err)) => {
println!("Mesh topology is invalid: {}", topo_err);
}
Ok(mesh) => {
println!("Mesh created successfully");
}
}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
}
_ => {}
}Trait Implementations§
Source§impl Clone for TriMeshBuilderError
impl Clone for TriMeshBuilderError
Source§fn clone(&self) -> TriMeshBuilderError
fn clone(&self) -> TriMeshBuilderError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TriMeshBuilderError
impl Debug for TriMeshBuilderError
Source§impl Display for TriMeshBuilderError
impl Display for TriMeshBuilderError
Source§impl Error for TriMeshBuilderError
impl Error for TriMeshBuilderError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<TriMeshBuilderError> for MeshIntersectionError
impl From<TriMeshBuilderError> for MeshIntersectionError
Source§fn from(value: TriMeshBuilderError) -> Self
fn from(value: TriMeshBuilderError) -> Self
Source§impl PartialEq for TriMeshBuilderError
impl PartialEq for TriMeshBuilderError
impl Copy for TriMeshBuilderError
impl Eq for TriMeshBuilderError
impl StructuralPartialEq for TriMeshBuilderError
Auto Trait Implementations§
impl Freeze for TriMeshBuilderError
impl RefUnwindSafe for TriMeshBuilderError
impl Send for TriMeshBuilderError
impl Sync for TriMeshBuilderError
impl Unpin for TriMeshBuilderError
impl UnwindSafe for TriMeshBuilderError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.