User Manual example of Collision filtering using masks

passionfruit
Posts: 2
Joined: Wed Jan 07, 2009 7:17 am

User Manual example of Collision filtering using masks

Post by passionfruit »

In the section on filtering collisions using masks, the User Manual suggests that you can have a space ship collide with walls but have the walls collide with nothing by setting the spaceships mask to include walls and the walls mask to include nothing.

As far as I can tell this will never actually work as the broadphase will cull the collision unless both objects flag each other - see below

Code: Select all

inline bool needsBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
{
	if (m_overlapFilterCallback)
		return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1);

	bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
	collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
			
	return collides;
}
Is that correct? If so how does one implement the example given in the user manual?

cheers,

passionfruit
Romain Daize
Posts: 15
Joined: Tue Jan 06, 2009 10:04 am

Re: User Manual example of Collision filtering using masks

Post by Romain Daize »

Hello,

You are right. This is based on a AND logic. The user manual seems wrong, as when you assign a flag to an object, you tell it that it is ALLOWED to collide with a type of objects, so this is not a FORCE_TO_COLLIDE_WITH logic. So if another objects is not marked as allowed to collide with a type of objects, this will prevent him to collide with this type in all cases. I think example case in user manual should be revised.
passionfruit
Posts: 2
Joined: Wed Jan 07, 2009 7:17 am

Re: User Manual example of Collision filtering using masks

Post by passionfruit »

In my particular case I have two ghost objects, one that I'm trying to use as a sensor/trigger and one as part of a kinematic character controller.

So to get the desired behaviour (sensor collides with character, character doen't collide with sensor) it would seem I need to flag them both to collide with each other and have the character controller explicitly ignore any sensor collisions when updating its position (which works).
TheMadGamer
Posts: 2
Joined: Thu May 20, 2010 6:32 am

Re: User Manual example of Collision filtering using masks

Post by TheMadGamer »

It also seems that the Mask based example in the 2.74 manual, ch5 is also misleading. If one were to use the setup:

Code: Select all

int shipCollidesWith = COL_WALL; 
int wallCollidesWith = COL_NOTHING; 
int powerupCollidesWith = COL_SHIP | COL_WALL; 
Would the wall/ship collision would be pruned, as would ship/wall collisions? This is the sort of behavior I'm experiencing w/ rigid body collisions.