RavEngine
Loading...
Searching...
No Matches
PxGeometryQuery.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_GEOMETRY_QUERY_H
30#define PX_GEOMETRY_QUERY_H
31
38#define PX_MAX_SWEEP_DISTANCE 1e8f
39
44#include "common/PxPhysXCommonConfig.h"
45#include "geometry/PxGeometryHit.h"
46#include "geometry/PxGeometryQueryFlags.h"
47#include "geometry/PxGeometryQueryContext.h"
48
49#if !PX_DOXYGEN
50namespace physx
51{
52#endif
53
54class PxGeometry;
55class PxContactBuffer;
56
61{
62public:
63
85 PX_PHYSX_COMMON_API static PxU32 raycast( const PxVec3& origin, const PxVec3& unitDir,
86 const PxGeometry& geom, const PxTransform& pose,
87 PxReal maxDist, PxHitFlags hitFlags,
88 PxU32 maxHits, PxGeomRaycastHit* PX_RESTRICT rayHits, PxU32 stride, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT,
89 PxRaycastThreadContext* threadContext = NULL);
90
95 template<class HitT>
96 PX_DEPRECATED PX_FORCE_INLINE static PxU32 raycast( const PxVec3& origin, const PxVec3& unitDir,
97 const PxGeometry& geom, const PxTransform& pose,
98 PxReal maxDist, PxHitFlags hitFlags,
99 PxU32 maxHits, HitT* PX_RESTRICT rayHits)
100 {
101 return raycast(origin, unitDir, geom, pose, maxDist, hitFlags, maxHits, rayHits, sizeof(HitT));
102 }
103
124 PX_PHYSX_COMMON_API static bool overlap(const PxGeometry& geom0, const PxTransform& pose0,
125 const PxGeometry& geom1, const PxTransform& pose1,
126 PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT, PxOverlapThreadContext* threadContext=NULL);
127
154 PX_PHYSX_COMMON_API static bool sweep( const PxVec3& unitDir, const PxReal maxDist,
155 const PxGeometry& geom0, const PxTransform& pose0,
156 const PxGeometry& geom1, const PxTransform& pose1,
157 PxGeomSweepHit& sweepHit, PxHitFlags hitFlags = PxHitFlag::eDEFAULT,
158 const PxReal inflation = 0.0f, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT,
159 PxSweepThreadContext* threadContext = NULL);
160
193 PX_PHYSX_COMMON_API static bool computePenetration( PxVec3& direction, PxF32& depth,
194 const PxGeometry& geom0, const PxTransform& pose0,
195 const PxGeometry& geom1, const PxTransform& pose1,
196 PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT);
197
215 PX_PHYSX_COMMON_API static PxReal pointDistance(const PxVec3& point, const PxGeometry& geom, const PxTransform& pose,
216 PxVec3* closestPoint=NULL, PxU32* closestIndex=NULL,
217 PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT);
218
231 PX_PHYSX_COMMON_API static void computeGeomBounds(PxBounds3& bounds, const PxGeometry& geom, const PxTransform& pose, float offset=0.0f, float inflation=1.0f, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT);
232
244 PX_DEPRECATED PX_PHYSX_COMMON_API static PxBounds3 getWorldBounds(const PxGeometry& geom, const PxTransform& pose, float inflation=1.01f);
245
260 PX_PHYSX_COMMON_API static bool generateTriangleContacts(const PxGeometry& geom, const PxTransform& pose, const PxVec3 triangleVertices[3], PxU32 triangleIndex, PxReal contactDistance, PxReal meshContactMargin, PxReal toleranceLength, PxContactBuffer& contactBuffer);
261
270 PX_PHYSX_COMMON_API static bool isValid(const PxGeometry& geom);
271};
272
273#if !PX_DOXYGEN
274}
275#endif
276
278#endif
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
Definition PxContactBuffer.h:42
Collection of geometry object queries (sweeps, raycasts, overlaps, ...).
Definition PxGeometryQuery.h:61
static PX_PHYSX_COMMON_API 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.
Definition GuGeometryQuery.cpp:331
PX_DEPRECATED static PX_FORCE_INLINE PxU32 raycast(const PxVec3 &origin, const PxVec3 &unitDir, const PxGeometry &geom, const PxTransform &pose, PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, HitT *PX_RESTRICT rayHits)
Backward compatibility helper.
Definition PxGeometryQuery.h:96
static PX_PHYSX_COMMON_API bool isValid(const PxGeometry &geom)
Checks if provided geometry is valid.
Definition GuGeometryQuery.cpp:71
static PX_PHYSX_COMMON_API PxU32 raycast(const PxVec3 &origin, const PxVec3 &unitDir, const PxGeometry &geom, const PxTransform &pose, PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, PxGeomRaycastHit *PX_RESTRICT rayHits, PxU32 stride, PxGeometryQueryFlags queryFlags=PxGeometryQueryFlag::eDEFAULT, PxRaycastThreadContext *threadContext=NULL)
Raycast test against a geometry object.
Definition GuGeometryQuery.cpp:184
static PX_PHYSX_COMMON_API 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.
Definition GuGeometryQuery.cpp:205
static PX_PHYSX_COMMON_API 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.
Definition GuGeometryQuery.cpp:358
static PX_PHYSX_COMMON_API 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
Definition GuGeometryQuery.cpp:307
PX_DEPRECATED static PX_PHYSX_COMMON_API PxBounds3 getWorldBounds(const PxGeometry &geom, const PxTransform &pose, float inflation=1.01f)
get the bounds for a geometry object
Definition GuGeometryQuery.cpp:316
static PX_PHYSX_COMMON_API 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.
Definition GuGeometryQuery.cpp:174
static PX_PHYSX_COMMON_API 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.
Definition GuGeometryQuery.cpp:92
A geometry object.
Definition PxGeometry.h:79
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
#define PX_RESTRICT
Definition PxPreprocessor.h:355
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_DEPRECATED
Definition PxPreprocessor.h:418
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Stores results of raycast queries.
Definition PxGeometryHit.h:151
Stores results of sweep queries.
Definition PxGeometryHit.h:175
A per-thread context passed to low-level query functions.
Definition PxGeometryQueryContext.h:52