Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
xlambein opened this issue Oct 15, 2021 · 4 comments

Comments

@xlambein
Copy link

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.

@sebcrozet
Copy link
Member

sebcrozet commented Oct 15, 2021

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.

@xlambein
Copy link
Author

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?

@sebcrozet
Copy link
Member

sebcrozet commented Oct 15, 2021

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.

@xlambein
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants