I am creating a game using PhysX as the physics engine and I have a function which checks the overlapped bodies based on a sphere geometry. When there are overlapping bodies I just set a force on them. The problem is that the overlap function always return false. No matter what I feed it with. Here is my code:
void PhysxManager::ExplosionSphere(const glm::vec3& pos, float radius, float _force) { PxOverlapBuffer hit; // [out] Overlap results PxSphereGeometry overlapShape = PxSphereGeometry(radius); // [in] shape to test for overlaps PxTransform shapePose = PxTransform(PxVec3(pos.x, pos.y, pos.z)); // [in] initial shape pose (at distance=0) if (mScene->overlap(overlapShape, shapePose, hit, PxSceneQueryFilterData(PxQueryFlag::eNO_BLOCK))) { for (int i = 0; i < hit.nbTouches; ++i) { auto actor = dynamic_cast<physx::PxRigidDynamic*>(hit.touches[i].actor); if (actor) { PxVec3 force = (actor->getGlobalPose().p - PxVec3(pos.x, pos.y, pos.z)); actor->addForce(force * _force); } } } } Any ideas what might be the problem or maybe an alternative to overlap?