FIFE
2008.0
|
#include <quadtree.h>
Public Member Functions | |
QuadNode (QuadNode *parent, int x, int y, int size) | |
QuadNode * | find_container (int x, int y, int w, int h) |
template<typename Visitor > | |
void | apply_visitor (Visitor &visitor, int d=0) |
int | x () const |
int | y () const |
int | size () const |
DataType & | data () |
bool | contains (int x, int y, int w, int h) const |
void | splice () |
Expand the subnodes - only needed for debugging/profiling worst cases. | |
QuadNode * | parent () |
QuadNode * | create_parent (int x, int y, int w, int h) |
QuadTree Node
Definition at line 41 of file quadtree.h.
|
inline |
|
inline |
Apply a visitor recursively to the QuadTree A visitor is an object which has a visit
method which takes as parameters a pointer to a QuadNode
and an integer. The integer is the depth of the given node. If the method returns true
it is applied recursivly to all existing subnodes with a depth increased by one. The application happens in Z order (top left, top right, bottom left and finally bottom right).
Definition at line 93 of file quadtree.h.
References FIFE::QuadNode< DataType, MinimumSize >::apply_visitor().
Referenced by FIFE::QuadNode< DataType, MinimumSize >::apply_visitor(), and FIFE::QuadTree< InstanceList, kTreeDepth >::apply_visitor().
|
inline |
Check whether a rectangle is contained in the node. A rectangle is contained in a node, iff:
That is the top and left borders are inclusive, but the right and bottom borders are exclusive.
Definition at line 211 of file quadtree.h.
QuadNode< DataType, MinimumSize > * FIFE::QuadNode< DataType, MinimumSize >::create_parent | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
Create a new parent node for a rectangle This will create a new parent node end expand the tree so that the given rectangle will eventually be contained after enough calls of this function.
Definition at line 298 of file quadtree.h.
Referenced by FIFE::QuadTree< DataType, MinimumSize >::find_container().
|
inline |
Return a reference to the data of the node.
Definition at line 116 of file quadtree.h.
QuadNode< DataType, MinimumSize > * FIFE::QuadNode< DataType, MinimumSize >::find_container | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
Find a container node for a given rectangle. This guarantees to return a Node with the following properties: 1.) The node contains the rectangle (as defined by the contains function). 2.) All subnodes can not contain the rectangle or it has the MinimumSize. 3.) In case these properties can only be fulfilled by extending the tree upwards, that is by creating a new root node - this function will return null.
This function will extend the tree automatically so that this guarantee can be fulfilled.
Definition at line 254 of file quadtree.h.
References FIFE::QuadNode< DataType, MinimumSize >::find_container().
Referenced by FIFE::QuadNode< DataType, MinimumSize >::find_container(), and FIFE::QuadTree< DataType, MinimumSize >::find_container().
|
inline |
Return the parent node
Definition at line 133 of file quadtree.h.
|
inline |
Return the size (width and height) of the node.
Definition at line 112 of file quadtree.h.
|
inline |
Return the X position of the node.
Definition at line 104 of file quadtree.h.
|
inline |
Return the Y position of the node.
Definition at line 108 of file quadtree.h.