Struct TriMesh

Source
#[repr(C)]
pub struct TriMesh { /* private fields */ }
Expand description

A triangle mesh.

Implementations§

Source§

impl TriMesh

Source

pub fn bounding_sphere(&self, pos: &Isometry<f32>) -> BoundingSphere

Computes the world-space bounding sphere of this triangle mesh, transformed by pos.

Source

pub fn local_bounding_sphere(&self) -> BoundingSphere

Computes the local-space bounding sphere of this triangle mesh.

Source§

impl TriMesh

Source

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 vertices
  • indices - 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 created
  • Err(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);
Source

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 vertices
  • indices - A vector of triangles, where each triangle is represented by three indices into the vertex buffer
  • flags - A combination of TriMeshFlags controlling which optional features to compute
§Returns
  • Ok(TriMesh) - If the mesh was successfully created
  • Err(TriMeshBuilderError) - If the mesh is invalid or topology computation failed
§Errors

This function returns an error if:

§Performance
  • Base construction: O(n log n) for BVH building
  • HALF_EDGE_TOPOLOGY: O(n) where n is the number of triangles
  • CONNECTED_COMPONENTS: O(n) with union-find
  • ORIENTED or FIX_INTERNAL_EDGES: O(n) for pseudo-normal computation
  • MERGE_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());
Source

pub fn set_flags(&mut self, flags: TriMeshFlags) -> Result<(), TopologyError>

Sets the flags of this triangle mesh, controlling its optional associated data.

Source

pub fn total_memory_size(&self) -> usize

An approximation of the memory usage (in bytes) for this struct plus the memory it allocates dynamically.

Source

pub fn heap_memory_size(&self) -> usize

An approximation of the memory dynamically-allocated by this struct.

Source

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));
Source

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));
Source

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);
Source

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 succeeded
  • None - 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 (dim2 feature)
§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);
Source

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);
Source

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);
Source

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

Source

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));
Source

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)));
Source

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);
Source

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());
Source

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);
Source

pub fn is_backface(&self, feature: FeatureId) -> bool

Does the given feature ID identify a backface of this trimesh?

Source

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));
Source

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());
Source

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]);
Source

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());
Source

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);
}
Source

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 Clone for TriMesh

Source§

fn clone(&self) -> TriMesh

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl CompositeShape for TriMesh

Source§

fn map_part_at( &self, i: u32, f: &mut dyn FnMut(Option<&Isometry<f32>>, &dyn Shape, Option<&dyn NormalConstraints>), )

Applies a function to one sub-shape of this composite shape. Read more
Source§

fn bvh(&self) -> &Bvh

Gets the acceleration structure of the composite shape.
Source§

impl Debug for TriMesh

Source§

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

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

impl PointQuery for TriMesh

Source§

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

Projects a point on self. Read more
Source§

fn project_local_point_and_get_feature( &self, point: &Point<f32>, ) -> (PointProjection, FeatureId)

Projects a point on the boundary of self and returns the id of the feature the point was projected on.
Source§

fn contains_local_point(&self, point: &Point<f32>) -> bool

Tests if the given point is inside of self.
Source§

fn project_point_with_max_dist( &self, m: &Isometry<f32>, 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 distance_to_local_point(&self, pt: &Point<f32>, solid: bool) -> f32

Computes the minimal distance between a point and self.
Source§

fn project_point( &self, m: &Isometry<f32>, pt: &Point<f32>, solid: bool, ) -> PointProjection

Projects a point on self transformed by m.
Source§

fn distance_to_point( &self, m: &Isometry<f32>, pt: &Point<f32>, solid: bool, ) -> f32

Computes the minimal distance between a point and self transformed by m.
Source§

fn project_point_and_get_feature( &self, m: &Isometry<f32>, pt: &Point<f32>, ) -> (PointProjection, FeatureId)

Projects a point on the boundary of self transformed by m and returns the id of the feature the point was projected on.
Source§

fn contains_point(&self, m: &Isometry<f32>, pt: &Point<f32>) -> bool

Tests if the given point is inside of self transformed by m.
Source§

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)>

Projects a point on self, with a maximum projection distance.

Source§

type Location = (u32, TrianglePointLocation)

Additional shape-specific projection information Read more
Source§

fn project_local_point_and_get_location( &self, point: &Point<f32>, solid: bool, ) -> (PointProjection, Self::Location)

Projects a point on self.
Source§

fn project_point_and_get_location( &self, m: &Isometry<f32>, pt: &Point<f32>, solid: bool, ) -> (PointProjection, Self::Location)

Projects a point on self transformed by m.
Source§

fn project_point_and_get_location_with_max_dist( &self, m: &Isometry<f32>, pt: &Point<f32>, solid: bool, max_dist: f32, ) -> Option<(PointProjection, Self::Location)>

Projects a point on self transformed by m, with a maximum projection distance.
Source§

impl RayCast for TriMesh

Source§

fn cast_local_ray( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<f32>

Computes the time of impact between this transform shape and a ray.
Source§

fn cast_local_ray_and_get_normal( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<RayIntersection>

Computes the time of impact, and normal between this transformed shape and a ray.
Source§

fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: f32) -> bool

Tests whether a ray intersects this transformed shape.
Source§

fn cast_ray( &self, m: &Isometry<f32>, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<f32>

Computes the time of impact between this transform shape and a ray.
Source§

fn cast_ray_and_get_normal( &self, m: &Isometry<f32>, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<RayIntersection>

Computes the time of impact, and normal between this transformed shape and a ray.
Source§

fn intersects_ray( &self, m: &Isometry<f32>, ray: &Ray, max_time_of_impact: f32, ) -> bool

Tests whether a ray intersects this transformed shape.
Source§

impl Shape for TriMesh

Source§

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 clone_dyn(&self) -> Box<dyn Shape>

Clones this shape into a boxed trait-object. Read more
Source§

fn scale_dyn( &self, scale: &Vector<f32>, _num_subdivisions: u32, ) -> Option<Box<dyn Shape>>

Scales this shape by scale into a boxed trait-object. Read more
Source§

fn compute_local_aabb(&self) -> Aabb

Computes the Aabb of this shape.
Source§

fn compute_local_bounding_sphere(&self) -> BoundingSphere

Computes the bounding-sphere of this shape.
Source§

fn compute_aabb(&self, position: &Isometry<f32>) -> Aabb

Computes the Aabb of this shape with the given position.
Source§

fn mass_properties(&self, density: f32) -> MassProperties

Compute the mass-properties of this shape given its uniform density.
Source§

fn shape_type(&self) -> ShapeType

Gets the type tag of this shape.
Source§

fn as_typed_shape(&self) -> TypedShape<'_>

Gets the underlying shape as an enum.
Source§

fn ccd_thickness(&self) -> f32

Source§

fn ccd_angular_thickness(&self) -> f32

Source§

fn as_composite_shape(&self) -> Option<&dyn CompositeShape>

Source§

fn clone_box(&self) -> Box<dyn Shape>

👎Deprecated: renamed to clone_dyn
Clones this shape into a boxed trait-object. Read more
Source§

fn compute_bounding_sphere(&self, position: &Isometry<f32>) -> BoundingSphere

Computes the bounding-sphere of this shape with the given position.
Source§

fn is_convex(&self) -> bool

Is this shape known to be convex? Read more
Source§

fn as_support_map(&self) -> Option<&dyn SupportMap>

Converts this shape into its support mapping, if it has one.
Source§

fn as_polygonal_feature_map(&self) -> Option<(&dyn PolygonalFeatureMap, f32)>

Converts this shape to a polygonal feature-map, if it is one.
Source§

fn compute_swept_aabb( &self, start_pos: &Isometry<f32>, end_pos: &Isometry<f32>, ) -> Aabb

Computes the swept Aabb of this shape, i.e., the space it would occupy by moving from the given start position to the given end position.
Source§

impl TypedCompositeShape for TriMesh

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
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> 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 = 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.