#[repr(C)]pub struct TriMesh { /* private fields */ }Expand description
A triangle mesh.
Implementations§
Source§impl TriMesh
impl TriMesh
Sourcepub fn bounding_sphere(&self, pos: &Isometry<f32>) -> BoundingSphere
pub fn bounding_sphere(&self, pos: &Isometry<f32>) -> BoundingSphere
Computes the world-space bounding sphere of this triangle mesh, transformed by pos.
Sourcepub fn local_bounding_sphere(&self) -> BoundingSphere
pub fn local_bounding_sphere(&self) -> BoundingSphere
Computes the local-space bounding sphere of this triangle mesh.
Source§impl TriMesh
impl TriMesh
Sourcepub fn new(
vertices: Vec<Point<f32>>,
indices: Vec<[u32; 3]>,
) -> Result<Self, TriMeshBuilderError>
pub fn new( vertices: Vec<Point<f32>>, indices: Vec<[u32; 3]>, ) -> Result<Self, TriMeshBuilderError>
Creates a new triangle mesh from a vertex buffer and an index buffer.
This is the most common way to construct a TriMesh. The mesh is created with
default settings (no topology computation, no pseudo-normals, etc.). For more
control over these optional features, use TriMesh::with_flags instead.
§Arguments
vertices- A vector of 3D points representing the mesh verticesindices- A vector of triangles, where each triangle is represented by three indices into the vertex buffer. Indices should be in counter-clockwise order for outward-facing normals.
§Returns
Ok(TriMesh)- If the mesh was successfully createdErr(TriMeshBuilderError)- If the mesh is invalid (e.g., empty index buffer)
§Errors
This function returns an error if:
- The index buffer is empty (at least one triangle is required)
§Performance
This function builds a BVH (Bounding Volume Hierarchy) acceleration structure for the mesh, which takes O(n log n) time where n is the number of triangles.
§Example
use parry3d::shape::TriMesh;
use nalgebra::Point3;
// Create a simple triangle mesh (a single triangle)
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2]];
let trimesh = TriMesh::new(vertices, indices).expect("Invalid mesh");
assert_eq!(trimesh.num_triangles(), 1);use parry2d::shape::TriMesh;
use nalgebra::Point2;
// Create a quad (two triangles) in 2D
let vertices = vec![
Point2::origin(), // bottom-left
Point2::new(1.0, 0.0), // bottom-right
Point2::new(1.0, 1.0), // top-right
Point2::new(0.0, 1.0), // top-left
];
let indices = vec![
[0, 1, 2], // first triangle
[0, 2, 3], // second triangle
];
let quad = TriMesh::new(vertices, indices).unwrap();
assert_eq!(quad.num_triangles(), 2);
assert_eq!(quad.vertices().len(), 4);Sourcepub fn with_flags(
vertices: Vec<Point<f32>>,
indices: Vec<[u32; 3]>,
flags: TriMeshFlags,
) -> Result<Self, TriMeshBuilderError>
pub fn with_flags( vertices: Vec<Point<f32>>, indices: Vec<[u32; 3]>, flags: TriMeshFlags, ) -> Result<Self, TriMeshBuilderError>
Creates a new triangle mesh from a vertex buffer and an index buffer, and flags controlling optional properties.
This is the most flexible way to create a TriMesh, allowing you to specify exactly
which optional features should be computed. Use this when you need:
- Half-edge topology for adjacency information
- Connected components analysis
- Pseudo-normals for robust inside/outside tests
- Automatic merging of duplicate vertices
- Removal of degenerate or duplicate triangles
§Arguments
vertices- A vector of 3D points representing the mesh verticesindices- A vector of triangles, where each triangle is represented by three indices into the vertex bufferflags- A combination ofTriMeshFlagscontrolling which optional features to compute
§Returns
Ok(TriMesh)- If the mesh was successfully createdErr(TriMeshBuilderError)- If the mesh is invalid or topology computation failed
§Errors
This function returns an error if:
- The index buffer is empty
TriMeshFlags::HALF_EDGE_TOPOLOGYis set but the topology is invalid (e.g., non-manifold edges or inconsistent orientations)
§Performance
- Base construction: O(n log n) for BVH building
HALF_EDGE_TOPOLOGY: O(n) where n is the number of trianglesCONNECTED_COMPONENTS: O(n) with union-findORIENTEDorFIX_INTERNAL_EDGES: O(n) for pseudo-normal computationMERGE_DUPLICATE_VERTICES: O(n) with hash map lookups
§Example
use parry3d::shape::{TriMesh, TriMeshFlags};
use nalgebra::Point3;
// Create vertices for a simple mesh
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
Point3::new(1.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2], [1, 3, 2]];
// Create a mesh with half-edge topology
let flags = TriMeshFlags::HALF_EDGE_TOPOLOGY;
let mesh = TriMesh::with_flags(vertices.clone(), indices.clone(), flags)
.expect("Failed to create mesh");
// The topology information is now available
assert!(mesh.topology().is_some());use parry3d::shape::{TriMesh, TriMeshFlags};
use nalgebra::Point3;
// Combine multiple flags for advanced features
let flags = TriMeshFlags::HALF_EDGE_TOPOLOGY
| TriMeshFlags::MERGE_DUPLICATE_VERTICES
| TriMeshFlags::DELETE_DEGENERATE_TRIANGLES;
let mesh = TriMesh::with_flags(vertices, indices, flags)
.expect("Failed to create mesh");use parry3d::shape::{TriMesh, TriMeshFlags};
use nalgebra::Point3;
// For robust point containment tests in 3D
let flags = TriMeshFlags::ORIENTED;
let mesh = TriMesh::with_flags(vertices, indices, flags)
.expect("Failed to create mesh");
// Pseudo-normals are now computed for accurate inside/outside tests
assert!(mesh.pseudo_normals().is_some());Sourcepub fn set_flags(&mut self, flags: TriMeshFlags) -> Result<(), TopologyError>
pub fn set_flags(&mut self, flags: TriMeshFlags) -> Result<(), TopologyError>
Sets the flags of this triangle mesh, controlling its optional associated data.
Sourcepub fn total_memory_size(&self) -> usize
pub fn total_memory_size(&self) -> usize
An approximation of the memory usage (in bytes) for this struct plus the memory it allocates dynamically.
Sourcepub fn heap_memory_size(&self) -> usize
pub fn heap_memory_size(&self) -> usize
An approximation of the memory dynamically-allocated by this struct.
Sourcepub fn transform_vertices(&mut self, transform: &Isometry<f32>)
pub fn transform_vertices(&mut self, transform: &Isometry<f32>)
Transforms in-place the vertices of this triangle mesh.
Applies a rigid transformation (rotation and translation) to all vertices of the mesh. This is useful for positioning or orienting a mesh in world space. The transformation also updates the BVH and pseudo-normals (if present).
§Arguments
transform- The isometry (rigid transformation) to apply to all vertices
§Performance
This operation is O(n) for transforming vertices, plus O(n log n) for rebuilding the BVH, where n is the number of triangles.
§Example
use parry3d::shape::TriMesh;
use nalgebra::{Point3, Vector3, Isometry3};
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2]];
let mut mesh = TriMesh::new(vertices, indices).unwrap();
// Translate the mesh by (10, 0, 0)
let transform = Isometry3::translation(10.0, 0.0, 0.0);
mesh.transform_vertices(&transform);
// All vertices are now shifted
assert_eq!(mesh.vertices()[0], Point3::new(10.0, 0.0, 0.0));
assert_eq!(mesh.vertices()[1], Point3::new(11.0, 0.0, 0.0));
assert_eq!(mesh.vertices()[2], Point3::new(10.0, 1.0, 0.0));Sourcepub fn scaled(self, scale: &Vector<f32>) -> Self
pub fn scaled(self, scale: &Vector<f32>) -> Self
Returns a scaled version of this triangle mesh.
Creates a new mesh with all vertices scaled by the given per-axis scale factors. Unlike rigid transformations, scaling can change the shape of the mesh (when scale factors differ between axes).
The scaling also updates pseudo-normals (if present) to remain valid after the transformation, and efficiently scales the BVH structure.
§Arguments
scale- The scale factors for each axis (x, y, z in 3D)
§Returns
A new TriMesh with scaled vertices
§Example
use parry3d::shape::TriMesh;
use nalgebra::{Point3, Vector3};
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2]];
let mesh = TriMesh::new(vertices, indices).unwrap();
// Uniform scaling: double all dimensions
let scaled = mesh.clone().scaled(&Vector3::new(2.0, 2.0, 2.0));
assert_eq!(scaled.vertices()[1], Point3::new(2.0, 0.0, 0.0));
// Non-uniform scaling: stretch along X axis
let stretched = mesh.scaled(&Vector3::new(3.0, 1.0, 1.0));
assert_eq!(stretched.vertices()[1], Point3::new(3.0, 0.0, 0.0));
assert_eq!(stretched.vertices()[2], Point3::new(0.0, 1.0, 0.0));Sourcepub fn append(&mut self, rhs: &TriMesh)
pub fn append(&mut self, rhs: &TriMesh)
Appends a second triangle mesh to this triangle mesh.
This combines two meshes into one by adding all vertices and triangles from
the rhs mesh to this mesh. The vertex indices in the appended triangles
are automatically adjusted to reference the correct vertices in the combined
vertex buffer.
After appending, all optional features (topology, pseudo-normals, etc.) are recomputed according to this mesh’s current flags.
§Arguments
rhs- The mesh to append to this mesh
§Performance
This operation rebuilds the entire mesh with all its features, which can be expensive for large meshes. Time complexity is O(n log n) where n is the total number of triangles after appending.
§Example
use parry3d::shape::TriMesh;
use nalgebra::Point3;
// Create first mesh (a triangle)
let vertices1 = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let indices1 = vec![[0, 1, 2]];
let mut mesh1 = TriMesh::new(vertices1, indices1).unwrap();
// Create second mesh (another triangle, offset in space)
let vertices2 = vec![
Point3::new(2.0, 0.0, 0.0),
Point3::new(3.0, 0.0, 0.0),
Point3::new(2.0, 1.0, 0.0),
];
let indices2 = vec![[0, 1, 2]];
let mesh2 = TriMesh::new(vertices2, indices2).unwrap();
// Append second mesh to first
mesh1.append(&mesh2);
assert_eq!(mesh1.num_triangles(), 2);
assert_eq!(mesh1.vertices().len(), 6);Sourcepub fn from_polygon(vertices: Vec<Point<f32>>) -> Option<Self>
pub fn from_polygon(vertices: Vec<Point<f32>>) -> Option<Self>
Create a TriMesh from a set of points assumed to describe a counter-clockwise non-convex polygon.
This function triangulates a 2D polygon using ear clipping algorithm. The polygon can be convex or concave, but must be simple (no self-intersections) and have counter-clockwise winding order.
§Arguments
vertices- The vertices of the polygon in counter-clockwise order
§Returns
Some(TriMesh)- If triangulation succeededNone- If the polygon is invalid (self-intersecting, degenerate, etc.)
§Requirements
- Polygon must be simple (no self-intersections)
- Vertices must be in counter-clockwise order
- Polygon must have non-zero area
- Only available in 2D (
dim2feature)
§Performance
Ear clipping has O(n²) time complexity in the worst case, where n is the number of vertices.
§Example
use parry2d::shape::TriMesh;
use nalgebra::Point2;
// Create a simple concave polygon (L-shape)
let vertices = vec![
Point2::origin(),
Point2::new(2.0, 0.0),
Point2::new(2.0, 1.0),
Point2::new(1.0, 1.0),
Point2::new(1.0, 2.0),
Point2::new(0.0, 2.0),
];
let mesh = TriMesh::from_polygon(vertices)
.expect("Failed to triangulate polygon");
// The polygon has been triangulated
assert!(mesh.num_triangles() > 0);Sourcepub fn flat_indices(&self) -> &[u32]
pub fn flat_indices(&self) -> &[u32]
A flat view of the index buffer of this mesh.
Returns the triangle indices as a flat array of u32 values, where every
three consecutive values form a triangle. This is useful for interfacing
with graphics APIs that expect flat index buffers.
§Example
use parry3d::shape::TriMesh;
use nalgebra::Point3;
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
Point3::new(1.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2], [1, 3, 2]];
let mesh = TriMesh::new(vertices, indices).unwrap();
let flat = mesh.flat_indices();
assert_eq!(flat, &[0, 1, 2, 1, 3, 2]);
assert_eq!(flat.len(), mesh.num_triangles() * 3);Sourcepub fn reverse(&mut self)
pub fn reverse(&mut self)
Reverse the orientation of the triangle mesh.
This flips the winding order of all triangles, effectively turning the mesh “inside-out”. If triangles had counter-clockwise winding (outward normals), they will have clockwise winding (inward normals) after this operation.
This is useful when:
- A mesh was imported with incorrect orientation
- You need to flip normals for rendering or physics
- Creating the “back side” of a mesh
§Performance
This operation modifies triangles in-place (O(n)), but recomputes topology and pseudo-normals if they were present, which can be expensive for large meshes.
§Example
use parry3d::shape::TriMesh;
use nalgebra::Point3;
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2]];
let mut mesh = TriMesh::new(vertices, indices).unwrap();
let original_triangle = mesh.triangle(0);
// Reverse the mesh orientation
mesh.reverse();
let reversed_triangle = mesh.triangle(0);
// The first two vertices are swapped
assert_eq!(original_triangle.a, reversed_triangle.b);
assert_eq!(original_triangle.b, reversed_triangle.a);
assert_eq!(original_triangle.c, reversed_triangle.c);Sourcepub fn triangles(&self) -> impl ExactSizeIterator<Item = Triangle> + '_
pub fn triangles(&self) -> impl ExactSizeIterator<Item = Triangle> + '_
An iterator through all the triangles of this mesh.
Returns an iterator that yields Triangle shapes representing each
triangle in the mesh. Each triangle contains the actual 3D coordinates
of its three vertices (not indices).
§Performance
The iterator performs vertex lookups on-the-fly, so iterating through all triangles is O(n) where n is the number of triangles.
§Example
use parry3d::shape::TriMesh;
use nalgebra::Point3;
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
Point3::new(1.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2], [1, 3, 2]];
let mesh = TriMesh::new(vertices, indices).unwrap();
// Iterate through all triangles
for triangle in mesh.triangles() {
println!("Triangle: {:?}, {:?}, {:?}", triangle.a, triangle.b, triangle.c);
}
// Count triangles with specific properties
let count = mesh.triangles()
.filter(|tri| tri.area() > 0.1)
.count();Source§impl TriMesh
impl TriMesh
Sourcepub fn flags(&self) -> TriMeshFlags
pub fn flags(&self) -> TriMeshFlags
The flags of this triangle mesh.
Returns the TriMeshFlags that were used to construct this mesh,
indicating which optional features are enabled.
§Example
use parry3d::shape::{TriMesh, TriMeshFlags};
use nalgebra::Point3;
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2]];
let flags = TriMeshFlags::HALF_EDGE_TOPOLOGY;
let mesh = TriMesh::with_flags(vertices, indices, flags).unwrap();
assert!(mesh.flags().contains(TriMeshFlags::HALF_EDGE_TOPOLOGY));Sourcepub fn aabb(&self, pos: &Isometry<f32>) -> Aabb
pub fn aabb(&self, pos: &Isometry<f32>) -> Aabb
Compute the axis-aligned bounding box of this triangle mesh.
Returns the AABB that tightly bounds all triangles of the mesh after applying the given isometry transformation.
§Arguments
pos- The position/orientation of the mesh in world space
§Example
use parry3d::shape::TriMesh;
use nalgebra::{Point3, Isometry3};
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2]];
let mesh = TriMesh::new(vertices, indices).unwrap();
let identity = Isometry3::identity();
let aabb = mesh.aabb(&identity);
// The AABB contains all vertices
assert!(aabb.contains_local_point(&Point3::new(0.5, 0.5, 0.0)));Sourcepub fn local_aabb(&self) -> Aabb
pub fn local_aabb(&self) -> Aabb
Gets the local axis-aligned bounding box of this triangle mesh.
Returns the AABB in the mesh’s local coordinate system (without any
transformation applied). This is faster than TriMesh::aabb when
no transformation is needed.
§Example
use parry3d::shape::TriMesh;
use nalgebra::Point3;
let vertices = vec![
Point3::new(-1.0, -1.0, 0.0),
Point3::new(1.0, -1.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2]];
let mesh = TriMesh::new(vertices, indices).unwrap();
let aabb = mesh.local_aabb();
assert_eq!(aabb.mins.x, -1.0);
assert_eq!(aabb.maxs.x, 1.0);Sourcepub fn bvh(&self) -> &Bvh
pub fn bvh(&self) -> &Bvh
The acceleration structure used by this triangle-mesh.
Returns a reference to the BVH (Bounding Volume Hierarchy) that accelerates spatial queries on this mesh. The BVH is used internally for ray casting, collision detection, and other geometric queries.
§Example
use parry3d::shape::TriMesh;
use nalgebra::Point3;
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2]];
let mesh = TriMesh::new(vertices, indices).unwrap();
let bvh = mesh.bvh();
// The BVH can be used for advanced spatial queries
assert!(!bvh.is_empty());Sourcepub fn num_triangles(&self) -> usize
pub fn num_triangles(&self) -> usize
The number of triangles forming this mesh.
§Example
use parry3d::shape::TriMesh;
use nalgebra::Point3;
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
Point3::new(1.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2], [1, 3, 2]];
let mesh = TriMesh::new(vertices, indices).unwrap();
assert_eq!(mesh.num_triangles(), 2);Sourcepub fn is_backface(&self, feature: FeatureId) -> bool
pub fn is_backface(&self, feature: FeatureId) -> bool
Does the given feature ID identify a backface of this trimesh?
Sourcepub fn triangle(&self, i: u32) -> Triangle
pub fn triangle(&self, i: u32) -> Triangle
Get the i-th triangle of this mesh.
Returns a Triangle shape with the actual vertex coordinates (not indices)
of the requested triangle. The triangle index must be less than the number
of triangles in the mesh.
§Arguments
i- The index of the triangle to retrieve (0-based)
§Panics
Panics if i >= self.num_triangles().
§Example
use parry3d::shape::TriMesh;
use nalgebra::Point3;
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2]];
let mesh = TriMesh::new(vertices, indices).unwrap();
let triangle = mesh.triangle(0);
assert_eq!(triangle.a, Point3::origin());
assert_eq!(triangle.b, Point3::new(1.0, 0.0, 0.0));
assert_eq!(triangle.c, Point3::new(0.0, 1.0, 0.0));Sourcepub fn vertices(&self) -> &[Point<f32>] ⓘ
pub fn vertices(&self) -> &[Point<f32>] ⓘ
The vertex buffer of this mesh.
Returns a slice containing all vertex positions as 3D points. The vertices are stored in the order they were provided during construction.
§Example
use parry3d::shape::TriMesh;
use nalgebra::Point3;
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2]];
let mesh = TriMesh::new(vertices, indices).unwrap();
assert_eq!(mesh.vertices().len(), 3);
assert_eq!(mesh.vertices()[0], Point3::origin());Sourcepub fn indices(&self) -> &[[u32; 3]]
pub fn indices(&self) -> &[[u32; 3]]
The index buffer of this mesh.
Returns a slice of triangles, where each triangle is represented as an
array of three vertex indices. The indices reference positions in the
vertex buffer returned by TriMesh::vertices.
§Example
use parry3d::shape::TriMesh;
use nalgebra::Point3;
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
Point3::new(1.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2], [1, 3, 2]];
let mesh = TriMesh::new(vertices, indices).unwrap();
assert_eq!(mesh.indices().len(), 2);
assert_eq!(mesh.indices()[0], [0, 1, 2]);
assert_eq!(mesh.indices()[1], [1, 3, 2]);Sourcepub fn topology(&self) -> Option<&TriMeshTopology>
pub fn topology(&self) -> Option<&TriMeshTopology>
Returns the topology information of this trimesh, if it has been computed.
Topology information includes half-edge data structures that describe
adjacency relationships between vertices, edges, and faces. This is
computed when the TriMeshFlags::HALF_EDGE_TOPOLOGY flag is set.
§Example
use parry3d::shape::{TriMesh, TriMeshFlags};
use nalgebra::Point3;
let vertices = vec![
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2]];
// Without topology flag
let mesh = TriMesh::new(vertices.clone(), indices.clone()).unwrap();
assert!(mesh.topology().is_none());
// With topology flag
let mesh = TriMesh::with_flags(
vertices,
indices,
TriMeshFlags::HALF_EDGE_TOPOLOGY
).unwrap();
assert!(mesh.topology().is_some());Sourcepub fn connected_components(&self) -> Option<&TriMeshConnectedComponents>
pub fn connected_components(&self) -> Option<&TriMeshConnectedComponents>
Returns the connected-component information of this trimesh, if it has been computed.
Connected components represent separate, non-connected parts of the mesh.
This is computed when the TriMeshFlags::CONNECTED_COMPONENTS flag is set
(requires the std feature).
§Example
use parry3d::shape::{TriMesh, TriMeshFlags};
use nalgebra::Point3;
// Create two separate triangles (not connected)
let vertices = vec![
// First triangle
Point3::origin(),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
// Second triangle (separate)
Point3::new(5.0, 0.0, 0.0),
Point3::new(6.0, 0.0, 0.0),
Point3::new(5.0, 1.0, 0.0),
];
let indices = vec![[0, 1, 2], [3, 4, 5]];
let mesh = TriMesh::with_flags(
vertices,
indices,
TriMeshFlags::CONNECTED_COMPONENTS
).unwrap();
if let Some(cc) = mesh.connected_components() {
assert_eq!(cc.num_connected_components(), 2);
}Sourcepub fn connected_component_meshes(
&self,
flags: TriMeshFlags,
) -> Option<Vec<Result<TriMesh, TriMeshBuilderError>>>
pub fn connected_component_meshes( &self, flags: TriMeshFlags, ) -> Option<Vec<Result<TriMesh, TriMeshBuilderError>>>
Returns the connected-component of this mesh.
The connected-components are returned as a set of TriMesh build with the given flags.
Trait Implementations§
Source§impl CompositeShape for TriMesh
impl CompositeShape for TriMesh
Source§impl PointQuery for TriMesh
impl PointQuery for TriMesh
Source§fn project_local_point_with_max_dist(
&self,
pt: &Point<f32>,
solid: bool,
max_dist: f32,
) -> Option<PointProjection>
fn project_local_point_with_max_dist( &self, pt: &Point<f32>, solid: bool, max_dist: f32, ) -> Option<PointProjection>
Projects a point on self transformed by m, unless the projection lies further than the given max distance.
Source§fn project_local_point(
&self,
point: &Point<f32>,
solid: bool,
) -> PointProjection
fn project_local_point( &self, point: &Point<f32>, solid: bool, ) -> PointProjection
self. Read moreSource§fn project_local_point_and_get_feature(
&self,
point: &Point<f32>,
) -> (PointProjection, FeatureId)
fn project_local_point_and_get_feature( &self, point: &Point<f32>, ) -> (PointProjection, FeatureId)
self and returns the id of the
feature the point was projected on.Source§fn contains_local_point(&self, point: &Point<f32>) -> bool
fn contains_local_point(&self, point: &Point<f32>) -> bool
self.Source§fn project_point_with_max_dist(
&self,
m: &Isometry<f32>,
pt: &Point<f32>,
solid: bool,
max_dist: f32,
) -> Option<PointProjection>
fn project_point_with_max_dist( &self, m: &Isometry<f32>, pt: &Point<f32>, solid: bool, max_dist: f32, ) -> Option<PointProjection>
self transformed by m, unless the projection lies further than the given max distance.Source§fn distance_to_local_point(&self, pt: &Point<f32>, solid: bool) -> f32
fn distance_to_local_point(&self, pt: &Point<f32>, solid: bool) -> f32
self.Source§fn project_point(
&self,
m: &Isometry<f32>,
pt: &Point<f32>,
solid: bool,
) -> PointProjection
fn project_point( &self, m: &Isometry<f32>, pt: &Point<f32>, solid: bool, ) -> PointProjection
self transformed by m.Source§fn distance_to_point(
&self,
m: &Isometry<f32>,
pt: &Point<f32>,
solid: bool,
) -> f32
fn distance_to_point( &self, m: &Isometry<f32>, pt: &Point<f32>, solid: bool, ) -> f32
self transformed by m.Source§fn project_point_and_get_feature(
&self,
m: &Isometry<f32>,
pt: &Point<f32>,
) -> (PointProjection, FeatureId)
fn project_point_and_get_feature( &self, m: &Isometry<f32>, pt: &Point<f32>, ) -> (PointProjection, FeatureId)
self transformed by m and returns the id of the
feature the point was projected on.Source§impl PointQueryWithLocation for TriMesh
impl PointQueryWithLocation for TriMesh
Source§fn project_local_point_and_get_location_with_max_dist(
&self,
point: &Point<f32>,
solid: bool,
max_dist: f32,
) -> Option<(PointProjection, Self::Location)>
fn project_local_point_and_get_location_with_max_dist( &self, point: &Point<f32>, solid: bool, max_dist: f32, ) -> Option<(PointProjection, Self::Location)>
Projects a point on self, with a maximum projection distance.
Source§type Location = (u32, TrianglePointLocation)
type Location = (u32, TrianglePointLocation)
Source§fn project_local_point_and_get_location(
&self,
point: &Point<f32>,
solid: bool,
) -> (PointProjection, Self::Location)
fn project_local_point_and_get_location( &self, point: &Point<f32>, solid: bool, ) -> (PointProjection, Self::Location)
self.Source§fn project_point_and_get_location(
&self,
m: &Isometry<f32>,
pt: &Point<f32>,
solid: bool,
) -> (PointProjection, Self::Location)
fn project_point_and_get_location( &self, m: &Isometry<f32>, pt: &Point<f32>, solid: bool, ) -> (PointProjection, Self::Location)
self transformed by m.Source§impl RayCast for TriMesh
impl RayCast for TriMesh
Source§fn cast_local_ray(
&self,
ray: &Ray,
max_time_of_impact: f32,
solid: bool,
) -> Option<f32>
fn cast_local_ray( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<f32>
Source§fn cast_local_ray_and_get_normal(
&self,
ray: &Ray,
max_time_of_impact: f32,
solid: bool,
) -> Option<RayIntersection>
fn cast_local_ray_and_get_normal( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<RayIntersection>
Source§fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: f32) -> bool
fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: f32) -> bool
Source§fn cast_ray(
&self,
m: &Isometry<f32>,
ray: &Ray,
max_time_of_impact: f32,
solid: bool,
) -> Option<f32>
fn cast_ray( &self, m: &Isometry<f32>, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<f32>
Source§fn cast_ray_and_get_normal(
&self,
m: &Isometry<f32>,
ray: &Ray,
max_time_of_impact: f32,
solid: bool,
) -> Option<RayIntersection>
fn cast_ray_and_get_normal( &self, m: &Isometry<f32>, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<RayIntersection>
Source§impl Shape for TriMesh
impl Shape for TriMesh
Source§fn feature_normal_at_point(
&self,
_feature: FeatureId,
_point: &Point<f32>,
) -> Option<Unit<Vector<f32>>>
fn feature_normal_at_point( &self, _feature: FeatureId, _point: &Point<f32>, ) -> Option<Unit<Vector<f32>>>
Gets the normal of the triangle represented by feature.
Source§fn scale_dyn(
&self,
scale: &Vector<f32>,
_num_subdivisions: u32,
) -> Option<Box<dyn Shape>>
fn scale_dyn( &self, scale: &Vector<f32>, _num_subdivisions: u32, ) -> Option<Box<dyn Shape>>
scale into a boxed trait-object. Read moreSource§fn compute_local_aabb(&self) -> Aabb
fn compute_local_aabb(&self) -> Aabb
Aabb of this shape.Source§fn compute_local_bounding_sphere(&self) -> BoundingSphere
fn compute_local_bounding_sphere(&self) -> BoundingSphere
Source§fn compute_aabb(&self, position: &Isometry<f32>) -> Aabb
fn compute_aabb(&self, position: &Isometry<f32>) -> Aabb
Aabb of this shape with the given position.Source§fn mass_properties(&self, density: f32) -> MassProperties
fn mass_properties(&self, density: f32) -> MassProperties
Source§fn shape_type(&self) -> ShapeType
fn shape_type(&self) -> ShapeType
Source§fn as_typed_shape(&self) -> TypedShape<'_>
fn as_typed_shape(&self) -> TypedShape<'_>
fn ccd_thickness(&self) -> f32
fn ccd_angular_thickness(&self) -> f32
fn as_composite_shape(&self) -> Option<&dyn CompositeShape>
Source§fn clone_box(&self) -> Box<dyn Shape>
fn clone_box(&self) -> Box<dyn Shape>
clone_dynSource§fn compute_bounding_sphere(&self, position: &Isometry<f32>) -> BoundingSphere
fn compute_bounding_sphere(&self, position: &Isometry<f32>) -> BoundingSphere
Source§fn as_support_map(&self) -> Option<&dyn SupportMap>
fn as_support_map(&self) -> Option<&dyn SupportMap>
Source§fn as_polygonal_feature_map(&self) -> Option<(&dyn PolygonalFeatureMap, f32)>
fn as_polygonal_feature_map(&self) -> Option<(&dyn PolygonalFeatureMap, f32)>
Source§impl TypedCompositeShape for TriMesh
impl TypedCompositeShape for TriMesh
type PartShape = Triangle
type PartNormalConstraints = TrianglePseudoNormals
fn map_typed_part_at<T>( &self, i: u32, f: impl FnMut(Option<&Isometry<f32>>, &Self::PartShape, Option<&Self::PartNormalConstraints>) -> T, ) -> Option<T>
fn map_untyped_part_at<T>( &self, i: u32, f: impl FnMut(Option<&Isometry<f32>>, &dyn Shape, Option<&dyn NormalConstraints>) -> T, ) -> Option<T>
Auto Trait Implementations§
impl Freeze for TriMesh
impl RefUnwindSafe for TriMesh
impl Send for TriMesh
impl Sync for TriMesh
impl Unpin for TriMesh
impl UnwindSafe for TriMesh
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<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.