- removed STL from the Bullet library: replace std::vector by btAlignedObjectArray. Also removed the std::set for overlapping pair set, and turned it into an overlapping pair array. The SAP only adds objects, never removed. Removal is postponed for during traversal of overlapping pairs (duplicates and non-overlapping pairs are removed during that traversal).
- added heap sort and binary search/linear search to btAlignedObjectArray - fixed wrong cast, thanks Hamstray, http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1015
This commit is contained in:
@@ -15,7 +15,6 @@ subject to the following restrictions:
|
||||
|
||||
#include "btUnionFind.h"
|
||||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
|
||||
@@ -50,11 +49,16 @@ void btUnionFind::reset(int N)
|
||||
}
|
||||
}
|
||||
|
||||
bool btUnionFindElementSortPredicate(const btElement& lhs, const btElement& rhs)
|
||||
{
|
||||
return lhs.m_id < rhs.m_id;
|
||||
}
|
||||
|
||||
class btUnionFindElementSortPredicate
|
||||
{
|
||||
public:
|
||||
|
||||
bool operator() ( const btElement& lhs, const btElement& rhs )
|
||||
{
|
||||
return lhs.m_id < rhs.m_id;
|
||||
}
|
||||
};
|
||||
|
||||
///this is a special operation, destroying the content of btUnionFind.
|
||||
///it sorts the elements, based on island id, in order to make it easy to iterate over islands
|
||||
@@ -71,7 +75,9 @@ void btUnionFind::sortIslands()
|
||||
}
|
||||
|
||||
// Sort the vector using predicate and std::sort
|
||||
std::sort(m_elements.begin(), m_elements.end(), btUnionFindElementSortPredicate);
|
||||
//std::sort(m_elements.begin(), m_elements.end(), btUnionFindElementSortPredicate);
|
||||
//perhaps use radix sort?
|
||||
m_elements.heapSort(btUnionFindElementSortPredicate());
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user