src/systems/CollisionDetectionSystem.cpp
void CollisionDetectionSystem::computeNarrowPhase() {

    RP3D_PROFILE("CollisionDetectionSystem::computeNarrowPhase()", mProfiler);

    MemoryAllocator& allocator = mMemoryManager.getSingleFrameAllocator();

    // Swap the previous and current contacts arrays
    swapPreviousAndCurrentContacts();

    mPotentialContactManifolds.reserve(mNbPreviousPotentialContactManifolds);
    mPotentialContactPoints.reserve(mNbPreviousPotentialContactPoints);

    // Test the narrow-phase collision detection on the batches to be tested
    testNarrowPhaseCollision(mNarrowPhaseInput, true, allocator);

    // Process all the potential contacts after narrow-phase collision
    processAllPotentialContacts(mNarrowPhaseInput, true, mPotentialContactPoints,
                                mPotentialContactManifolds, mCurrentContactPairs);

    // Reduce the number of contact points in the manifolds
    reducePotentialContactManifolds(mCurrentContactPairs, mPotentialContactManifolds, mPotentialContactPoints);

    // Add the contact pairs to the bodies
    addContactPairsToBodies();

    assert(mCurrentContactManifolds->size() == 0);
    assert(mCurrentContactPoints->size() == 0);
}
// Compute the narrow-phase collision detection
Compute the narrow-phase collision detection
Compute the narrow - phase collision detection
void CollisionDetectionSystem::computeNarrowPhase() {
    RP3D_PROFILE("CollisionDetectionSystem::computeNarrowPhase()", mProfiler);
    MemoryAllocator& allocator = mMemoryManager.getSingleFrameAllocator();
    swapPreviousAndCurrentContacts();
    mPotentialContactManifolds.reserve(mNbPreviousPotentialContactManifolds);
    mPotentialContactPoints.reserve(mNbPreviousPotentialContactPoints);
    testNarrowPhaseCollision(mNarrowPhaseInput, true, allocator);
    processAllPotentialContacts(mNarrowPhaseInput, true, mPotentialContactPoints,
                                mPotentialContactManifolds, mCurrentContactPairs);
    reducePotentialContactManifolds(mCurrentContactPairs, mPotentialContactManifolds, mPotentialContactPoints);
    addContactPairsToBodies();
    assert(mCurrentContactManifolds->size() == 0);
    assert(mCurrentContactPoints->size() == 0);
}
void CollisionDetectionSystem :: computeNarrowPhase ( ) { RP3D_PROFILE ( " " , mProfiler ) ; MemoryAllocator & allocator = mMemoryManager . getSingleFrameAllocator ( ) ; swapPreviousAndCurrentContacts ( ) ; mPotentialContactManifolds . reserve ( mNbPreviousPotentialContactManifolds ) ; mPotentialContactPoints . reserve ( mNbPreviousPotentialContactPoints ) ; testNarrowPhaseCollision ( mNarrowPhaseInput , true , allocator ) ; processAllPotentialContacts ( mNarrowPhaseInput , true , mPotentialContactPoints , mPotentialContactManifolds , mCurrentContactPairs ) ; reducePotentialContactManifolds ( mCurrentContactPairs , mPotentialContactManifolds , mPotentialContactPoints ) ; addContactPairsToBodies ( ) ; assert ( mCurrentContactManifolds -> size ( ) == 0 ) ; assert ( mCurrentContactPoints -> size ( ) == 0 ) ; }
Compute the narrow-phase collision detection
Compute the narrow - phase collision detection
// Swap the previous and current contacts arrays // Test the narrow-phase collision detection on the batches to be tested // Process all the potential contacts after narrow-phase collision // Reduce the number of contact points in the manifolds // Add the contact pairs to the bodies