Esempio n. 1
0
        private void ValidateBuffer()
        {
#if DEBUG
            //Box2DXDebug.Assert(_pairBufferCount <= _pairCount);

            //std::sort(m_pairBuffer, m_pairBuffer + m_pairBufferCount);
            BufferedPair[] tmp = new BufferedPair[_pairBufferCount];
            Array.Copy(_pairBuffer, 0, tmp, 0, _pairBufferCount);
            Array.Sort(tmp, BufferedPairSortPredicate);
            Array.Copy(tmp, 0, _pairBuffer, 0, _pairBufferCount);

            for (int i = 0; i < _pairBufferCount; ++i)
            {
                if (i > 0)
                {
                    //Box2DXDebug.Assert(Equals(_pairBuffer[i], _pairBuffer[i - 1]) == false);
                }

                Pair pair = Find(_pairBuffer[i].ProxyId1, _pairBuffer[i].ProxyId2);
                //Box2DXDebug.Assert(pair.IsBuffered());

                //Box2DXDebug.Assert(pair.ProxyId1 != pair.ProxyId2);
                //Box2DXDebug.Assert(pair.ProxyId1 < Settings.MaxProxies);
                //Box2DXDebug.Assert(pair.ProxyId2 < Settings.MaxProxies);

                Proxy proxy1 = _broadPhase._proxyPool[pair.ProxyId1];
                Proxy proxy2 = _broadPhase._proxyPool[pair.ProxyId2];

                //Box2DXDebug.Assert(proxy1.IsValid == true);
                //Box2DXDebug.Assert(proxy2.IsValid == true);
            }
#endif
        }
Esempio n. 2
0
        public static int BufferedPairSortPredicate(BufferedPair pair1, BufferedPair pair2)
        {
            if (pair1.ProxyId1 > pair2.ProxyId1)
            {
                return(1);
            }
            else if (pair1.ProxyId1 < pair2.ProxyId1)
            {
                return(-1);
            }
            else
            {
                if (pair1.ProxyId2 > pair2.ProxyId2)
                {
                    return(1);
                }
                else if (pair1.ProxyId2 < pair2.ProxyId2)
                {
                    return(-1);
                }
            }

            return(0);
        }
Esempio n. 3
0
 private bool Equals(ref BufferedPair pair1, ref BufferedPair pair2)
 {
     return(pair1.ProxyId1 == pair2.ProxyId1 && pair1.ProxyId2 == pair2.ProxyId2);
 }