Pass in a const reference to a CompareFunc for quickSort, to make Visual Studio 2011 happy.

Thanks to Cameron Hart
Fixes Issue 588
This commit is contained in:
erwin.coumans
2012-01-23 21:39:44 +00:00
parent ce50f11fea
commit f754952232
11 changed files with 14 additions and 13 deletions

View File

@@ -22,6 +22,7 @@
#include <set> #include <set>
#include <vector> #include <vector>
#include <queue> #include <queue>
#include <functional>
namespace HACD namespace HACD
{ {

View File

@@ -246,7 +246,7 @@ class btBroadphasePairSortPredicate
{ {
public: public:
bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b ) bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b ) const
{ {
const int uidA0 = a.m_pProxy0 ? a.m_pProxy0->m_uniqueId : -1; const int uidA0 = a.m_pProxy0 ? a.m_pProxy0->m_uniqueId : -1;
const int uidB0 = b.m_pProxy0 ? b.m_pProxy0->m_uniqueId : -1; const int uidB0 = b.m_pProxy0 ? b.m_pProxy0->m_uniqueId : -1;

View File

@@ -341,7 +341,7 @@ class btMultiSapBroadphasePairSortPredicate
{ {
public: public:
bool operator() ( const btBroadphasePair& a1, const btBroadphasePair& b1 ) bool operator() ( const btBroadphasePair& a1, const btBroadphasePair& b1 ) const
{ {
btMultiSapBroadphase::btMultiSapProxy* aProxy0 = a1.m_pProxy0 ? (btMultiSapBroadphase::btMultiSapProxy*)a1.m_pProxy0->m_multiSapParentProxy : 0; btMultiSapBroadphase::btMultiSapProxy* aProxy0 = a1.m_pProxy0 ? (btMultiSapBroadphase::btMultiSapProxy*)a1.m_pProxy0->m_multiSapParentProxy : 0;
btMultiSapBroadphase::btMultiSapProxy* aProxy1 = a1.m_pProxy1 ? (btMultiSapBroadphase::btMultiSapProxy*)a1.m_pProxy1->m_multiSapParentProxy : 0; btMultiSapBroadphase::btMultiSapProxy* aProxy1 = a1.m_pProxy1 ? (btMultiSapBroadphase::btMultiSapProxy*)a1.m_pProxy1->m_multiSapParentProxy : 0;

View File

@@ -193,7 +193,7 @@ class btPersistentManifoldSortPredicate
{ {
public: public:
SIMD_FORCE_INLINE bool operator() ( const btPersistentManifold* lhs, const btPersistentManifold* rhs ) SIMD_FORCE_INLINE bool operator() ( const btPersistentManifold* lhs, const btPersistentManifold* rhs ) const
{ {
return getIslandId(lhs) < getIslandId(rhs); return getIslandId(lhs) < getIslandId(rhs);
} }

View File

@@ -53,7 +53,7 @@ class btUnionFindElementSortPredicate
{ {
public: public:
bool operator() ( const btElement& lhs, const btElement& rhs ) bool operator() ( const btElement& lhs, const btElement& rhs ) const
{ {
return lhs.m_id < rhs.m_id; return lhs.m_id < rhs.m_id;
} }

View File

@@ -58,7 +58,7 @@ class CONTACT_KEY_TOKEN_COMP
{ {
public: public:
bool operator() ( const CONTACT_KEY_TOKEN& a, const CONTACT_KEY_TOKEN& b ) bool operator() ( const CONTACT_KEY_TOKEN& a, const CONTACT_KEY_TOKEN& b ) const
{ {
return ( a < b ); return ( a < b );
} }

View File

@@ -71,7 +71,7 @@ class btSortConstraintOnIslandPredicate
{ {
public: public:
bool operator() ( const btTypedConstraint* lhs, const btTypedConstraint* rhs ) bool operator() ( const btTypedConstraint* lhs, const btTypedConstraint* rhs ) const
{ {
int rIslandId0,lIslandId0; int rIslandId0,lIslandId0;
rIslandId0 = btGetConstraintIslandId(rhs); rIslandId0 = btGetConstraintIslandId(rhs);

View File

@@ -1245,7 +1245,7 @@ void btDX11SoftBodySolver::prepareCollisionConstraints()
{ {
public: public:
bool operator() ( const CollisionShapeDescription& a, const CollisionShapeDescription& b ) bool operator() ( const CollisionShapeDescription& a, const CollisionShapeDescription& b ) const
{ {
return ( a.softBodyIdentifier < b.softBodyIdentifier ); return ( a.softBodyIdentifier < b.softBodyIdentifier );
} }

View File

@@ -1175,7 +1175,7 @@ class QuickSortCompare
{ {
public: public:
bool operator() ( const CollisionShapeDescription& a, const CollisionShapeDescription& b ) bool operator() ( const CollisionShapeDescription& a, const CollisionShapeDescription& b ) const
{ {
return ( a.softBodyIdentifier < b.softBodyIdentifier ); return ( a.softBodyIdentifier < b.softBodyIdentifier );
} }

View File

@@ -314,7 +314,7 @@ protected:
}; };
template <typename L> template <typename L>
void quickSortInternal(L CompareFunc,int lo, int hi) void quickSortInternal(const L& CompareFunc,int lo, int hi)
{ {
// lo is the lower index, hi is the upper index // lo is the lower index, hi is the upper index
// of the region of array a that is to be sorted // of the region of array a that is to be sorted
@@ -344,7 +344,7 @@ protected:
template <typename L> template <typename L>
void quickSort(L CompareFunc) void quickSort(const L& CompareFunc)
{ {
//don't sort 0 or 1 elements //don't sort 0 or 1 elements
if (size()>1) if (size()>1)
@@ -356,7 +356,7 @@ protected:
///heap sort from http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Heap/ ///heap sort from http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Heap/
template <typename L> template <typename L>
void downHeap(T *pArr, int k, int n,L CompareFunc) void downHeap(T *pArr, int k, int n, const L& CompareFunc)
{ {
/* PRE: a[k+1..N] is a heap */ /* PRE: a[k+1..N] is a heap */
/* POST: a[k..N] is a heap */ /* POST: a[k..N] is a heap */
@@ -402,7 +402,7 @@ protected:
} }
template <typename L> template <typename L>
void heapSort(L CompareFunc) void heapSort(const L& CompareFunc)
{ {
/* sort a[0..N-1], N.B. 0 to N-1 */ /* sort a[0..N-1], N.B. 0 to N-1 */
int k; int k;

View File

@@ -39,7 +39,7 @@ struct btAngleCompareFunc {
: m_anchor(anchor) : m_anchor(anchor)
{ {
} }
bool operator()(const GrahamVector2& a, const GrahamVector2& b) { bool operator()(const GrahamVector2& a, const GrahamVector2& b) const {
if (a.m_angle != b.m_angle) if (a.m_angle != b.m_angle)
return a.m_angle < b.m_angle; return a.m_angle < b.m_angle;
else else