24 #ifndef GF_SPACE_TREE_H 25 #define GF_SPACE_TREE_H 36 #ifndef DOXYGEN_SHOULD_SKIP_THIS 55 using Callback = std::function<
bool(
const SpaceTree&)>;
99 bool splitOnce(
Random& random, Vector2i minSize,
float maxRatio = 1.5f);
110 void splitRecursive(
Random& random,
int levelMax, Vector2i minSize, Vector2i maxSize,
float maxRatio = 1.5f);
120 return !m_left && !m_right;
138 return m_right.get();
157 bool contains(Vector2i position)
const;
228 std::unique_ptr<SpaceTree> m_left;
229 std::unique_ptr<SpaceTree> m_right;
234 #ifndef DOXYGEN_SHOULD_SKIP_THIS A random engine.
Definition: Random.h:43
bool splitOnce(Random &random, Vector2i minSize, float maxRatio=1.5f)
Split the node once.
const SpaceTree * getRightChild() const
Get the right child.
Definition: SpaceTree.h:137
void splitRecursive(Random &random, int levelMax, Vector2i minSize, Vector2i maxSize, float maxRatio=1.5f)
Split a node recursively.
The namespace for gf classes.
Definition: Action.h:34
bool traversePreOrder(Callback callback) const
Traverse the nodes in pre-order.
const SpaceTree * getFather() const
Get the father of the node.
Definition: SpaceTree.h:148
const SpaceTree * find(Vector2i position) const
Find the deepest node containing a position.
bool traverseInvertedLevelOrder(Callback callback) const
Traverse the nodes in inverted level-order.
void removeChildren()
Remove the children of the node.
bool traverseInOrder(Callback callback) const
Traverse the nodes in in-order.
bool isLeaf() const
Check if a node is a leaf.
Definition: SpaceTree.h:119
const RectI & getArea() const
Get the area of the node.
Definition: SpaceTree.h:69
#define GF_API
Definition: Portability.h:35
Binary space random partionning tree.
Definition: SpaceTree.h:47
bool traverseLevelOrder(Callback callback) const
Traverse the nodes in level-order.
int getLevel() const
Get the level of the node in the tree.
Definition: SpaceTree.h:80
bool contains(Vector2i position) const
Check if the area of the node contains a position.
SpaceTree(const RectI &area)
Constructor.
const SpaceTree * getLeftChild() const
Get the left child.
Definition: SpaceTree.h:128
bool traversePostOrder(Callback callback) const
Traverse the nodes in post-order.