diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-21 19:06:58 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-21 19:06:58 +0200 |
commit | fab0fccc0aaa18e915bcd08e81e5a04177e435cd (patch) | |
tree | 0e8e51ff61c88b60d1f845bc9fde20ea5ba7099b /QuadTreeCollisionChecker.h | |
parent | 10ce9f45b9551dc103272c2b2374db1c1e3b8bcb (diff) |
fix quad tree collision checker
Diffstat (limited to 'QuadTreeCollisionChecker.h')
-rw-r--r-- | QuadTreeCollisionChecker.h | 39 |
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(); +}; + + + |