Hi,
I have a small question about the default behaviour of PhysX3.
I created a class that inherits from PxSimulationEventCallback because i wan’t to receive the OnTrigger and onContact notifications. I also attached this callback interface to the scene.
When i test this implementation with a trigger, everything works as expected. But for some reason the onContact callback isn’t triggered when 2 bodies collide. It could be that this behaviour is changed with PhysX3 because as far as i know this worked with PhysX2.
I also tested with a custom SimulationFilterShader with simple logic.
PxFilterFlags CustomSimulationFilterShader(
PxFilterObjectAttributes attribute0, PxFilterData filterData0,
PxFilterObjectAttributes attribute1, PxFilterData filterData1,
PxPairFlags& pairFlags, const void* constantBlock, PxU32 constantBlockSize)
{
if((attribute0 & PxFilterObjectFlags::eTRIGGER) != 0 || (attribute0 & PxFilterObjectFlags::eTRIGGER) != 0)
{
pairFlags = PxPairFlag::eTRIGGER_DEFAULT;
return PxFilterFlags();
}
pairFlags = PxPairFlag::eCONTACT_DEFAULT;
return PxFilterFlags();
}
And the pairFlags are set to PxPairFlags::eContact_Default, but the PxSimulationEvent-OnContact isn’t called. (But OnTrigger works).
First of all, is my logic correct? (pairFlags == eCONTACT_DEFAULT => call onContact (PxSimulationEvent))?
Then, i experimented with different flags and suddenly my onContact method was called, using this code:
PxFilterFlags CustomSimulationFilterShader(
PxFilterObjectAttributes attribute0, PxFilterData filterData0,
PxFilterObjectAttributes attribute1, PxFilterData filterData1,
PxPairFlags& pairFlags, const void* constantBlock, PxU32 constantBlockSize)
{
pairFlags = PxPairFlag::eTRIGGER_DEFAULT;
return PxFilterFlags();
}
This called the onContact method. (2 bodies, not marked as triggers). I know this code is incorrect and can cause unexpected behaviour but it’s the only time that my onContact method was called. (Bodies didn’t collide anymore, because the pair is marked as triggers i guess).
Any advice on how i could successfully trigger the onContact ‘event’?