Oct 28, 2014

Currently I am trying to test out filtering in Physx engine. The plan was to make simple raycast check if one of the targets could see the white player and shoot back if it did (return false if raycast hits ground or air). I've set groups for terrain (0), "boxes" (1) and the projectiles (2). However only effect I've seen is that the projectiles won't go through ground anymore...
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;

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);
}

Oct 23, 2014

Hello everyone, this blog will contain my struggles on developing a game with physics elements. Currently I am using C++, Physx libraries for physics engine and opengl 3.3 core for graphics (with glm along).

White player shooting stream of colliding bullets against the brown target
I'll try to post updates at least weekly on how the project is going on and what I've learned during the process.