PxGeometryQuery

Defined in include/geometry/PxGeometryQuery.h

class PxGeometryQuery

Collection of geometry object queries (sweeps, raycasts, overlaps, …).

Public Static Functions

static PxU32 raycast(const PxVec3 &origin, const PxVec3 &unitDir, const PxGeometry &geom, const PxTransform &pose, PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, PxGeomRaycastHit *rayHits, PxU32 stride = sizeof(PxGeomRaycastHit), PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT, PxRaycastThreadContext *threadContext = NULL)

Raycast test against a geometry object.

All geometry types are supported except PxParticleSystemGeometry, PxTetrahedronMeshGeometry and PxHairSystemGeometry.

See also

PxGeomRaycastHit PxGeometry PxTransform

Parameters
  • origin[in] The origin of the ray to test the geometry object against

  • unitDir[in] Normalized direction of the ray to test the geometry object against

  • geom[in] The geometry object to test the ray against

  • pose[in] Pose of the geometry object

  • maxDist[in] Maximum ray length, has to be in the [0, inf) range

  • hitFlags[in] Specification of the kind of information to retrieve on hit. Combination of PxHitFlag flags

  • maxHits[in] max number of returned hits = size of ‘rayHits’ buffer

  • rayHits[out] Raycast hits information

  • stride[in] Stride value (in number of bytes) for rayHits array. Typically sizeof(PxGeomRaycastHit) for packed arrays.

  • queryFlags[in] Optional flags controlling the query.

  • threadContext[in] Optional user-defined per-thread context.

Returns

Number of hits between the ray and the geometry object

static bool overlap(const PxGeometry &geom0, const PxTransform &pose0, const PxGeometry &geom1, const PxTransform &pose1, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT, PxOverlapThreadContext *threadContext = NULL)

Overlap test for two geometry objects.

All combinations are supported except:

  • PxPlaneGeometry vs. {PxPlaneGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}

  • PxTriangleMeshGeometry vs. PxHeightFieldGeometry

  • PxHeightFieldGeometry vs. PxHeightFieldGeometry

  • Anything involving PxParticleSystemGeometry, PxTetrahedronMeshGeometry or PxHairSystemGeometry.

See also

PxGeometry PxTransform

Parameters
  • geom0[in] The first geometry object

  • pose0[in] Pose of the first geometry object

  • geom1[in] The second geometry object

  • pose1[in] Pose of the second geometry object

  • queryFlags[in] Optional flags controlling the query.

  • threadContext[in] Optional user-defined per-thread context.

Returns

True if the two geometry objects overlap

static bool sweep(const PxVec3 &unitDir, const PxReal maxDist, const PxGeometry &geom0, const PxTransform &pose0, const PxGeometry &geom1, const PxTransform &pose1, PxGeomSweepHit &sweepHit, PxHitFlags hitFlags = PxHitFlag::eDEFAULT, const PxReal inflation = 0.0f, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT, PxSweepThreadContext *threadContext = NULL)

Sweep a specified geometry object in space and test for collision with a given object.

The following combinations are supported.

  • PxSphereGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}

  • PxCapsuleGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}

  • PxBoxGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}

  • PxConvexMeshGeometry vs. {PxSphereGeometry, PxPlaneGeometry, PxCapsuleGeometry, PxBoxGeometry, PxConvexMeshGeometry, PxTriangleMeshGeometry, PxHeightFieldGeometry}

See also

PxGeomSweepHit PxGeometry PxTransform

Parameters
  • unitDir[in] Normalized direction along which object geom0 should be swept

  • maxDist[in] Maximum sweep distance, has to be in the [0, inf) range

  • geom0[in] The geometry object to sweep. Supported geometries are PxSphereGeometry, PxCapsuleGeometry, PxBoxGeometry and PxConvexMeshGeometry

  • pose0[in] Pose of the geometry object to sweep

  • geom1[in] The geometry object to test the sweep against

  • pose1[in] Pose of the geometry object to sweep against

  • sweepHit[out] The sweep hit information. Only valid if this method returns true.

  • hitFlags[in] Specify which properties per hit should be computed and written to result hit array. Combination of PxHitFlag flags

  • inflation[in] Surface of the swept shape is additively extruded in the normal direction, rounding corners and edges.

  • queryFlags[in] Optional flags controlling the query.

  • threadContext[in] Optional user-defined per-thread context.

Returns

True if the swept geometry object geom0 hits the object geom1

static bool computePenetration(PxVec3 &direction, PxF32 &depth, const PxGeometry &geom0, const PxTransform &pose0, const PxGeometry &geom1, const PxTransform &pose1, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT)

Compute minimum translational distance (MTD) between two geometry objects.

All combinations of geom objects are supported except:

  • plane/plane

  • plane/mesh

  • plane/heightfield

  • mesh/mesh

  • mesh/heightfield

  • heightfield/heightfield

  • anything involving PxParticleSystemGeometry, PxTetrahedronMeshGeometry or PxHairSystemGeometry

The function returns a unit vector (‘direction’) and a penetration depth (‘depth’).

The depenetration vector D = direction * depth should be applied to the first object, to get out of the second object.

Returned depth should always be positive or null.

If objects do not overlap, the function can not compute the MTD and returns false.

See also

PxGeometry PxTransform

Parameters
  • direction[out] Computed MTD unit direction

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

  • geom0[in] The first geometry object

  • pose0[in] Pose of the first geometry object

  • geom1[in] The second geometry object

  • pose1[in] Pose of the second geometry object

  • queryFlags[in] Optional flags controlling the query.

Returns

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

static PxReal pointDistance(const PxVec3 &point, const PxGeometry &geom, const PxTransform &pose, PxVec3 *closestPoint = NULL, PxU32 *closestIndex = NULL, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT)

Computes distance between a point and a geometry object.

Currently supported geometry objects: box, sphere, capsule, convex, mesh.

See also

PxGeometry PxTransform

Note

For meshes, only the BVH34 midphase data-structure is supported.

Parameters
  • point[in] The point P

  • geom[in] The geometry object

  • pose[in] Pose of the geometry object

  • closestPoint[out] Optionally returned closest point to P on the geom object. Only valid when returned distance is strictly positive.

  • closestIndex[out] Optionally returned closest (triangle) index. Only valid for triangle meshes.

  • queryFlags[in] Optional flags controlling the query.

Returns

Square distance between the point and the geom object, or 0.0 if the point is inside the object, or -1.0 if an error occured (geometry type is not supported, or invalid pose)

static void computeGeomBounds(PxBounds3 &bounds, const PxGeometry &geom, const PxTransform &pose, float offset = 0.0f, float inflation = 1.0f, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT)

computes the bounds for a geometry object

See also

PxGeometry PxTransform

Parameters
  • bounds[out] Returned computed bounds

  • geom[in] The geometry object

  • pose[in] Pose of the geometry object

  • offset[in] Offset for computed bounds. This value is added to the geom’s extents.

  • inflation[in] Scale factor for computed bounds. The geom’s extents are multiplied by this value.

  • queryFlags[in] Optional flags controlling the query.

static bool generateTriangleContacts(const PxGeometry &geom, const PxTransform &pose, const PxVec3 triangleVertices[3], PxU32 triangleIndex, PxReal contactDistance, PxReal meshContactMargin, PxReal toleranceLength, PxContactBuffer &contactBuffer)

Generate collision contacts between a convex geometry and a single triangle.

Parameters
  • geom[in] The geometry object. Can be a capsule, a box or a convex mesh

  • pose[in] Pose of the geometry object

  • triangleVertices[in] Triangle vertices in local space

  • triangleIndex[in] Triangle index

  • contactDistance[in] The distance at which contacts begin to be generated between the pairs

  • meshContactMargin[in] The mesh contact margin.

  • toleranceLength[in] The toleranceLength. Used for scaling distance-based thresholds internally to produce appropriate results given simulations in different units

  • contactBuffer[out] A buffer to write contacts to.

Returns

True if there was collision

static bool isValid(const PxGeometry &geom)

Checks if provided geometry is valid.

See also

PxGeometry

Parameters

geom[in] The geometry object.

Returns

True if geometry is valid.