more broadphase/pair cache/MultiSAP improvements.
This commit is contained in:
@@ -464,7 +464,7 @@ template <typename BP_FP_INT_TYPE>
|
|||||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::calculateOverlappingPairs(btDispatcher* dispatcher)
|
void btAxisSweep3Internal<BP_FP_INT_TYPE>::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (m_ownsPairCache && m_pairCache->hasDeferredRemoval())
|
if (m_pairCache->hasDeferredRemoval())
|
||||||
{
|
{
|
||||||
|
|
||||||
btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray();
|
btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray();
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ btMultiSapBroadphase::~btMultiSapBroadphase()
|
|||||||
{
|
{
|
||||||
if (m_ownsPairCache)
|
if (m_ownsPairCache)
|
||||||
{
|
{
|
||||||
|
m_overlappingPairs->~btOverlappingPairCache();
|
||||||
btAlignedFree(m_overlappingPairs);
|
btAlignedFree(m_overlappingPairs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,81 +116,83 @@ void btMultiSapBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
|||||||
{
|
{
|
||||||
m_simpleBroadphase->calculateOverlappingPairs(dispatcher);
|
m_simpleBroadphase->calculateOverlappingPairs(dispatcher);
|
||||||
|
|
||||||
#ifndef USE_HASH_PAIRCACHE
|
if (m_overlappingPairs->hasDeferredRemoval())
|
||||||
|
|
||||||
btBroadphasePairArray& overlappingPairArray = m_overlappingPairs->getOverlappingPairArray();
|
|
||||||
|
|
||||||
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
|
|
||||||
overlappingPairArray.heapSort(btBroadphasePairSortPredicate());
|
|
||||||
|
|
||||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
|
||||||
m_invalidPair = 0;
|
|
||||||
|
|
||||||
|
|
||||||
btBroadphasePair previousPair;
|
|
||||||
previousPair.m_pProxy0 = 0;
|
|
||||||
previousPair.m_pProxy1 = 0;
|
|
||||||
previousPair.m_algorithm = 0;
|
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i=0;i<overlappingPairArray.size();i++)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
btBroadphasePair& pair = overlappingPairArray[i];
|
|
||||||
|
|
||||||
bool isDuplicate = (pair == previousPair);
|
|
||||||
|
|
||||||
previousPair = pair;
|
btBroadphasePairArray& overlappingPairArray = m_overlappingPairs->getOverlappingPairArray();
|
||||||
|
|
||||||
|
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
|
||||||
|
overlappingPairArray.heapSort(btBroadphasePairSortPredicate());
|
||||||
|
|
||||||
bool needsRemoval = false;
|
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||||
|
m_invalidPair = 0;
|
||||||
|
|
||||||
if (!isDuplicate)
|
|
||||||
|
btBroadphasePair previousPair;
|
||||||
|
previousPair.m_pProxy0 = 0;
|
||||||
|
previousPair.m_pProxy1 = 0;
|
||||||
|
previousPair.m_algorithm = 0;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0;i<overlappingPairArray.size();i++)
|
||||||
{
|
{
|
||||||
bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
|
|
||||||
|
btBroadphasePair& pair = overlappingPairArray[i];
|
||||||
|
|
||||||
if (hasOverlap)
|
bool isDuplicate = (pair == previousPair);
|
||||||
|
|
||||||
|
previousPair = pair;
|
||||||
|
|
||||||
|
bool needsRemoval = false;
|
||||||
|
|
||||||
|
if (!isDuplicate)
|
||||||
{
|
{
|
||||||
needsRemoval = false;//callback->processOverlap(pair);
|
bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
|
||||||
|
|
||||||
|
if (hasOverlap)
|
||||||
|
{
|
||||||
|
needsRemoval = false;//callback->processOverlap(pair);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
needsRemoval = true;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
//remove duplicate
|
||||||
needsRemoval = true;
|
needsRemoval = true;
|
||||||
|
//should have no algorithm
|
||||||
|
btAssert(!pair.m_algorithm);
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
{
|
if (needsRemoval)
|
||||||
//remove duplicate
|
{
|
||||||
needsRemoval = true;
|
m_overlappingPairs->cleanOverlappingPair(pair,dispatcher);
|
||||||
//should have no algorithm
|
|
||||||
btAssert(!pair.m_algorithm);
|
// m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
||||||
|
// m_overlappingPairArray.pop_back();
|
||||||
|
pair.m_pProxy0 = 0;
|
||||||
|
pair.m_pProxy1 = 0;
|
||||||
|
m_invalidPair++;
|
||||||
|
gOverlappingPairs--;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsRemoval)
|
|
||||||
{
|
|
||||||
m_overlappingPairs->cleanOverlappingPair(pair,dispatcher);
|
|
||||||
|
|
||||||
// m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
///if you don't like to skip the invalid pairs in the array, execute following code:
|
||||||
// m_overlappingPairArray.pop_back();
|
#define CLEAN_INVALID_PAIRS 1
|
||||||
pair.m_pProxy0 = 0;
|
#ifdef CLEAN_INVALID_PAIRS
|
||||||
pair.m_pProxy1 = 0;
|
|
||||||
m_invalidPair++;
|
//perform a sort, to sort 'invalid' pairs to the end
|
||||||
gOverlappingPairs--;
|
overlappingPairArray.heapSort(btBroadphasePairSortPredicate());
|
||||||
}
|
|
||||||
|
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||||
|
m_invalidPair = 0;
|
||||||
|
#endif//CLEAN_INVALID_PAIRS
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///if you don't like to skip the invalid pairs in the array, execute following code:
|
|
||||||
#define CLEAN_INVALID_PAIRS 1
|
|
||||||
#ifdef CLEAN_INVALID_PAIRS
|
|
||||||
|
|
||||||
//perform a sort, to sort 'invalid' pairs to the end
|
|
||||||
overlappingPairArray.heapSort(btBroadphasePairSortPredicate());
|
|
||||||
|
|
||||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
|
||||||
m_invalidPair = 0;
|
|
||||||
#endif//CLEAN_INVALID_PAIRS
|
|
||||||
|
|
||||||
#endif //USE_HASH_PAIRCACHE
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -204,12 +204,13 @@ void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
#ifdef USE_HASH_PAIRCACHE
|
if (!m_pairCache->hasDeferredRemoval())
|
||||||
|
{
|
||||||
if ( m_pairCache->findPair(proxy0,proxy1))
|
if ( m_pairCache->findPair(proxy0,proxy1))
|
||||||
{
|
{
|
||||||
m_pairCache->removeOverlappingPair(proxy0,proxy1,dispatcher);
|
m_pairCache->removeOverlappingPair(proxy0,proxy1,dispatcher);
|
||||||
}
|
}
|
||||||
#endif //USE_HASH_PAIRCACHE
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,9 +221,7 @@ void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_HASH_PAIRCACHE
|
if (m_ownsPairCache && m_pairCache->hasDeferredRemoval())
|
||||||
|
|
||||||
if (m_ownsPairCache)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray();
|
btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray();
|
||||||
@@ -296,7 +295,6 @@ void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
|||||||
#endif//CLEAN_INVALID_PAIRS
|
#endif//CLEAN_INVALID_PAIRS
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif //USE_HASH_PAIRCACHE
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user