Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- physx::PxPhysics* GetPhysX() {
- HMODULE hModule = GetModuleHandleA("PhysX3CHECKED_x64.dll");
- if (!hModule) {
- return nullptr;
- }
- typedef physx::PxPhysics* (__cdecl* GetPhysicsFn)();
- GetPhysicsFn GetPhysics = (GetPhysicsFn)GetProcAddress(hModule, "PxGetPhysics");
- if (!GetPhysics) {
- return nullptr;
- }
- return GetPhysics();
- }
- physx::PxScene* g_pPxScene = nullptr;
- void UpdatePhysX() {
- physx::PxPhysics* pPhysX = GetPhysX();
- if (!pPhysX) {
- return;
- }
- pPhysX->getScenes(&g_pPxScene, 1);
- }
- bool IsPointVisible(const Vector3& vStart, const Vector3& vEnd) {
- if (!g_pPxScene) {
- return false;
- }
- physx::PxVec3 pStart = *(physx::PxVec3*)&vStart;
- physx::PxVec3 pEnd = *(physx::PxVec3*)&vEnd;
- physx::PxVec3 pDirection = pEnd - pStart;
- physx::PxReal pLength = pDirection.magnitude();
- pDirection.normalize();
- physx::PxSceneQueryHit pHit;
- if (g_pPxScene->raycastAny(pStart, pDirection, pLength, pHit, physx::PxSceneQueryFilterData(physx::PxSceneQueryFilterFlag::eSTATIC))) {
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement