public static void DrawBvh(this IDebugCanvas canvas, BvhILS2 bvh)
        {
            void Helper(BvhILS2 node, int d)
            {
                if (d != 0)
                {
                    var s = new StrokeStyle(d % 2 == 0 ? Color.Red : Color.Lime, 10.0f / d, new[] { d % 2 == 0 ? 1.0f : 3.0f, d % 2 == 0 ? 3.0f : 1.0f });
                    canvas.DrawRectangle(node.Bounds, 0.0f, s);
                }
                if (node.First != null)
                {
                    Helper(node.First, d + 1);
                    Helper(node.Second, d + 1);
                }
                else
                {
                    for (var i = node.SegmentsStartIndexInclusive; i < node.SegmentsEndIndexExclusive; i++)
                    {
                        canvas.DrawLine(node.Segments[i].First, node.Segments[i].Second, StrokeStyle3);
                    }
                }
            }

            Helper(bvh, 0);
        }
 public static void DrawTriangulationQuadTree(this IDebugCanvas debugCanvas, Triangulation triangulation)
 {
     foreach (var island in triangulation.Islands)
     {
         var s = new Stack <Tuple <int, QuadTree <int> .Node> >();
         s.Push(Tuple.Create(0, island.TriangleIndexQuadTree.Root));
         while (s.Any())
         {
             var tuple = s.Pop();
             var depth = tuple.Item1;
             var node  = tuple.Item2;
             debugCanvas.DrawRectangle(node.Rect, 0.0f, new StrokeStyle(Color.Black));
             if (node.TopLeft != null)
             {
                 s.Push(Tuple.Create(depth + 1, node.TopLeft));
                 s.Push(Tuple.Create(depth + 1, node.TopRight));
                 s.Push(Tuple.Create(depth + 1, node.BottomLeft));
                 s.Push(Tuple.Create(depth + 1, node.BottomRight));
             }
         }
     }
 }