dimforge/parry

SharedShape 2D convex decomposition produces bad results if polygon is clockwise

Closed this issue · 4 comments

Hi!

I don't know whether this is a bug or a problem in the docs, but if you do a convex decomposition with a clockwise polygon, each shape in the decomposition will also be clockwise, and therefore will not work properly with SharedShape::convex_polyline. In turn, this means that the resulting compound shape will not work as expected.

let mut parts = vec![];
let decomp = VHACD::decompose(params, &vertices, &indices, true);
#[cfg(feature = "dim2")]
for vertices in decomp.compute_exact_convex_hulls(&vertices, &indices) {
if let Some(convex) = Self::convex_polyline(vertices) {
parts.push((Isometry::identity(), convex));
}
}

The docs for SharedShape::convex_decomposition don't mention that shapes have to be counter-clockwise, and neither do the user guides. Similarly, the docs for SharedShape::convex_polyline don't mention that either, and it's only when looking at ConvexPolygon::from_convex_polyline that the counter-clockwise condition is ever mentioned.

Thanks for the amazing engine btw :-) people who played my LDJam game kept saying they were impressed by the physics, for which y'all are 100% responsible.

Hi! Could you please try again with the master branch? It should be fixed by a recent PR (#53), but a new version of parry including this fix hasn’t been released yet.

Ah sorry, I looked up the problem but only in issues, not in PRs! I'll try it out.

There's still the (small) detail about the docs for SharedShape::convex_polyline, but not sure it's worth keeping the issue open for that?

Mmh, you are correct, the docs should be made more precise about the expected orientation!

but not sure it's worth keeping the issue open for that?

Let’s make another issue with a more suited title for that.

Cool, I'll do that if you want :-)