pub struct OffsetMesh {
pub vertices: Vec<[f64; 3]>,
pub normals: Vec<[f64; 3]>,
pub faces: Vec<[usize; 3]>,
}Expand description
A triangle mesh with per-vertex normals, supporting inward/outward offsetting.
Fields§
§vertices: Vec<[f64; 3]>§normals: Vec<[f64; 3]>§faces: Vec<[usize; 3]>Implementations§
Source§impl OffsetMesh
impl OffsetMesh
Sourcepub fn from_triangle_soup(verts: &[[f64; 3]], faces: &[[usize; 3]]) -> Self
pub fn from_triangle_soup(verts: &[[f64; 3]], faces: &[[usize; 3]]) -> Self
Build an OffsetMesh from a triangle soup, computing averaged vertex normals.
Sourcepub fn compute_vertex_normals(
verts: &[[f64; 3]],
faces: &[[usize; 3]],
) -> Vec<[f64; 3]>
pub fn compute_vertex_normals( verts: &[[f64; 3]], faces: &[[usize; 3]], ) -> Vec<[f64; 3]>
Compute per-vertex normals by area-weighted average of incident face normals.
Sourcepub fn offset(&self, d: f64) -> OffsetMesh
pub fn offset(&self, d: f64) -> OffsetMesh
Offset every vertex by d along its averaged normal.
Positive d expands outward; negative d shrinks inward.
Source§impl OffsetMesh
impl OffsetMesh
Sourcepub fn collision_offset_shell(&self, d: f64) -> OffsetMesh
pub fn collision_offset_shell(&self, d: f64) -> OffsetMesh
Compute the “collision offset” shell mesh.
Generates a new mesh where each face is moved outward by d along its
face normal (not vertex normal). Unlike vertex-normal offsetting, this
produces a shell mesh useful for broad CCD convex hull testing.
Sourcepub fn normals_are_unit(&self) -> bool
pub fn normals_are_unit(&self) -> bool
Validate that all vertex normals are unit length.
Sourcepub fn surface_area(&self) -> f64
pub fn surface_area(&self) -> f64
Surface area of the mesh (sum of triangle areas).
Auto Trait Implementations§
impl Freeze for OffsetMesh
impl RefUnwindSafe for OffsetMesh
impl Send for OffsetMesh
impl Sync for OffsetMesh
impl Unpin for OffsetMesh
impl UnsafeUnpin for OffsetMesh
impl UnwindSafe for OffsetMesh
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
Mutably borrows from an owned value. Read more
Source§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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.