diff options
Diffstat (limited to 'src/geometry/collider.rs')
| -rw-r--r-- | src/geometry/collider.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs index c58548e..d72e098 100644 --- a/src/geometry/collider.rs +++ b/src/geometry/collider.rs @@ -2,7 +2,7 @@ use crate::dynamics::{CoefficientCombineRule, MassProperties, RigidBodyHandle}; use crate::geometry::{ ActiveCollisionTypes, BroadPhaseProxyIndex, ColliderBroadPhaseData, ColliderChanges, ColliderFlags, ColliderMassProps, ColliderMaterial, ColliderParent, ColliderPosition, - ColliderShape, ColliderType, InteractionGroups, SharedShape, + ColliderShape, ColliderType, InteractionGroups, MeshConverter, MeshConverterError, SharedShape, }; use crate::math::{AngVector, Isometry, Point, Real, Rotation, Vector, DIM}; use crate::parry::transformation::vhacd::VHACDParameters; @@ -698,6 +698,21 @@ impl ColliderBuilder { Self::new(SharedShape::trimesh_with_flags(vertices, indices, flags)) } + /// Initializes a collider builder with a shape converted from the given triangle mesh index + /// and vertex buffer. + /// + /// All the conversion variants could be achieved with other constructors of [`ColliderBuilder`] + /// but having this specified by an enum can occasionally be easier or more flexible (determined + /// at runtime). + pub fn converted_trimesh( + vertices: Vec<Point<Real>>, + indices: Vec<[u32; 3]>, + converter: MeshConverter, + ) -> Result<Self, MeshConverterError> { + let (shape, pose) = converter.convert(vertices, indices)?; + Ok(Self::new(shape).position(pose)) + } + /// Initializes a collider builder with a compound shape obtained from the decomposition of /// the given trimesh (in 3D) or polyline (in 2D) into convex parts. pub fn convex_decomposition(vertices: &[Point<Real>], indices: &[[u32; DIM]]) -> Self { |
