Make the btDbvtBroadphase deterministic/reproducable, by sorting the btBroadphasePair using unique ID, instead of proxy address.

The btAxisSweep3 didn't suffer from this issue, because proxies were always allocated in-order, as part of an array.
This commit is contained in:
erwin.coumans
2008-12-08 20:16:29 +00:00
parent 65cdd7146f
commit 6db1b932fd
5 changed files with 16 additions and 27 deletions

View File

@@ -187,7 +187,7 @@ BT_DECLARE_ALIGNED_ALLOCATOR();
{
//keep them sorted, so the std::set operations work
if (&proxy0 < &proxy1)
if (proxy0.m_uniqueId < proxy1.m_uniqueId)
{
m_pProxy0 = &proxy0;
m_pProxy1 = &proxy1;
@@ -228,8 +228,8 @@ class btBroadphasePairSortPredicate
bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b )
{
return a.m_pProxy0 > b.m_pProxy0 ||
(a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 > b.m_pProxy1) ||
return a.m_pProxy0->m_uniqueId > b.m_pProxy0->m_uniqueId ||
(a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1->m_uniqueId > b.m_pProxy1->m_uniqueId) ||
(a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm);
}
};