Advertisement
keybode

H1Z1 Visible Check

Jan 17th, 2015
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. // physx sdk 3.2.0.1 needed
  2.  
  3. physx::PxScene* GetScene ()
  4. {
  5. typedef void* (__cdecl* GetPhysicsFn)();
  6.  
  7. GetPhysicsFn GetPhysics = (GetPhysicsFn) GetProcAddress ( GetModuleHandleA ( "PhysX3_x64" ), "PxGetPhysics" );
  8.  
  9. void* pPhysics = GetPhysics ();
  10.  
  11. physx::PxScene* pScene = nullptr;
  12.  
  13. typedef void (__thiscall* getActiveSceneFn)( void*, physx::PxScene**, int, int );
  14.  
  15. GetMethod<getActiveSceneFn> ( pPhysics, INDEX_GETSCENE )( pPhysics, &pScene, 1, 0 );
  16.  
  17. return pScene;
  18. }
  19.  
  20. bool IsPointVisible ( const Vecotr3& vStart, const Vector3& vEnd )
  21. {
  22. static physx::PxScene* pScene = GetScene ();
  23.  
  24. if ( !pScene )
  25. return false;
  26.  
  27. physx::PxVec3 pStart = *(physx::PxVec3*)&vStart;
  28. physx::PxVec3 pEnd = *(physx::PxVec3*)&vEnd;
  29.  
  30. physx::PxVec3 pDelta = pEnd - pStart;
  31.  
  32. physx::PxReal Length = pDelta.magnitude ();
  33.  
  34. pDelta.normalize ();
  35.  
  36. physx::PxSceneQueryHit Hit;
  37.  
  38. if ( pScene->raycastAny ( pStart, pDelta, Length, Hit, physx::PxSceneQueryFilterData ( physx::PxSceneQueryFilterFlag::eSTATIC ) ) )
  39. return false;
  40.  
  41. return true;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement