Quadtree transforms
authorDavid Gow <[email protected]>
Mon, 14 Jul 2014 01:24:00 +0000 (09:24 +0800)
committerDavid Gow <[email protected]>
Mon, 14 Jul 2014 01:24:00 +0000 (09:24 +0800)
src/Makefile
src/quadtree.h
src/view.cpp

index 64408ed..ce6ac42 100644 (file)
@@ -3,7 +3,7 @@ ARCH := $(shell uname -m)
 # TODO: stb_truetype doesn't compile with some of these warnings.
 CXX = g++ -std=gnu++0x -g -Wall -Werror -Wshadow -pedantic -rdynamic
 MAIN = main.o
 # TODO: stb_truetype doesn't compile with some of these warnings.
 CXX = g++ -std=gnu++0x -g -Wall -Werror -Wshadow -pedantic -rdynamic
 MAIN = main.o
-OBJ = log.o real.o bezier.o document.o objectrenderer.o view.o screen.o vfpu.o graphicsbuffer.o framebuffer.o shaderprogram.o stb_truetype.o gl_core44.o add_digits_asm.o sub_digits_asm.o mul_digits_asm.o div_digits_asm.o arbint.o
+OBJ = log.o real.o bezier.o document.o objectrenderer.o view.o screen.o vfpu.o quadtree.o graphicsbuffer.o framebuffer.o shaderprogram.o stb_truetype.o gl_core44.o add_digits_asm.o sub_digits_asm.o mul_digits_asm.o div_digits_asm.o arbint.o
 LIB_x86_64 = ../contrib/lib/libSDL2-2.0.so.0 -lGL -lgmp
 LIB_i386 = ../contrib/lib32/libSDL2-2.0.so.0 -lGL -lgmp
 
 LIB_x86_64 = ../contrib/lib/libSDL2-2.0.so.0 -lGL -lgmp
 LIB_i386 = ../contrib/lib32/libSDL2-2.0.so.0 -lGL -lgmp
 
index d5eddd8..29d60ba 100644 (file)
@@ -6,6 +6,7 @@
 
 
 #include "common.h"
 
 
 #include "common.h"
+#include "ipdf.h"
 
 namespace IPDF
 {
 
 namespace IPDF
 {
@@ -46,6 +47,9 @@ namespace IPDF
                QuadTreeIndex root_id;
                std::vector<QuadTreeNode> nodes;
        };
                QuadTreeIndex root_id;
                std::vector<QuadTreeNode> nodes;
        };
+
+       Rect TransformToQuadChild(const Rect& src, QuadTreeNodeChildren child_type);
+       Rect TransformFromQuadChild(const Rect& src, QuadTreeNodeChildren child_type);
 }
 
 #else
 }
 
 #else
index 02859c5..aaf7aae 100644 (file)
@@ -135,13 +135,20 @@ void View::Render(int width, int height)
 #ifndef QUADTREE_DISABLED
 void View::RenderQuadtreeNode(int width, int height, QuadTreeIndex node, int remaining_depth)
 {
 #ifndef QUADTREE_DISABLED
 void View::RenderQuadtreeNode(int width, int height, QuadTreeIndex node, int remaining_depth)
 {
+       Rect old_bounds = m_bounds;
        if (node == QUADTREE_EMPTY) return;
        if (!remaining_depth) return;
        RenderRange(width, height, m_document.GetQuadTree().nodes[node].object_begin, m_document.GetQuadTree().nodes[node].object_end);
        if (node == QUADTREE_EMPTY) return;
        if (!remaining_depth) return;
        RenderRange(width, height, m_document.GetQuadTree().nodes[node].object_begin, m_document.GetQuadTree().nodes[node].object_end);
+
+       m_bounds = TransformToQuadChild(old_bounds, QTC_TOP_LEFT);
        RenderQuadtreeNode(width, height, m_document.GetQuadTree().nodes[node].top_left, remaining_depth-1);
        RenderQuadtreeNode(width, height, m_document.GetQuadTree().nodes[node].top_left, remaining_depth-1);
+       m_bounds = TransformToQuadChild(old_bounds, QTC_TOP_RIGHT);
        RenderQuadtreeNode(width, height, m_document.GetQuadTree().nodes[node].top_right, remaining_depth-1);
        RenderQuadtreeNode(width, height, m_document.GetQuadTree().nodes[node].top_right, remaining_depth-1);
+       m_bounds = TransformToQuadChild(old_bounds, QTC_BOTTOM_LEFT);
        RenderQuadtreeNode(width, height, m_document.GetQuadTree().nodes[node].bottom_left, remaining_depth-1);
        RenderQuadtreeNode(width, height, m_document.GetQuadTree().nodes[node].bottom_left, remaining_depth-1);
+       m_bounds = TransformToQuadChild(old_bounds, QTC_BOTTOM_RIGHT);
        RenderQuadtreeNode(width, height, m_document.GetQuadTree().nodes[node].bottom_right, remaining_depth-1);
        RenderQuadtreeNode(width, height, m_document.GetQuadTree().nodes[node].bottom_right, remaining_depth-1);
+       m_bounds = old_bounds;
 }
 #endif
 
 }
 #endif
 

UCC git Repository :: git.ucc.asn.au