Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
worldtreenode.h
1 #pragma once
2 
3 #include <list>
4 #include <set>
5 #include <vector>
6 
7 #include "geometry/aabb.h"
8 
9 
10 class WorldTreeGeode;
11 class WorldTreeNode;
12 
14 {
15 public:
16  WorldTreeNode(int octIndex, WorldTreeNode* parent, const IAABB &aabb);
17  WorldTreeNode(const IAABB &aabb, WorldTreeNode* initialSubnode);
18  virtual ~WorldTreeNode();
19 
20  void clear();
21 
22  int octIndex() const;
23  void setOctIndex(int octIndex);
24 
25  const IAABB& aabb() const;
26 
27  WorldTreeNode *parent();
28  const WorldTreeNode *parent() const;
29  void setParent(WorldTreeNode *parent);
30 
31  bool active() const;
32  void setActive(bool active);
33 
34  const std::list<WorldTreeGeode*>& geodes() const;
35  const std::list<WorldTreeNode*>& subnodes() const;
36 
37  bool isLeaf() const;
38  bool isEmpty() const;
39  bool isRootnode() const;
40  bool isAtomic() const;
41 
42  void insert(WorldTreeGeode* geode);
43  void remove(WorldTreeGeode* geode);
44 
45 
46 protected:
47  static const int MIN_EXTENT = 16;
48  static const int MAX_GEODES = 8;
49 
50  WorldTreeNode* m_parent;
51  IAABB m_aabb;
52  int m_octIndex;
53  float m_extent;
54  bool m_active;
55 
56  std::list<WorldTreeGeode*> m_normalGeodes;
57  std::list<WorldTreeGeode*> m_passiveGeodes;
58  std::vector<WorldTreeNode*> m_subnodes;
59  std::list<WorldTreeNode*> m_activeSubnodes;
60 
64  void convertToGroup(WorldTreeNode* initialSubnode = nullptr);
68  void moveToSubnode(WorldTreeGeode* geode, WorldTreeNode* subnode);
69 
70  void subnodeActivated(WorldTreeNode* subnode);
71  void subnodeDeactivated(WorldTreeNode* subnode);
72 
73  std::list<WorldTreeGeode*>& geodesList(WorldTreeGeode* geode);
74 
75 };
76 
Definition: worldtreegeode.h:11
void moveToSubnode(WorldTreeGeode *geode, WorldTreeNode *subnode)
Definition: worldtreenode.cpp:213
void convertToGroup(WorldTreeNode *initialSubnode=nullptr)
Definition: worldtreenode.cpp:174
Definition: worldtreenode.h:13