aboutsummaryrefslogtreecommitdiff
path: root/QuadTreeCollisionChecker.h
blob: 420e0b78e6f97c1bb30be2b90e881c30067bed87 (plain)
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
#pragma once

#include <memory>
#include <forward_list>

#include "Artist.h"
#include "CollisionChecker.h"
#include "Rectangle.h"

class QuadTreeCollisionChecker : public CollisionChecker {
public:
	QuadTreeCollisionChecker(Museum &);
	virtual void check();

public:
	const Rectangle & get_boundary() { return this->boundary; }
	std::unique_ptr<QuadTreeCollisionChecker> subtree[4] = {
		nullptr,
		nullptr,
		nullptr,
		nullptr,
	};

private:
	QuadTreeCollisionChecker(const QuadTreeCollisionChecker *, const Rectangle & boundary);

	const int capacity = 2;

	std::forward_list<Artist *> artists;
	size_t artists_size = 0;

	Rectangle boundary;

	void subdivide();
	void cull();
};