Exemplo n.º 1
0
        /// <summary>
        ///     Validates the buffer
        /// </summary>
        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);
                Box2DxDebug.Assert(proxy2.IsValid);
            }
#endif
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Buffereds the pair sort predicate using the specified pair 1
        /// </summary>
        /// <param name="pair1">The pair</param>
        /// <param name="pair2">The pair</param>
        /// <returns>The int</returns>
        public static int BufferedPairSortPredicate(BufferedPair pair1, BufferedPair pair2)
        {
            if (pair1.ProxyId1 < pair2.ProxyId1)
            {
                return(1);
            }

            if (pair1.ProxyId1 > pair2.ProxyId1)
            {
                return(-1);
            }

            if (pair1.ProxyId2 < pair2.ProxyId2)
            {
                return(1);
            }

            if (pair1.ProxyId2 > pair2.ProxyId2)
            {
                return(-1);
            }

            return(0);
        }
Exemplo n.º 3
0
 /// <summary>
 ///     Describes whether this instance equals
 /// </summary>
 /// <param name="pair1">The pair</param>
 /// <param name="pair2">The pair</param>
 /// <returns>The bool</returns>
 private bool Equals(ref BufferedPair pair1, ref BufferedPair pair2)
 {
     return(pair1.ProxyId1 == pair2.ProxyId1 && pair1.ProxyId2 == pair2.ProxyId2);
 }