forked from teamnwah/openmw-tes3coop
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
8 years ago
|
#ifndef OPENMW_COMPONENTS_TERRAIN_QUADTREENODE_H
|
||
|
#define OPENMW_COMPONENTS_TERRAIN_QUADTREENODE_H
|
||
|
|
||
|
#include <osg/Group>
|
||
|
|
||
|
#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
|