Particle Game Maker Engine  1.0.0
Enables the user to create their own particle game using a simple and coherent api in the PongChamp scripting language
Public Member Functions | Public Attributes | List of all members
QuadTree Class Reference

A class to represent QuadTree. More...

#include <QuadTree.h>

Public Member Functions

 QuadTree (Point topL, Point botR)
 Construct a quadtree of bounds topL and botR. More...
 
void remove (Node *n)
 
void insert (Node *)
 
bool inBoundary (Point)
 Check if current quadtree contains the point. More...
 
void shrink ()
 

Public Attributes

Point topLeft
 
Point botRight
 
Nodenodes [QUAD_MAX] = {nullptr, nullptr, nullptr, nullptr}
 The particles of this Quadtree. More...
 
int size = 0
 The number of particles in this QuadTree including children. More...
 
int nextFreeNode = 0
 
bool treeHolder = false
 A bool stating whether this tree is a parent of other nodes. More...
 
QuadTree * parent
 Pointer to parent of this tree. More...
 
QuadTree * topLeftTree
 Top left child. More...
 
QuadTree * topRightTree
 Top right child. More...
 
QuadTree * botLeftTree
 bottom left child More...
 
QuadTree * botRightTree
 bottom right child More...
 

Detailed Description

A class to represent QuadTree.

Constructor & Destructor Documentation

QuadTree::QuadTree ( Point  topL,
Point  botR 
)

Construct a quadtree of bounds topL and botR.

Member Function Documentation

bool QuadTree::inBoundary ( Point  p)

Check if current quadtree contains the point.

void QuadTree::insert ( Node node)

INSERT Check if TreeHolder (in remove if this shouldn't be a tree holder anymore make it not) if Treeholder just go subtrees Check if space open in this tree yes-> put this node in here bro && add 1 to ur parent no-> make yourself a tree holder size is the sum of its children sizes

void QuadTree::remove ( Node n)

ONLY CALLED FROM NON-TREE Holders look for node to remove make sure list is adjacent remove the given point from the quadtree if it exists

void QuadTree::shrink ( )

SHRINK shrink the tree starting from this quadtree, shrinks subtrees and then if this tree size is 4 then it can assume its subtrees are not treeholders. INVARIANT: after a tree is shrunk, size < QUAD_MAX => !treeholder

Member Data Documentation

QuadTree* QuadTree::botLeftTree

bottom left child

Point QuadTree::botRight
QuadTree* QuadTree::botRightTree

bottom right child

int QuadTree::nextFreeNode = 0
Node* QuadTree::nodes[QUAD_MAX] = {nullptr, nullptr, nullptr, nullptr}

The particles of this Quadtree.

QuadTree* QuadTree::parent

Pointer to parent of this tree.

int QuadTree::size = 0

The number of particles in this QuadTree including children.

Point QuadTree::topLeft
QuadTree* QuadTree::topLeftTree

Top left child.

QuadTree* QuadTree::topRightTree

Top right child.

bool QuadTree::treeHolder = false

A bool stating whether this tree is a parent of other nodes.


The documentation for this class was generated from the following files: