Return true if two bodies overlap (collide)
| 1773 | |
| 1774 | // Return true if two bodies overlap (collide) |
| 1775 | bool CollisionDetectionSystem::testOverlap(Body* body1, Body* body2) { |
| 1776 | |
| 1777 | NarrowPhaseInput narrowPhaseInput(mMemoryManager.getPoolAllocator(), mOverlappingPairs); |
| 1778 | |
| 1779 | // Compute the broad-phase collision detection |
| 1780 | computeBroadPhase(); |
| 1781 | |
| 1782 | // Filter the overlapping pairs to get only the ones with the selected body involved |
| 1783 | Array<uint64> convexPairs(mMemoryManager.getPoolAllocator()); |
| 1784 | Array<uint64> concavePairs(mMemoryManager.getPoolAllocator()); |
| 1785 | filterOverlappingPairs(body1->getEntity(), body2->getEntity(), convexPairs, concavePairs); |
| 1786 | |
| 1787 | if (convexPairs.size() > 0 || concavePairs.size() > 0) { |
| 1788 | |
| 1789 | // Compute the middle-phase collision detection |
| 1790 | computeMiddlePhaseCollisionSnapshot(convexPairs, concavePairs, narrowPhaseInput, false); |
| 1791 | |
| 1792 | // Compute the narrow-phase collision detection |
| 1793 | return computeNarrowPhaseOverlapSnapshot(narrowPhaseInput, nullptr); |
| 1794 | } |
| 1795 | |
| 1796 | return false; |
| 1797 | } |
| 1798 | |
| 1799 | // Report all the bodies that overlap (collide) in the world |
| 1800 | void CollisionDetectionSystem::testOverlap(OverlapCallback& callback) { |