schteppe / p2.js

JavaScript 2D physics library
Other
2.64k stars 330 forks source link

Collision group on polygons #191

Open jstoeffler opened 8 years ago

jstoeffler commented 8 years ago

Hi,

I'd like to create polygons belonging to collision group.

I found two different approaches:

And they don't seem consistent with the API, it feels some decoupling is needed. Did I miss something, or is it an improvement that could be done?

jstoeffler commented 8 years ago

Just saw that it's probably the same idea than #172 Feel free to close the issue if it is.

schteppe commented 8 years ago

It probably is. I see two possible ways to solve it. Either keep it as it is, and the collision groups/masks can be added to each convex shape created by body.fromPolygon. Or, make a Polygon shape that holds all the convex shapes and add some special treatment for collision groups/masks for each subshape... Both ways are sort of inconsistent with the API :(

jstoeffler commented 8 years ago

Thanks for the answer. Some thoughts:

schteppe commented 8 years ago

Both options are good! But I think the latter would be the best. It would make build sizes smaller if the poly-decomp library could be moved away from the Body class.