From fab0fccc0aaa18e915bcd08e81e5a04177e435cd Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 21 Oct 2024 19:06:58 +0200 Subject: fix quad tree collision checker --- QuadTreeCollisionChecker.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 QuadTreeCollisionChecker.h (limited to 'QuadTreeCollisionChecker.h') 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 +#include + +#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 subtree[4] = { + nullptr, + nullptr, + nullptr, + nullptr, + }; + +private: + QuadTreeCollisionChecker(const QuadTreeCollisionChecker *, const Rectangle & boundary); + + const int capacity = 2; + + std::forward_list artists; + size_t artists_size = 0; + + Rectangle boundary; + + void subdivide(); + void cull(); +}; + + + -- cgit v1.2.3