// Buffer a pair for removal.
        public void RemoveBufferedPair(b2Proxy proxy1, b2Proxy proxy2)
        {
            //b2Settings.b2Assert(proxy1 && proxy2);

            b2Pair pair = Find(proxy1, proxy2);

            if (pair == null)
            {
                // The pair never existed. This is legal (due to collision filtering).
                return;
            }

            // If this pair is not in the pair buffer ...
            if (pair.IsBuffered() == false)
            {
                // This must be an old pair.
                //b2Settings.b2Assert(pair.IsFinal() == true);

                pair.SetBuffered();
                m_pairBuffer[m_pairBufferCount] = pair;
                ++m_pairBufferCount;

                //b2Settings.b2Assert(m_pairBufferCount <= m_pairCount);
            }

            pair.SetRemoved();

            if (b2BroadPhase.s_validate)
            {
                ValidateBuffer();
            }
        }
        /*
         * As proxies are created and moved, many pairs are created and destroyed. Even worse, the same
         * pair may be added and removed multiple times in a single time step of the physics engine. To reduce
         * traffic in the pair manager, we try to avoid destroying pairs in the pair manager until the
         * end of the physics step. This is done by buffering all the RemovePair requests. AddPair
         * requests are processed immediately because we need the hash table entry for quick lookup.
         *
         * All user user callbacks are delayed until the buffered pairs are confirmed in Commit.
         * This is very important because the user callbacks may be very expensive and client logic
         * may be harmed if pairs are added and removed within the same time step.
         *
         * Buffer a pair for addition.
         * We may add a pair that is not in the pair manager or pair buffer.
         * We may add a pair that is already in the pair manager and pair buffer.
         * If the added pair is not a new pair, then it must be in the pair buffer (because RemovePair was called).
         */
        public void AddBufferedPair(b2Proxy proxy1, b2Proxy proxy2)
        {
            //b2Settings.b2Assert(proxy1 && proxy2);

            b2Pair pair = AddPair(proxy1, proxy2);

            // If this pair is not in the pair buffer ...
            if (pair.IsBuffered() == false)
            {
                // This must be a newly added pair.
                //b2Settings.b2Assert(pair.IsFinal() == false);

                // Add it to the pair buffer.
                pair.SetBuffered();
                m_pairBuffer[m_pairBufferCount] = pair;
                ++m_pairBufferCount;
                //b2Settings.b2Assert(m_pairBufferCount <= m_pairCount);
            }

            // Confirm this pair for the subsequent call to Commit.
            pair.ClearRemoved();

            if (b2BroadPhase.s_validate)
            {
                ValidateBuffer();
            }
        }