Skip to content

Commit

Permalink
Addressing fallibility issues (#282)
Browse files Browse the repository at this point in the history
* Making heap peek fallible

* Switching to use of fallible convex hull processing when instantiating ConvexPolyhedron
  • Loading branch information
bellwether-softworks authored Jan 8, 2025
1 parent 8932cf3 commit 2a03d5a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/query/epa/epa3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl EPA {

let mut niter = 0;
let mut max_dist = Real::max_value();
let mut best_face_id = *self.heap.peek().unwrap();
let mut best_face_id = *self.heap.peek()?;
let mut old_dist = 0.0;

/*
Expand Down
5 changes: 3 additions & 2 deletions src/shape/convex_polyhedron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ impl ConvexPolyhedron {
/// This explicitly computes the convex hull of the given set of points. Use
/// Returns `None` if the convex hull computation failed.
pub fn from_convex_hull(points: &[Point<Real>]) -> Option<ConvexPolyhedron> {
let (vertices, indices) = crate::transformation::convex_hull(points);
Self::from_convex_mesh(vertices, &indices)
crate::transformation::try_convex_hull(points)
.ok()
.and_then(|(vertices, indices)| Self::from_convex_mesh(vertices, &indices))
}

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

0 comments on commit 2a03d5a

Please sign in to comment.