aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/PhysXCooking/src/convex/InflationConvexHullLib.cpp
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/PhysXCooking/src/convex/InflationConvexHullLib.cpp
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/PhysXCooking/src/convex/InflationConvexHullLib.cpp')
-rw-r--r--PhysX_3.4/Source/PhysXCooking/src/convex/InflationConvexHullLib.cpp36
1 files changed, 33 insertions, 3 deletions
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)
{