27 int initialAllocatedSize = 2;
28 m_overlappingPairArray.reserve(initialAllocatedSize);
38 if (pair.m_algorithm && dispatcher)
41 pair.m_algorithm->~btCollisionAlgorithm();
58 : m_cleanProxy(cleanProxy),
59 m_pairCache(pairCache),
65 if ((pair.m_pProxy0 == m_cleanProxy) ||
66 (pair.m_pProxy1 == m_cleanProxy))
74 CleanPairCallback cleanPairs(proxy,
this, dispatcher);
87 : m_obsoleteProxy(obsoleteProxy)
92 return ((pair.m_pProxy0 == m_obsoleteProxy) ||
93 (pair.m_pProxy1 == m_obsoleteProxy));
97 RemovePairCallback removeCallback(proxy);
104 if (proxy0->m_uniqueId > proxy1->m_uniqueId)
106 int proxyId1 = proxy0->getUid();
107 int proxyId2 = proxy1->getUid();
112 int hash =
static_cast<int>(getHash(
static_cast<unsigned int>(proxyId1),
static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity() - 1));
120 while (index !=
BT_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) ==
false)
130 btAssert(index < m_overlappingPairArray.size());
132 return &m_overlappingPairArray[index];
137 void btHashedOverlappingPairCache::growTables()
139 int newCapacity = m_overlappingPairArray.capacity();
151 for (i = 0; i < newCapacity; ++i)
155 for (i = 0; i < newCapacity; ++i)
160 for (i = 0; i < curHashtableSize; i++)
163 int proxyId1 = pair.m_pProxy0->getUid();
164 int proxyId2 = pair.m_pProxy1->getUid();
167 int hashValue =
static_cast<int>(getHash(
static_cast<unsigned int>(proxyId1),
static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity() - 1));
176 if (proxy0->m_uniqueId > proxy1->m_uniqueId)
178 int proxyId1 = proxy0->getUid();
179 int proxyId2 = proxy1->getUid();
184 int hash =
static_cast<int>(getHash(
static_cast<unsigned int>(proxyId1),
static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity() - 1));
200 int count = m_overlappingPairArray.size();
201 int oldCapacity = m_overlappingPairArray.capacity();
202 void* mem = &m_overlappingPairArray.expandNonInitializing();
208 int newCapacity = m_overlappingPairArray.capacity();
210 if (oldCapacity < newCapacity)
214 hash =
static_cast<int>(getHash(
static_cast<unsigned int>(proxyId1),
static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity() - 1));
220 pair->m_algorithm = 0;
221 pair->m_internalTmpValue = 0;
231 if (proxy0->m_uniqueId > proxy1->m_uniqueId)
233 int proxyId1 = proxy0->getUid();
234 int proxyId2 = proxy1->getUid();
239 int hash =
static_cast<int>(getHash(
static_cast<unsigned int>(proxyId1),
static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity() - 1));
249 void* userData = pair->m_internalInfo1;
251 btAssert(pair->m_pProxy0->getUid() == proxyId1);
252 btAssert(pair->m_pProxy1->getUid() == proxyId2);
254 int pairIndex = int(pair - &m_overlappingPairArray[0]);
255 btAssert(pairIndex < m_overlappingPairArray.size());
262 while (index != pairIndex)
282 int lastPairIndex = m_overlappingPairArray.
size() - 1;
288 if (lastPairIndex == pairIndex)
290 m_overlappingPairArray.pop_back();
297 int lastHash =
static_cast<int>(getHash(
static_cast<unsigned int>(last->m_pProxy0->getUid()),
static_cast<unsigned int>(last->m_pProxy1->getUid())) & (m_overlappingPairArray.capacity() - 1));
303 while (index != lastPairIndex)
320 m_overlappingPairArray[pairIndex] = m_overlappingPairArray[lastPairIndex];
334 BT_PROFILE(
"btHashedOverlappingPairCache::processAllOverlappingPairs");
338 for (i = 0; i < m_overlappingPairArray.size();)
341 if (
callback->processOverlap(*pair))
364 const int uidA0 =
a.m_uidA0;
365 const int uidB0 =
b.m_uidA0;
366 const int uidA1 =
a.m_uidA1;
367 const int uidB1 =
b.m_uidA1;
368 return uidA0 > uidB0 || (uidA0 == uidB0 && uidA1 > uidB1);
381 for (
int i = 0; i <
indices.size(); i++)
384 const int uidA0 = p.m_pProxy0 ? p.m_pProxy0->m_uniqueId : -1;
385 const int uidA1 = p.m_pProxy1 ? p.m_pProxy1->m_uniqueId : -1;
394 BT_PROFILE(
"btHashedOverlappingPairCache::processAllOverlappingPairs");
396 for (i = 0; i <
indices.size();)
399 if (
callback->processOverlap(*pair))
416 void btHashedOverlappingPairCache::sortOverlappingPairs(
btDispatcher* dispatcher)
421 for (i = 0; i < m_overlappingPairArray.size(); i++)
423 tmpPairs.
push_back(m_overlappingPairArray[i]);
426 for (i = 0; i < tmpPairs.
size(); i++)
438 for (i = 0; i < tmpPairs.
size(); i++)
446 if (!hasDeferredRemoval())
450 int findIndex = m_overlappingPairArray.findLinearSearch(
findPair);
451 if (findIndex < m_overlappingPairArray.size())
454 void* userData = pair.m_internalInfo1;
459 m_overlappingPairArray.swap(findIndex, m_overlappingPairArray.capacity() - 1);
460 m_overlappingPairArray.pop_back();
476 void* mem = &m_overlappingPairArray.expandNonInitializing();
494 int findIndex = m_overlappingPairArray.findLinearSearch(tmpPair);
496 if (findIndex < m_overlappingPairArray.size())
511 for (i = 0; i < m_overlappingPairArray.size();)
514 if (
callback->processOverlap(*pair))
519 m_overlappingPairArray.swap(i, m_overlappingPairArray.size() - 1);
520 m_overlappingPairArray.pop_back();
529 btSortedOverlappingPairCache::btSortedOverlappingPairCache() : m_blockedForChanges(false),
530 m_hasDeferredRemoval(true),
534 int initialAllocatedSize = 2;
535 m_overlappingPairArray.reserve(initialAllocatedSize);
538 btSortedOverlappingPairCache::~btSortedOverlappingPairCache()
544 if (pair.m_algorithm)
547 pair.m_algorithm->~btCollisionAlgorithm();
549 pair.m_algorithm = 0;
564 : m_cleanProxy(cleanProxy),
565 m_pairCache(pairCache),
571 if ((pair.m_pProxy0 == m_cleanProxy) ||
572 (pair.m_pProxy1 == m_cleanProxy))
580 CleanPairCallback cleanPairs(proxy,
this, dispatcher);
593 : m_obsoleteProxy(obsoleteProxy)
598 return ((pair.m_pProxy0 == m_obsoleteProxy) ||
599 (pair.m_pProxy1 == m_obsoleteProxy));
603 RemovePairCallback removeCallback(proxy);
608 void btSortedOverlappingPairCache::sortOverlappingPairs(
btDispatcher* dispatcher)
btBroadphaseProxy * m_pProxy0
btBroadphaseProxy * m_pProxy1
btDispatcher * m_dispatcher
SIMD_FORCE_INLINE bool needsBroadphaseCollision(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1) const
virtual ~btHashedOverlappingPairCache()
btAlignedObjectArray< int > m_next
virtual void * removeOverlappingPair(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1, btDispatcher *dispatcher)
virtual void processAllOverlappingPairs(btOverlapCallback *, btDispatcher *dispatcher)
btOverlapFilterCallback * m_overlapFilterCallback
btHashedOverlappingPairCache()
void removeOverlappingPairsContainingProxy(btBroadphaseProxy *proxy, btDispatcher *dispatcher)
void cleanOverlappingPair(btBroadphasePair &pair, btDispatcher *dispatcher)
btBroadphasePair * findPair(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)
virtual btBroadphasePair * addOverlappingPair(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)
btOverlappingPairCallback * m_ghostPairCallback
btBroadphasePairArray & getOverlappingPairArray()
void cleanProxyFromPairs(btBroadphaseProxy *proxy, btDispatcher *dispatcher)
btAlignedObjectArray< int > m_hashTable
SIMD_FORCE_INLINE void btSwap(T &a, T &b)
bool operator()(const MyPairIndex &a, const MyPairIndex &b) const
SIMD_FORCE_INLINE int size() const
return the number of elements in the array
SIMD_FORCE_INLINE void pop_back()
SIMD_FORCE_INLINE void resize(int newsize, const T &fillData=T())
void quickSort(const L &CompareFunc)
SIMD_FORCE_INLINE void push_back(const T &_Val)
virtual void freeCollisionAlgorithm(void *ptr)=0
virtual void cleanOverlappingPair(btBroadphasePair &pair, btDispatcher *dispatcher)=0
virtual void * removeOverlappingPair(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1, btDispatcher *dispatcher)=0
virtual btBroadphasePair * addOverlappingPair(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)=0
DEGForeachIDComponentCallback callback
ccl_gpu_kernel_postfix int ccl_global int * indices
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
bool m_deterministicOverlappingPairs
virtual bool processOverlap(btBroadphasePair &pair)=0