Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool PhysXWorld::raycastSingle(const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, PxSceneQueryFlags outputFlags, PxRaycastHit& hit, const PxSceneQueryFilterData& filterData /* = PxSceneQueryFilterData */)
- {
- PxRaycastHit hits[32];
- bool blockingHit;
- // some weird PhysX shit. Sometimes raycastSingle will just return distance 0 and show collision with terrain!!! even though there is no even close terrain to the ray
- outputFlags |= PxSceneQueryFlag::eDISTANCE; // always add, as we need distance to check for physX bug
- int numHits = g_pPhysicsWorld->PhysXScene->raycastMultiple(origin, unitDir, distance, outputFlags, hits, 32, blockingHit, filterData);
- bool foundProperHit = false;
- float closestHit = 99999999.0f;
- if(numHits)
- {
- for(int i=0; i<numHits; ++i)
- {
- if(hits[i].distance > 0)
- {
- if(hits[i].distance < closestHit)
- {
- hit = hits[i];
- closestHit = hits[i].distance;
- foundProperHit = true;
- }
- }
- }
- }
- return foundProperHit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement