Fallible methods for decomposition#348
Fallible methods for decomposition#348ThierryBerger wants to merge 8 commits intodimforge:masterfrom
Conversation
| indices: &[[u32; DIM]], | ||
| params: &VHACDParameters, | ||
| ) -> Self { | ||
| ) -> Option<Self> { |
There was a problem hiding this comment.
This is a bit complicated to promote to fallible, because the input may contain multiple incorrect shapes.
behavior on master is to only return the shapes that the algorithm could make, and crash when NO shapes are able to be made.
This PR improves this by not crashing. It may be interesting to have more information about why it failed (and how to fix).
There was a problem hiding this comment.
add a todo to improve error reporting (done, keeping the discussion open for discoverability)
| } | ||
|
|
||
| /// Approximate convex decomposition using the VHACD algorithm. | ||
| #[derive(Debug)] |
There was a problem hiding this comment.
I added a few debug derive to help me with degugging
| right_ch = convex_hull(&right_ch_pts) | ||
| .unwrap_or_else(ConvexHullError::into_incorrect_empty); |
There was a problem hiding this comment.
I'm not a fan of this behavior, but I think it makes sense to have an indicator at call site that the return may be incorrect (empty).
d6e5bcb to
084efbc
Compare
This approach is to wrap computation results into
Results when it makes sense.We can probably go further into this approach, and really hunt for any misconfiguration and return an error whenever the inputs don't make sense, but let's discuss this first.
I considered adding
tryvariants, but it doesn't add too much value so I went straight to migrating to fallible everywhere.