dimforge / dimforge/parry

Should convex decomposition return an option or a result?

Open
#264 1 comment 0 reactions 0 assignees View on GitHub
C-Enhancement D-Medium P-High
Dominant language
Rust
Stars
867
Forks
157
Avg merge
7d 13h
Merged PRs (30d)
2

Description

I ran into
```
A compound shape must contain at least one shape.
```

I'm generating lots of convex decomposition colliders like this:

```rust
let contours = self.contours_with_holes_flat(bitmap_to_pixels, simplify_epsilon);
if contours.len() < 4 {
return vec![];
}
let indices = (0..contours.len() as u32 - 1)
.map(|i| [i, i + 1])
.collect::>();
let collider = ColliderBuilder::convex_decomposition_with_params(
&contours,
&indices,
&VHACDParameters {
resolution: 64,
fill_mode,
..Default::default()
},
)
.build();
```

The assertion in `parry2d-0.17.0\src\shape\compound.rs:35:9` causes a panic, and can't do much about it. I don't really know when exactly the function fails to generate a shape, and my attempt to not let too small contours only helps for some other panics...

I would prefer no panics, and let the user handle the issues (Option or Result).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.