+
+ // Otherwise, we'll arbitrarily select the bottom-right.
+ // TODO: Perhaps select based on greatest area?
+ while (m_bounds.w < 0.5 || m_bounds.h < 0.5)
+ {
+ if (m_document.GetQuadTree().nodes[m_current_quadtree_node].bottom_right == QUADTREE_EMPTY)
+ {
+ // We want to reparent into a child node, but none exist. Get the document to create one.
+ m_document.GenQuadChild(m_current_quadtree_node, QTC_BOTTOM_RIGHT);
+ m_render_dirty = true;
+ }
+ m_bounds = TransformToQuadChild(m_bounds, QTC_BOTTOM_RIGHT);
+ m_current_quadtree_node = m_document.GetQuadTree().nodes[m_current_quadtree_node].bottom_right;
+ }
+ g_profiler.EndZone();
+ }
+
+ m_screen.DebugFontPrintF("Current View QuadTree");
+ QuadTreeIndex overlay = m_current_quadtree_node;
+ while (overlay != -1)
+ {
+ m_screen.DebugFontPrintF(" Node: %d (objs: %d -> %d)", overlay, m_document.GetQuadTree().nodes[overlay].object_begin,
+ m_document.GetQuadTree().nodes[overlay].object_end);
+ overlay = m_document.GetQuadTree().nodes[overlay].next_overlay;
+ }
+ m_screen.DebugFontPrintF("\n");
+ m_screen.DebugFontPrintF("Left: %d, Right: %d, Up: %d, Down: %d\n",
+ m_document.GetQuadTree().GetNeighbour(m_current_quadtree_node, -1, 0, 0),
+ m_document.GetQuadTree().GetNeighbour(m_current_quadtree_node, 1, 0, 0),
+ m_document.GetQuadTree().GetNeighbour(m_current_quadtree_node, 0, -1, 0),
+ m_document.GetQuadTree().GetNeighbour(m_current_quadtree_node, 0, 1, 0));
+
+
+ Rect view_top_bounds = m_bounds;
+ QuadTreeIndex tmp = m_current_quadtree_node;
+ while (tmp != -1)
+ {
+ view_top_bounds = TransformFromQuadChild(view_top_bounds, m_document.GetQuadTree().nodes[tmp].child_type);
+ tmp = m_document.GetQuadTree().nodes[tmp].parent;