![]() |
ProtoTracer
1.0
Real-time 3D rendering and animation engine
|
Represents a quadtree for spatial partitioning of 2D entities. More...
#include <QuadTree.h>
Public Member Functions | |
QuadTree (const Vector2D &min, const Vector2D &max) | |
Constructs a QuadTree with specified bounds. | |
~QuadTree () | |
Destructor for the QuadTree class. | |
bool | Insert (Triangle2D *triangle) |
Inserts a triangle entity into the quadtree. | |
Node * | Intersect (const Vector2D &p) |
Finds the node intersecting with a given point. | |
void | Rebuild () |
Rebuilds the quadtree, recalculating all spatial partitions. | |
Private Member Functions | |
Node * | Intersect (Node *node, const Vector2D &p) |
Recursively finds the node intersecting with a given point. | |
Private Attributes | |
BoundingBox2D | bbox |
Bounding box representing the spatial extent of the quadtree. | |
Node | root |
Root node of the quadtree. | |
uint16_t | count = 0 |
Current count of entities in the quadtree. | |
Represents a quadtree for spatial partitioning of 2D entities.
Definition at line 22 of file QuadTree.h.
Constructs a QuadTree with specified bounds.
min | Minimum bounds of the quadtree. |
max | Maximum bounds of the quadtree. |
Definition at line 3 of file QuadTree.cpp.
~QuadTree | ( | ) |
Destructor for the QuadTree class.
Definition at line 5 of file QuadTree.cpp.
bool Insert | ( | Triangle2D * | triangle | ) |
Inserts a triangle entity into the quadtree.
triangle | Pointer to the Triangle2D entity to insert. |
Definition at line 7 of file QuadTree.cpp.
References count, Node::Insert(), and root.
Referenced by Rasterizer::Rasterize().
Finds the node intersecting with a given point.
p | The point to check for intersection. |
Definition at line 25 of file QuadTree.cpp.
References Intersect(), and root.
Recursively finds the node intersecting with a given point.
node | Pointer to the current node being checked. |
p | The point to check for intersection. |
Definition at line 15 of file QuadTree.cpp.
References BoundingBox2D::Contains(), Node::GetBBox(), Node::GetChildNodes(), Intersect(), and Node::IsLeaf().
Referenced by Intersect(), Intersect(), and Rasterizer::Rasterize().
void Rebuild | ( | ) |
Rebuilds the quadtree, recalculating all spatial partitions.
Definition at line 29 of file QuadTree.cpp.
References root, and Node::Subdivide().
Referenced by Rasterizer::Rasterize().
|
private |
Bounding box representing the spatial extent of the quadtree.
Definition at line 24 of file QuadTree.h.
|
private |
Current count of entities in the quadtree.
Definition at line 26 of file QuadTree.h.
Referenced by Insert().
|
private |
Root node of the quadtree.
Definition at line 25 of file QuadTree.h.
Referenced by Insert(), Intersect(), and Rebuild().