Maybe the filters for models are working correctly but there is something wrong with the raycast filter (since it's different kind of filter compared to settings filters).
PxReal maxDistance = 10000.0f; // [in] Raycast max distance
PxRaycastBuffer hit; // [out] Raycast results
PxQueryFilterData tmp_filter_data = PxQueryFilterData();
tmp_filter_data.data.word0 = 2; // Projectile group
tmp_filter_data.data.word1 = 1; // "Player" group
tmp_filter_data.flags |= PxQueryFlag::eANY_HIT;
// Always returns 0 if using filters..but why?
bool status = gScene->raycast(origin, unitDir, maxDistance, hit, PxHitFlags(PxHitFlag::eDEFAULT), tmp_filter_data);
Well, to get some kind of progress I've added some inaccuracy to the shots, now bullets wont travel in straight line against the target.
White player shooting inaccurately at the brown boxes |
After getting filters to work, I'll try to make custom oncontact triggers. If I can manage that, then i can convert my bullets to exploding bullets which could be some fun :)
*** EDIT ***
I had one simple mistake when I was setting the filters for my boxes. Instead of setting setQueryFilterData I was using setSimulationFilterData.
So setting the filters simple worked like this:
PxFilterData filterData;
filterData.word0 = 1;
filterData.word0 = 1;
const PxU32 numShapes = gBox3->getNbShapes();
PxShape* shapes;
gBox3->getShapes(&shapes, numShapes);
for(PxU32 i = 0; i < numShapes; i++)
{
PxShape* shape = &shapes[i];
shape->setQueryFilterData(filterData);
}
PxShape* shape = &shapes[i];
shape->setQueryFilterData(filterData);
}