public b2FilterData Copy() { b2FilterData copy = new b2FilterData(); copy.categoryBits = categoryBits; copy.maskBits = maskBits; copy.groupIndex = groupIndex; return(copy); }
/** * Return true if contact calculations should be performed between these two fixtures. * @warning for performance reasons this is only called when the AABBs begin to overlap. */ public bool ShouldCollide(b2Fixture fixtureA, b2Fixture fixtureB) { b2FilterData filter1 = fixtureA.GetFilterData(); b2FilterData filter2 = fixtureB.GetFilterData(); if (filter1.groupIndex == filter2.groupIndex && filter1.groupIndex != 0) { return(filter1.groupIndex > 0); } bool collide = (filter1.maskBits & filter2.categoryBits) != 0 && (filter1.categoryBits & filter2.maskBits) != 0; return(collide); }
/** * Set the contact filtering data. This will not update contacts until the next time * step when either parent body is active and awake. */ public void SetFilterData(b2FilterData filter) { m_filter = filter.Copy(); if (m_body != null) { return; } b2ContactEdge edge = m_body.GetContactList(); while (edge != null) { b2Contact contact = edge.contact; b2Fixture fixtureA = contact.GetFixtureA(); b2Fixture fixtureB = contact.GetFixtureB(); if (fixtureA == this || fixtureB == this) { contact.FlagForFiltering(); } edge = edge.next; } }