29#ifndef GU_PCM_CONTACT_MESH_CALLBACK_H
30#define GU_PCM_CONTACT_MESH_CALLBACK_H
32#include "GuMidphaseInterface.h"
33#include "GuEntityReport.h"
34#include "GuHeightFieldUtil.h"
35#include "GuTriangleCache.h"
36#include "GuConvexEdgeFlags.h"
43template <
typename Derived>
50 static const PxU32 CacheSize = 16;
55 mMeshScaling(meshScaling), mExtraTrigData(extraTrigData), mIdtMeshScale(idtMeshScale)
61 if (!mCache.isEmpty())
63 (
static_cast<Derived*
>(
this))->template processTriangleCache< CacheSize >(mCache);
71 if (!(
static_cast<Derived*
>(
this))->doTest(v0, v1, v2))
74 const PxU32 triangleIndex = hit.
faceIndex;
75 PxU8 extraData = getConvexEdgeFlags(mExtraTrigData, triangleIndex);
77 const PxU32* vertexIndices = vinds;
79 PxU32 localStorage[3];
88 const PxI32 winding = mMeshScaling.flipsNormal() ? 1 : 0;
89 v[0] = mMeshScaling * v0;
90 v[1 + winding] = mMeshScaling * v1;
91 v[2 - winding] = mMeshScaling * v2;
95 flipConvexEdgeFlags(extraData);
96 localStorage[0] = vinds[0];
97 localStorage[1] = vinds[2];
98 localStorage[2] = vinds[1];
99 vertexIndices = localStorage;
105 (
static_cast<Derived*
>(
this))->template processTriangleCache< CacheSize >(mCache);
108 mCache.addTriangle(v, vertexIndices, triangleIndex, extraData);
117template <
typename Derived>
123 bool mBoundaryCollisions;
126 mHfUtil(hfUtil), mHeightfieldTransform(heightfieldTransform)
132 virtual bool reportTouchedTris(PxU32 nb,
const PxU32* indices)
134 const PxU32 CacheSize = 16;
137 const PxU32 nbPasses = (nb+(CacheSize-1))/CacheSize;
139 const PxU32* inds0 = indices;
141 const PxU8 nextInd[] = {2,0,1};
143 for(PxU32 i = 0; i < nbPasses; ++i)
145 cache.mNumTriangles = 0;
146 PxU32 trigCount =
PxMin(nbTrigs, CacheSize);
147 nbTrigs -= trigCount;
150 PxU32 triangleIndex = *(inds0++);
151 PxU32 vertIndices[3];
156 mHfUtil.getTriangle(mHeightfieldTransform, currentTriangle, vertIndices, adjInds, triangleIndex,
false,
false);
159 currentTriangle.
normal(normal);
163 for(PxU32 a = 0; a < 3; ++a)
165 if (adjInds[a] != 0xFFFFFFFF)
169 mHfUtil.getTriangle(mHeightfieldTransform, adjTri, inds, NULL, adjInds[a],
false,
false);
172 PX_ASSERT(inds[0] == vertIndices[a] || inds[1] == vertIndices[a] || inds[2] == vertIndices[a]);
173 PX_ASSERT(inds[0] == vertIndices[(a + 1) % 3] || inds[1] == vertIndices[(a + 1) % 3] || inds[2] == vertIndices[(a + 1) % 3]);
177 PxU32 otherIndex = nextInd[a];
178 PxF32 projD = adjNormal.
dot(currentTriangle.
verts[otherIndex] - adjTri.
verts[0]);
184 PxF32 proj = adjNormal.
dot(normal);
188 triFlags |= (1 << (a + 3));
192 else if (mBoundaryCollisions)
194 triFlags |= (1 << (a + 3));
197 triFlags |= (1 << a);
200 cache.addTriangle(currentTriangle.
verts, vertIndices, triangleIndex, triFlags);
202 PX_ASSERT(cache.mNumTriangles <= 16);
204 (
static_cast<Derived*
>(
this))->template processTriangleCache< CacheSize >(cache);
212template <
typename Derived>
217 static const PxU32 CacheSize = 16;
226 if (!mCache.isEmpty())
228 (
static_cast<Derived*
>(
this))->template processTetrahedronCache< CacheSize >(mCache);
236 if (!(
static_cast<Derived*
>(
this))->doTest(v0, v1, v2, v3))
239 PxVec3 v[4] = { v0, v1, v2, v3 };
245 (
static_cast<Derived*
>(
this))->template processTetrahedronCache< CacheSize >(mCache);
248 mCache.addTetrahedrons(v, vinds, tetIndex);
Definition CmScaling.h:61
Definition GuHeightFieldUtil.h:69
virtual PxHeightFieldFlags getFlags() const
Retrieves the flags bits, combined from values of the enum ::PxHeightFieldFlag.
Definition GuHeightField.h:86
Definition GuEntityReport.h:48
Triangle class.
Definition PxTriangle.h:47
PxVec3 verts[3]
Array of Vertices.
Definition PxTriangle.h:140
PX_FORCE_INLINE void denormalizedNormal(PxVec3 &_normal) const
Compute the unnormalized normal of the triangle.
Definition PxTriangle.h:111
PX_FORCE_INLINE void normal(PxVec3 &_normal) const
Compute the normal of the Triangle.
Definition PxTriangle.h:100
3 Element vector class.
Definition PxVec3.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE float dot(const PxVec3 &v) const
returns the scalar product of this and other.
Definition PxVec3.h:276
PX_CUDA_CALLABLE PX_FORCE_INLINE float normalize()
normalizes the vector in place
Definition PxVec3.h:300
#define PX_RESTRICT
Definition PxPreprocessor.h:355
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
bool PxAgain
Describes query behavior after returning a partial query result via a callback.
Definition PxQueryReport.h:78
PX_CUDA_CALLABLE PX_FORCE_INLINE T PxMin(T a, T b)
The return value is the lesser of the two specified values.
Definition PxMath.h:88
Definition GuMidphaseInterface.h:61
Definition GuMidphaseInterface.h:78
Definition GuTriangleCache.h:205
Definition GuTriangleCache.h:172
Stores results of raycast queries.
Definition PxGeometryHit.h:151
@ eNO_BOUNDARY_EDGES
Disable collisions with height field with boundary edges.
Definition PxHeightFieldFlag.h:143
PxU32 faceIndex
Definition PxGeometryHit.h:106