dimforge / ncollide

2 and 3-dimensional collision detection library in Rust.
https://ncollide.org
Apache License 2.0
921 stars 107 forks source link

In 2d, why is `Triangular` not implementing `Shape`? #339

Open robinmoussu opened 4 years ago

robinmoussu commented 4 years ago

I think I don't understand what the use of Triangular is since it doesn't implements the trait Shape. After reading #202, it feels that the right shape to use is ConvexPolygon, but in that case, I don't see why Triangular exists at all (and I'm sure there is a reason). I think that the documentation could be more explicit.

sebcrozet commented 4 years ago

Hi!

Yes, Triangle does not implements the trait Shape because that would be redundant with ConvexPolygon.

Yet, triangles exist because they are used by triangle-meshes to simply their collision detection. So basically, they are not expected to be used directly by the end-user, but are useful for algorithmic reasons.

I agree the documentation should be more explicit. Or event better: you should consider putting in the shape module only geometries actually implementing the Shape trait.

robinmoussu commented 4 years ago

I also have the same question for Compound. I guess, it's the same answer?

sebcrozet commented 4 years ago

Shape is implemented for Compound.

robinmoussu commented 4 years ago

I don't know what I've done, I guess I did a syntax error and was too tired, so I just iterated over my ConvexPolgon manually.