PxMeshQuery

Defined in include/geometry/PxMeshQuery.h

class PxMeshQuery

Public Static Functions

static void getTriangle(const PxTriangleMeshGeometry &triGeom, const PxTransform &transform, PxTriangleID triangleIndex, PxTriangle &triangle, PxU32 *vertexIndices = NULL, PxU32 *adjacencyIndices = NULL)

Retrieves triangle data from a triangle ID.

This function can be used together with findOverlapTriangleMesh() to retrieve triangle properties.

See also

PxTriangle PxTriangleFlags PxTriangleID findOverlapTriangleMesh()

Note

This function will flip the triangle normal whenever triGeom.scale.hasNegativeDeterminant() is true.

Parameters
  • triGeom[in] Geometry of the triangle mesh to extract the triangle from.

  • transform[in] Transform for the triangle mesh

  • triangleIndex[in] The index of the triangle to retrieve.

  • triangle[out] Triangle points in world space.

  • vertexIndices[out] Returned vertex indices for given triangle

  • adjacencyIndices[out] Returned 3 triangle adjacency internal face indices (0xFFFFFFFF if no adjacency). The mesh must be cooked with cooking param buildTriangleAdjacencies enabled.

static void getTriangle(const PxHeightFieldGeometry &hfGeom, const PxTransform &transform, PxTriangleID triangleIndex, PxTriangle &triangle, PxU32 *vertexIndices = NULL, PxU32 *adjacencyIndices = NULL)

Retrieves triangle data from a triangle ID.

This function can be used together with findOverlapHeightField() to retrieve triangle properties.

See also

PxTriangle PxTriangleFlags PxTriangleID findOverlapHeightField()

Note

This function will flip the triangle normal whenever triGeom.scale.hasNegativeDeterminant() is true.

Note

TriangleIndex is an index used in internal format, which does have an index out of the bounds in last row. To traverse all tri indices in the HF, the following code can be applied: for (PxU32 row = 0; row < (nbRows - 1); row++) { for (PxU32 col = 0; col < (nbCols - 1); col++) { for (PxU32 k = 0; k < 2; k++) { const PxU32 triIndex = 2 * (row*nbCols + col) + k; …. } } }

Parameters
  • hfGeom[in] Geometry of the height field to extract the triangle from.

  • transform[in] Transform for the height field.

  • triangleIndex[in] The index of the triangle to retrieve.

  • triangle[out] Triangle points in world space.

  • vertexIndices[out] Returned vertex indices for given triangle

  • adjacencyIndices[out] Returned 3 triangle adjacency triangle indices (0xFFFFFFFF if no adjacency).

static PxU32 findOverlapTriangleMesh(const PxGeometry &geom, const PxTransform &geomPose, const PxTriangleMeshGeometry &meshGeom, const PxTransform &meshPose, PxU32 *results, PxU32 maxResults, PxU32 startIndex, bool &overflow, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT)

Find the mesh triangles which touch the specified geometry object.

For mesh-vs-mesh overlap tests, please use the specialized function below.

Returned triangle indices can be used with getTriangle() to retrieve the triangle properties.

See also

PxTriangleMeshGeometry getTriangle() PxGeometryQueryFlags

Parameters
  • geom[in] The geometry object to test for mesh triangle overlaps. Supported geometries are PxSphereGeometry, PxCapsuleGeometry and PxBoxGeometry

  • geomPose[in] Pose of the geometry object

  • meshGeom[in] The triangle mesh geometry to check overlap against

  • meshPose[in] Pose of the triangle mesh

  • results[out] Indices of overlapping triangles

  • maxResults[in] Size of ‘results’ buffer

  • startIndex[in] Index of first result to be retrieved. Previous indices are skipped.

  • overflow[out] True if a buffer overflow occurred

  • queryFlags[in] Optional flags controlling the query.

Returns

Number of overlaps found, i.e. number of elements written to the results buffer

static bool findOverlapTriangleMesh(PxReportCallback<PxGeomIndexPair> &callback, const PxTriangleMeshGeometry &meshGeom0, const PxTransform &meshPose0, const PxTriangleMeshGeometry &meshGeom1, const PxTransform &meshPose1, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT, PxMeshMeshQueryFlags meshMeshFlags = PxMeshMeshQueryFlag::eDEFAULT)

Mesh-vs-mesh overlap test.

A specialized findOverlapTriangleMesh function for mesh-vs-mesh. The other findOverlapTriangleMesh() function above cannot be used directly since it only returns a single set of triangle indices that belongs to one of the meshes only. This function returns pairs of triangle indices that belong to both the first & second input meshes.

Returned triangle indices can be used with getTriangle() to retrieve the triangle properties.

See also

PxTriangleMeshGeometry getTriangle() PxReportCallback PxGeometryQueryFlags PxMeshMeshQueryFlags

Note

This is only implemented for the PxMeshMidPhase::eBVH34 data structure.

Parameters
  • callback[in] The callback object used to report results

  • meshGeom0[in] First triangle mesh geometry

  • meshPose0[in] Pose of first triangle mesh geometry

  • meshGeom1[in] Second triangle mesh geometry

  • meshPose1[in] Pose of second triangle mesh geometry

  • queryFlags[in] Optional flags controlling the query.

  • meshMeshFlags[in] Optional flags controlling the query.

Returns

true if an overlap has been detected, false if the meshes are disjoint

static PxU32 findOverlapHeightField(const PxGeometry &geom, const PxTransform &geomPose, const PxHeightFieldGeometry &hfGeom, const PxTransform &hfPose, PxU32 *results, PxU32 maxResults, PxU32 startIndex, bool &overflow, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT)

Find the height field triangles which touch the specified geometry object.

Returned triangle indices can be used with getTriangle() to retrieve the triangle properties.

See also

PxHeightFieldGeometry getTriangle() PxGeometryQueryFlags

Parameters
  • geom[in] The geometry object to test for height field overlaps. Supported geometries are PxSphereGeometry, PxCapsuleGeometry and PxBoxGeometry. The sphere and capsule queries are currently conservative estimates.

  • geomPose[in] Pose of the geometry object

  • hfGeom[in] The height field geometry to check overlap against

  • hfPose[in] Pose of the height field

  • results[out] Indices of overlapping triangles

  • maxResults[in] Size of ‘results’ buffer

  • startIndex[in] Index of first result to be retrieved. Previous indices are skipped.

  • overflow[out] True if a buffer overflow occurred

  • queryFlags[in] Optional flags controlling the query.

Returns

Number of overlaps found, i.e. number of elements written to the results buffer

static bool sweep(const PxVec3 &unitDir, const PxReal distance, const PxGeometry &geom, const PxTransform &pose, PxU32 triangleCount, const PxTriangle *triangles, PxGeomSweepHit &sweepHit, PxHitFlags hitFlags = PxHitFlag::eDEFAULT, const PxU32 *cachedIndex = NULL, const PxReal inflation = 0.0f, bool doubleSided = false, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT)

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

This function simply sweeps input geometry against each input triangle, in the order they are given. This is an O(N) operation with N = number of input triangles. It does not use any particular acceleration structure.

See also

PxTriangle PxSweepHit PxGeometry PxTransform PxGeometryQueryFlags

Note

Only the following geometry types are currently supported: PxSphereGeometry, PxCapsuleGeometry, PxBoxGeometry

Note

If a shape from the scene is already overlapping with the query shape in its starting position, the hit is returned unless eASSUME_NO_INITIAL_OVERLAP was specified.

Note

This function returns a single closest hit across all the input triangles. Multiple hits are not supported.

Note

ePOSITION is only defined when there is no initial overlap (sweepHit.hadInitialOverlap() == false)

Note

The returned normal for initially overlapping sweeps is set to -unitDir.

Note

Otherwise the returned normal is the front normal of the triangle even if PxHitFlag::eMESH_BOTH_SIDES is set.

Note

The returned PxGeomSweepHit::faceIndex parameter will hold the index of the hit triangle in input array, i.e. the range is [0; triangleCount). For initially overlapping sweeps, this is the index of overlapping triangle.

Note

The inflation parameter is not compatible with PxHitFlag::ePRECISE_SWEEP.

Parameters
  • unitDir[in] Normalized direction of the sweep.

  • distance[in] Sweep distance. Needs to be larger than 0. Clamped to PX_MAX_SWEEP_DISTANCE.

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

  • pose[in] Pose of the geometry object to sweep.

  • triangleCount[in] Number of specified triangles

  • triangles[in] Array of triangles to sweep against

  • sweepHit[out] The sweep hit information. See the notes below for limitations about returned results.

  • hitFlags[in] Specification of the kind of information to retrieve on hit. Combination of PxHitFlag flags. See the notes below for limitations about supported flags.

  • cachedIndex[in] Cached triangle index for subsequent calls. Cached triangle is tested first. Optional parameter.

  • inflation[in] This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal.

  • doubleSided[in] Counterpart of PxMeshGeometryFlag::eDOUBLE_SIDED for input triangles.

  • queryFlags[in] Optional flags controlling the query.

Returns

True if the swept geometry object hits the specified triangles