Home Game Development PhysX overlap all the time returns false

PhysX overlap all the time returns false

0
PhysX overlap all the time returns false

[ad_1]

I’m making a sport utilizing PhysX because the physics engine and I’ve a perform which checks the overlapped our bodies based mostly on a sphere geometry. When there are overlapping our bodies I simply set a drive on them. The drawback is that the overlap perform all the time 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 outcomes
    PxSphereGeometry overlapShape = PxSphereGeometry(radius);  // [in] form to check for overlaps
    PxTransform shapePose = PxTransform(PxVec3(pos.x, pos.y, pos.z));    // [in] preliminary form 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 drive = (actor->getGlobalPose().p - PxVec3(pos.x, pos.y, pos.z));

                actor->addForce(drive * _force);
            }
        }
    }
}

Any concepts what is likely to be the issue or perhaps a substitute for overlap?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here