void	btHashedOverlappingPairCache::cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher)
{

	class	CleanPairCallback : public btOverlapCallback
	{
		btBroadphaseProxy* m_cleanProxy;
		btOverlappingPairCache*	m_pairCache;
		btDispatcher* m_dispatcher;

	public:
		CleanPairCallback(btBroadphaseProxy* cleanProxy,btOverlappingPairCache* pairCache,btDispatcher* dispatcher)
			:m_cleanProxy(cleanProxy),
			m_pairCache(pairCache),
			m_dispatcher(dispatcher)
		{
		}
		virtual	bool	processOverlap(btBroadphasePair& pair)
		{
			if ((pair.m_pProxy0 == m_cleanProxy) ||
				(pair.m_pProxy1 == m_cleanProxy))
			{
				m_pairCache->cleanOverlappingPair(pair,m_dispatcher);
			}
			return false;
		}
		
	};

	CleanPairCallback cleanPairs(proxy,this,dispatcher);

	processAllOverlappingPairs(&cleanPairs,dispatcher);

}
void	btHashedOverlappingPairCache::removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher)
{

	class	RemovePairCallback : public btOverlapCallback
	{
		btBroadphaseProxy* m_obsoleteProxy;

	public:
		RemovePairCallback(btBroadphaseProxy* obsoleteProxy)
			:m_obsoleteProxy(obsoleteProxy)
		{
		}
		virtual	bool	processOverlap(btBroadphasePair& pair)
		{
			return ((pair.m_pProxy0 == m_obsoleteProxy) ||
				(pair.m_pProxy1 == m_obsoleteProxy));
		}
		
	};


	RemovePairCallback removeCallback(proxy);

	processAllOverlappingPairs(&removeCallback,dispatcher);
}
void	b3HashedOverlappingPairCache::removeOverlappingPairsContainingProxy(int proxy,b3Dispatcher* dispatcher)
{

	class	RemovePairCallback : public b3OverlapCallback
	{
		int m_obsoleteProxy;

	public:
		RemovePairCallback(int obsoleteProxy)
			:m_obsoleteProxy(obsoleteProxy)
		{
		}
		virtual	bool	processOverlap(b3BroadphasePair& pair)
		{
			return ((pair.x == m_obsoleteProxy) ||
				(pair.y == m_obsoleteProxy));
		}
		
	};


	RemovePairCallback removeCallback(proxy);

	processAllOverlappingPairs(&removeCallback,dispatcher);
}
void	b3HashedOverlappingPairCache::cleanProxyFromPairs(int proxy,b3Dispatcher* dispatcher)
{

	class	CleanPairCallback : public b3OverlapCallback
	{
		int m_cleanProxy;
		b3OverlappingPairCache*	m_pairCache;
		b3Dispatcher* m_dispatcher;

	public:
		CleanPairCallback(int cleanProxy,b3OverlappingPairCache* pairCache,b3Dispatcher* dispatcher)
			:m_cleanProxy(cleanProxy),
			m_pairCache(pairCache),
			m_dispatcher(dispatcher)
		{
		}
		virtual	bool	processOverlap(b3BroadphasePair& pair)
		{
			if ((pair.x == m_cleanProxy) ||
				(pair.y == m_cleanProxy))
			{
				m_pairCache->cleanOverlappingPair(pair,m_dispatcher);
			}
			return false;
		}
		
	};

	CleanPairCallback cleanPairs(proxy,this,dispatcher);

	processAllOverlappingPairs(&cleanPairs,dispatcher);

}
Example #5
0
void    btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback,btDispatcher* dispatcher, const struct btDispatcherInfo& dispatchInfo)
{
    if (dispatchInfo.m_deterministicOverlappingPairs)
    {
        btBroadphasePairArray& pa = getOverlappingPairArray();
        btAlignedObjectArray<MyPairIndex> indices;
        {
            BT_PROFILE("sortOverlappingPairs");
            indices.resize(pa.size());
            for (int i=0;i<indices.size();i++)
            {
                const btBroadphasePair& p = pa[i];
                const int uidA0 = p.m_pProxy0 ? p.m_pProxy0->m_uniqueId : -1;
                const int uidA1 = p.m_pProxy1 ? p.m_pProxy1->m_uniqueId : -1;
                
                indices[i].m_uidA0 = uidA0;
                indices[i].m_uidA1 = uidA1;
                indices[i].m_orgIndex = i;
            }
            indices.quickSort(MyPairIndeSortPredicate());
        }
        {
            BT_PROFILE("btHashedOverlappingPairCache::processAllOverlappingPairs");
            int i;
            for (i=0;i<indices.size();)
            {
                btBroadphasePair* pair = &pa[indices[i].m_orgIndex];
                if (callback->processOverlap(*pair))
                {
                    removeOverlappingPair(pair->m_pProxy0,pair->m_pProxy1,dispatcher);
                } else
                {
                    i++;
                }
            }
        }
    } else
    {
        processAllOverlappingPairs(callback, dispatcher);
    }
}