예제 #1
0
        public void UpdatePairs(b2ContactManager callback)
        {
            // Reset pair buffer
            m_pairCount = 0;

            // Perform tree queries for all moving proxies.
            // Console.WriteLine("move_count={0}", m_moveCount);

            for (int i = 0; i < m_moveCount; ++i)
            {
                m_queryProxyId = m_moveBuffer[i];
                if (m_queryProxyId == 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(this, fatAABB);
            }

            // Reset move buffer
            m_moveCount = 0;

            // Sort the pair buffer to expose duplicates.
            // Sort starting with the m_pairCount
            Array.Sort(m_pairBuffer, 0, m_pairCount, this);
//			if (m_pairCount > 0)
//				Console.WriteLine("UpdatePairs " + m_pairCount);
            // Send the pairs back to the client.
            int i2 = 0;

            while (i2 < m_pairCount)
            {
                int    i1          = i2;
                b2Pair primaryPair = m_pairBuffer[i2];
                object userDataA   = m_tree.GetUserData(primaryPair.proxyIdA);
                object userDataB   = m_tree.GetUserData(primaryPair.proxyIdB);

                callback.AddPair(userDataA, userDataB);
                ++i2;

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

            // Try to keep the tree balanced.
            //m_tree.Rebalance(4);
        }
예제 #2
0
        protected override void Draw(Settings settings)
        {
            base.Draw(settings);

            b2ContactManager cm    = m_world.ContactManager;
            int   height           = cm.BroadPhase.GetTreeHeight();
            int   leafCount        = cm.BroadPhase.GetProxyCount();
            int   minimumNodeCount = 2 * leafCount - 1;
            float minimumHeight    = (float)Math.Ceiling((float)Math.Log(minimumNodeCount) / (float)Math.Log(2.0f));

            m_debugDraw.DrawString(5, m_textLine, "dynamic tree height = {0}, min = {1}", height, minimumHeight);
            m_textLine += 15;

            m_debugDraw.DrawString(5, m_textLine, "create time = {0:000000.00} ms, fixture count = {1}",
                                   m_createTime, m_fixtureCount);
            m_textLine += 15;
        }
예제 #3
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(b2ContactManager obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
예제 #4
0
        public b2ContactManager GetContactManager()
        {
            b2ContactManager ret = new b2ContactManager(Box2dPINVOKE.b2World_GetContactManager(swigCPtr), false);

            return(ret);
        }