X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fdocument.cpp;h=041519c09d0744ce1524ecac65f188d37c735f0a;hp=921763a827590e89d5a3d8cbfd6a830387e417ea;hb=8e97d741cf713296c96b53f4ebb1615e8d443391;hpb=f59f24dff392428d7219ba2d6be5e1e81c344ee0 diff --git a/src/document.cpp b/src/document.cpp index 921763a..041519c 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -85,6 +85,17 @@ void Document::Save(const string & filename) Debug("Successfully saved %u objects to \"%s\"", ObjectCount(), filename.c_str()); } +#ifndef QUADTREE_DISABLED + +void Document::GenBaseQuadtree() +{ + m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, 1, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QTC_UNKNOWN, 0, 1}); + m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QTC_UNKNOWN, 1, ObjectCount()}); + m_quadtree.root_id = 0; +} + +#endif + void Document::Load(const string & filename) { m_objects.bounds.clear(); @@ -132,6 +143,12 @@ void Document::Load(const string & filename) } } Debug("Successfully loaded %u objects from \"%s\"", ObjectCount(), filename.c_str()); +#ifndef QUADTREE_DISABLED + if (m_quadtree.root_id == QUADTREE_EMPTY) + { + GenBaseQuadtree(); + } +#endif } void Document::Add(ObjectType type, const Rect & bounds, unsigned data_index)