20 #ifdef BT_DEBUG_COLLISION_PAIRS
21 int gOverlappingSimplePairs = 0;
22 int gRemoveSimplePairs = 0;
23 int gAddedSimplePairs = 0;
24 int gFindSimplePairs = 0;
29 int initialAllocatedSize = 2;
30 m_overlappingPairArray.
reserve(initialAllocatedSize);
40 m_overlappingPairArray.
clear();
44 int initialAllocatedSize = 2;
45 m_overlappingPairArray.
reserve(initialAllocatedSize);
51 #ifdef BT_DEBUG_COLLISION_PAIRS
58 int hash =
static_cast<int>(getHash(
static_cast<unsigned int>(indexA),
static_cast<unsigned int>(indexB)) & (m_overlappingPairArray.
capacity() - 1));
66 while (index !=
BT_SIMPLE_NULL_PAIR && equalsPair(m_overlappingPairArray[index], indexA, indexB) ==
false)
78 return &m_overlappingPairArray[index];
83 void btHashedSimplePairCache::growTables()
85 int newCapacity = m_overlappingPairArray.
capacity();
97 for (i = 0; i < newCapacity; ++i)
101 for (i = 0; i < newCapacity; ++i)
106 for (i = 0; i < curHashtableSize; i++)
112 int hashValue =
static_cast<int>(getHash(
static_cast<unsigned int>(indexA),
static_cast<unsigned int>(indexB)) & (m_overlappingPairArray.
capacity() - 1));
119 btSimplePair* btHashedSimplePairCache::internalAddPair(
int indexA,
int indexB)
121 int hash =
static_cast<int>(getHash(
static_cast<unsigned int>(indexA),
static_cast<unsigned int>(indexB)) & (m_overlappingPairArray.
capacity() - 1));
129 int count = m_overlappingPairArray.
size();
130 int oldCapacity = m_overlappingPairArray.
capacity();
133 int newCapacity = m_overlappingPairArray.
capacity();
135 if (oldCapacity < newCapacity)
139 hash =
static_cast<int>(getHash(
static_cast<unsigned int>(indexA),
static_cast<unsigned int>(indexB)) & (m_overlappingPairArray.
capacity() - 1));
154 #ifdef BT_DEBUG_COLLISION_PAIRS
155 gRemoveSimplePairs++;
161 int hash =
static_cast<int>(getHash(
static_cast<unsigned int>(indexA),
static_cast<unsigned int>(indexB)) & (m_overlappingPairArray.
capacity() - 1));
171 int pairIndex = int(pair - &m_overlappingPairArray[0]);
179 while (index != pairIndex)
199 int lastPairIndex = m_overlappingPairArray.
size() - 1;
202 if (lastPairIndex == pairIndex)
209 const btSimplePair* last = &m_overlappingPairArray[lastPairIndex];
211 int lastHash =
static_cast<int>(getHash(
static_cast<unsigned int>(last->
m_indexA),
static_cast<unsigned int>(last->
m_indexB)) & (m_overlappingPairArray.
capacity() - 1));
217 while (index != lastPairIndex)
234 m_overlappingPairArray[pairIndex] = m_overlappingPairArray[lastPairIndex];
const int BT_SIMPLE_NULL_PAIR
SIMD_FORCE_INLINE void reserve(int _Count)
SIMD_FORCE_INLINE void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0),...
SIMD_FORCE_INLINE int capacity() const
return the pre-allocated (reserved) elements, this is at least as large as the total number of elemen...
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())
SIMD_FORCE_INLINE T & expandNonInitializing()
virtual ~btHashedSimplePairCache()
btAlignedObjectArray< int > m_hashTable
btAlignedObjectArray< int > m_next
btHashedSimplePairCache()
btSimplePair * findPair(int indexA, int indexB)
virtual void * removeOverlappingPair(int indexA, int indexB)