aboutsummaryrefslogtreecommitdiff
path: root/QuadTreeCollisionChecker.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-21 19:06:58 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-21 19:06:58 +0200
commitfab0fccc0aaa18e915bcd08e81e5a04177e435cd (patch)
tree0e8e51ff61c88b60d1f845bc9fde20ea5ba7099b /QuadTreeCollisionChecker.h
parent10ce9f45b9551dc103272c2b2374db1c1e3b8bcb (diff)
fix quad tree collision checker
Diffstat (limited to 'QuadTreeCollisionChecker.h')
-rw-r--r--QuadTreeCollisionChecker.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/QuadTreeCollisionChecker.h b/QuadTreeCollisionChecker.h
new file mode 100644
index 0000000..420e0b7
--- /dev/null
+++ b/QuadTreeCollisionChecker.h
@@ -0,0 +1,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();
+};
+
+
+