/// Update the pairs. This results in pair callbacks. This can only add pairs. public void UpdatePairs(b2BroadphaseCallback callback) { // Reset pair buffer m_pairCount = 0; int i; // Perform tree queries for all moving proxies. for (i = 0; i < m_moveCount; ++i) { m_queryProxyId = m_moveBuffer[i]; if (m_queryProxyId == (int)AnonymousEnum.e_nullProxy) { 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. b2AABB fatAABB = m_tree.GetFatAABB(m_queryProxyId); // Query tree, create pairs and add them pair buffer. m_tree.Query(QueryCallback, fatAABB); } // 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) { b2Pair primaryPair = m_pairBuffer[i]; object userDataA = m_tree.GetUserData(primaryPair.proxyIdA); object userDataB = m_tree.GetUserData(primaryPair.proxyIdB); callback(userDataA, userDataB); ++i; // Skip any duplicate pairs. while (i < m_pairCount) { b2Pair pair = m_pairBuffer[i]; if (pair.proxyIdA != primaryPair.proxyIdA || pair.proxyIdB != primaryPair.proxyIdB) { break; } ++i; } } // Try to keep the tree balanced. //m_tree.Rebalance(4); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(b2Pair obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }