#pragma once #include #include #include namespace Geometry { template class QuadTree { public: struct Node { Node *parent; uint32_t childIndex; std::vector objects; Vector2 center; Vector2 radius; bool IsLeaf() const { return childIndex == 0xFFFFFFFF;} uint32_t TopLeftChildIndex() const { return childIndex;} uint32_t TopRightChildIndex() const { return childIndex+1;} uint32_t BottomLeftChildIndex() const { return childIndex+2;} uint32_t BottomRightChildIndex() const { return childIndex+3;} /// This assumes that the QuadTree contains unique objects and never duplicates void Remove(const T &object) { for (size_t i = 0; i < objects.size(); ++i){ if (objects[i] == object) { AssociateQuadTreeNode(object, 0); // Mark in the object that it has been removed from the QuadTree. std::swap(objects[i], objects.back()); objects.pop_back(); return; } } } AABB2D ComputeAABB() {} }; }; }