Why don't filter flags work for static objects? - PhysX 3.3.1 Windows

If my objects are all dynamic, they collide as expected. If I set some to static, everything passes through the static objects as if they weren’t there (PVD verifies that they are there). I’m using filter masks for the dynamic objects but was only able to get static collisions working by adding a brute-force check in the filter shader.

Here is my filter shader with the brute force check specified. Why do I need to do this for static objects?

// let triggers through
if(PxFilterObjectIsTrigger(attributes0) || PxFilterObjectIsTrigger(attributes1))
{
   pairFlags = PxPairFlag::eTRIGGER_DEFAULT;
   return PxFilterFlag::eDEFAULT;
}

// generate contacts for all that were not filtered above
pairFlags = PxPairFlag::eCONTACT_DEFAULT;

// BRUTE FORCE CHECK for static object collision. Why is this required?
if( PxGetFilterObjectType(attributes0) == PxFilterObjectType::eRIGID_STATIC || PxGetFilterObjectType(attributes1) == PxFilterObjectType::eRIGID_STATIC )
{
   return PxFilterFlags();
}

// trigger the contact callback for pairs (A,B) where
// the filtermask of A contains the ID of B and vice versa.
if((filterData0.word0 & filterData1.word1) && (filterData1.word0 & filterData0.word1))
{
   pairFlags |= PxPairFlag::eNOTIFY_TOUCH_FOUND | PxPairFlag::eNOTIFY_CONTACT_POINTS ;
   return PxFilterFlags();
}

// If the mask didn't match, then suppress the collision
return PxFilterFlag::eSUPPRESS;

Did you set up filter data on all static and dynamic objects? Ignoring the brute force code in your shader for a second, the key lines in your shader are:

if((filterData0.word0 & filterData1.word1) && (filterData1.word0 & filterData0.word1))
{
pairFlags |= PxPairFlag::eNOTIFY_TOUCH_FOUND | PxPairFlag::eNOTIFY_CONTACT_POINTS ;
return PxFilterFlags();
}

This requires both objects to be set up to collide with the other object in the pair.

It should be straightforward to test this by creating a test scene that only has a single static and a single dynamic.

Hope this helps,

Gordon

I do, all objects (static and dynamic) use the same filter data. If I hadn’t setup the filter correctly then the dynamic collisions wouldn’t be working. The only difference between dynamic and static object creation is the omission of damping and mass calls on the static object.

Is there any actual code I can see for the default shader?

If you run in debug you will be able to put a breakpoint in your shader and step through the code. I recommend setting up a scene with a single dynamic falling on a single static. In such a simple scene you know that the only call to the shader can be a dynamic-static pair.

The sdk ships with a default shader PxDefaultSimulationFilterShader in extensions. Binary customers get full source to this so you can compare it with your shader.

Thanks,

Gordon