erincatto / box2d

Box2D is a 2D physics engine for games
https://box2d.org
MIT License
7.44k stars 1.47k forks source link

Handling of Complex Polygons in Box2D #750

Closed kaustubhShetty closed 11 months ago

kaustubhShetty commented 11 months ago

Make sure these boxes are checked before submitting your issue - thank you!

I am a researcher working on simulating the random packing of carbon fibers with no overlaps in an RVE (Representative elementary volume), which could have convex or concave cross-sections with anywhere from 60 to 180 vertices. The complexity and irregularity of these shapes present a significant challenge.

We chose Box2D as our physics engine due to its wide usage and solid reputation. However, we've run into a hurdle. My understanding is that Box2D is designed to work primarily with convex polygons of 8 vertices or less, which limits our ability to simulate the complex and irregular fiber shapes we're interested in.

To work around this, we have considered the possibility of decomposing the complex shapes into simpler polygons that fall within Box2D's limitations, but we are wondering if there might be a better way.

In the course of our research, we came across the Viper software, which is reported to use Box2D and is capable of handling smooth polygon and C-shaped fiber cross-sections. This suggests to us that it might be possible to use Box2D for our purposes after all.

Could you provide any insight on how Viper achieves this? Are there any specific adaptations or extensions to Box2D that could facilitate our handling of complex polygons? Alternatively, could you provide any suggestions or guidance on how to best work with complex polygons in Box2D?

Your expertise and advice would be invaluable to our project. Thank you in advance for your assistance.

erincatto commented 11 months ago

I believe we chatted on discord. Let me know if you have any other questions.