| 843 | /////////////////////////////////////////////////////////////////////////////// |
| 844 | |
| 845 | static 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 | |
| 883 | static bool computeMTD_SphereMesh(PxVec3& mtd, PxF32& depth, const Sphere& sphere, const PxTriangleMeshGeometry& meshGeom, const PxTransform& meshPose) |
| 884 | { |
no test coverage detected