RavEngine
Loading...
Searching...
No Matches
GuOverlapTests.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 GU_OVERLAP_TESTS_H
30#define GU_OVERLAP_TESTS_H
31
32#include "foundation/PxVec3.h"
33#include "foundation/PxTransform.h"
34#include "foundation/PxAssert.h"
35#include "foundation/PxErrors.h"
36#include "foundation/PxFoundation.h"
37#include "geometry/PxGeometry.h"
38#include "geometry/PxGeometryHit.h"
39#include "geometry/PxGeometryQueryContext.h"
40
41namespace physx
42{
43namespace Gu
44{
45 class Capsule;
46 class Sphere;
47
48 // PT: this is just a shadow of what it used to be. We currently don't use TRIGGER_INSIDE anymore, but I leave it for now,
49 // since I really want to put this back the way it was before.
50 enum TriggerStatus
51 {
52 TRIGGER_DISJOINT,
53 TRIGGER_INSIDE,
54 TRIGGER_OVERLAP
55 };
56
57 // PT: currently only used for convex triggers
59 {
60 PxVec3 dir;
61 PxU16 state;
62 PxU16 gjkState; //gjk succeed or fail
63 };
64
65 #define UNUSED_OVERLAP_THREAD_CONTEXT NULL
66
67 // PT: we use a define to be able to quickly change the signature of all overlap functions.
68 // (this also ensures they all use consistent names for passed parameters).
69 // \param[in] geom0 first geometry object
70 // \param[in] pose0 pose of first geometry object
71 // \param[in] geom1 second geometry object
72 // \param[in] pose1 pose of second geometry object
73 // \param[in] cache optional cached data for triggers
74 // \param[in] threadContext optional per-thread context
75 #define GU_OVERLAP_FUNC_PARAMS const PxGeometry& geom0, const PxTransform& pose0, \
76 const PxGeometry& geom1, const PxTransform& pose1, \
77 Gu::TriggerCache* cache, PxOverlapThreadContext* threadContext
78
79 // PT: function pointer for Geom-indexed overlap functions
80 // See GU_OVERLAP_FUNC_PARAMS for function parameters details.
81 // \return true if an overlap was found, false otherwise
82 typedef bool (*GeomOverlapFunc) (GU_OVERLAP_FUNC_PARAMS);
83
84 // PT: typedef for a bundle of all overlap functions, i.e. the function table itself (indexed by geom-type).
85 typedef GeomOverlapFunc GeomOverlapTable[PxGeometryType::eGEOMETRY_COUNT];
86
87 // PT: retrieves the overlap function table (for access by external non-Gu modules)
88 PX_PHYSX_COMMON_API const GeomOverlapTable* getOverlapFuncTable();
89
90 // dynamic registration of height fields
91 PX_PHYSX_COMMON_API void registerHeightFields();
92
93 PX_FORCE_INLINE bool overlap( const PxGeometry& geom0, const PxTransform& pose0,
94 const PxGeometry& geom1, const PxTransform& pose1,
95 const GeomOverlapTable* PX_RESTRICT overlapFuncs, PxOverlapThreadContext* threadContext)
96 {
97 PX_CHECK_AND_RETURN_VAL(pose0.isValid(), "Gu::overlap(): pose0 is not valid.", false);
98 PX_CHECK_AND_RETURN_VAL(pose1.isValid(), "Gu::overlap(): pose1 is not valid.", false);
99
100 if(geom0.getType() > geom1.getType())
101 {
102 GeomOverlapFunc overlapFunc = overlapFuncs[geom1.getType()][geom0.getType()];
103 PX_ASSERT(overlapFunc);
104 return overlapFunc(geom1, pose1, geom0, pose0, NULL, threadContext);
105 }
106 else
107 {
108 GeomOverlapFunc overlapFunc = overlapFuncs[geom0.getType()][geom1.getType()];
109 PX_ASSERT(overlapFunc);
110 return overlapFunc(geom0, pose0, geom1, pose1, NULL, threadContext);
111 }
112 }
113
114} // namespace Gu
115
116}
117
118#endif
A geometry object.
Definition PxGeometry.h:79
PX_CUDA_CALLABLE PX_FORCE_INLINE PxGeometryType::Enum getType() const
Returns the type of the geometry.
Definition PxGeometry.h:85
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
PX_CUDA_CALLABLE bool isValid() const
returns true if finite and q is a unit quaternion
Definition PxTransform.h:148
3 Element vector class.
Definition PxVec3.h:50
#define PX_RESTRICT
Definition PxPreprocessor.h:355
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition GuOverlapTests.h:59
@ eGEOMETRY_COUNT
internal use only!
Definition PxGeometry.h:65
A per-thread context passed to low-level query functions.
Definition PxGeometryQueryContext.h:52