MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / processContacts

Function processContacts

physx/source/geomutils/src/GuMTD.cpp:845–881  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

843///////////////////////////////////////////////////////////////////////////////
844
845static bool processContacts(PxVec3& mtd, PxF32& depth, PxU32 nbContacts, const ContactPoint* contacts)
846{
847 if(nbContacts)
848 {
849 PxVec3 mn(0.0f), mx(0.0f);
850 for(PxU32 i=0; i<nbContacts; i++)
851 {
852 const ContactPoint& ct = contacts[i];
853 PxVec3 depenetration = ct.separation * ct.normal;
854
855 mn = mn.minimum(depenetration);
856 mx = mx.maximum(depenetration);
857 }
858
859 // even if we are already moving in separation direction, we should still depenetrate
860 // so no dot velocity test
861 // here we attempt to equalize the separations pushing in opposing directions along each axis
862 PxVec3 mn1, mx1;
863 mn1.x = (mn.x == 0.0f) ? mx.x : mn.x;
864 mn1.y = (mn.y == 0.0f) ? mx.y : mn.y;
865 mn1.z = (mn.z == 0.0f) ? mx.z : mn.z;
866 mx1.x = (mx.x == 0.0f) ? mn.x : mx.x;
867 mx1.y = (mx.y == 0.0f) ? mn.y : mx.y;
868 mx1.z = (mx.z == 0.0f) ? mn.z : mx.z;
869 PxVec3 sepDir((mn1 + mx1)*0.5f);
870
871 if(sepDir.magnitudeSquared() < 1e-10f)
872 {
873
874 return false;
875
876 }
877 mtd = -sepDir.getNormalized();
878 depth = sepDir.magnitude();
879 }
880 return true;
881}
882
883static bool computeMTD_SphereMesh(PxVec3& mtd, PxF32& depth, const Sphere& sphere, const PxTriangleMeshGeometry& meshGeom, const PxTransform& meshPose)
884{

Callers 11

computeMTD_SphereMeshFunction · 0.85
computeMTD_CapsuleMeshFunction · 0.85
computeMTD_BoxMeshFunction · 0.85
computeMTD_ConvexMeshFunction · 0.85
addContactsToPatchMethod · 0.85
addToPatchMethod · 0.85
processTriangleMethod · 0.85

Calls 5

minimumMethod · 0.45
maximumMethod · 0.45
magnitudeSquaredMethod · 0.45
getNormalizedMethod · 0.45
magnitudeMethod · 0.45

Tested by

no test coverage detected