Skip to main content

OffsetMesh

Struct OffsetMesh 

Source
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

Source

pub fn from_triangle_soup(verts: &[[f64; 3]], faces: &[[usize; 3]]) -> Self

Build an OffsetMesh from a triangle soup, computing averaged vertex normals.

Source

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.

Source

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

Source

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.

Source

pub fn normals_are_unit(&self) -> bool

Validate that all vertex normals are unit length.

Source

pub fn surface_area(&self) -> f64

Surface area of the mesh (sum of triangle areas).

Source

pub fn centroid(&self) -> [f64; 3]

Centroid of the mesh (average vertex position).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.