#ifndef OPENMW_COMPONENTS_TERRAIN_QUADTREENODE_H #define OPENMW_COMPONENTS_TERRAIN_QUADTREENODE_H #include #include "defs.hpp" namespace Terrain { enum ChildDirection { NW = 0, NE = 1, SW = 2, SE = 3, Root }; class QuadTreeNode : public osg::Group { public: QuadTreeNode(QuadTreeNode* parent, ChildDirection dir, float size, const osg::Vec2f& center); QuadTreeNode* getParent(); QuadTreeNode* getChild(unsigned int i); using osg::Group::getNumChildren; /// Returns our direction relative to the parent node, or Root if we are the root node. ChildDirection getDirection() { return mDirection; } /// Get neighbour node in this direction QuadTreeNode* getNeighbour (Direction dir); /// Initialize neighbours - do this after the quadtree is built void initNeighbours(); void setBoundingBox(const osg::BoundingBox& boundingBox); const osg::BoundingBox& getBoundingBox() const; virtual osg::BoundingSphere computeBound() const; /// size in cell coordinates float getSize() const; /// center in cell coordinates const osg::Vec2f& getCenter() const; virtual void traverse(osg::NodeVisitor& nv); private: QuadTreeNode* mParent; QuadTreeNode* mNeighbours[4]; ChildDirection mDirection; osg::BoundingBox mBoundingBox; float mSize; osg::Vec2f mCenter; }; } #endif