public void ForAllPairs(PairCallback callback)
 {
     foreach (long y in Y)
     {
         callback(x, y);
     }
 }
 public void ForAllPairs(PairCallback callback)
 {
     foreach (Column col in columns.Values)
     {
         col.ForAllPairs(callback);
     }
 }
Beispiel #3
0
        /**
         * Update the pairs. This results in pair callbacks. This can only add pairs.
         *
         * @param callback
         */

        public void updatePairs(PairCallback callback)
        {
            // log.debug("beginning to update pairs");
            // Reset pair buffer
            m_pairCount = 0;

            // Perform tree queries for all moving proxies.
            for (int i = 0; i < m_moveCount; ++i)
            {
                m_queryProxyId = m_moveBuffer[i];
                if (m_queryProxyId == NULL_PROXY)
                {
                    continue;
                }

                // We have to query the tree with the fat AABB so that
                // we don't fail to create a pair that may touch later.
                AABB fatAABB = m_tree.getFatAABB(m_queryProxyId);

                // Query tree, create pairs and add them pair buffer.
                // log.debug("quering aabb: "+m_queryProxy.aabb);
                m_tree.query(this, fatAABB);
            }
            // log.debug("Number of pairs found: "+m_pairCount);

            // Reset move buffer
            m_moveCount = 0;

            // Sort the pair buffer to expose duplicates.
            ArrayHelper.Sort(m_pairBuffer, 0, m_pairCount);

            // Send the pairs back to the client.
            int index0 = 0;

            while (index0 < m_pairCount)
            {
                Pair   primaryPair = m_pairBuffer[index0];
                object userDataA   = m_tree.getUserData(primaryPair.proxyIdA);
                object userDataB   = m_tree.getUserData(primaryPair.proxyIdB);

                // log.debug("returning pair: "+userDataA+", "+userDataB);
                callback.addPair(userDataA, userDataB);
                ++index0;

                // Skip any duplicate pairs.
                while (index0 < m_pairCount)
                {
                    Pair pair = m_pairBuffer[index0];
                    if (pair.proxyIdA != primaryPair.proxyIdA || pair.proxyIdB != primaryPair.proxyIdB)
                    {
                        break;
                    }
                    // log.debug("skipping duplicate");
                    ++index0;
                }
            }

            // Try to keep the tree balanced.
            // m_tree.rebalance(Settings.TREE_REBALANCE_STEPS);
        }
        // Iterates through all the pairs and runs your callback function for them
        public void ForLeafLevelPairs(PairCallback callback)
        {
            bool[,] pairs = GetLeafLevelPairs();
            int w = pairs.GetLength(0), h = pairs.GetLength(1);

            for (int x = 0; x < w; x++)
                for (int y = 0; y < h; y++)
                    if (pairs[x, y])
                        callback(x, y);
        }
Beispiel #5
0
        // Iterates through all the pairs and runs your callback function for them
        public void ForLeafLevelPairs(PairCallback callback)
        {
            bool[,] pairs = GetLeafLevelPairs();
            int w = pairs.GetLength(0), h = pairs.GetLength(1);

            for (int x = 0; x < w; x++)
            {
                for (int y = 0; y < h; y++)
                {
                    if (pairs[x, y])
                    {
                        callback(x, y);
                    }
                }
            }
        }
 public void ForAllPairs(PairCallback callback)
 {
     foreach (Column col in columns.Values)
         col.ForAllPairs(callback);
 }
 public void ForAllPairs(PairCallback callback)
 {
     foreach (long y in Y)
         callback(x, y);
 }
        public void updatePairs(PairCallback callback)
        {
            // Reset pair buffer
            m_pairCount = 0;

            // Perform tree queries for all moving proxies.
            int i;
            for (i = 0; i < m_moveCount; ++i)
            {
                m_queryProxyId = m_moveBuffer[i];
                if (m_queryProxyId == (int)BroadPhaseProxy.Null)
                {
                    continue;
                }

                // We have to query the tree with the fat AABB so that
                // we don't fail to create a pair that may touch later.
                AABB fatAABB = m_tree.getFatAABB(m_queryProxyId);

                // Query tree, create pairs and add them pair buffer.
                // log.debug("quering aabb: "+m_queryProxy.aabb);
                m_tree.query(this, fatAABB);
            }
            // log.debug("Number of pairs found: "+m_pairCount);

            // Reset move buffer
            m_moveCount = 0;

            // Sort the pair buffer to expose duplicates.
            Array.Sort(m_pairBuffer, 0, m_pairCount);

            // Send the pairs back to the client.
            i = 0;
            while (i < m_pairCount)
            {
                Pair primaryPair = m_pairBuffer[i];
                object userDataA = m_tree.getUserData(primaryPair.proxyIdA);
                object userDataB = m_tree.getUserData(primaryPair.proxyIdB);

                // log.debug("returning pair: "+userDataA+", "+userDataB);
                callback.addPair(userDataA, userDataB);
                ++i;

                // Skip any duplicate pairs.
                while (i < m_pairCount)
                {
                    Pair pair = m_pairBuffer[i];
                    if (pair.proxyIdA != primaryPair.proxyIdA || pair.proxyIdB != primaryPair.proxyIdB)
                    {
                        break;
                    }
                    ++i;
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Update the pairs. This results in pair callbacks. This can only add pairs.
        /// </summary>
        /// <param name="callback"></param>
        public void updatePairs(PairCallback callback)
        {
            // log.debug("beginning to update pairs");
            // Reset pair buffer
            m_pairCount = 0;

            // Perform tree queries for all moving proxies.
            for (int i = 0; i < m_moveCount; ++i)
            {
                m_queryProxyId = m_moveBuffer[i];
                if (m_queryProxyId == NULL_PROXY)
                {
                    continue;
                }

                // We have to query the tree with the fat AABB so that
                // we don't fail to create a pair that may touch later.
                AABB fatAABB = m_tree.getFatAABB(m_queryProxyId);

                // Query tree, create pairs and add them pair buffer.
                // log.debug("quering aabb: "+m_queryProxy.aabb);
                m_tree.query(this, fatAABB);
            }
            // log.debug("Number of pairs found: "+m_pairCount);

            // Reset move buffer
            m_moveCount = 0;

            // Sort the pair buffer to expose duplicates.
            Array.Sort(m_pairBuffer, 0, m_pairCount - 0);

            // Send the pairs back to the client.
            int i2 = 0;
            while (i2 < m_pairCount)
            {
                Pair primaryPair = m_pairBuffer[i2];
                Object userDataA = m_tree.getUserData(primaryPair.proxyIdA);
                Object userDataB = m_tree.getUserData(primaryPair.proxyIdB);

                // log.debug("returning pair: "+userDataA+", "+userDataB);
                callback.addPair(userDataA, userDataB);
                ++i2;

                // Skip any duplicate pairs.
                while (i2 < m_pairCount)
                {
                    Pair pair = m_pairBuffer[i2];
                    if (pair.proxyIdA != primaryPair.proxyIdA || pair.proxyIdB != primaryPair.proxyIdB)
                    {
                        break;
                    }
                    // log.debug("skipping duplicate");
                    ++i2;
                }
            }

            // Try to keep the tree balanced.
            // m_tree.rebalance(Settings.TREE_REBALANCE_STEPS);
        }