Handle masks and categories in our contact filter

Turns out, setting our own contact filter bypasses the inbuilt mask and category handling,
this means, however, that masks and categories are processed before your contact filter is
called, so if you really want to do all the filtering manually, you should just make sure
you never change the default masks and category, or restore it.
This commit is contained in:
Bart van Strien
2012-02-09 20:26:18 +01:00
parent e02a2679c2
commit 0c9d8f3c41
+16
View File
@@ -109,6 +109,22 @@ namespace box2d
bool World::ContactFilter::process(Fixture * a, Fixture * b)
{
// Handle masks, reimplemented from the manual
int filterA[3], filterB[3];
// [0] categoryBits
// [1] maskBits
// [2] groupIndex
a->getFilterData(filterA);
b->getFilterData(filterB);
if (filterA[2] != 0 && // 0 is the default group, so this does not count
filterA[2] == filterB[2]) // if they are in the same group
return filterA[2] > 0; // Negative indexes mean you don't collide
if ((filterA[1] & filterB[0]) == 0 ||
(filterB[1] & filterA[0]) == 0)
return false; // A and B aren't set to collide
if (ref != 0)
{
lua_State * L = ref->getL();