Beispiel #1
0
        private void ValidateBuffer()
        {
#if DEBUG
            Box2DNetDebug.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 <BufferedPair>(tmp, BufferedPairSortPredicate);
            Array.Copy(tmp, 0, _pairBuffer, 0, _pairBufferCount);

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

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

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

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

                Box2DNetDebug.Assert(proxy1.IsValid == true);
                Box2DNetDebug.Assert(proxy2.IsValid == true);
            }
#endif
        }
Beispiel #2
0
        private void ValidateBuffer()
        {
#if DEBUG
            //std::sort(m_pairBuffer, m_pairBuffer + m_pairBufferCount);
            BufferedPair[] tmp = new BufferedPair[_pairBufferCount];
            Array.Copy(_pairBuffer, 0, tmp, 0, _pairBufferCount);
            Array.Sort <BufferedPair>(tmp, BufferedPairSortPredicate);
            Array.Copy(tmp, 0, _pairBuffer, 0, _pairBufferCount);

            for (int i = 0; i < _pairBufferCount; ++i)
            {
                if (i > 0)
                {
                }

                Pair pair = Find(_pairBuffer[i].ProxyId1, _pairBuffer[i].ProxyId2);


                Proxy proxy1 = _broadPhase._proxyPool[pair.ProxyId1];
                Proxy proxy2 = _broadPhase._proxyPool[pair.ProxyId2];
            }
#endif
        }
Beispiel #3
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);
        }
Beispiel #4
0
 private bool Equals(ref BufferedPair pair1, ref BufferedPair pair2)
 {
     return(pair1.ProxyId1 == pair2.ProxyId1 && pair1.ProxyId2 == pair2.ProxyId2);
 }