aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/GeomUtils/src
diff options
context:
space:
mode:
authorSheikh Dawood Abdul Ajees <[email protected]>2018-02-12 15:31:42 -0600
committerSheikh Dawood Abdul Ajees <[email protected]>2018-02-12 15:31:42 -0600
commit52dae55c0c65f42caffa9d803be27be44ac4b8a3 (patch)
treec2fa77a97691d026593fe6aa45f1a56389fc5c70 /PhysX_3.4/Source/GeomUtils/src
parentPhysX 3.4, APEX 1.4 patch release @23472123 (diff)
downloadphysx-3.4-52dae55c0c65f42caffa9d803be27be44ac4b8a3.tar.xz
physx-3.4-52dae55c0c65f42caffa9d803be27be44ac4b8a3.zip
PhysX 3.4, APEX 1.4 patch release @23576764
Diffstat (limited to 'PhysX_3.4/Source/GeomUtils/src')
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/GuRaycastTests.cpp6
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/convex/GuConvexEdgeFlags.h3
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexCommon.h4
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexHeightField.cpp4
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexMesh.cpp10
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactMeshCallback.h17
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMTriangleContactGen.cpp38
7 files changed, 54 insertions, 28 deletions
diff --git a/PhysX_3.4/Source/GeomUtils/src/GuRaycastTests.cpp b/PhysX_3.4/Source/GeomUtils/src/GuRaycastTests.cpp
index fa7056ad..086d4ca2 100644
--- a/PhysX_3.4/Source/GeomUtils/src/GuRaycastTests.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/GuRaycastTests.cpp
@@ -487,6 +487,12 @@ PxU32 raycast_heightField(GU_RAY_FUNC_PARAMS)
PxBounds3 hfLocalBounds;
hfUtil.computeLocalBounds(hfLocalBounds);
+ // PT: inflate the bounds like we do in the scene-tree (see PX-1179)
+ const PxVec3 center = hfLocalBounds.getCenter();
+ const PxVec3 extents = hfLocalBounds.getExtents() * 1.01f; //SQ_PRUNER_INFLATION;
+ hfLocalBounds.minimum = center - extents;
+ hfLocalBounds.maximum = center + extents;
+
PxVec3 localImpact;
PxReal t; // closest intersection, t==0 hit inside
PxU32 rval = rayAABBIntersect2(hfLocalBounds.minimum, hfLocalBounds.maximum, localRayOrig, localRayDir, localImpact, t);
diff --git a/PhysX_3.4/Source/GeomUtils/src/convex/GuConvexEdgeFlags.h b/PhysX_3.4/Source/GeomUtils/src/convex/GuConvexEdgeFlags.h
index 71f2a761..d8fffd52 100644
--- a/PhysX_3.4/Source/GeomUtils/src/convex/GuConvexEdgeFlags.h
+++ b/PhysX_3.4/Source/GeomUtils/src/convex/GuConvexEdgeFlags.h
@@ -38,6 +38,9 @@ namespace Gu
{
enum ExtraTrigDataFlag
{
+ ETD_SILHOUETTE_EDGE_01 = (1 << 0), //First edge is a silhouette edge
+ ETD_SILHOUETTE_EDGE_12 = (1 << 1), //Second edge is a silhouette edge
+ ETD_SILHOUETTE_EDGE_20 = (1 << 2), //Third edge is a silhouette edge
ETD_CONVEX_EDGE_01 = (1<<3), // PT: important value, don't change
ETD_CONVEX_EDGE_12 = (1<<4), // PT: important value, don't change
ETD_CONVEX_EDGE_20 = (1<<5), // PT: important value, don't change
diff --git a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexCommon.h b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexCommon.h
index cae46bdd..215c2c11 100644
--- a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexCommon.h
+++ b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexCommon.h
@@ -281,6 +281,7 @@ public:
SupportLocal* mPolyMap;
const Cm::FastVertex2ShapeScaling& mConvexScaling;
bool mIdtConvexScale;
+ bool mSilhouetteEdgesAreActive;
Cm::RenderOutput* mRenderOutput;
@@ -297,6 +298,7 @@ public:
Ps::InlineArray<PxU32,LOCAL_CONTACTS_SIZE>* delayedContacts,
const Cm::FastVertex2ShapeScaling& convexScaling,
bool idtConvexScale,
+ bool silhouetteEdgesAreActive,
Cm::RenderOutput* renderOutput
) : PCMMeshContactGeneration(contactDistance, replaceBreakingThreshold, convexTransform, meshTransform, multiManifold, contactBuffer,
@@ -305,7 +307,9 @@ public:
mPolyMap(polyMap),
mConvexScaling(convexScaling),
mIdtConvexScale(idtConvexScale),
+ mSilhouetteEdgesAreActive(silhouetteEdgesAreActive),
mRenderOutput(renderOutput)
+
{
using namespace Ps::aos;
diff --git a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexHeightField.cpp b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexHeightField.cpp
index 6901a5c3..45bec74c 100644
--- a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexHeightField.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexHeightField.cpp
@@ -75,12 +75,13 @@ public:
Gu::ContactBuffer& contactBuffer,
Gu::HeightFieldUtil& hfUtil,
Ps::InlineArray<PxU32,LOCAL_CONTACTS_SIZE>* delayedContacts,
+ bool silhouetteEdgesAreActive,
Cm::RenderOutput* renderOutput = NULL
) :
PCMHeightfieldContactGenerationCallback< PCMConvexVsHeightfieldContactGenerationCallback >(hfUtil, heightfieldTransform1),
mGeneration(contactDistance, replaceBreakingThreshold, convexTransform, heightfieldTransform, multiManifold,
- contactBuffer, polyData, polyMap, delayedContacts, convexScaling, idtConvexScale, renderOutput)
+ contactBuffer, polyData, polyMap, delayedContacts, convexScaling, idtConvexScale, silhouetteEdgesAreActive, renderOutput)
{
}
@@ -156,6 +157,7 @@ bool Gu::PCMContactConvexHeightfield(
contactBuffer,
hfUtil,
&delayedContacts,
+ !(hf.getFlags() & PxHeightFieldFlag::eNO_BOUNDARY_EDGES),
renderOutput
);
diff --git a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexMesh.cpp b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexMesh.cpp
index 2bacfb87..0f79d83b 100644
--- a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexMesh.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactConvexMesh.cpp
@@ -61,24 +61,26 @@ public:
PCMConvexVsMeshContactGenerationCallback(
const Ps::aos::FloatVArg contactDistance,
const Ps::aos::FloatVArg replaceBreakingThreshold,
- const PsTransformV& convexTransform,
+ const PsTransformV& convexTransform,
const PsTransformV& meshTransform,
MultiplePersistentContactManifold& multiManifold,
ContactBuffer& contactBuffer,
const PolygonalData& polyData,
SupportLocal* polyMap,
- Ps::InlineArray<PxU32,LOCAL_CONTACTS_SIZE>* delayedContacts,
+ Ps::InlineArray<PxU32, LOCAL_CONTACTS_SIZE>* delayedContacts,
const Cm::FastVertex2ShapeScaling& convexScaling,
bool idtConvexScale,
const Cm::FastVertex2ShapeScaling& meshScaling,
const PxU8* extraTriData,
bool idtMeshScale,
+ bool silhouetteEdgesAreActive,
const BoxPadded& box,
Cm::RenderOutput* renderOutput = NULL
) :
PCMMeshContactGenerationCallback<PCMConvexVsMeshContactGenerationCallback>(meshScaling, extraTriData, idtMeshScale),
- mGeneration(contactDistance, replaceBreakingThreshold, convexTransform, meshTransform, multiManifold, contactBuffer, polyData, polyMap, delayedContacts, convexScaling, idtConvexScale, renderOutput),
+ mGeneration(contactDistance, replaceBreakingThreshold, convexTransform, meshTransform, multiManifold, contactBuffer, polyData, polyMap,
+ delayedContacts, convexScaling, idtConvexScale, silhouetteEdgesAreActive, renderOutput),
mBox(box)
{
}
@@ -143,7 +145,7 @@ bool Gu::PCMContactConvexMesh(const PolygonalData& polyData, SupportLocal* polyM
const PxU8* PX_RESTRICT extraData = meshData->getExtraTrigData();
PCMConvexVsMeshContactGenerationCallback blockCallback(
contactDist, replaceBreakingThreshold, convexTransform, meshTransform, multiManifold, contactBuffer,
- polyData, polyMap, &delayedContacts, convexScaling, idtConvexScale, meshScaling, extraData, idtMeshScale,
+ polyData, polyMap, &delayedContacts, convexScaling, idtConvexScale, meshScaling, extraData, idtMeshScale, true,
hullOBB, renderOutput);
Midphase::intersectOBB(meshData, hullOBB, blockCallback, true);
diff --git a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactMeshCallback.h b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactMeshCallback.h
index de38099c..595c0463 100644
--- a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactMeshCallback.h
+++ b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactMeshCallback.h
@@ -111,11 +111,12 @@ struct PCMHeightfieldContactGenerationCallback : Gu::EntityReport<PxU32>
public:
const Gu::HeightFieldUtil& mHfUtil;
const PxTransform& mHeightfieldTransform;
+ bool mBoundaryCollisions;
PCMHeightfieldContactGenerationCallback(const Gu::HeightFieldUtil& hfUtil, const PxTransform& heightfieldTransform) :
mHfUtil(hfUtil), mHeightfieldTransform(heightfieldTransform)
{
-
+ mBoundaryCollisions = !(hfUtil.getHeightField().getFlags() & PxHeightFieldFlag::eNO_BOUNDARY_EDGES);
}
// PT: TODO: refactor/unify with similar code in other places
@@ -153,7 +154,7 @@ public:
for(PxU32 a = 0; a < 3; ++a)
{
- if(adjInds[a] != 0xFFFFFFFF)
+ if (adjInds[a] != 0xFFFFFFFF)
{
PxTriangle adjTri;
PxU32 inds[3];
@@ -161,7 +162,7 @@ public:
//We now compare the triangles to see if this edge is active
PX_ASSERT(inds[0] == vertIndices[a] || inds[1] == vertIndices[a] || inds[2] == vertIndices[a]);
- PX_ASSERT(inds[0] == vertIndices[(a+1)%3] || inds[1] == vertIndices[(a+1)%3] || inds[2] == vertIndices[(a+1)%3]);
+ PX_ASSERT(inds[0] == vertIndices[(a + 1) % 3] || inds[1] == vertIndices[(a + 1) % 3] || inds[2] == vertIndices[(a + 1) % 3]);
PxVec3 adjNormal;
@@ -169,20 +170,22 @@ public:
PxU32 otherIndex = nextInd[a];
PxF32 projD = adjNormal.dot(currentTriangle.verts[otherIndex] - adjTri.verts[0]);
- if(projD < 0.f)
+ if (projD < 0.f)
{
adjNormal.normalize();
PxF32 proj = adjNormal.dot(normal);
- if(proj < 0.997f)
+ if (proj < 0.997f)
{
- triFlags |= (1 << (a+3));
+ triFlags |= (1 << (a + 3));
}
}
}
+ else if (mBoundaryCollisions)
+ triFlags |= (1 << (a + 3)); //Mark as boudary active edge
else
- triFlags |= (1 << (a+3));
+ triFlags |= (1 << a); //Mark as silhouette edge
}
cache.addTriangle(currentTriangle.verts, vertIndices, triangleIndex, triFlags);
diff --git a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMTriangleContactGen.cpp b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMTriangleContactGen.cpp
index 5f0b20a2..99229dc3 100644
--- a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMTriangleContactGen.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMTriangleContactGen.cpp
@@ -32,6 +32,7 @@
#include "GuPCMContactConvexCommon.h"
#include "GuVecTriangle.h"
#include "GuBarycentricCoordinates.h"
+#include "GuConvexEdgeFlags.h"
#if PCM_LOW_LEVEL_DEBUG
#include "PxRenderBuffer.h"
@@ -1153,23 +1154,28 @@ namespace physx
else
{
//ML : defer the contacts generation
- const PxU32 nb = sizeof(PCMDeferredPolyData)/sizeof(PxU32);
- PxU32 newSize = nb + mDeferredContacts->size();
- mDeferredContacts->reserve(newSize);
- PCMDeferredPolyData* PX_RESTRICT data = reinterpret_cast<PCMDeferredPolyData*>(mDeferredContacts->end());
- mDeferredContacts->forceSize_Unsafe(newSize);
-
- data->mTriangleIndex = triangleIndex;
- data->mFeatureIndex = feature1;
- data->triFlags = triFlags;
- data->mInds[0] = triIndices[0];
- data->mInds[1] = triIndices[1];
- data->mInds[2] = triIndices[2];
- V3StoreU(localTriangle.verts[0], data->mVerts[0]);
- V3StoreU(localTriangle.verts[1], data->mVerts[1]);
- V3StoreU(localTriangle.verts[2], data->mVerts[2]);
- return true;
+ if (mSilhouetteEdgesAreActive ||
+ !(triFlags & (ETD_SILHOUETTE_EDGE_01 | ETD_SILHOUETTE_EDGE_12 | ETD_SILHOUETTE_EDGE_20)))
+ {
+ const PxU32 nb = sizeof(PCMDeferredPolyData) / sizeof(PxU32);
+ PxU32 newSize = nb + mDeferredContacts->size();
+ mDeferredContacts->reserve(newSize);
+ PCMDeferredPolyData* PX_RESTRICT data = reinterpret_cast<PCMDeferredPolyData*>(mDeferredContacts->end());
+ mDeferredContacts->forceSize_Unsafe(newSize);
+
+ data->mTriangleIndex = triangleIndex;
+ data->mFeatureIndex = feature1;
+ data->triFlags = triFlags;
+ data->mInds[0] = triIndices[0];
+ data->mInds[1] = triIndices[1];
+ data->mInds[2] = triIndices[2];
+ V3StoreU(localTriangle.verts[0], data->mVerts[0]);
+ V3StoreU(localTriangle.verts[1], data->mVerts[1]);
+ V3StoreU(localTriangle.verts[2], data->mVerts[2]);
+ }
+
+ return true;
}
}
else