Defined in include/extensions/PxTriangleMeshExt.h

bool PxComputeHeightFieldPenetration(PxVec3 &direction, PxReal &depth, const PxGeometry &geom, const PxTransform &geomPose, const PxHeightFieldGeometry &heightFieldGeom, const PxTransform &heightFieldPose, PxU32 maxIter, PxU32 *usedIter = NULL)

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

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

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 heightfield, 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 PxHeightFieldGeometry

  • 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

  • heightFieldGeom[in] The heightfield geometry

  • heightFieldPose[in] Pose for the heightfield

  • 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.


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