Improve collision filters #341

Open
liabru opened this Issue Jan 3, 2017 · 1 comment

Projects

None yet

2 participants

@liabru
Owner
liabru commented Jan 3, 2017

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:

  • Limits the number of categories to just 32
  • Not a particularly standard JavaScript style of implementation
  • It's pretty confusing

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.

@Swendude
Swendude commented Jan 4, 2017 edited

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.

Update:
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment