PhysX-3.4 - problem with cooking mesh collider

In PhysX when trying to cook mesh collider for sphere object observed ConvexMeshCookingResult returning ePOLYGONS_LIMIT_REACHED, though same method works fine for all other primitive objects. I also tried setting CookingParams.ConvexMeshCookingType to ConvexMeshCookingType.InflationIncrementalHull with CookingParams.SkinWidth to 0.001 but still able to observe the same error ePOLYGONS_LIMIT_REACHED.

I would be very thankful if anybody can throw some light on it?

Wondering if this problem be solved using TriangleMesh with rigid dynamic(without kinematic)? If not is there anyway we can generate mesh collider for rigid dynamic object(without kinematic)?

Hi,
PhysX does support only up to 256 polygons. So if you try to create a convex mesh for a high density sphere mesh, then this limit will kick in and the computation fails.

Why do you not create a PxSphereGeometry and use directly a sphere geometry rather than trying to create a convex mesh out of a sphere?

Btw, yes PhysX does not support dynamic rigids with PxTriangleMesh geometry.

Hi Mr.Ales,

Thank you very much for your valuable response!
We have requirement to cook mesh collider for any shaped dynamic object, so just wondering if there is any way to cook mesh collider for dynamic object?

Yes, there is a way how to force the convex cooking to always create a convex hull, even from a high density sphere.

Setup PxCooking:

  • use the default PxConvexMeshCookingType::eQUICKHULL
  • when cooking the sphere add flag PxConvexFlag::ePLANE_SHIFTING
  • set the PxConvexMeshDesc::vertexLimit to something reasonable like 128, maybe more if you need to

Now with this setup when the vertex limit is reached (note that the vertex limit must be reached before the polygons hard limit), then the algorithm does take the hull when the computation stopped (the vertex limit was reached) and then shifts the planes of the hull to encapsulate all the input points. This works quite well if your vertex limit is high. You can try these settings and see if the produced hull does have good enough quality for you. But there is no way to create a high density hull with more than 255 polygons.

@Ales Thank you very much for your response! It doesn’t throw any exception now.