aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/GeomUtils/src
diff options
context:
space:
mode:
authorAles Borovicka <[email protected]>2017-03-15 15:20:53 +0100
committerAles Borovicka <[email protected]>2017-03-15 15:20:53 +0100
commit2398860b2b9bd6d9ec55a4b1cfddbcf1f6e4ebf6 (patch)
tree31a4af0fa12e07fc3a90477a1e3cadaba91cfe05 /PhysX_3.4/Source/GeomUtils/src
parentPhysX 3.4, APEX 1.4 final release @21757769 (diff)
downloadphysx-3.4-2398860b2b9bd6d9ec55a4b1cfddbcf1f6e4ebf6.tar.xz
physx-3.4-2398860b2b9bd6d9ec55a4b1cfddbcf1f6e4ebf6.zip
PhysX 3.4, APEX 1.4 patch release @21821222
Diffstat (limited to 'PhysX_3.4/Source/GeomUtils/src')
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/GuMeshFactory.cpp6
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/GuSweepMTD.cpp50
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/GuSweepMTD.h6
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_AABBSweep.cpp2
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_BoxOverlap.cpp10
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_CapsuleSweep.cpp2
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_CapsuleSweepAA.cpp2
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_OBBSweep.cpp2
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Raycast.cpp2
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_SphereOverlap.cpp6
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_SphereSweep.cpp2
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuMidphaseBV4.cpp2
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactCapsuleBox.cpp6
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactCapsuleConvex.cpp8
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactPlaneCapsule.cpp13
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/pcm/GuPersistentContactManifold.cpp5
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/pcm/GuPersistentContactManifold.h2
17 files changed, 79 insertions, 47 deletions
diff --git a/PhysX_3.4/Source/GeomUtils/src/GuMeshFactory.cpp b/PhysX_3.4/Source/GeomUtils/src/GuMeshFactory.cpp
index 838aeb2d..0ce25e11 100644
--- a/PhysX_3.4/Source/GeomUtils/src/GuMeshFactory.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/GuMeshFactory.cpp
@@ -138,12 +138,10 @@ PxTriangleMesh* GuMeshFactory::createTriangleMesh(TriangleMeshData& data)
{
PX_NEW_SERIALIZED(np, RTreeTriangleMesh)(*this, data);
}
-#if !defined(PX_SIMD_DISABLED)
else if(data.mType==PxMeshMidPhase::eBVH34)
{
PX_NEW_SERIALIZED(np, BV4TriangleMesh)(*this, data);
}
-#endif
else return NULL;
if(np)
@@ -194,10 +192,8 @@ static TriangleMeshData* loadMeshData(PxInputStream& stream)
TriangleMeshData* data;
if(midphaseID==PxMeshMidPhase::eBVH33)
data = PX_NEW(RTreeTriangleData);
-#if !defined(PX_SIMD_DISABLED)
else if(midphaseID==PxMeshMidPhase::eBVH34)
data = PX_NEW(BV4TriangleData);
-#endif
else return NULL;
// Import mesh
@@ -333,7 +329,6 @@ static TriangleMeshData* loadMeshData(PxInputStream& stream)
return NULL;
}
}
-#if !defined(PX_SIMD_DISABLED)
else if(midphaseID==PxMeshMidPhase::eBVH34)
{
BV4TriangleData* bv4data = static_cast<BV4TriangleData*>(data);
@@ -352,7 +347,6 @@ static TriangleMeshData* loadMeshData(PxInputStream& stream)
bv4data->mMeshInterface.setPointers(reinterpret_cast<IndTri32*>(tris), NULL, verts);
bv4data->mBV4Tree.mMeshInterface = &bv4data->mMeshInterface;
}
-#endif
else PX_ASSERT(0);
// Import local bounds
diff --git a/PhysX_3.4/Source/GeomUtils/src/GuSweepMTD.cpp b/PhysX_3.4/Source/GeomUtils/src/GuSweepMTD.cpp
index 39c24c2c..b0a98c50 100644
--- a/PhysX_3.4/Source/GeomUtils/src/GuSweepMTD.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/GuSweepMTD.cpp
@@ -297,9 +297,13 @@ bool physx::Gu::computeCapsule_TriangleMeshMTD( const PxTriangleMeshGeometry& tr
}
}
- normal = V3Normalize(translation);
- distV = FNeg(V3Length(translation));
+ const FloatV translationF = V3Length(translation);
+ distV = FNeg(translationF);
+
+ const BoolV con = FIsGrtr(translationF, FZero());
+ normal = V3Sel(con, V3ScaleInv(translation, translationF), zeroV);
+
if(foundInitial)
{
FStore(distV, &hit.distance);
@@ -409,8 +413,12 @@ bool physx::Gu::computeCapsule_HeightFieldMTD(const PxHeightFieldGeometry& heigh
}
}
- normal = V3Normalize(translation);
- distV = FNeg(V3Length(translation));
+ const FloatV translationF = V3Length(translation);
+ distV = FNeg(translationF);
+
+ const BoolV con = FIsGrtr(translationF, FZero());
+ normal = V3Sel(con, V3ScaleInv(translation, translationF), zeroV);
+
if(foundInitial)
{
FStore(distV, &hit.distance);
@@ -580,8 +588,12 @@ bool physx::Gu::computeBox_TriangleMeshMTD(const PxTriangleMeshGeometry& triMesh
}
}
- worldNormal = V3Normalize(translation);
- distV = FNeg(V3Length(translation));
+ const FloatV translationF = V3Length(translation);
+ distV = FNeg(translationF);
+
+ const BoolV con = FIsGrtr(translationF, FZero());
+ worldNormal = V3Sel(con, V3ScaleInv(translation, translationF), zeroV);
+
if(foundInitial)
{
//transform closestA to world space
@@ -722,8 +734,12 @@ bool physx::Gu::computeBox_HeightFieldMTD( const PxHeightFieldGeometry& heightFi
}
}
- worldNormal = V3Normalize(translation);
- distV = FNeg(V3Length(translation));
+
+ const FloatV translationF = V3Length(translation);
+ distV = FNeg(translationF);
+
+ const BoolV con = FIsGrtr(translationF, FZero());
+ worldNormal = V3Sel(con, V3ScaleInv(translation, translationF), zeroV);
if(foundInitial)
{
@@ -881,8 +897,13 @@ bool physx::Gu::computeConvex_TriangleMeshMTD( const PxTriangleMeshGeometry& tri
}
}
- worldNormal = V3Normalize(translation);
- distV = FNeg(V3Length(translation));
+
+ const FloatV translationF = V3Length(translation);
+ distV = FNeg(translationF);
+
+ const BoolV con = FIsGrtr(translationF, FZero());
+ worldNormal = V3Sel(con, V3ScaleInv(translation, translationF), zeroV);
+
if(foundInitial)
{
//transform closestA to world space
@@ -1041,8 +1062,13 @@ bool physx::Gu::computeConvex_HeightFieldMTD( const PxHeightFieldGeometry& heigh
}
}
- worldNormal = V3Normalize(translation);
- distV = FNeg(V3Length(translation));
+
+ const FloatV translationF = V3Length(translation);
+ distV = FNeg(translationF);
+
+ const BoolV con = FIsGrtr(translationF, FZero());
+ worldNormal = V3Sel(con, V3ScaleInv(translation, translationF), zeroV);
+
if(foundInitial)
{
//transform closestA to world space
diff --git a/PhysX_3.4/Source/GeomUtils/src/GuSweepMTD.h b/PhysX_3.4/Source/GeomUtils/src/GuSweepMTD.h
index 1ea7333e..f9ed88ca 100644
--- a/PhysX_3.4/Source/GeomUtils/src/GuSweepMTD.h
+++ b/PhysX_3.4/Source/GeomUtils/src/GuSweepMTD.h
@@ -78,7 +78,13 @@ namespace Gu
}
else
{
+ //ML: touching contact. We need to overwrite the normal to the negative of sweep direction
+ if (sweepHit.distance == 0.0f)
+ {
+ sweepHit.normal = -unitDir;
+ }
sweepHit.flags |= PxHitFlag::ePOSITION;
+
}
}
}
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_AABBSweep.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_AABBSweep.cpp
index f353d55c..4c4efe3d 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_AABBSweep.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_AABBSweep.cpp
@@ -31,7 +31,7 @@
using namespace physx;
using namespace Gu;
-#if PX_INTEL_FAMILY
+#if PX_INTEL_FAMILY && !defined(PX_SIMD_DISABLED)
#define SWEEP_AABB_IMPL
#include "PsVecMath.h"
using namespace physx::shdfnd::aos;
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_BoxOverlap.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_BoxOverlap.cpp
index f949d220..a3605cff 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_BoxOverlap.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_BoxOverlap.cpp
@@ -31,7 +31,7 @@
using namespace physx;
using namespace Gu;
-#if PX_INTEL_FAMILY
+#if PX_INTEL_FAMILY && !defined(PX_SIMD_DISABLED)
#include "PsVecMath.h"
using namespace physx::shdfnd::aos;
@@ -153,10 +153,10 @@ public:
if(intersectTriangleBoxBV4(params->mVerts[VRef0], params->mVerts[VRef1], params->mVerts[VRef2], params->mRModelToBox_Padded, params->mTModelToBox_Padded, params->mBoxExtents_PaddedAligned))
{
OBBParamsAll* ParamsAll = static_cast<OBBParamsAll*>(params);
- ParamsAll->mHits[ParamsAll->mNbHits] = primIndex;
- ParamsAll->mNbHits++;
if(ParamsAll->mNbHits==ParamsAll->mMaxNbHits)
return 1;
+ ParamsAll->mHits[ParamsAll->mNbHits] = primIndex;
+ ParamsAll->mNbHits++;
}
primIndex++;
}while(nbToGo--);
@@ -373,10 +373,10 @@ public:
{
if(__CapsuleTriangle(ParamsAll, primIndex))
{
- ParamsAll->mHits[ParamsAll->mNbHits] = primIndex;
- ParamsAll->mNbHits++;
if(ParamsAll->mNbHits==ParamsAll->mMaxNbHits)
return 1;
+ ParamsAll->mHits[ParamsAll->mNbHits] = primIndex;
+ ParamsAll->mNbHits++;
}
primIndex++;
}while(nbToGo--);
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_CapsuleSweep.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_CapsuleSweep.cpp
index 3a1e5266..46141ba5 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_CapsuleSweep.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_CapsuleSweep.cpp
@@ -32,7 +32,7 @@
using namespace physx;
using namespace Gu;
-#if PX_INTEL_FAMILY
+#if PX_INTEL_FAMILY && !defined(PX_SIMD_DISABLED)
#include "PsVecMath.h"
using namespace physx::shdfnd::aos;
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_CapsuleSweepAA.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_CapsuleSweepAA.cpp
index ff10270b..2ce7f17a 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_CapsuleSweepAA.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_CapsuleSweepAA.cpp
@@ -32,7 +32,7 @@
using namespace physx;
using namespace Gu;
-#if PX_INTEL_FAMILY
+#if PX_INTEL_FAMILY && !defined(PX_SIMD_DISABLED)
#include "PsVecMath.h"
using namespace physx::shdfnd::aos;
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_OBBSweep.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_OBBSweep.cpp
index 6378005d..097ab63d 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_OBBSweep.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_OBBSweep.cpp
@@ -31,7 +31,7 @@
using namespace physx;
using namespace Gu;
-#if PX_INTEL_FAMILY
+#if PX_INTEL_FAMILY && !defined(PX_SIMD_DISABLED)
#include "PsVecMath.h"
using namespace physx::shdfnd::aos;
#include "GuBV4_BoxSweep_Internal.h"
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Raycast.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Raycast.cpp
index e13a71c6..82cdc40d 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Raycast.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Raycast.cpp
@@ -31,7 +31,7 @@
using namespace physx;
using namespace Gu;
-#if PX_INTEL_FAMILY
+#if PX_INTEL_FAMILY && !defined(PX_SIMD_DISABLED)
#include "PxQueryReport.h"
#include "GuInternal.h"
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_SphereOverlap.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_SphereOverlap.cpp
index 259347c3..49ade4b8 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_SphereOverlap.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_SphereOverlap.cpp
@@ -31,7 +31,7 @@
using namespace physx;
using namespace Gu;
-#if PX_INTEL_FAMILY
+#if PX_INTEL_FAMILY && !defined(PX_SIMD_DISABLED)
#include "PsVecMath.h"
using namespace physx::shdfnd::aos;
@@ -228,10 +228,10 @@ public:
if(__SphereTriangle(params, primIndex))
{
SphereParamsAll* ParamsAll = static_cast<SphereParamsAll*>(params);
- ParamsAll->mHits[ParamsAll->mNbHits] = primIndex;
- ParamsAll->mNbHits++;
if(ParamsAll->mNbHits==ParamsAll->mMaxNbHits)
return 1;
+ ParamsAll->mHits[ParamsAll->mNbHits] = primIndex;
+ ParamsAll->mNbHits++;
}
primIndex++;
}while(nbToGo--);
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_SphereSweep.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_SphereSweep.cpp
index d6b13cae..9139b7cc 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_SphereSweep.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_SphereSweep.cpp
@@ -38,7 +38,7 @@
using namespace physx;
using namespace Gu;
-#if PX_INTEL_FAMILY
+#if PX_INTEL_FAMILY && !defined(PX_SIMD_DISABLED)
#include "PsVecMath.h"
using namespace physx::shdfnd::aos;
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuMidphaseBV4.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuMidphaseBV4.cpp
index 084b29e2..06aa4c7e 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuMidphaseBV4.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuMidphaseBV4.cpp
@@ -57,7 +57,7 @@ using namespace physx;
using namespace Gu;
using namespace Cm;
-#if PX_INTEL_FAMILY
+#if PX_INTEL_FAMILY && !defined(PX_SIMD_DISABLED)
Ps::IntBool BV4_RaycastSingle (const PxVec3& origin, const PxVec3& dir, const BV4Tree& tree, const PxMat44* PX_RESTRICT worldm_Aligned, PxRaycastHit* PX_RESTRICT hit, float maxDist, float geomEpsilon, PxU32 flags, PxHitFlags hitFlags);
PxU32 BV4_RaycastAll (const PxVec3& origin, const PxVec3& dir, const BV4Tree& tree, const PxMat44* PX_RESTRICT worldm_Aligned, PxRaycastHit* PX_RESTRICT hits, PxU32 maxNbHits, float maxDist, float geomEpsilon, PxU32 flags, PxHitFlags hitFlags);
void BV4_RaycastCB (const PxVec3& origin, const PxVec3& dir, const BV4Tree& tree, const PxMat44* PX_RESTRICT worldm_Aligned, float maxDist, float geomEpsilon, PxU32 flags, MeshRayCallback callback, void* userData);
diff --git a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactCapsuleBox.cpp b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactCapsuleBox.cpp
index d2dc305a..ecb94a66 100644
--- a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactCapsuleBox.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactCapsuleBox.cpp
@@ -72,7 +72,7 @@ static bool fullContactsGenerationCapsuleBox(const CapsuleV& capsule, const BoxV
normal = transf1.rotate(normal);
- manifold.addManifoldContactsToContactBuffer(contactBuffer, normal, transf0, capsule.radius, contactDist);
+ manifold.addManifoldContactsToContactBuffer(contactBuffer, normal, normal, transf0, capsule.radius, contactDist);
return true;
@@ -210,7 +210,7 @@ bool pcmContactCapsuleBox(GU_CONTACT_METHOD_ARGS)
manifold.addManifoldPoint2(curRTrans.transformInv(closestA), closestB, localNormalPen, replaceBreakingThreshold);
normal = transf1.rotate(normal);
- manifold.addManifoldContactsToContactBuffer(contactBuffer, normal, transf0, capsuleRadius, contactDist);
+ manifold.addManifoldContactsToContactBuffer(contactBuffer, normal, normal, transf0, capsuleRadius, contactDist);
return true;
}
@@ -219,7 +219,7 @@ bool pcmContactCapsuleBox(GU_CONTACT_METHOD_ARGS)
else if(manifold.getNumContacts() > 0)
{
const Vec3V worldNormal = manifold.getWorldNormal(transf1);
- manifold.addManifoldContactsToContactBuffer(contactBuffer, worldNormal, transf0, capsuleRadius, contactDist);
+ manifold.addManifoldContactsToContactBuffer(contactBuffer, worldNormal, worldNormal, transf0, capsuleRadius, contactDist);
return true;
}
diff --git a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactCapsuleConvex.cpp b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactCapsuleConvex.cpp
index ad34a263..fff3a19d 100644
--- a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactCapsuleConvex.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactCapsuleConvex.cpp
@@ -70,14 +70,14 @@ static bool fullContactsGenerationCapsuleConvex(const CapsuleV& capsule, const C
manifold.addBatchManifoldContacts2(manifoldContacts, numContacts);
//transform normal into the world space
normal = transf1.rotate(normal);
- manifold.addManifoldContactsToContactBuffer(contactBuffer, normal, transf0, capsule.radius, contactDist);
+ manifold.addManifoldContactsToContactBuffer(contactBuffer, normal, normal, transf0, capsule.radius, contactDist);
}
else
{
if (!doOverlapTest)
{
normal = transf1.rotate(normal);
- manifold.addManifoldContactsToContactBuffer(contactBuffer, normal, transf0, capsule.radius, contactDist);
+ manifold.addManifoldContactsToContactBuffer(contactBuffer, normal, normal, transf0, capsule.radius, contactDist);
}
}
@@ -248,7 +248,7 @@ bool pcmContactCapsuleConvex(GU_CONTACT_METHOD_ARGS)
{
//This contact is either come from GJK or EPA
normal = transf1.rotate(normal);
- manifold.addManifoldContactsToContactBuffer(contactBuffer, normal, transf0, capsuleRadius, contactDist);
+ manifold.addManifoldContactsToContactBuffer(contactBuffer, normal, normal, transf0, capsuleRadius, contactDist);
#if PCM_LOW_LEVEL_DEBUG
manifold.drawManifold(*renderOutput, transf0, transf1);
#endif
@@ -259,7 +259,7 @@ bool pcmContactCapsuleConvex(GU_CONTACT_METHOD_ARGS)
else if (manifold.getNumContacts() > 0)
{
normal = manifold.getWorldNormal(transf1);
- manifold.addManifoldContactsToContactBuffer(contactBuffer, normal, transf0, capsuleRadius, contactDist);
+ manifold.addManifoldContactsToContactBuffer(contactBuffer, normal, normal, transf0, capsuleRadius, contactDist);
#if PCM_LOW_LEVEL_DEBUG
manifold.drawManifold(*renderOutput, transf0, transf1);
#endif
diff --git a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactPlaneCapsule.cpp b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactPlaneCapsule.cpp
index be1fb0e3..b300ee73 100644
--- a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactPlaneCapsule.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPCMContactPlaneCapsule.cpp
@@ -58,7 +58,9 @@ bool pcmContactPlaneCapsule(GU_CONTACT_METHOD_ARGS)
const PsTransformV aToB(transf1.transformInv(transf0));
//in world space
- const Vec3V negPlaneNormal = V3Normalize(V3Neg(QuatGetBasisVector0(transf1.q)));
+ const Vec3V planeNormal = V3Normalize(QuatGetBasisVector0(transf1.q));
+ const Vec3V contactNormal = V3Neg(planeNormal);
+
//ML:localNormal is the local space of plane normal, however, because shape1 is capulse and shape0 is plane, we need to use the reverse of contact normal(which will be the plane normal) to make the refreshContactPoints
//work out the correct pentration for points
const Vec3V localNormal = V3UnitX();
@@ -86,7 +88,6 @@ bool pcmContactPlaneCapsule(GU_CONTACT_METHOD_ARGS)
const PxU32 newContacts = manifold.mNumContacts;
const bool bLostContacts = (newContacts != initialContacts);//((initialContacts == 0) || (newContacts != initialContacts));
- //PX_UNUSED(bLostContacts);
if(bLostContacts || manifold.invalidate_PrimitivesPlane(aToB, radius, FLoad(0.02f)))
{
manifold.mNumContacts = 0;
@@ -106,20 +107,24 @@ bool pcmContactPlaneCapsule(GU_CONTACT_METHOD_ARGS)
if(FAllGrtr(inflatedRadius, signDist1))
{
const Vec3V localPointA = aToB.transformInv(e);
+
const Vec3V localPointB = V3NegScaleSub(localNormal, signDist1, e);
const Vec4V localNormalPen = V4SetW(Vec4V_From_Vec3V(localNormal), signDist1);
//add to manifold
manifold.addManifoldPoint2(localPointA, localPointB, localNormalPen, replaceBreakingThreshold);
}
- manifold.addManifoldContactsToContactBuffer(contactBuffer, negPlaneNormal, transf0, radius, contactDist);
+ manifold.addManifoldContactsToContactBuffer(contactBuffer, contactNormal, planeNormal, transf0, radius, contactDist);
+#if PCM_LOW_LEVEL_DEBUG
+ manifold.drawManifold(*renderOutput, transf0, transf1);
+#endif
return manifold.getNumContacts() > 0;
}
else
{
- manifold.addManifoldContactsToContactBuffer(contactBuffer, negPlaneNormal, transf0, radius, contactDist);
+ manifold.addManifoldContactsToContactBuffer(contactBuffer, contactNormal, planeNormal, transf0, radius, contactDist);
return manifold.getNumContacts() > 0;
}
}
diff --git a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPersistentContactManifold.cpp b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPersistentContactManifold.cpp
index 7c144892..f93c703e 100644
--- a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPersistentContactManifold.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPersistentContactManifold.cpp
@@ -818,7 +818,8 @@ void Gu::PersistentContactManifold::addManifoldContactsToContactBuffer(Gu::Conta
This function is for sphere/capsule vs other primitives. We treat sphere as a point and capsule as a segment in the contact gen and store the sphere center or a point in the segment for capsule
in the manifold.
*/
-void Gu::PersistentContactManifold::addManifoldContactsToContactBuffer(Gu::ContactBuffer& contactBuffer, const Ps::aos::Vec3VArg normal, const Ps::aos::PsTransformV& transf0, const Ps::aos::FloatVArg radius, const Ps::aos::FloatVArg contactOffset)
+void Gu::PersistentContactManifold::addManifoldContactsToContactBuffer(Gu::ContactBuffer& contactBuffer, const Ps::aos::Vec3VArg normal, const Ps::aos::Vec3VArg projectionNormal,
+ const Ps::aos::PsTransformV& transf0, const Ps::aos::FloatVArg radius, const Ps::aos::FloatVArg contactOffset)
{
using namespace Ps::aos;
@@ -837,7 +838,7 @@ void Gu::PersistentContactManifold::addManifoldContactsToContactBuffer(Gu::Conta
//may introduce noticeable instability.
if(FAllGrtrOrEq(contactOffset, dist))
{
- const Vec3V worldP =V3NegScaleSub(normal, radius, transf0.transform(p.mLocalPointA));
+ const Vec3V worldP =V3NegScaleSub(projectionNormal, radius, transf0.transform(p.mLocalPointA));
Gu::ContactPoint& contact = contactBuffer.contacts[contactCount++];
//Fast allign store
diff --git a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPersistentContactManifold.h b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPersistentContactManifold.h
index fbbf581b..e06622da 100644
--- a/PhysX_3.4/Source/GeomUtils/src/pcm/GuPersistentContactManifold.h
+++ b/PhysX_3.4/Source/GeomUtils/src/pcm/GuPersistentContactManifold.h
@@ -341,7 +341,7 @@ public:
//This function is for adding box/convexhull manifold contacts to the contact buffer
void addManifoldContactsToContactBuffer(Gu::ContactBuffer& contactBuffer, const Ps::aos::Vec3VArg normal, const Ps::aos::PsTransformV& transf1, const Ps::aos::FloatVArg contactOffset);
//This function is for adding sphere/capsule manifold contacts to the contact buffer
- void addManifoldContactsToContactBuffer(Gu::ContactBuffer& contactBuffer, const Ps::aos::Vec3VArg normal, const Ps::aos::PsTransformV& transf0, const Ps::aos::FloatVArg radius, const Ps::aos::FloatVArg contactOffset);
+ void addManifoldContactsToContactBuffer(Gu::ContactBuffer& contactBuffer, const Ps::aos::Vec3VArg normal, const Ps::aos::Vec3VArg projectionNormal, const Ps::aos::PsTransformV& transf0, const Ps::aos::FloatVArg radius, const Ps::aos::FloatVArg contactOffset);
//get the average normal in the manifold in world space
Ps::aos::Vec3V getWorldNormal(const Ps::aos::PsTransformV& trB);