NVIDIAGameWorks/PhysX

Capsule overlap doesn't work in some cases

Closed this issue · 3 comments

Hello!

There is an issue with capsule overlap. Sometimes it reports false, when there is actual overlap with another actor.
What have I found:

  1. here we call method to calculate node center and extents:

    node->getAABBCenterExtentsV(&center, &extents);

    Actual method:
    PX_FORCE_INLINE void getAABBCenterExtentsV(shdfnd::aos::Vec3V* center, shdfnd::aos::Vec3V* extents) const

    I got following values as input:
    mBV.minimum = {x=-56475.7344 y=-4.47370236e+14 z=-2.05951517e+11} mBV.maximum = {x=1067442.25 y=4.39207167e+15 z=3012.03174 }
    After calculations I got following results:
    center = {505483.250, 1.97235072e+15, -1.02975758e+11, 0.00000000} extents = {561959.000, 2.41972096e+15, 1.02975758e+11, 0.00000000}
    Keep this in mind for now.

  2. Then these values will be using in test:

    while (test(center, extents))

    For my case test will be object of CapsuleAABBTest class. Which basically uses RayAABBTest method to test intersection:
    const Vec3V iExt = TInflate ? V3Add(extents, mInflation) : extents;

    Here we will reconstruct min and max for the same node and will get following results:
    nodeMax = {1067442.50, 4.39207167e+15, 0.00000000, 0.00000000} nodeMin = {-56476.0625, -4.47370236e+14, -2.05951517e+11, 0.00000000}
    As you can see, max Z is less than original value (from p1) which is stored on node itself.

Center of my capsule is in {x=-191.259476 y=16.7793903 z=378.330444 } and radius=0.34, thus this node will be rejected(capsule Z is greater than node's max Z (reconstructed)). I assume that the issue is in float operation and difference in mantissa.

  1. I also tested aabb vs aabb overlap (I constructed aabb from capsule's radius and height), and this overlap test works.
    But the reason why it works is the same issue with float precision:
    return Ps::IntBool(V3AllGrtrOrEq(V3Add(mExtents, extents), V3Abs(V3Sub(center, mCenter))));

    Here we will get V3Sub(center, mCenter) = {505674.500, 1.97235072e+15, -1.02975758e+11} with center={505483.250, 1.97235072e+15, -1.02975758e+11} and mCenter = {-191.259476, 17.0318909, 378.330444.
    As you can see, mCenter's Z is ignored in the resulting value thus the check will return true.

Any ideas how can this be fixed with minor changes to PhysX code? Or maybe I got something wrong here.
Thanks in advance!

There might be issue with actors on our scene, will keep you updated.

Yep, so there were actors with unrealistic positions like (-56475.519531,-447370236002304.000000,479.603851). They broke BHV tree.
Nonetheless, after I fixed the tree, I got actors to check overlap(on broad phase), but actual overlap(capsule vs trimesh) returned no contacts, while it should. Investigating further.

yeah, blame is on scene setup totally, no problems on PhtsX side.
closing the ticket, sorry for bothering ^_^