RavEngine
Loading...
Searching...
No Matches
GuContactMethodImpl.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_CONTACTMETHODIMPL_H
30#define GU_CONTACTMETHODIMPL_H
31
32#include "foundation/PxAssert.h"
33#include "common/PxPhysXCommonConfig.h"
34#include "collision/PxCollisionDefs.h"
35#include "GuGeometryChecks.h"
36
37namespace physx
38{
39 class PxGeometry;
40 class PxRenderOutput;
41 class PxContactBuffer;
42
43namespace Gu
44{
45 class PersistentContactManifold;
46 class MultiplePersistentContactManifold;
47
49 {
50 PX_FORCE_INLINE NarrowPhaseParams(PxReal contactDistance, PxReal meshContactMargin, PxReal toleranceLength) :
51 mContactDistance(contactDistance),
52 mMeshContactMargin(meshContactMargin),
53 mToleranceLength(toleranceLength) {}
54
55 PxReal mContactDistance;
56 PxReal mMeshContactMargin; // PT: Margin used to generate mesh contacts. Temp & unclear, should be removed once GJK is default path.
57 PxReal mToleranceLength; // PT: copy of PxTolerancesScale::length
58 };
59
60 enum ManifoldFlags
61 {
62 IS_MANIFOLD = (1<<0),
63 IS_MULTI_MANIFOLD = (1<<1)
64 };
65
66 struct Cache : public PxCache
67 {
68 Cache()
69 {
70 }
71
72 PX_FORCE_INLINE void setManifold(void* manifold)
73 {
74 PX_ASSERT((size_t(manifold) & 0xF) == 0);
75 mCachedData = reinterpret_cast<PxU8*>(manifold);
76 mManifoldFlags |= IS_MANIFOLD;
77 }
78
79 PX_FORCE_INLINE void setMultiManifold(void* manifold)
80 {
81 PX_ASSERT((size_t(manifold) & 0xF) == 0);
82 mCachedData = reinterpret_cast<PxU8*>(manifold);
83 mManifoldFlags |= IS_MANIFOLD|IS_MULTI_MANIFOLD;
84 }
85
86 PX_FORCE_INLINE PxU8 isManifold() const
87 {
88 return PxU8(mManifoldFlags & IS_MANIFOLD);
89 }
90
91 PX_FORCE_INLINE PxU8 isMultiManifold() const
92 {
93 return PxU8(mManifoldFlags & IS_MULTI_MANIFOLD);
94 }
95
97 {
98 PX_ASSERT(isManifold());
99 PX_ASSERT(!isMultiManifold());
100 PX_ASSERT((uintptr_t(mCachedData) & 0xf) == 0);
101 return *reinterpret_cast<PersistentContactManifold*>(mCachedData);
102 }
103
105 {
106 PX_ASSERT(isManifold());
107 PX_ASSERT(isMultiManifold());
108 PX_ASSERT((uintptr_t(mCachedData) & 0xf) == 0);
109 return *reinterpret_cast<MultiplePersistentContactManifold*>(mCachedData);
110 }
111 };
112}
113
114template<class Geom> PX_CUDA_CALLABLE PX_FORCE_INLINE const Geom& checkedCast(const PxGeometry& geom)
115{
116 checkType<Geom>(geom);
117 return static_cast<const Geom&>(geom);
118}
119
120#define GU_CONTACT_METHOD_ARGS \
121 const PxGeometry& shape0, \
122 const PxGeometry& shape1, \
123 const PxTransform& transform0, \
124 const PxTransform& transform1, \
125 const Gu::NarrowPhaseParams& params, \
126 Gu::Cache& cache, \
127 PxContactBuffer& contactBuffer, \
128 PxRenderOutput* renderOutput
129
130#define GU_CONTACT_METHOD_ARGS_UNUSED \
131 const PxGeometry&, \
132 const PxGeometry&, \
133 const PxTransform&, \
134 const PxTransform&, \
135 const Gu::NarrowPhaseParams&, \
136 Gu::Cache&, \
137 PxContactBuffer&, \
138 PxRenderOutput*
139
140namespace Gu
141{
142 PX_PHYSX_COMMON_API bool contactSphereSphere(GU_CONTACT_METHOD_ARGS);
143 PX_PHYSX_COMMON_API bool contactSphereCapsule(GU_CONTACT_METHOD_ARGS);
144 PX_PHYSX_COMMON_API bool contactSphereBox(GU_CONTACT_METHOD_ARGS);
145 PX_PHYSX_COMMON_API bool contactCapsuleCapsule(GU_CONTACT_METHOD_ARGS);
146 PX_PHYSX_COMMON_API bool contactCapsuleBox(GU_CONTACT_METHOD_ARGS);
147 PX_PHYSX_COMMON_API bool contactCapsuleConvex(GU_CONTACT_METHOD_ARGS);
148 PX_PHYSX_COMMON_API bool contactBoxBox(GU_CONTACT_METHOD_ARGS);
149 PX_PHYSX_COMMON_API bool contactBoxConvex(GU_CONTACT_METHOD_ARGS);
150 PX_PHYSX_COMMON_API bool contactConvexConvex(GU_CONTACT_METHOD_ARGS);
151
152 PX_PHYSX_COMMON_API bool contactSphereMesh(GU_CONTACT_METHOD_ARGS);
153 PX_PHYSX_COMMON_API bool contactCapsuleMesh(GU_CONTACT_METHOD_ARGS);
154 PX_PHYSX_COMMON_API bool contactBoxMesh(GU_CONTACT_METHOD_ARGS);
155 PX_PHYSX_COMMON_API bool contactConvexMesh(GU_CONTACT_METHOD_ARGS);
156
157 PX_PHYSX_COMMON_API bool contactSphereHeightfield(GU_CONTACT_METHOD_ARGS);
158 PX_PHYSX_COMMON_API bool contactCapsuleHeightfield(GU_CONTACT_METHOD_ARGS);
159 PX_PHYSX_COMMON_API bool contactBoxHeightfield(GU_CONTACT_METHOD_ARGS);
160 PX_PHYSX_COMMON_API bool contactConvexHeightfield(GU_CONTACT_METHOD_ARGS);
161
162 PX_PHYSX_COMMON_API bool contactSpherePlane(GU_CONTACT_METHOD_ARGS);
163 PX_PHYSX_COMMON_API bool contactPlaneBox(GU_CONTACT_METHOD_ARGS);
164 PX_PHYSX_COMMON_API bool contactPlaneCapsule(GU_CONTACT_METHOD_ARGS);
165 PX_PHYSX_COMMON_API bool contactPlaneConvex(GU_CONTACT_METHOD_ARGS);
166
167 PX_PHYSX_COMMON_API bool contactCustomGeometryGeometry(GU_CONTACT_METHOD_ARGS);
168 PX_PHYSX_COMMON_API bool contactGeometryCustomGeometry(GU_CONTACT_METHOD_ARGS);
169
170 PX_PHYSX_COMMON_API bool pcmContactSphereMesh(GU_CONTACT_METHOD_ARGS);
171 PX_PHYSX_COMMON_API bool pcmContactCapsuleMesh(GU_CONTACT_METHOD_ARGS);
172 PX_PHYSX_COMMON_API bool pcmContactBoxMesh(GU_CONTACT_METHOD_ARGS);
173 PX_PHYSX_COMMON_API bool pcmContactConvexMesh(GU_CONTACT_METHOD_ARGS);
174
175 PX_PHYSX_COMMON_API bool pcmContactSphereHeightField(GU_CONTACT_METHOD_ARGS);
176 PX_PHYSX_COMMON_API bool pcmContactCapsuleHeightField(GU_CONTACT_METHOD_ARGS);
177 PX_PHYSX_COMMON_API bool pcmContactBoxHeightField(GU_CONTACT_METHOD_ARGS);
178 PX_PHYSX_COMMON_API bool pcmContactConvexHeightField(GU_CONTACT_METHOD_ARGS);
179
180 PX_PHYSX_COMMON_API bool pcmContactPlaneCapsule(GU_CONTACT_METHOD_ARGS);
181 PX_PHYSX_COMMON_API bool pcmContactPlaneBox(GU_CONTACT_METHOD_ARGS);
182 PX_PHYSX_COMMON_API bool pcmContactPlaneConvex(GU_CONTACT_METHOD_ARGS);
183
184 PX_PHYSX_COMMON_API bool pcmContactSphereSphere(GU_CONTACT_METHOD_ARGS);
185 PX_PHYSX_COMMON_API bool pcmContactSpherePlane(GU_CONTACT_METHOD_ARGS);
186 PX_PHYSX_COMMON_API bool pcmContactSphereCapsule(GU_CONTACT_METHOD_ARGS);
187 PX_PHYSX_COMMON_API bool pcmContactSphereBox(GU_CONTACT_METHOD_ARGS);
188 PX_PHYSX_COMMON_API bool pcmContactSphereConvex(GU_CONTACT_METHOD_ARGS);
189
190 PX_PHYSX_COMMON_API bool pcmContactCapsuleCapsule(GU_CONTACT_METHOD_ARGS);
191 PX_PHYSX_COMMON_API bool pcmContactCapsuleBox(GU_CONTACT_METHOD_ARGS);
192 PX_PHYSX_COMMON_API bool pcmContactCapsuleConvex(GU_CONTACT_METHOD_ARGS);
193 PX_PHYSX_COMMON_API bool pcmContactBoxBox(GU_CONTACT_METHOD_ARGS);
194 PX_PHYSX_COMMON_API bool pcmContactBoxConvex(GU_CONTACT_METHOD_ARGS);
195 PX_PHYSX_COMMON_API bool pcmContactConvexConvex(GU_CONTACT_METHOD_ARGS);
196
197 PX_PHYSX_COMMON_API bool pcmContactGeometryCustomGeometry(GU_CONTACT_METHOD_ARGS);
198}
199}
200
201#endif
Definition GuPersistentContactManifold.h:532
Definition GuPersistentContactManifold.h:149
A geometry object.
Definition PxGeometry.h:79
#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 GuContactMethodImpl.h:67
Definition GuContactMethodImpl.h:49
A structure to cache contact information produced by low-level contact generation functions.
Definition PxCollisionDefs.h:68
PxU8 * mCachedData
Cached data pointer. Allocated via PxCacheAllocator.
Definition PxCollisionDefs.h:69
PxU8 mManifoldFlags
Manifold flags used to identify the format the cached data is stored in.
Definition PxCollisionDefs.h:72