| 667 | } |
| 668 | |
| 669 | static bool computeMTD_BoxConvex(PxVec3& mtd, PxF32& depth, const Box& box, const PxConvexMeshGeometry& convexGeom, const PxTransform& convexPose) |
| 670 | { |
| 671 | const Vec3V zeroV = V3Zero(); |
| 672 | const PxTransform boxPose = box.getTransform(); |
| 673 | const Vec3V boxExtents = V3LoadU(box.extents); |
| 674 | BoxV boxV(zeroV, boxExtents); |
| 675 | |
| 676 | // Convex mesh |
| 677 | const ConvexMesh* convexMesh = static_cast<const ConvexMesh*>(convexGeom.convexMesh); |
| 678 | const ConvexHullData* hull = &convexMesh->getHull(); |
| 679 | const Vec3V vScale = V3LoadU_SafeReadW(convexGeom.scale.scale); // PT: safe because 'rotation' follows 'scale' in PxMeshScale |
| 680 | const QuatV vQuat = QuatVLoadU(&convexGeom.scale.rotation.x); |
| 681 | ConvexHullV convexHullV(hull, zeroV, vScale, vQuat, convexGeom.scale.isIdentity()); |
| 682 | //~Convex mesh |
| 683 | |
| 684 | |
| 685 | const QuatV q0 = QuatVLoadU(&boxPose.q.x); |
| 686 | const Vec3V p0 = V3LoadU(&boxPose.p.x); |
| 687 | |
| 688 | const QuatV q1 = QuatVLoadU(&convexPose.q.x); |
| 689 | const Vec3V p1 = V3LoadU(&convexPose.p.x); |
| 690 | |
| 691 | const PsTransformV transf0(p0, q0); |
| 692 | const PsTransformV transf1(p1, q1); |
| 693 | |
| 694 | Vec3V normal=zeroV; |
| 695 | FloatV penetrationDepth=FZero(); |
| 696 | |
| 697 | const bool idtScale = convexGeom.scale.isIdentity(); |
| 698 | bool hasContacts = internalComputeMTD_BoxConvex(box.extents, boxV, idtScale, convexHullV, transf0, transf1, penetrationDepth, normal); |
| 699 | if(hasContacts) |
| 700 | { |
| 701 | FStore(penetrationDepth, &depth); |
| 702 | depth = validateDepth(depth); |
| 703 | V3StoreU(normal, mtd); |
| 704 | } |
| 705 | |
| 706 | return hasContacts; |
| 707 | |
| 708 | } |
| 709 | |
| 710 | |
| 711 | static bool internalComputeMTD_ConvexConvex(const bool idtScale0, const bool idtScale1, ConvexHullV& convexHullV0, ConvexHullV& convexHullV1, const Ps::aos::PsTransformV& transf0, const Ps::aos::PsTransformV& transf1, |
no test coverage detected