Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. bool PhysXWorld::raycastSingle(const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, PxSceneQueryFlags outputFlags, PxRaycastHit& hit, const PxSceneQueryFilterData& filterData /* = PxSceneQueryFilterData */)
  2. {
  3. PxRaycastHit hits[32];
  4. bool blockingHit;
  5. // 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
  6. outputFlags |= PxSceneQueryFlag::eDISTANCE; // always add, as we need distance to check for physX bug
  7. int numHits = g_pPhysicsWorld->PhysXScene->raycastMultiple(origin, unitDir, distance, outputFlags, hits, 32, blockingHit, filterData);
  8. bool foundProperHit = false;
  9. float closestHit = 99999999.0f;
  10. if(numHits)
  11. {
  12. for(int i=0; i<numHits; ++i)
  13. {
  14. if(hits[i].distance > 0)
  15. {
  16. if(hits[i].distance < closestHit)
  17. {
  18. hit = hits[i];
  19. closestHit = hits[i].distance;
  20. foundProperHit = true;
  21. }
  22. }
  23. }
  24. }
  25.  
  26. return foundProperHit;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement