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
impl TriangleMesh
Sourcepub fn cast_ray(&self, ray: &Ray) -> Option<MeshHit>
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.
Sourcepub fn sweep_sphere(&self, segment: &Segment, radius: f64) -> Option<MeshHit>
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.
Sourcepub fn sweep_capsule(
&self,
segment: &Segment,
radius: f64,
half_height: f64,
) -> Option<MeshHit>
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.
Sourcepub fn overlaps_sphere(&self, sphere: &Sphere) -> bool
pub fn overlaps_sphere(&self, sphere: &Sphere) -> bool
Whether a sphere in the mesh’s frame touches any triangle.
Sourcepub fn overlaps_aabb(&self, aabb: &Aabb) -> bool
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.
Sourcepub fn capsule_penetration(&self, capsule: &Capsule) -> Option<Penetration>
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
impl TriangleMesh
Sourcepub const MIN_ASPECT: f64 = 1.0e-6
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.
Sourcepub const ACTIVE_EDGE_COSINE: f64 = 0.996_194_698_091_745_5
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.
Sourcepub fn new(
vertices: &[DVec3],
triangles: &[[u32; 3]],
) -> Result<Self, MeshError>
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.
Sourcepub fn collide_with_all_edges(self) -> Self
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.
Sourcepub fn triangles(&self) -> &[[u32; 3]]
pub fn triangles(&self) -> &[[u32; 3]]
The triangles, as given: three indices into vertices
each.
Sourcepub fn triangle_count(&self) -> usize
pub fn triangle_count(&self) -> usize
How many triangles there are.
Sourcepub fn active_edges(&self, index: usize) -> u8
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.