Currently collision filters work as they do in Box2D, which uses a bitwise implementation which supposedly should give good performance. Here is a good explanation.
This comes with some downsides:
I also doubt the approach gives much of a performance boost compared to other possible nicer alternatives. I still need to decide on exactly what though. Changing the implementation is mostly a matter of changing:
Back compatibility is important here, so the old scheme should be supported but deprecated.
If anyone has any thoughts let me know.
What would be the downside to using the already available collisionFilter.group and adding a field collisionFilter.collidesWith that can contain an array of collision groups the body collides with? This seems like a straightforward easy-to-use feature.
I created a working pen of this idea, I have no idea how to test performance implications. It is a monkey patched version but shows the idea. The default settings for collisionFilter.group should be 0 (maybe -1) since that makes the body accept collision with everything.