Hello,
i have a small scene with a particle system and a trigger shape. There also is a dynamic rigid object.
I want to be able to detect if a particle is inside the trigger object. If i am not completely wrong i should be able to do this with a custom filter and the onTrigger() callback function. However, if the dynamic rigid object touches the trigger, onTrigger() is called, but when a particle enters the trigger shape, it is detected by the filter (i can see it when i set a breakpoint inside my filter shader) but the onTrigger() callback is never called. (How) can i fix this? Or is it impossible at all to get a trigger callback from a single particle?
This is my filter shader:
PxFilterFlags ParticleFilterShader(
PxFilterObjectAttributes attributes0,
PxFilterData filterData0,
PxFilterObjectAttributes attributes1,
PxFilterData filterData1,
PxPairFlags& pairFlags,
const void* constantBlock,
PxU32 constantBlockSize)
{
pairFlags = PxPairFlag::eCONTACT_DEFAULT;
if(PxFilterObjectIsTrigger(attributes0) || PxFilterObjectIsTrigger(attributes1))
{
if ( (isParticleGroup ( filterData0 ) && isTriggerGroup ( filterData1 )) || (isTriggerGroup ( filterData0 ) && isParticleGroup ( filterData1 )) ) {
pairFlags = PxPairFlag::eTRIGGER_DEFAULT;
return PxFilterFlag::eDEFAULT;
}
/* When i use only this, without the check above, my rigid dynamic triggers the callback.
* pairFlags = PxPairFlag::eTRIGGER_DEFAULT;
* return PxFilterFlag::eDEFAULT;
*/
}
return PxFilterFlag::eDEFAULT;
}
And this is my onTrigger() (it does not do much at the moment…):
void PhysXConnector::onTrigger(physx::PxTriggerPair* pairs,physx:: PxU32 count) {
for(physx::PxU32 i=0; i < count; i++) {
if (physx::PxPairFlag::eTRIGGER_DEFAULT) {
PxFilterData filterFlags0 = pairs[i].otherShape->getQueryFilterData();
PxFilterData filterFlags1 = pairs[i].triggerShape->getQueryFilterData();
}
}
}
The PhysxConnector Class defined like this:
class PhysXConnector : public physx::PxSimulationEventCallback {
/* Other private functions * /
public:
/* Other public functions * /
void onConstraintBreak(physx::PxConstraintInfo* , physx::PxU32 ) { }
void onWake(physx::PxActor** , physx::PxU32 ) { }
void onSleep(physx::PxActor** , physx::PxU32 ) { }
void onContact(const physx::PxContactPairHeader& , const physx::PxContactPair* , physx::PxU32 ) { }
void onTrigger(physx::PxTriggerPair*,physx::PxU32);
/* Other public functions * /
};