aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/GeomUtils/src/gjk
diff options
context:
space:
mode:
authorSheikh Dawood Abdul Ajees <[email protected]>2017-05-12 17:45:18 -0500
committerSheikh Dawood Abdul Ajees <[email protected]>2017-05-12 17:45:18 -0500
commit7f12de60542edc8f1c6683e6b4cdce8570e51456 (patch)
tree0b5d533bae189ea286257b5ab78b635fafb19aa0 /PhysX_3.4/Source/GeomUtils/src/gjk
parentPhysX 3.4, APEX 1.4 patch release @22017166 (diff)
downloadphysx-3.4-7f12de60542edc8f1c6683e6b4cdce8570e51456.tar.xz
physx-3.4-7f12de60542edc8f1c6683e6b4cdce8570e51456.zip
PhysX 3.4, APEX 1.4 patch release @22121272
Diffstat (limited to 'PhysX_3.4/Source/GeomUtils/src/gjk')
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/gjk/GuEPA.cpp60
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/gjk/GuEPAFacet.h2
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/gjk/GuGJKType.h7
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/gjk/GuVecBox.h21
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvex.h25
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvexHull.h11
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvexHullNoScale.h4
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkBox.h6
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkConvexHull.h32
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkConvexHullNoScale.h28
10 files changed, 130 insertions, 66 deletions
diff --git a/PhysX_3.4/Source/GeomUtils/src/gjk/GuEPA.cpp b/PhysX_3.4/Source/GeomUtils/src/gjk/GuEPA.cpp
index 6eede077..54cded49 100644
--- a/PhysX_3.4/Source/GeomUtils/src/gjk/GuEPA.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/gjk/GuEPA.cpp
@@ -36,6 +36,7 @@
#define EPA_DEBUG 0
+
namespace physx
{
namespace Gu
@@ -422,13 +423,17 @@ namespace Gu
const FloatV dist = facet->getPlaneDist();
//planeNormal is pointing from B to A, however, the normal we are expecting is from A to B which match the GJK margin intersect case, therefore,
//we need to flip the normal
- const Vec3V n =V3Neg(facet->getPlaneNormal());
+ Vec3V planeNormal = facet->getPlaneNormal();
+
+ const Vec3V normalDir = V3Sub(a.getCenter(), b.getCenter());
+ if (FAllGrtr(zero, V3Dot(normalDir, planeNormal)))
+ planeNormal = V3Neg(planeNormal);
if(takeCoreShape)
{
pa = _pa;
pb = _pb;
- normal = n;
+ normal = planeNormal;
penDepth = FNeg(dist);
}
else
@@ -440,12 +445,27 @@ namespace Gu
const FloatV marginA = FSel(aQuadratic, a.getMargin(), zero);
const FloatV marginB = FSel(bQuadratic, b.getMargin(), zero);
const FloatV sumMargin = FAdd(marginA, marginB);
- pa = V3NegScaleSub(n, marginA, _pa);
- pb = V3ScaleAdd(n, marginB, _pb);
- normal = n;
+ pa = V3NegScaleSub(planeNormal, marginA, _pa);
+ pb = V3ScaleAdd(planeNormal, marginB, _pb);
+ normal = planeNormal;
penDepth = FNeg(FAdd(dist, sumMargin));
-
+
#if EPA_DEBUG
+
+ PxVec3 tempA, tempB;
+
+ V3StoreU(pa, tempA);
+ V3StoreU(pb, tempB);
+
+ if (!tempA.isFinite())
+ {
+ Ps::debugBreak();
+ }
+
+ if (!tempB.isFinite())
+ {
+ Ps::debugBreak();
+ }
const Vec3V v = V3Sub(_pb, _pa);
const FloatV length = V3Length(v);
const Vec3V cn = V3ScaleInv(v, length);
@@ -554,15 +574,13 @@ namespace Gu
}
}
- const FloatV eps = FEps();
+
const FloatV tenPerc = FLoad(0.1f);
const FloatV minMargin = FMin(a.getMinMargin(), b.getMinMargin());
const FloatV eps2 = FMul(minMargin, tenPerc);
Facet* PX_RESTRICT facet = NULL;
- Facet* PX_RESTRICT bestFacet = NULL;
-
- bool hasMoreFacets = false;
+
Vec3V tempa, tempb, q;
do
@@ -574,7 +592,6 @@ namespace Gu
if (!facet->isObsolete())
{
- bestFacet = facet;
Ps::prefetchLine(edgeBuffer.m_pEdges);
Ps::prefetchLine(edgeBuffer.m_pEdges,128);
Ps::prefetchLine(edgeBuffer.m_pEdges,256);
@@ -594,6 +611,7 @@ namespace Gu
//the plane normal, which means the distance should be positive. However, if the origin isn't contained in the polytope, dist
//might be negative
const FloatV dist = V3Dot(q, planeNormal);
+
//update the upper bound to the minimum between exisiting upper bound and the distance if distance is positive
upper_bound = FSel(FIsGrtrOrEq(dist, zero), FMin(upper_bound, dist), upper_bound);
//lower bound is the plane distance, which will be the smallest among all the facets in the prority queue
@@ -608,13 +626,14 @@ namespace Gu
}
//if planeDist is the same as dist, which means the support point we get out from the Mincowsky sum is one of the point
- //in the triangle facet, we should exist because we can't progress further.
+ //in the triangle facet, we should exist because we can't progress further. We can use the fact as contact information
const FloatV dif = FSub(dist, planeDist);
- const BoolV degeneratedCondition = FIsGrtr(eps, dif);
- if(BAllEqTTTT(degeneratedCondition))
+ const BoolV degeneratedCondition = FIsGrtr(eps2, dif);
+ if (BAllEqTTTT(degeneratedCondition))
{
calculateContactInformation(aBuf, bBuf, facet, a, b, pa, pb, normal, penDepth, takeCoreShape);
- return EPA_DEGENERATE;
+
+ return EPA_CONTACT;
}
aBuf[numVertsLocal]=tempa;
@@ -677,17 +696,8 @@ namespace Gu
}
facetManager.freeID(facet->m_FacetId);
- hasMoreFacets = (heap.size() > 0);
- //after polytope expansion, we don't have a better facet to work with so that we should process the best facet
- //this sometime won't produce the MTD but the result seems close enough so we accept it as contact.
- //test case in BenchMark_GJKEPABoxConvex
- if(hasMoreFacets && FAllGrtr( heap.top()->getPlaneDist(), upper_bound))
- {
- calculateContactInformation(aBuf, bBuf, bestFacet, a, b, pa, pb, normal, penDepth, takeCoreShape);
- return EPA_CONTACT;
- }
}
- while(hasMoreFacets && numVertsLocal != MaxSupportPoints);
+ while((heap.size() > 0) && FAllGrtr(upper_bound, heap.top()->getPlaneDist()) && numVertsLocal != MaxSupportPoints);
calculateContactInformation(aBuf, bBuf, facet, a, b, pa, pb, normal, penDepth, takeCoreShape);
diff --git a/PhysX_3.4/Source/GeomUtils/src/gjk/GuEPAFacet.h b/PhysX_3.4/Source/GeomUtils/src/gjk/GuEPAFacet.h
index 946b2b8e..dee06e90 100644
--- a/PhysX_3.4/Source/GeomUtils/src/gjk/GuEPAFacet.h
+++ b/PhysX_3.4/Source/GeomUtils/src/gjk/GuEPAFacet.h
@@ -261,7 +261,7 @@ namespace Gu
const FloatV p0dv2 = V3Dot(p0, v2);
const FloatV det = FNegScaleSub(v1dv2, v1dv2, FMul(v1dv1, v2dv2));//FSub( FMul(v1dv1, v2dv2), FMul(v1dv2, v1dv2) ); // non-negative
- const FloatV recip = FRecip(det);
+ const FloatV recip = FSel(FIsGrtr(det, FEps()), FRecip(det), FZero());
const FloatV lambda1 = FMul(FNegScaleSub(p0dv1, v2dv2, FMul(p0dv2, v1dv2)), recip);
const FloatV lambda2 = FMul(FNegScaleSub(p0dv2, v1dv1, FMul(p0dv1, v1dv2)), recip);
diff --git a/PhysX_3.4/Source/GeomUtils/src/gjk/GuGJKType.h b/PhysX_3.4/Source/GeomUtils/src/gjk/GuGJKType.h
index d81a8ca3..e93dd66d 100644
--- a/PhysX_3.4/Source/GeomUtils/src/gjk/GuGJKType.h
+++ b/PhysX_3.4/Source/GeomUtils/src/gjk/GuGJKType.h
@@ -57,7 +57,7 @@ namespace Gu
PX_FORCE_INLINE Ps::aos::BoolV isMarginEqRadius() const { return mConvex.isMarginEqRadius(); }
PX_FORCE_INLINE bool getMarginIsRadius() const { return mConvex.getMarginIsRadius(); }
PX_FORCE_INLINE Ps::aos::FloatV getMargin() const { return mConvex.getMargin(); }
- PX_FORCE_INLINE Ps::aos::Vec3V getCenter() const { return mConvex.getCenter(); }
+
template <typename Convex>
PX_FORCE_INLINE const Convex& getConvex() const { return static_cast<const Convex&>(mConvex); }
@@ -66,6 +66,7 @@ namespace Gu
virtual Ps::aos::Vec3V support(const Ps::aos::Vec3VArg v) const = 0;
virtual Ps::aos::Vec3V support(const Ps::aos::Vec3VArg dir, PxI32& index, Ps::aos::FloatV* marginDif) const = 0;
virtual Ps::aos::FloatV getSweepMargin() const = 0;
+ virtual Ps::aos::Vec3V getCenter() const = 0;
virtual ~GjkConvexBase(){}
@@ -117,6 +118,8 @@ namespace Gu
return getConvex<Convex>().supportLocal(dir, index, marginDif);
}
+ virtual Ps::aos::Vec3V getCenter() const { return getConvex<Convex>().getCenter(); }
+
//ML: we can't force inline function, otherwise win modern will throw compiler error
PX_INLINE LocalConvex<typename Shrink<Convex>::Type > getShrunkConvex() const
{
@@ -149,6 +152,8 @@ namespace Gu
return getConvex<Convex>().supportRelative(dir, mAToB, mAToBTransposed, index, marginDif);
}
+ virtual Ps::aos::Vec3V getCenter() const { return mAToB.transform(getConvex<Convex>().getCenter()); }
+
PX_FORCE_INLINE Ps::aos::PsMatTransformV& getRelativeTransform(){ return mAToB; }
//ML: we can't force inline function, otherwise win modern will throw compiler error
diff --git a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecBox.h b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecBox.h
index 5edb3705..6787a93e 100644
--- a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecBox.h
+++ b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecBox.h
@@ -58,20 +58,16 @@ namespace Gu
class CapsuleV;
- PX_FORCE_INLINE void CalculateBoxMargin(const Ps::aos::Vec3VArg extent, PxReal& margin, PxReal& minMargin, PxReal& sweepMargin,
- const PxReal marginR = BOX_MARGIN_RATIO, const PxReal minMarginR = BOX_MIN_MARGIN_RATIO)
+ PX_FORCE_INLINE void CalculateBoxMargin(const Ps::aos::Vec3VArg extent, PxReal& minExtent, PxReal& minMargin, PxReal& sweepMargin,
+ const PxReal minMarginR = BOX_MIN_MARGIN_RATIO)
{
using namespace Ps::aos;
const FloatV min = V3ExtractMin(extent);
+ FStore(min, &minExtent);
- const FloatV margin_ = FMul(min, FLoad(marginR));
- const FloatV minMargin_ = FMul(min, FLoad(minMarginR));
- const FloatV sweepMargin_ = FMul(min, FLoad(BOX_SWEEP_MARGIN_RATIO));
-
- FStore(margin_, &margin);
- FStore(minMargin_, &minMargin);
- FStore(sweepMargin_, &sweepMargin);
+ minMargin = minExtent * minMarginR;
+ sweepMargin = minExtent * BOX_SWEEP_MARGIN_RATIO;
}
PX_FORCE_INLINE Ps::aos::FloatV CalculateBoxTolerance(const Ps::aos::Vec3VArg extent)
@@ -106,8 +102,9 @@ namespace Gu
PX_FORCE_INLINE BoxV(const Ps::aos::Vec3VArg origin, const Ps::aos::Vec3VArg extent) :
ConvexV(ConvexType::eBOX, origin), extents(extent)
{
- CalculateBoxMargin(extent, margin, minMargin, sweepMargin);
+ CalculateBoxMargin(extent, minExtent, minMargin, sweepMargin);
marginDif = Ps::aos::FZero();
+ margin = 0.f;
}
PX_FORCE_INLINE BoxV(const PxGeometry& geom) : ConvexV(ConvexType::eBOX, Ps::aos::V3Zero())
@@ -116,8 +113,9 @@ namespace Gu
const PxBoxGeometry& boxGeom = static_cast<const PxBoxGeometry&>(geom);
const Vec3V extent = Ps::aos::V3LoadU(boxGeom.halfExtents);
extents = extent;
- CalculateBoxMargin(extent, margin, minMargin, sweepMargin, BOX_MARGIN_CCD_RATIO, BOX_MIN_MARGIN_CCD_RATIO);
+ CalculateBoxMargin(extent, minExtent, minMargin, sweepMargin, BOX_MIN_MARGIN_CCD_RATIO);
marginDif = Ps::aos::FZero();
+ margin = 0.f;
}
/**
@@ -208,6 +206,7 @@ namespace Gu
Ps::aos::Vec3V extents;
Ps::aos::FloatV marginDif;
+ PxReal minExtent;
};
} //PX_COMPILE_TIME_ASSERT(sizeof(Gu::BoxV) == 96);
diff --git a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvex.h b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvex.h
index a04e2777..84f2b7ec 100644
--- a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvex.h
+++ b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvex.h
@@ -64,6 +64,7 @@ namespace Gu
minMargin = 0.f;
sweepMargin = 0.f;
center = Ps::aos::V3Zero();
+ maxMargin = PX_MAX_F32;
}
PX_FORCE_INLINE ConvexV(const ConvexType::Type type_, const Ps::aos::Vec3VArg center_) : type(type_), bMarginIsRadius(false)
@@ -73,9 +74,9 @@ namespace Gu
margin = 0.f;
minMargin = 0.f;
sweepMargin = 0.f;
+ maxMargin = PX_MAX_F32;
}
-
//everytime when someone transform the object, they need to up
PX_FORCE_INLINE void setCenter(const Ps::aos::Vec3VArg _center)
{
@@ -90,6 +91,15 @@ namespace Gu
PX_FORCE_INLINE void setMargin(const PxReal margin_)
{
margin = margin_;
+ //compare with margin and choose the smallest one
+ margin = PxMin<PxReal>(maxMargin, margin);
+ }
+
+ PX_FORCE_INLINE void setMaxMargin(const PxReal maxMargin_)
+ {
+ maxMargin = maxMargin_;
+ //compare with margin and choose the smallest one
+ margin = PxMin<PxReal>(maxMargin, margin);
}
PX_FORCE_INLINE void setMinMargin(const Ps::aos::FloatVArg minMargin_)
@@ -137,12 +147,19 @@ namespace Gu
return bMarginIsRadius;
}
+ PX_FORCE_INLINE PxReal getMarginF() const
+ {
+ return margin;
+ }
+
+
protected:
~ConvexV(){}
Ps::aos::Vec3V center;
- PxReal margin; //margin is the amount by which we shrunk the shape for a convex or box. If the shape are sphere/capsule, margin is the radius
- PxReal minMargin; //minMargin is some percentage of marginBase, which is used to determine the termination condition for gjk
- PxReal sweepMargin;// sweepMargin minMargin is some percentage of marginBase, which is used to determine the termination condition for gjkRaycast
+ PxReal margin; //margin is the amount by which we shrunk the shape for a convex or box. If the shape are sphere/capsule, margin is the radius
+ PxReal minMargin; //minMargin is some percentage of marginBase, which is used to determine the termination condition for gjk
+ PxReal sweepMargin; //sweepMargin minMargin is some percentage of marginBase, which is used to determine the termination condition for gjkRaycast
+ PxReal maxMargin; //the shrunk amount defined by the application
ConvexType::Type type;
bool bMarginIsRadius;
};
diff --git a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvexHull.h b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvexHull.h
index 6014d120..1c2fd660 100644
--- a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvexHull.h
+++ b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvexHull.h
@@ -91,7 +91,7 @@ namespace Gu
return M33MulM33(trans, rot);
}
- PX_SUPPORT_FORCE_INLINE void ConstructSkewMatrix(const Ps::aos::Vec3VArg scale, const Ps::aos::QuatVArg rotation, Ps::aos::Mat33V& vertex2Shape, Ps::aos::Mat33V& shape2Vertex, const bool idtScale)
+ PX_SUPPORT_FORCE_INLINE void ConstructSkewMatrix(const Ps::aos::Vec3VArg scale, const Ps::aos::QuatVArg rotation, Ps::aos::Mat33V& vertex2Shape, Ps::aos::Mat33V& shape2Vertex, Ps::aos::Vec3V& center, const bool idtScale)
{
using namespace Ps::aos;
@@ -141,6 +141,9 @@ namespace Gu
//shape2Vertex = M33Inverse(vertex2Shape);
}
+
+ //transform center to shape space
+ center = M33MulV3(vertex2Shape, center);
}
}
@@ -193,7 +196,7 @@ namespace Gu
verts = tempVerts;
numVerts = _hullData->mNbHullVertices;
CalculateConvexMargin( _hullData, margin, minMargin, sweepMargin, scale);
- ConstructSkewMatrix(scale, scaleRot, vertex2Shape, shape2Vertex, idtScale);
+ ConstructSkewMatrix(scale, scaleRot, vertex2Shape, shape2Vertex, center, idtScale);
/*skewScale = Mat33V temp(V3Scale(trans.col0, V3GetX(scale)), V3Scale(trans.col1, V3GetY(scale)), V3Scale(trans.col2, V3GetZ(scale)));
skewRot = QuatGetMat33V(scaleRot);*/
@@ -215,7 +218,7 @@ namespace Gu
verts = tempVerts;
numVerts = hData->mNbHullVertices;
CalculateConvexMargin( hData, margin, minMargin, sweepMargin, vScale);
- ConstructSkewMatrix(vScale, vRot, vertex2Shape, shape2Vertex, idtScale);
+ ConstructSkewMatrix(vScale, vRot, vertex2Shape, shape2Vertex, center, idtScale);
data = hData->mBigConvexRawData;
}
@@ -226,7 +229,7 @@ namespace Gu
const PxVec3* tempVerts = _hullData->getHullVertices();
CalculateConvexMargin(_hullData, margin, minMargin, sweepMargin, scale);
- ConstructSkewMatrix(scale, scaleRot, vertex2Shape, shape2Vertex, idtScale);
+ ConstructSkewMatrix(scale, scaleRot, vertex2Shape, shape2Vertex, center, idtScale);
verts = tempVerts;
numVerts = _hullData->mNbHullVertices;
diff --git a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvexHullNoScale.h b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvexHullNoScale.h
index cea44d8f..d4a09435 100644
--- a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvexHullNoScale.h
+++ b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecConvexHullNoScale.h
@@ -131,7 +131,7 @@ namespace Gu
}
- // PT: TODO: is there a difference between 'originalVerts' and the 'verts' class member? Also why is this a member function at all?
+ //This funcation is just to load the PxVec3 to Vec3V. However, for GuVecConvexHul.h, this is used to transform all the verts from vertex space to shape space
PX_SUPPORT_INLINE void populateVerts(const PxU8* inds, PxU32 numInds, const PxVec3* originalVerts, Ps::aos::Vec3V* verts_)const
{
using namespace Ps::aos;
@@ -163,7 +163,6 @@ namespace Gu
using namespace Ps::aos;
//transform dir into the shape space
-// const Vec3V _dir = aTob.rotateInv(dir);//relTra.rotateInv(dir);
const Vec3V _dir = aTobT.rotate(dir);//relTra.rotateInv(dir);
const Vec3V maxPoint = supportLocal(_dir);
//translate maxPoint from shape space of a back to the b space
@@ -189,7 +188,6 @@ namespace Gu
using namespace Ps::aos;
//transform dir from b space to the shape space of a space
-// const Vec3V _dir = aTob.rotateInv(dir);//relTra.rotateInv(dir);//M33MulV3(skewInvRot, dir);
const Vec3V _dir = aTobT.rotate(dir);//relTra.rotateInv(dir);//M33MulV3(skewInvRot, dir);
const Vec3V p = supportLocal(_dir, index, marginDif);
//transfrom from a to b space
diff --git a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkBox.h b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkBox.h
index 076606d4..f8a214d1 100644
--- a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkBox.h
+++ b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkBox.h
@@ -79,6 +79,7 @@ namespace Gu
PX_INLINE ShrunkBoxV(const PxGeometry& geom) : BoxV(geom)
{
+ margin = minExtent * BOX_MARGIN_CCD_RATIO;
initialiseMarginDif();
}
@@ -92,6 +93,8 @@ namespace Gu
PX_FORCE_INLINE ShrunkBoxV(const Ps::aos::Vec3VArg origin, const Ps::aos::Vec3VArg extent) :
BoxV(origin, extent)
{
+ //calculate margin
+ margin = minExtent * BOX_MARGIN_RATIO;
initialiseMarginDif();
}
@@ -178,9 +181,6 @@ namespace Gu
const PxReal tempMarginDif = sqrtf(sqMargin * 3.f);
const PxReal marginDif_ = tempMarginDif - margin;
marginDif = FLoad(marginDif_);
- /* const FloatV sqMargin = FMul(margin, margin);
- const FloatV tempMarginDif = FSqrt(FAdd(sqMargin, FAdd(sqMargin, sqMargin)));
- marginDif = FSub(tempMarginDif, margin);*/
}
};
}
diff --git a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkConvexHull.h b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkConvexHull.h
index c0dec847..50ee49dc 100644
--- a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkConvexHull.h
+++ b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkConvexHull.h
@@ -78,18 +78,26 @@ namespace Gu
{
}
- PX_SUPPORT_INLINE ShrunkConvexHullV(const Gu::ConvexHullData* _hullData, const Ps::aos::Vec3VArg _center, const Ps::aos::Vec3VArg scale, const Ps::aos::QuatVArg scaleRot, const bool idtScale):
- ConvexHullV(_hullData, _center, scale, scaleRot, idtScale)
+ PX_SUPPORT_INLINE ShrunkConvexHullV(const Gu::ConvexHullData* hullData_, const Ps::aos::Vec3VArg center_, const Ps::aos::Vec3VArg scale, const Ps::aos::QuatVArg scaleRot,
+ const bool idtScale):
+ ConvexHullV(hullData_, center_, scale, scaleRot, idtScale)
{
}
-
-
-
PX_FORCE_INLINE Ps::aos::Vec3V supportPoint(const PxI32 index, Ps::aos::FloatV* marginDif) const
{
+ using namespace Ps::aos;
+
+ if (getMarginF() > 0.f)
+ {
+ //p is in the shape space
+ return planeShift(PxU32(index), getMargin(), marginDif);
+ }
+ else
+ {
+ return M33MulV3(vertex2Shape, V3LoadU_SafeReadW(verts[index]));
+ }
- return planeShift(PxU32(index), getMargin(), marginDif);
}
//get the support point in vertex space
@@ -155,8 +163,15 @@ namespace Gu
//get the extreme point index
const PxU32 maxIndex = supportVertexIndex(_dir);
index = PxI32(maxIndex);
- //p is in the shape space
- return planeShift(maxIndex, getMargin(), marginDif);
+ if (getMarginF() > 0.f)
+ {
+ //p is in the shape space
+ return planeShift(maxIndex, getMargin(), marginDif);
+ }
+ else
+ {
+ return M33MulV3(vertex2Shape, V3LoadU_SafeReadW(verts[index]));
+ }
}
@@ -173,7 +188,6 @@ namespace Gu
//transfrom from a to b space
return aTob.transform(p);
}
-
};
}
diff --git a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkConvexHullNoScale.h b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkConvexHullNoScale.h
index f64577c6..c6f43f51 100644
--- a/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkConvexHullNoScale.h
+++ b/PhysX_3.4/Source/GeomUtils/src/gjk/GuVecShrunkConvexHullNoScale.h
@@ -60,8 +60,9 @@ namespace Gu
{
}
- PX_SUPPORT_INLINE ShrunkConvexHullNoScaleV(const Gu::ConvexHullData* _hullData, const Ps::aos::Vec3VArg _center, const Ps::aos::Vec3VArg scale, const Ps::aos::QuatVArg scaleRot):
- ShrunkConvexHullV(_hullData, _center, scale, scaleRot, true)
+ PX_SUPPORT_INLINE ShrunkConvexHullNoScaleV(const Gu::ConvexHullData* hullData_, const Ps::aos::Vec3VArg center_, const Ps::aos::Vec3VArg scale,
+ const Ps::aos::QuatVArg scaleRot):
+ ShrunkConvexHullV(hullData_, center_, scale, scaleRot, true)
{
}
@@ -69,7 +70,17 @@ namespace Gu
PX_FORCE_INLINE Ps::aos::Vec3V supportPoint(const PxI32 index, Ps::aos::FloatV* marginDif) const
{
- return planeShift(PxU32(index), getMargin(), marginDif);
+ using namespace Ps::aos;
+
+ if (getMarginF() > 0)
+ {
+ //p is in the shape space
+ return planeShift(PxU32(index), getMargin(), marginDif);
+ }
+ else
+ {
+ return V3LoadU_SafeReadW(verts[index]);
+ }
}
//get the support point in vertex space
@@ -129,8 +140,15 @@ namespace Gu
//get the extreme point index
const PxU32 maxIndex = supportVertexIndex(dir);
index = PxI32(maxIndex);
- //p is in the shape space
- return planeShift(maxIndex, getMargin(), marginDif);
+ if (getMarginF() > 0)
+ {
+ //p is in the shape space
+ return planeShift(maxIndex, getMargin(), marginDif);
+ }
+ else
+ {
+ return V3LoadU_SafeReadW(verts[index]);
+ }
}
PX_SUPPORT_INLINE Ps::aos::Vec3V supportRelative( const Ps::aos::Vec3VArg dir, const Ps::aos::PsMatTransformV& aTob,