예제 #1
0
        public void Dump()
        {
            if ((m_flags & b2WorldType.e_locked) == e_locked)
            {
                return;
            }

            System.Diagnostics.Debug.WriteLine("b2Vec2 g({0:N5}, {0:N5});", m_gravity.x, m_gravity.y);
            System.Diagnostics.Debug.WriteLine("m_world.SetGravity(g);");

            System.Diagnostics.Debug.WriteLine("b2Body* bodies = (b2Body*)b2Alloc({0} * sizeof(b2Body));", m_bodyCount);
            System.Diagnostics.Debug.WriteLine("b2Joint* joints = (b2Joint*)b2Alloc({0} * sizeof(b2Joint));", m_jointCount);
            int i = 0;

            for (b2Body b = m_bodyList; b != null; b = b.Next)
            {
                b.IslandIndex = i;
                b.Dump();
                ++i;
            }

            i = 0;
            for (b2Joint j = m_jointList; j != null; j = j.Next)
            {
                j.Index = i;
                ++i;
            }

            // First pass on joints, skip gear joints.
            for (b2Joint j = m_jointList; j != null; j = j.Next)
            {
                if (j.JointType == b2JointType.e_gearJoint)
                {
                    continue;
                }

                System.Diagnostics.Debug.WriteLine("{");
                j.Dump();
                System.Diagnostics.Debug.WriteLine("}");
            }

            // Second pass on joints, only gear joints.
            for (b2Joint j = m_jointList; j != null; j = j.Next)
            {
                if (j.JointType != b2JointType.e_gearJoint)
                {
                    continue;
                }

                System.Diagnostics.Debug.WriteLine("{");
                j.Dump();
                System.Diagnostics.Debug.WriteLine("}");
            }

            System.Diagnostics.Debug.WriteLine("b2Free(joints);");
            System.Diagnostics.Debug.WriteLine("b2Free(bodies);");
            System.Diagnostics.Debug.WriteLine("joints = null;");
            System.Diagnostics.Debug.WriteLine("bodies = null;");
        }