Compute the narrow-phase collision detection
| 689 | |
| 690 | // Compute the narrow-phase collision detection |
| 691 | void CollisionDetectionSystem::computeNarrowPhase() { |
| 692 | |
| 693 | RP3D_PROFILE("CollisionDetectionSystem::computeNarrowPhase()", mProfiler); |
| 694 | |
| 695 | MemoryAllocator& allocator = mMemoryManager.getSingleFrameAllocator(); |
| 696 | |
| 697 | // Swap the previous and current contacts arrays |
| 698 | swapPreviousAndCurrentContacts(); |
| 699 | |
| 700 | mPotentialContactManifolds.reserve(mNbPreviousPotentialContactManifolds); |
| 701 | mPotentialContactPoints.reserve(mNbPreviousPotentialContactPoints); |
| 702 | |
| 703 | // Test the narrow-phase collision detection on the batches to be tested |
| 704 | testNarrowPhaseCollision(mNarrowPhaseInput, true, allocator); |
| 705 | |
| 706 | // Process all the potential contacts after narrow-phase collision |
| 707 | processAllPotentialContacts(mNarrowPhaseInput, true, mPotentialContactPoints, |
| 708 | mPotentialContactManifolds, mCurrentContactPairs); |
| 709 | |
| 710 | // Reduce the number of contact points in the manifolds |
| 711 | reducePotentialContactManifolds(mCurrentContactPairs, mPotentialContactManifolds, mPotentialContactPoints); |
| 712 | |
| 713 | // Add the contact pairs to the bodies |
| 714 | addContactPairsToBodies(); |
| 715 | |
| 716 | assert(mCurrentContactManifolds->size() == 0); |
| 717 | assert(mCurrentContactPoints->size() == 0); |
| 718 | } |
| 719 | |
| 720 | // Add the contact pairs to the corresponding bodies |
| 721 | void CollisionDetectionSystem::addContactPairsToBodies() { |