34 for (uint16_t i = 0; i < newCount; ++i) {
60 for (uint8_t i = 0; i < 4; ++i) {
83 uint16_t entityCount = 0;
86 for (uint8_t i = 0; i < 4; ++i) {
87 for (uint16_t j = 0; j <
count; ++j) {
100 return childEntitySum / 2 <
count;
Defines the Node class for quadtree spatial partitioning in 2D space.
Represents a 2D axis-aligned bounding box.
Vector2D GetCenter()
Gets the center point of the bounding box.
Vector2D GetMinimum()
Gets the minimum corner of the bounding box.
Vector2D GetMaximum()
Gets the maximum corner of the bounding box.
Represents a node in a quadtree structure for spatial partitioning.
BoundingBox2D * GetBBox()
Retrieves the bounding box of the node.
void Expand(uint16_t newCount)
Expands the node's capacity to accommodate more entities.
bool ShouldSubdivide(uint16_t childEntitySum)
Determines whether the node should be subdivided.
Triangle2D ** GetEntities()
Retrieves the entities contained in this node.
Triangle2D ** entities
Array of entities (triangles) contained in the node.
uint16_t capacity
Capacity of entities allocated in the node.
static const uint8_t maxDepth
Maximum depth of the quadtree.
~Node()
Destructor for the Node class.
BoundingBox2D bbox
Bounding box defining the spatial area of this node.
bool IsLeaf()
Checks if the node is a leaf node (i.e., has no child nodes).
uint16_t GetCount()
Retrieves the current count of entities in the node.
bool Insert(Triangle2D *triangle)
Inserts a triangle entity into the node.
void Subdivide(uint8_t depth=0)
Subdivides the node into child nodes if needed.
Node * childNodes
Pointer to the child nodes of this node.
uint16_t DistributeEntities()
Distributes entities to child nodes after subdivision.
static const uint16_t maxEntities
Maximum number of entities a node can hold before subdividing.
void CreateChildNodes()
Creates child nodes for this node.
Node(const Vector2D &min, const Vector2D &max)
Constructs a Node with specified bounds.
uint16_t count
Current number of entities in the node.
Node * GetChildNodes()
Retrieves the child nodes of this node.
Represents a 2D triangle with support for UV mapping, depth, and intersection testing.
bool DidIntersect(const float &x, const float &y, float &u, float &v, float &w)
Checks if a point intersects the triangle using barycentric coordinates.
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
float X
The X-component of the 2D vector.
float Y
The Y-component of the 2D vector.