Exemplo n.º 1
0
        void IBroadphase.DebugDraw(IDebugDrawer debugDrawer)
        {
            Queue <Tuple <Node, int> > q = new Queue <Tuple <Node, int> >();

            if (root != null)
            {
                q.Enqueue(new Tuple <Node, int>(root, 1));
            }

            while (q.Count > 0)
            {
                var  param = q.Dequeue();
                Node node  = param.Item1;
                int  depth = param.Item2;

                Vec2[] verts = new Vec2[] {
                    node.bounds.min,
                    new Vec2(node.bounds.max.x, node.bounds.min.y),
                    node.bounds.max,
                    new Vec2(node.bounds.min.x, node.bounds.max.y)
                };

                debugDrawer.Draw(verts, (object)depth);

                if (!node.IsLeaf)
                {
                    q.Enqueue(new Tuple <Node, int>(node.child0, depth + 1));
                    q.Enqueue(new Tuple <Node, int>(node.child1, depth + 1));
                }
            }
        }
Exemplo n.º 2
0
        private void Draw()
        {
            if (m_material)
            {
                Camera camera = Camera.current;
                if (camera)
                {
                    GL.PushMatrix();
                    GL.LoadProjectionMatrix(camera.projectionMatrix);
                    GL.modelview = camera.worldToCameraMatrix;

                    m_material.SetPass(0);

                    for (int i = m_drawers.Count - 1; i >= 0; --i)
                    {
                        IDebugDrawer drawable = m_drawers[i];
                        if (drawable != null)
                        {
                            drawable.Draw();
                        }
                    }

                    GL.PopMatrix();
                }
            }
        }