PxComputeTriangleMeshPenetration

Defined in include/extensions/PxTriangleMeshExt.h

bool PxComputeTriangleMeshPenetration(PxVec3 &direction, PxReal &depth, const PxGeometry &geom, const PxTransform &geomPose, const PxTriangleMeshGeometry &meshGeom, const PxTransform &meshPose, PxU32 maxIter, PxU32 *usedIter = NULL)

Computes an approximate minimum translational distance (MTD) between a geometry object and a mesh.

This iterative function computes an approximate vector that can be used to depenetrate a geom object from a triangle mesh. Returned depenetration vector should be applied to ‘geom’, to get out of the mesh.

The function works best when the amount of overlap between the geom object and the mesh is small. If the geom object’s center goes inside the mesh, backface culling usually kicks in, no overlap is detected, and the function does not compute an MTD vector.

The function early exits if no overlap is detected after a depenetration attempt. This means that if maxIter = N, the code will attempt at most N iterations but it might exit earlier if depenetration has been successful. Usually N = 4 gives good results.

See also

PxGeometry PxTransform PxTriangleMeshGeometry

Parameters
  • direction[out] Computed MTD unit direction

  • depth[out] Penetration depth. Always positive or zero.

  • geom[in] The geometry object

  • geomPose[in] Pose for the geometry object

  • meshGeom[in] The mesh geometry

  • meshPose[in] Pose for the mesh

  • maxIter[in] Max number of iterations before returning.

  • usedIter[out] Number of depenetrations attempts performed during the call. Will not be returned if the pointer is NULL.

Returns

True if the MTD has successfully been computed, i.e. if objects do overlap.