1 // Copyright (C) 2008 Tim Moore
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #ifndef SIMGEAR_QUADTREEBUILDER_HXX
17 #define SIMGEAR_QUADTREEBUILDER_HXX 1
20 #include <osg/ref_ptr>
28 // Create a quad tree based on x, y extents
29 class QuadTreeBuilder {
31 QuadTreeBuilder(const osg::Vec2& min, const osg::Vec2& max);
33 osg::Group* getRoot() { return _root.get(); }
34 // Add node to the quadtree using its x, y
35 void addNode(osg::Node* node, const osg::Matrix& transform);
36 // Make a quadtree of nodes from a vector of nodes
37 static osg::Group* makeQuadTree(std::vector<osg::ref_ptr<osg::Node> >& nodes,
38 const osg::Matrix& transform);
40 osg::ref_ptr<osg::Group> _root;
41 osg::Group* _leaves[4][4];