-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuadtree.h
52 lines (39 loc) · 1017 Bytes
/
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
#ifndef QUADTREE_HPP
#define QUADTREE_HPP
#include <vector>
#include "GameObject.h"
using namespace std;
class QuadTree {
public:
QuadTree(float x,
float y,
float width,
float height,
int level,
int maxLevel,
QuadTree* parent);
~QuadTree();
vector<GameObj*> getObjectsAt(float x, float y, int layer = 0) const;
vector<GameObj*> getAllObjects() const;
void addObject(GameObj *object);
void clear();
void update(const std::vector<GameObj*>& objects);
void render(ID2D1HwndRenderTarget* renderTarget, ID2D1SolidColorBrush* brush);
private:
float _x;
float _y;
float _width;
float _height;
int _level;
int _maxLevel;
vector<GameObj*> _objects;
QuadTree * _parent;
QuadTree * _nw;
QuadTree * _ne;
QuadTree * _sw;
QuadTree * _se;
bool contains(QuadTree* child, GameObj* object);
bool hasAnyLayer(GameObj* object, int layer) const;
std::vector<GameObj*> getObjectsAtLayer(int layer) const;
};
#endif //QUADTREE_HPP