Quadtree for 2D collision detection
I'm trying to use a quadtree for 2D collision detection, but I'm a little stumped on how to implement it. First of all, I'd have a quadtree which contains four subtrees (one representing each quadrant), as well as a collection of objects which don't fit into a single subtree. When checking an object for collisions in the tree, I would do something like this (thanks to QuadTree for 2D collision detection ): Check the object for collisions with any objects in the current node. For any subtree whose space overlaps the object, recurse. To find all collisions within a quadtree tree: Check each