-
Notifications
You must be signed in to change notification settings - Fork 1
/
Quadtree.h
63 lines (40 loc) · 1.01 KB
/
Quadtree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include "Application.h"
#include "MathGeoLib/include/MathGeoLib.h"
#define QUADTREE_MAX_ITEMS 2
class GameObject;
class QuadTreeNode;
class Quadtree
{
public:
Quadtree(AABB& box);
~Quadtree();
void Draw();
void Insert(GameObject * gameObject);
void Remove(GameObject * gameObject);
void Clear();
public:
QuadTreeNode* tree_node = nullptr;
};
class QuadTreeNode {
friend class Quadtree;
public:
QuadTreeNode(AABB& box);
~QuadTreeNode();
void Insert(GameObject * col);
void Split();
void Redistribute();
bool SendToChilds(GameObject * gameObject);
bool Remove(GameObject * gameObject);
//void RemoveChilds(GameObject * gameObject, uint & i);
void RemoveChilds();
void GetChilds(std::vector<GameObject*>& vector, QuadTreeNode * cur_node);
void Draw();
QuadTreeNode* newQuadTreeNode(QuadTreeNode* parent, uint corner);
std::vector<GameObject*> bucket;
private:
AABB box;
//std::vector<GameObject*> bucket;
QuadTreeNode* parent = nullptr;
std::vector<QuadTreeNode*> childs;
};