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

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

    // For each convex pairs
    for (uint64 i=0; i < mOverlappingPairs.mConvexPairs.size(); i++) {

        OverlappingPairs::ConvexOverlappingPair& overlappingPair = mOverlappingPairs.mConvexPairs[i];

        // Check if we need to test overlap. If so, test if the two shapes are still overlapping.
        // Otherwise, we destroy the overlapping pair
        if (overlappingPair.needToTestOverlap) {

            if(mBroadPhaseSystem.testOverlappingShapes(overlappingPair.broadPhaseId1, overlappingPair.broadPhaseId2)) {
                overlappingPair.needToTestOverlap = false;
            }
            else {

                // If the two colliders of the pair were colliding in the previous frame
                if (overlappingPair.collidingInPreviousFrame) {

                    // Create a new lost contact pair
                    addLostContactPair(overlappingPair);
                }

                mOverlappingPairs.removePair(i, true);
                i--;
            }
        }
    }

    // For each concave pairs
    for (uint64 i=0; i < mOverlappingPairs.mConcavePairs.size(); i++) {

        OverlappingPairs::ConcaveOverlappingPair& overlappingPair = mOverlappingPairs.mConcavePairs[i];

        // Check if we need to test overlap. If so, test if the two shapes are still overlapping.
        // Otherwise, we destroy the overlapping pair
        if (overlappingPair.needToTestOverlap) {

            if(mBroadPhaseSystem.testOverlappingShapes(overlappingPair.broadPhaseId1, overlappingPair.broadPhaseId2)) {
                overlappingPair.needToTestOverlap = false;
            }
            else {

                // If the two colliders of the pair were colliding in the previous frame
                if (overlappingPair.collidingInPreviousFrame) {

                    // Create a new lost contact pair
                    addLostContactPair(overlappingPair);
                }

                mOverlappingPairs.removePair(i, false);
                i--;
            }
        }
    }
}
// Remove pairs that are not overlapping anymore
Remove pairs that are not overlapping anymore
Remove pairs that are not overlapping anymore
void CollisionDetectionSystem::removeNonOverlappingPairs() {
    RP3D_PROFILE("CollisionDetectionSystem::removeNonOverlappingPairs()", mProfiler);
    for (uint64 i=0; i < mOverlappingPairs.mConvexPairs.size(); i++) {
        OverlappingPairs::ConvexOverlappingPair& overlappingPair = mOverlappingPairs.mConvexPairs[i];
        if (overlappingPair.needToTestOverlap) {
            if(mBroadPhaseSystem.testOverlappingShapes(overlappingPair.broadPhaseId1, overlappingPair.broadPhaseId2)) {
                overlappingPair.needToTestOverlap = false;
            }
            else {
                if (overlappingPair.collidingInPreviousFrame) {
                    addLostContactPair(overlappingPair);
                }
                mOverlappingPairs.removePair(i, true);
                i--;
            }
        }
    }
    for (uint64 i=0; i < mOverlappingPairs.mConcavePairs.size(); i++) {
        OverlappingPairs::ConcaveOverlappingPair& overlappingPair = mOverlappingPairs.mConcavePairs[i];
        if (overlappingPair.needToTestOverlap) {
            if(mBroadPhaseSystem.testOverlappingShapes(overlappingPair.broadPhaseId1, overlappingPair.broadPhaseId2)) {
                overlappingPair.needToTestOverlap = false;
            }
            else {
                if (overlappingPair.collidingInPreviousFrame) {
                    addLostContactPair(overlappingPair);
                }
                mOverlappingPairs.removePair(i, false);
                i--;
            }
        }
    }
}
void CollisionDetectionSystem :: removeNonOverlappingPairs ( ) { RP3D_PROFILE ( " " , mProfiler ) ; for ( uint64 i = 0 ; i < mOverlappingPairs . mConvexPairs . size ( ) ; i ++ ) { OverlappingPairs :: ConvexOverlappingPair & overlappingPair = mOverlappingPairs . mConvexPairs [ i ] ; if ( overlappingPair . needToTestOverlap ) { if ( mBroadPhaseSystem . testOverlappingShapes ( overlappingPair . broadPhaseId1 , overlappingPair . broadPhaseId2 ) ) { overlappingPair . needToTestOverlap = false ; } else { if ( overlappingPair . collidingInPreviousFrame ) { addLostContactPair ( overlappingPair ) ; } mOverlappingPairs . removePair ( i , true ) ; i -- ; } } } for ( uint64 i = 0 ; i < mOverlappingPairs . mConcavePairs . size ( ) ; i ++ ) { OverlappingPairs :: ConcaveOverlappingPair & overlappingPair = mOverlappingPairs . mConcavePairs [ i ] ; if ( overlappingPair . needToTestOverlap ) { if ( mBroadPhaseSystem . testOverlappingShapes ( overlappingPair . broadPhaseId1 , overlappingPair . broadPhaseId2 ) ) { overlappingPair . needToTestOverlap = false ; } else { if ( overlappingPair . collidingInPreviousFrame ) { addLostContactPair ( overlappingPair ) ; } mOverlappingPairs . removePair ( i , false ) ; i -- ; } } } }
Remove pairs that are not overlapping anymore
Remove pairs that are not overlapping anymore
// For each convex pairs // Check if we need to test overlap. If so, test if the two shapes are still overlapping. // Otherwise, we destroy the overlapping pair // If the two colliders of the pair were colliding in the previous frame // Create a new lost contact pair // For each concave pairs // Check if we need to test overlap. If so, test if the two shapes are still overlapping. // Otherwise, we destroy the overlapping pair // If the two colliders of the pair were colliding in the previous frame // Create a new lost contact pair