aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/LowLevelDynamics
diff options
context:
space:
mode:
authorSheikh Dawood Abdul Ajees <[email protected]>2017-11-20 11:35:52 -0600
committerSheikh Dawood Abdul Ajees <[email protected]>2017-11-20 11:35:52 -0600
commit3cc1861221d761b7f0301b9b61de4e1aa18c09f4 (patch)
treea51eb808016e1710a4bbd537000a493250602944 /PhysX_3.4/Source/LowLevelDynamics
parentPhysX 3.4.1, APEX 1.4.1 Release @22845541 (diff)
downloadphysx-3.4-3cc1861221d761b7f0301b9b61de4e1aa18c09f4.tar.xz
physx-3.4-3cc1861221d761b7f0301b9b61de4e1aa18c09f4.zip
PhysX 3.4.1, APEX 1.4.1 Release @23131702
Diffstat (limited to 'PhysX_3.4/Source/LowLevelDynamics')
-rw-r--r--PhysX_3.4/Source/LowLevelDynamics/src/DyContactPrepShared.h1
-rw-r--r--PhysX_3.4/Source/LowLevelDynamics/src/DyCorrelationBuffer.h5
-rw-r--r--PhysX_3.4/Source/LowLevelDynamics/src/DyFrictionCorrelation.cpp25
3 files changed, 28 insertions, 3 deletions
diff --git a/PhysX_3.4/Source/LowLevelDynamics/src/DyContactPrepShared.h b/PhysX_3.4/Source/LowLevelDynamics/src/DyContactPrepShared.h
index c973f1cf..cf1705de 100644
--- a/PhysX_3.4/Source/LowLevelDynamics/src/DyContactPrepShared.h
+++ b/PhysX_3.4/Source/LowLevelDynamics/src/DyContactPrepShared.h
@@ -118,6 +118,7 @@ inline bool getFrictionPatches(CorrelationBuffer& c,
//Rotate the contact normal into world space
c.frictionPatchWorldNormal[c.frictionPatchCount] = bodyFrame0.rotate(patch.body0Normal);
c.frictionPatchContactCounts[c.frictionPatchCount] = 0;
+ c.patchBounds[c.frictionPatchCount].setEmpty();
c.correlationListHeads[c.frictionPatchCount] = CorrelationBuffer::LIST_END;
PxMemCopy(&c.frictionPatches[c.frictionPatchCount++], &patch, sizeof(FrictionPatch));
}
diff --git a/PhysX_3.4/Source/LowLevelDynamics/src/DyCorrelationBuffer.h b/PhysX_3.4/Source/LowLevelDynamics/src/DyCorrelationBuffer.h
index 23945071..9d115c36 100644
--- a/PhysX_3.4/Source/LowLevelDynamics/src/DyCorrelationBuffer.h
+++ b/PhysX_3.4/Source/LowLevelDynamics/src/DyCorrelationBuffer.h
@@ -38,6 +38,7 @@
#include "foundation/PxTransform.h"
#include "DyFrictionPatch.h"
#include "GuContactBuffer.h"
+#include "foundation/PxBounds3.h"
namespace physx
{
@@ -60,13 +61,15 @@ struct CorrelationBuffer
PxU8 flags;
PxU8 count;
PxReal staticFriction, dynamicFriction, restitution;
+ PxBounds3 patchBounds;
};
// we can have as many contact patches as contacts, unfortunately
ContactPatchData contactPatches[Gu::ContactBuffer::MAX_CONTACTS];
FrictionPatch PX_ALIGN(16, frictionPatches[MAX_FRICTION_PATCHES]);
- PxVec3 PX_ALIGN(16, frictionPatchWorldNormal[MAX_FRICTION_PATCHES]);
+ PxVec3 PX_ALIGN(16, frictionPatchWorldNormal[MAX_FRICTION_PATCHES]);
+ PxBounds3 patchBounds[MAX_FRICTION_PATCHES];
PxU32 frictionPatchContactCounts[MAX_FRICTION_PATCHES];
PxU32 correlationListHeads[MAX_FRICTION_PATCHES+1];
diff --git a/PhysX_3.4/Source/LowLevelDynamics/src/DyFrictionCorrelation.cpp b/PhysX_3.4/Source/LowLevelDynamics/src/DyFrictionCorrelation.cpp
index 2d0af683..75e9d0ee 100644
--- a/PhysX_3.4/Source/LowLevelDynamics/src/DyFrictionCorrelation.cpp
+++ b/PhysX_3.4/Source/LowLevelDynamics/src/DyFrictionCorrelation.cpp
@@ -89,6 +89,8 @@ bool createContactPatches(CorrelationBuffer& fb, const Gu::ContactPoint* cb, PxU
initContactPatch(fb.contactPatches[contactPatchCount++], Ps::to16(0), contacts[0].restitution,
contacts[0].staticFriction, contacts[0].dynamicFriction, PxU8(contacts[0].materialFlags));
+ PxBounds3 bounds(contacts[0].point, contacts[0].point);
+
PxU32 patchIndex = 0;
for (PxU32 i = 1; i<contactCount; i++)
@@ -101,6 +103,7 @@ bool createContactPatches(CorrelationBuffer& fb, const Gu::ContactPoint* cb, PxU
&& curContact.restitution == preContact.restitution
&& curContact.normal.dot(preContact.normal)>=normalTolerance)
{
+ bounds.include(curContact.point);
count++;
}
else
@@ -110,14 +113,20 @@ bool createContactPatches(CorrelationBuffer& fb, const Gu::ContactPoint* cb, PxU
patchIndex = i;
currentPatchData->count = count;
count = 1;
+ currentPatchData->patchBounds = bounds;
currentPatchData = fb.contactPatches + contactPatchCount;
initContactPatch(fb.contactPatches[contactPatchCount++], Ps::to16(i), curContact.restitution,
curContact.staticFriction, curContact.dynamicFriction, PxU8(curContact.materialFlags));
+
+
+ bounds = PxBounds3(curContact.point, curContact.point);
}
}
if(count!=1)
currentPatchData->count = count;
+
+ currentPatchData->patchBounds = bounds;
}
fb.contactPatchCount = contactPatchCount;
return true;
@@ -155,11 +164,13 @@ bool correlatePatches(CorrelationBuffer& fb,
fb.frictionPatchWorldNormal[j] = patchNormal;
fb.frictionPatchContactCounts[frictionPatchCount] = c.count;
fb.contactID[frictionPatchCount][0] = 0xffff;
+ fb.patchBounds[frictionPatchCount] = c.patchBounds;
fb.contactID[frictionPatchCount++][1] = 0xffff;
c.next = CorrelationBuffer::LIST_END;
}
else
{
+ fb.patchBounds[j].include(c.patchBounds);
fb.frictionPatchContactCounts[j] += c.count;
c.next = Ps::to16(fb.correlationListHeads[j]);
}
@@ -187,8 +198,18 @@ void growPatches(CorrelationBuffer& fb,
{
FrictionPatch& fp = fb.frictionPatches[i];
- if(fp.anchorCount==2 || fb.correlationListHeads[i]==CorrelationBuffer::LIST_END)
- continue;
+ if (fp.anchorCount == 2 || fb.correlationListHeads[i] == CorrelationBuffer::LIST_END)
+ {
+ const PxReal frictionPatchDiagonalSq = fb.patchBounds[i].getDimensions().magnitudeSquared();
+ const PxReal anchorSqDistance = (fp.body0Anchors[0] - fp.body0Anchors[1]).magnitudeSquared();
+
+ //If the squared distance between the anchors is more than a quarter of the patch diagonal, we can keep,
+ //otherwise the anchors are potentially clustered around a corner so force a rebuild of the patch
+ if(fb.frictionPatchContactCounts[i] == 0 || (anchorSqDistance * 4.f) >= frictionPatchDiagonalSq)
+ continue;
+
+ fp.anchorCount = 0;
+ }
PxVec3 worldAnchors[2];
PxU16 anchorCount = 0;