Understanding filter bits

General discussion about Box2D tutorials
Post Reply
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Understanding filter bits

Post by tescott »

I've got a video up on Youtube that might help people that are new to Box2D. It demonstrates how filter bits are used and an easy way of remembering the distinction between category bits and mask bits.

http://www.youtube.com/watch?v=cS8yeyCHj5A

Thanks,
--tim
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Re: Understanding filter bits

Post by tescott »

Well, I was on a roll today. Made two more videos that applied some collision filtering concepts:

One-sided platforms:
http://www.youtube.com/watch?v=g7zkiOE7NT4

Railway switch type construct:
http://www.youtube.com/watch?v=yHvIdAaK3jk

--tim
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Understanding filter bits

Post by iforce2d »

Really nice set of tuts there Tim!

The one-way walls is a good solution. I think that the more you can do in the editor visually the better, eg. once you have the scripts set up to do something with a certain type of sensor, the rest comes down to placing them visually.

One tiny thing you might find is that changing the collision bits does not make any difference to a contact that is already existing, and a contact is a pair of overlapping AABBs for two fixtures that may or may not actually be touching. iirc the collision bits is only checked when the AABBs first overlap. You can call Refilter on the fixtures after changing the collision bits to update this.

The reason I thought it might be a problem for the one-way walls is when the upper edge of the platform is not axis-aligned, because in that case the ball will likely still be inside the AABB of the platform when you revert the collision bits to normal. When the upper edge of the platform is horizontal, this is not a problem because the upper edge of the AABB of the two fixtures is pretty much the same, and fits much closer to the fixtures themselves.

Then again, you show examples of platforms with upper edges that are not horizontal, and they seem to be working fine, so maybe I'm remembering something wrong.
Post Reply