
These results can be accessed via the hit input argument to the post-filtering callback (PxQueryFilterCallback::postFilter).
To determine whether a hit should be discarded or not.
Post-filtering happens after the narrow phase test and can therefore use the results of the test (such as PxRaycastHit.position). These tests are more expensive for triangle meshes, heightfields, convexes and most sweeps than raycastĪnd overlap tests involving only simple shapes (such as spheres, capsules and boxes.) Pre-filtering happens before midphase and narrow phase and allows shapes to be efficiently discarded before the potentiallyĮxpensive exact collision test. To implement custom filtering in queries, set the PxQueryFlag::ePREFILTER and/or PxQueryFlag::ePOSTFILTER flags and subclass PxQueryFilterCallback with the required filtering logic. Or overlap tests for sweep() and overlap() queries). Narrow phase performs exact intersection tests (ray test for raycast() queries, and exact sweep shape tests. midphase traverses the triangle mesh and heightfield internal culling structures, to find a smaller subset of the triangles. Broad phase traverses the global scene spatial partitioning structure to find the candidates for mid and narrow phases. Scene queries are performed in three phases: broad phase, midphase and narrow phase. PxQueryFlag::ePREFILTER, PxQueryFlag::ePOSTFILTER ¶ Before using query results check PxHitFlag::ePOSITION, eNORMAL, eDISTANCE, eUV flags first, as in some cases they are not set. Raycasts results include position, normal, hit distance, shape and actor, and a face index with UV coordinates for triangle meshes and heightfields. The distance for raycasts has to be in the [0, inf) range. hit.hadBlock is also set to true if there was a hit. Overplay the scene code#
In this code snippet a PxRaycastBuffer object is used to receive results from the raycast query.Ī call to raycast() returns true if there was a hit. Raycast max distance PxRaycastBuffer hit // Raycast results // Raycast against all static & dynamic objects (no filtering) // The main result from this call is the closest hit, stored in the 'hit.block' structure bool status = scene -> raycast ( origin, unitDir, maxDistance, hit ) if ( status ) applyDamage ( hit. Normalized ray direction PxReal maxDistance =.