P2.js Polygon Collider Support


So I had a short discussion already on this, but I’ve noticed the p2.js integration doesn’t include support for convex shapes. I was wondering how time-consuming it would be to add support for convex shapes, and what the best way to do it would be. I’ve tried hacking it by manually inputting coordinates and parsing it out with regex, but this is far from ideal, so any suggestions on how to implement this feature?

Integration script is actually open source: https://github.com/playcanvas/playcanvas-p2.js
So you could just take it and add missing functionality following same conventions of the plugin code.

@will probably will be best to loop into this conversation.

@max That is actually what I originally did, however I found that my method for integrating it (with String input) was not very good. I was wondering if there was some way I could use the editor to add vertex points in a cleaner way.

There could be couple:

  1. Writing custom plugin, against undocumented Editor API, which is possible and there is a documentation about how to do simple stuff for editor on forum, check search.
  2. You could make simple geometry polygons as normal model (FBX), then have component attribute for model asset. This allows you to get model asset and its vertex buffer - pretty much is what you need.

Thank you for the reply! Apologies if this question is somewhat noobish, I’m not very experienced with 3d xD