diff options
Diffstat (limited to 'PhysX_3.4/Source')
29 files changed, 148 insertions, 60 deletions
diff --git a/PhysX_3.4/Source/Common/src/CmUtils.h b/PhysX_3.4/Source/Common/src/CmUtils.h index 4aa126c1..e7bccbbd 100644 --- a/PhysX_3.4/Source/Common/src/CmUtils.h +++ b/PhysX_3.4/Source/Common/src/CmUtils.h @@ -136,7 +136,7 @@ public: PX_ASSERT(&element<mData || &element>=mData+mSize); if(mSize==mCapacity) - (owner.*realloc)(mData, mCapacity, mSize, PxU16(mSize+1)); + (owner.*realloc)(mData, mCapacity, mSize, IndexType(mSize+1)); PX_ASSERT(mData && mSize<mCapacity); mData[mSize++] = element; 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); diff --git a/PhysX_3.4/Source/LowLevel/software/include/PxsCCD.h b/PhysX_3.4/Source/LowLevel/software/include/PxsCCD.h index d9952422..85ee5979 100644 --- a/PhysX_3.4/Source/LowLevel/software/include/PxsCCD.h +++ b/PhysX_3.4/Source/LowLevel/software/include/PxsCCD.h @@ -129,6 +129,7 @@ struct PxsCCDBody PxsRigidBody* mBody; //The rigid body PxsCCDOverlap* mOverlappingObjects; //A list of overlapping bodies for island update PxU32 mUpdateCount; //How many times this body has eben updated in the CCD. This is correlated with CCD shapes' update counts. + PxU32 mNbInteractionsThisPass; //How many interactions this pass diff --git a/PhysX_3.4/Source/LowLevel/software/src/PxsCCD.cpp b/PhysX_3.4/Source/LowLevel/software/src/PxsCCD.cpp index 288f17ad..70d24cc0 100644 --- a/PhysX_3.4/Source/LowLevel/software/src/PxsCCD.cpp +++ b/PhysX_3.4/Source/LowLevel/software/src/PxsCCD.cpp @@ -1478,9 +1478,10 @@ void PxsCCDContext::updateCCD(PxReal dt, PxBaseTask* continuation, bool disableR b->mCCD->mOverlappingObjects = NULL; b->mCCD->mUpdateCount = 0; b->mCCD->mHasAnyPassDone = false; - + b->mCCD->mNbInteractionsThisPass = 0; } b->mCCD->mPassDone = 0; + b->mCCD->mNbInteractionsThisPass++; } if(ba0 && ba1) { @@ -1591,7 +1592,10 @@ void PxsCCDContext::updateCCD(PxReal dt, PxBaseTask* continuation, bool disableR for (PxU32 j = 0; j < ccdBodyCount; j++) { //If the body has already been labelled or if it is kinematic, continue - if (islandLabels[j] != noLabelYet || mCCDBodies[j].mBody->isKinematic()) + //Also, if the body has no interactions this pass, continue. In single-pass CCD, only bodies with interactions would be part of the CCD. However, + //with multi-pass CCD, we keep all bodies that interacted in previous passes. If the body now has no interactions, we skip it to ensure that island grouping doesn't fail in + //later stages by assigning an island ID to a body with no interactions + if (islandLabels[j] != noLabelYet || mCCDBodies[j].mBody->isKinematic() || mCCDBodies[j].mNbInteractionsThisPass == 0) continue; top = &mCCDBodies[j]; @@ -1899,6 +1903,7 @@ void PxsCCDContext::postCCDDepenetrate(PxBaseTask* /*continuation*/) for (PxU32 j = 0; j < mCCDBodies.size(); j ++) { mCCDBodies[j].mOverlappingObjects = NULL; + mCCDBodies[j].mNbInteractionsThisPass = 0; } mCCDOverlaps.clear_NoDelete(); diff --git a/PhysX_3.4/Source/LowLevelAABB/include/BpSimpleAABBManager.h b/PhysX_3.4/Source/LowLevelAABB/include/BpSimpleAABBManager.h index 6f879cfd..db8b5c79 100644 --- a/PhysX_3.4/Source/LowLevelAABB/include/BpSimpleAABBManager.h +++ b/PhysX_3.4/Source/LowLevelAABB/include/BpSimpleAABBManager.h @@ -324,6 +324,7 @@ namespace Bp BoundsIndex destroyAggregate(AggregateHandle aggregateHandle); bool addBounds(BoundsIndex index, PxReal contactDistance, PxU32 group, void* userdata, AggregateHandle aggregateHandle, PxU8 volumeType); + void reserveSpaceForBounds(BoundsIndex index); void removeBounds(BoundsIndex index); void setContactOffset(BoundsIndex handle, PxReal offset) diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp b/PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp index 1e3cb164..ad3adf60 100644 --- a/PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp +++ b/PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp @@ -1617,6 +1617,14 @@ static void removeAggregateFromDirtyArray(Aggregate* aggregate, Ps::Array<Aggreg } } +void SimpleAABBManager::reserveSpaceForBounds(BoundsIndex index) +{ + if (index >= mVolumeData.size()) + reserveShapeSpace(index); + + resetEntry(index); //KS - make sure this entry is flagged as invalid +} + // PT: TODO: what is the "userData" here? bool SimpleAABBManager::addBounds(BoundsIndex index, PxReal contactDistance, PxU32 group, void* userData, AggregateHandle aggregateHandle, PxU8 volumeType) { diff --git a/PhysX_3.4/Source/PhysXCooking/src/convex/InflationConvexHullLib.cpp b/PhysX_3.4/Source/PhysXCooking/src/convex/InflationConvexHullLib.cpp index 392a890a..e4fd034f 100644 --- a/PhysX_3.4/Source/PhysXCooking/src/convex/InflationConvexHullLib.cpp +++ b/PhysX_3.4/Source/PhysXCooking/src/convex/InflationConvexHullLib.cpp @@ -609,10 +609,10 @@ PxConvexMeshCookingResult::Enum InflationConvexHullLib::createConvexHull() // compute the actual hull ConvexHullLibResult::ErrorCode hullResult = computeHull(ovcount,vsource); - if(hullResult == ConvexHullLibResult::eSUCCESS) + if(hullResult == ConvexHullLibResult::eSUCCESS || hullResult == ConvexHullLibResult::ePOLYGON_LIMIT_REACHED) { mFinished = true; - res = PxConvexMeshCookingResult::eSUCCESS; + res = (hullResult == ConvexHullLibResult::eSUCCESS) ? PxConvexMeshCookingResult::eSUCCESS : PxConvexMeshCookingResult::ePOLYGONS_LIMIT_REACHED; } else { @@ -705,11 +705,33 @@ ConvexHullLibResult::ErrorCode InflationConvexHullLib::calchull(const PxVec3* ve if ((rc == ConvexHullLibResult::eFAILURE) || (rc == ConvexHullLibResult::eZERO_AREA_TEST_FAILED)) return rc; + // count the triangles if we did not reached the polygons count hard limit 255 + PxU32 numTriangles = 0; + for (PxU32 i = 0; i < triangles.size(); i++) + { + if((triangles)[i]) + numTriangles++; + } + + // if the polygons hard limit has been reached run the overhull, that will terminate + // when either polygons or vertex limit has been reached + if(numTriangles > 255) + { + Ps::Array<PxPlane> planes; + if(!calchullplanes(verts,triangles,planes)) + return ConvexHullLibResult::eFAILURE; + + if(!overhull(verts, verts_count, planes,hullOut)) + return ConvexHullLibResult::eFAILURE; + + return ConvexHullLibResult::ePOLYGON_LIMIT_REACHED; + } + // if vertex limit reached construct the hullOut from the expanded planes if(rc == ConvexHullLibResult::eVERTEX_LIMIT_REACHED) { if(mConvexMeshDesc.flags & PxConvexFlag::ePLANE_SHIFTING) - rc = expandHull(verts,verts_count,triangles,hullOut); + rc = expandHull(verts,verts_count,triangles,hullOut); else rc = expandHullOBB(verts,verts_count,triangles,hullOut); if ((rc == ConvexHullLibResult::eFAILURE) || (rc == ConvexHullLibResult::eZERO_AREA_TEST_FAILED)) @@ -1433,6 +1455,14 @@ bool InflationConvexHullLib::overhull(const PxVec3* verts, PxU32 vertsCount,cons maxplanes = 0; break; } + // check for polygons hard limit + if(c->getFacets().size() > 255) + { + PX_DELETE(c); + c=tmp; + maxplanes = 0; + break; + } // check for vertex limit per face if necessary, GRB supports max 32 verts per face if ((mConvexMeshDesc.flags & PxConvexFlag::eGPU_COMPATIBLE) && c->maxNumVertsPerFace() > gpuMaxVertsPerFace) { diff --git a/PhysX_3.4/Source/PhysXCooking/src/convex/InflationConvexHullLib.h b/PhysX_3.4/Source/PhysXCooking/src/convex/InflationConvexHullLib.h index 154c495e..3713bdb7 100644 --- a/PhysX_3.4/Source/PhysXCooking/src/convex/InflationConvexHullLib.h +++ b/PhysX_3.4/Source/PhysXCooking/src/convex/InflationConvexHullLib.h @@ -54,7 +54,8 @@ namespace physx eSUCCESS = 0, // success! eFAILURE, // failed. eVERTEX_LIMIT_REACHED, // vertex limit reached fallback. - eZERO_AREA_TEST_FAILED// area test failed - failed to create simplex + eZERO_AREA_TEST_FAILED, // area test failed - failed to create simplex + ePOLYGON_LIMIT_REACHED // polygons hard limit 255 reached }; PxU32 mVcount; diff --git a/PhysX_3.4/Source/PhysXMetaData/core/include/PxMetaDataCompare.h b/PhysX_3.4/Source/PhysXMetaData/core/include/PxMetaDataCompare.h index 4b415c01..2ac4839d 100644 --- a/PhysX_3.4/Source/PhysXMetaData/core/include/PxMetaDataCompare.h +++ b/PhysX_3.4/Source/PhysXMetaData/core/include/PxMetaDataCompare.h @@ -96,9 +96,11 @@ struct EqualityOp void operator()( const PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxArticulationLink_Children, PxArticulationLink, PxArticulationLink* >& inProp, PxU32 ) {} void operator()( const PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxRigidActor_Constraints, PxRigidActor, PxConstraint* >& inProp, PxU32 ){} void operator()( const PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxAggregate_Actors, PxAggregate, PxActor* >& inProp, PxU32 ) {} +#if PX_USE_CLOTH_API void operator()( const PxWriteOnlyPropertyInfo<PxPropertyInfoName::PxCloth_TargetPose, PxCloth, const PxTransform & >& inProp, PxU32 ) {} void operator()( const PxWriteOnlyPropertyInfo<PxPropertyInfoName::PxCloth_InertiaScale, PxCloth, PxReal >& inProp, PxU32 ) {} void operator()( const PxWriteOnlyPropertyInfo<PxPropertyInfoName::PxCloth_DragCoefficient, PxCloth, PxReal >& inProp, PxU32 ) {} +#endif template<PxU32 TKey, typename TObjType, typename TGetPropType> void operator()( const PxBufferCollectionPropertyInfo<TKey, TObjType, TGetPropType> & inProp, PxU32 ) diff --git a/PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp b/PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp index 508d1b14..43532883 100644 --- a/PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp +++ b/PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp @@ -518,7 +518,7 @@ void AABBPruner::visualize(Cm::RenderOutput& out, PxU32 color) const // getAABBTree() asserts when pruner is dirty. NpScene::visualization() does not enforce flushUpdate. see DE7834 const AABBTree* tree = mAABBTree; - if(tree) + if(tree && tree->getNodes()) { struct Local { diff --git a/PhysX_3.4/Source/SceneQuery/src/SqExtendedBucketPruner.cpp b/PhysX_3.4/Source/SceneQuery/src/SqExtendedBucketPruner.cpp index 178cff85..a218f655 100644 --- a/PhysX_3.4/Source/SceneQuery/src/SqExtendedBucketPruner.cpp +++ b/PhysX_3.4/Source/SceneQuery/src/SqExtendedBucketPruner.cpp @@ -764,9 +764,9 @@ PxAgain ExtendedBucketPruner::sweep(const Gu::ShapeData& queryVolume, const PxVe #include "CmRenderOutput.h" // visualization -void visualizeTree(Cm::RenderOutput& out, PxU32 color, AABBTree* tree) +static void visualizeTree(Cm::RenderOutput& out, PxU32 color, AABBTree* tree) { - if (tree) + if(tree && tree->getNodes()) { struct Local { diff --git a/PhysX_3.4/Source/SimulationController/src/ScElementSim.cpp b/PhysX_3.4/Source/SimulationController/src/ScElementSim.cpp index 9d9b2a7c..9ff82819 100644 --- a/PhysX_3.4/Source/SimulationController/src/ScElementSim.cpp +++ b/PhysX_3.4/Source/SimulationController/src/ScElementSim.cpp @@ -119,8 +119,13 @@ void Sc::ElementSim::setElementInteractionsDirty(InteractionDirtyFlag::Enum flag // we pun these constants in order to increment the stats when adding and removing from BP PX_COMPILE_TIME_ASSERT(PxU32(PxSimulationStatistics::eRIGID_BODY) == PxU32(Sc::ElementType::eSHAPE)); +#if PX_USE_CLOTH_API PX_COMPILE_TIME_ASSERT(PxU32(PxSimulationStatistics::eCLOTH) == PxU32(Sc::ElementType::eCLOTH)); +#endif + +#if PX_USE_PARTICLE_SYSTEM_API PX_COMPILE_TIME_ASSERT(PxU32(PxSimulationStatistics::ePARTICLE_SYSTEM) == PxU32(Sc::ElementType::ePARTICLE_PACKET)); +#endif void Sc::ElementSim::addToAABBMgr(PxReal contactDistance, PxU32 group, bool isTrigger) { diff --git a/PhysX_3.4/Source/SimulationController/src/ScShapeSim.cpp b/PhysX_3.4/Source/SimulationController/src/ScShapeSim.cpp index 06474839..cb3b5f66 100644 --- a/PhysX_3.4/Source/SimulationController/src/ScShapeSim.cpp +++ b/PhysX_3.4/Source/SimulationController/src/ScShapeSim.cpp @@ -100,10 +100,13 @@ void Sc::ShapeSim::initSubsystemsDependingOnElementID() PX_PROFILE_ZONE("API.simAddShapeToBroadPhase", scScene.getContextId()); if(isBroadPhase(mCore.getFlags())) { - internalAddToBroadPhase(); - - scScene.updateContactDistance(index, getContactOffset()); + internalAddToBroadPhase(); + } + else + { + scScene.getAABBManager()->reserveSpaceForBounds(index); } + scScene.updateContactDistance(index, getContactOffset()); } if(scScene.getDirtyShapeSimMap().size() <= index) |