I'm using PhysX 3.3.0.
I need to know when two actors have started touching and ended touching, but can't figure out how to properly implement that.
This is my filter shader for testing purposes:
static physx::PxFilterFlags testFilterShader(
physx::PxFilterObjectAttributes attributes0,physx::PxFilterData filterData0,
physx::PxFilterObjectAttributes attributes1,physx::PxFilterData filterData1,
physx::PxPairFlags &pairFlags,const void *constantBlock,physx::PxU32 constantBlockSize
)
{
if(physx::PxFilterObjectIsTrigger(attributes0) || physx::PxFilterObjectIsTrigger(attributes1))
{
pairFlags = physx::PxPairFlag::eTRIGGER_DEFAULT;
return physx::PxFilterFlag::eDEFAULT;
}
pairFlags = physx::PxPairFlag::eCONTACT_DEFAULT;
if(((filterData0.word0 &filterData1.word1) == 0) || ((filterData1.word0 &filterData0.word1) == 0))
return physx::PxFilterFlag::eKILL;
if(filterData0.word2 || filterData1.word2)
pairFlags |= physx::PxPairFlag::eNOTIFY_TOUCH_FOUND;
return physx::PxFilterFlag::eDEFAULT;
}
If word2 is set to anything but 0 (Which is the case for my test-actors), the PxPairFlag::eNOTIFY_TOUCH_FOUND flag is set. According to the physx documentation, this should invoke the 'onContact' method of my event callback:
class WVPxEventCallback : public physx::PxSimulationEventCallback
{
public:
WVPxEventCallback();
virtual void onContact(const physx::PxContactPairHeader &pairHeader,const physx::PxContactPair *pairs,physx::PxU32 nbPairs);
virtual void onTrigger(physx::PxTriggerPair *pairs,physx::PxU32 count);
virtual void onConstraintBreak(physx::PxConstraintInfo *constraints,physx::PxU32 count);
virtual void onWake(physx::PxActor **actors,physx::PxU32 count);
virtual void onSleep(physx::PxActor **actors,physx::PxU32 count);
};
However 'onContact' is never called, no matter what.
In case of a trigger, it's calling the 'onTrigger' event if an object is touching it, as it should, but it's also called at seemingly random times while the object (capsule controller) is moving around within the trigger.
I've set both the PxSceneFlag::eENABLE_KINEMATIC_PAIRS and PxSceneFlag::eENABLE_KINEMATIC_STATIC_PAIRS flags for the scene.
Is there anything else I forgot/need?
I'd also like to know if there's a way to check if two actors are touching at any time, or if I have to keep track of that myself?
Thanks.