Test collision and report contacts between two bodies.
| 1836 | |
| 1837 | // Test collision and report contacts between two bodies. |
| 1838 | void CollisionDetectionSystem::testCollision(Body* body1, Body* body2, CollisionCallback& callback) { |
| 1839 | |
| 1840 | NarrowPhaseInput narrowPhaseInput(mMemoryManager.getPoolAllocator(), mOverlappingPairs); |
| 1841 | |
| 1842 | // Compute the broad-phase collision detection |
| 1843 | computeBroadPhase(); |
| 1844 | |
| 1845 | // Filter the overlapping pairs to get only the ones with the selected body involved |
| 1846 | Array<uint64> convexPairs(mMemoryManager.getPoolAllocator()); |
| 1847 | Array<uint64> concavePairs(mMemoryManager.getPoolAllocator()); |
| 1848 | filterOverlappingPairs(body1->getEntity(), body2->getEntity(), convexPairs, concavePairs); |
| 1849 | |
| 1850 | if (convexPairs.size() > 0 || concavePairs.size() > 0) { |
| 1851 | |
| 1852 | // Compute the middle-phase collision detection |
| 1853 | computeMiddlePhaseCollisionSnapshot(convexPairs, concavePairs, narrowPhaseInput, true); |
| 1854 | |
| 1855 | // Compute the narrow-phase collision detection and report contacts |
| 1856 | computeNarrowPhaseCollisionSnapshot(narrowPhaseInput, callback); |
| 1857 | } |
| 1858 | } |
| 1859 | |
| 1860 | // Test collision and report all the contacts involving the body in parameter |
| 1861 | void CollisionDetectionSystem::testCollision(Body* body, CollisionCallback& callback) { |