public void DebugDraw() { AABBExtension.DebugDrawAABB(Bounds, RayConfig.QUAD_TREE_COLOR); foreach (AABB aabb in AABBs) { AABBExtension.DebugDrawAABB(aabb); } if (m_NorthEast == null) { return; } else { m_NorthWest.DebugDraw(); m_NorthEast.DebugDraw(); m_SouthWest.DebugDraw(); m_SouthEast.DebugDraw(); } }
public bool Insert(AABB newAABB) { //AABB does not overlap with the quadtree, you should not add it if (!AABBExtension.OverlapsAABB(Bounds, newAABB)) { return(false); } //check if there is space to insert left && check if tree has been subdivided yet if (!isFull() && !HasBeenSubdivided()) { AABBs.Add(newAABB); return(false); } //else this tree needs to be subdivided if (m_NorthWest == null) { Subdivide(); } //insert in subdivisions, return true if you succesfully inserted bool succesufull = false; if (m_NorthWest.Insert(newAABB)) { succesufull = true; } if (m_NorthEast.Insert(newAABB)) { succesufull = true; } if (m_SouthEast.Insert(newAABB)) { succesufull = true; } if (m_SouthWest.Insert(newAABB)) { succesufull = true; } return(succesufull); }