Skip to content

Commit 2a03d5a

Browse files
Addressing fallibility issues (#282)
* Making heap peek fallible * Switching to use of fallible convex hull processing when instantiating ConvexPolyhedron
1 parent 8932cf3 commit 2a03d5a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/query/epa/epa3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl EPA {
314314

315315
let mut niter = 0;
316316
let mut max_dist = Real::max_value();
317-
let mut best_face_id = *self.heap.peek().unwrap();
317+
let mut best_face_id = *self.heap.peek()?;
318318
let mut old_dist = 0.0;
319319

320320
/*

src/shape/convex_polyhedron.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ impl ConvexPolyhedron {
117117
/// This explicitly computes the convex hull of the given set of points. Use
118118
/// Returns `None` if the convex hull computation failed.
119119
pub fn from_convex_hull(points: &[Point<Real>]) -> Option<ConvexPolyhedron> {
120-
let (vertices, indices) = crate::transformation::convex_hull(points);
121-
Self::from_convex_mesh(vertices, &indices)
120+
crate::transformation::try_convex_hull(points)
121+
.ok()
122+
.and_then(|(vertices, indices)| Self::from_convex_mesh(vertices, &indices))
122123
}
123124

124125
/// Attempts to create a new solid assumed to be convex from the set of points and indices.

0 commit comments

Comments
 (0)