Skip to main content

TriangleMesh

Struct TriangleMesh 

Source
pub struct TriangleMesh { /* private fields */ }
Expand description

A static triangle mesh, validated, with active edges and a tree over its triangles: see the module docs.

Cloning copies a pointer: the data is shared behind an Arc.

Implementations§

Source§

impl TriangleMesh

Source

pub fn cast_ray(&self, ray: &Ray) -> Option<MeshHit>

The nearest triangle a ray in the mesh’s frame crosses within its bounds, from either side: ShapeHit::started_inside is never set, since a surface has no inside. A ray running along a triangle’s plane does not strike it.

Source

pub fn sweep_sphere(&self, segment: &Segment, radius: f64) -> Option<MeshHit>

The first triangle a sphere of radius meets moving along segment, in the mesh’s frame, as crate::swept_sphere_vs_sphere reports one: t in [0, 1], a sweep that starts touching a triangle is a contact at t = 0 with ShapeHit::started_inside.

Source

pub fn sweep_capsule( &self, segment: &Segment, radius: f64, half_height: f64, ) -> Option<MeshHit>

sweep_sphere for a capsule standing up the mesh frame’s y axis, segment the path of its centre, as crate::swept_capsule_vs_aabb takes one.

Source

pub fn overlaps_sphere(&self, sphere: &Sphere) -> bool

Whether a sphere in the mesh’s frame touches any triangle.

Source

pub fn overlaps_aabb(&self, aabb: &Aabb) -> bool

Whether a box in the mesh’s frame touches any triangle, exactly: by the separating axis test of Akenine-Möller’s triangle–box overlap, not by bounds.

Source

pub fn capsule_penetration(&self, capsule: &Capsule) -> Option<Penetration>

How far a capsule standing up the mesh frame’s y axis must move, and which way, to leave the triangle it is deepest in — the push-out crate::capsule_penetration_vs_aabb gives for a box — or None if it is inside none.

A capsule whose core crosses a triangle is pushed out along the triangle’s normal on the side its centre is, far enough for the end behind it to clear the plane.

Source§

impl TriangleMesh

Source

pub const MIN_ASPECT: f64 = 1.0e-6

The least a triangle’s height across its longest edge may be, as a share of that edge, before it is refused as degenerate: a micrometre across a metre. Below it the normal is rounding.

Source

pub const ACTIVE_EDGE_COSINE: f64 = 0.996_194_698_091_745_5

The cosine of the angle a convex edge between two triangles must bend by to be active: five degrees, Jolt’s default mActiveEdgeCosThresholdAngle. A seam flatter than that is treated as flat.

Source

pub fn new( vertices: &[DVec3], triangles: &[[u32; 3]], ) -> Result<Self, MeshError>

A mesh of triangles, each three indices into vertices wound so (v1 − v0) × (v2 − v0) is its outward normal.

§Errors

See the module docs: MeshError::NoTriangles and MeshError::TooManyTriangles first, then the first non-finite vertex in vertex order, then the first bad triangle in triangle order — an index out of range before degeneracy.

Source

pub fn collide_with_all_edges(self) -> Self

This mesh with every edge active, seams included: Jolt’s EActiveEdgeMode::CollideWithAll. A body sliding across a seam then catches on it, which is what the active edges are there to stop; this is for comparing against that, not for a level.

Source

pub fn vertices(&self) -> &[DVec3]

The vertices, as given.

Source

pub fn triangles(&self) -> &[[u32; 3]]

The triangles, as given: three indices into vertices each.

Source

pub fn triangle_count(&self) -> usize

How many triangles there are.

Source

pub fn corners(&self, index: usize) -> [DVec3; 3]

Triangle index’s three corners.

§Panics

Panics if there is no triangle index.

Source

pub fn normal(&self, index: usize) -> DVec3

Triangle index’s unit normal.

§Panics

Panics if there is no triangle index.

Source

pub fn active_edges(&self, index: usize) -> u8

Triangle index’s active edges: bit i set when edge i, from its vertex i to vertex i + 1, is active. See the module docs.

§Panics

Panics if there is no triangle index.

Source

pub fn bounds(&self) -> Aabb

The bounds of every triangle, in the mesh’s frame.

Trait Implementations§

Source§

impl Clone for TriangleMesh

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TriangleMesh

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TriangleMesh

Source§

fn eq(&self, other: &Self) -> bool

Equal when the vertices, the triangles and the active edges are: the normals and the tree follow from those.

1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.