I've noticed in the logs a bit of a game of "telephone" going on with something I said about the effectiveness of the current quadtree a while back, and I was a bit confused in my description in the first place. Luckily, Sleek has shone a brilliant light into the discussion with an excellent demo application.
Basically, I was expecting something like this:
http://donar.umiacs.umd.edu/quadtree/points/prbuckquad.htmlBut phoku's implementation was more like this:
http://donar.umiacs.umd.edu/quadtree/rectangles/cifquad.htmlNote the way that in the first one, it takes at least a few dozen points before you get down to the smallest size box, while in the second, a single small rectangle will cause this. There are advantages and disadvantages to each approach, but since I was expecting the first, and only coming to grips with the second glimpse by glimpse, I was a bit baffled.
I do think we have a bit of a solution looking for a problem with the current quadtree approach. That is we took a quadtree optimized for one particular use, and then tried to figure out how to build our needs around it. Rather than go further down that path, I think it would be best to determine what we want to use the quadtree for, then build the quadtree (or quadtrees, or some other data structure) up around that.
Here are some general areas that seem like likely candidates. If someone knowledgable about these areas can comment on how they would like to utilize a quadtree (or other instance-locator), please do. That is very specifically what data you would expect want to pass in (e.g. top left and bottom right points in floating point model-layer-substrate coordinates), and what data you would want to get out (circular doubly linked list containing all rectangles intersecting the box described). Also, if you know of other areas that could potentially benefit from this sort of optimization, please add them. I'll try to fill in any gaps.
Rendering -- we only want to process and draw stuff that will actually show up. We don't want to have to check each object individually to know if it will show up or not.
User Instance Picking -- The user clicks (or just points) somewhere on the screen; the game needs to know what is there.
Pathfinding -- As the pathfinder looks around the map, it wants some way to tell if there is anything locally to avoid.
Radius effects -- A grenade goes off, or a poison cloud spreads through the air ducts. The damage dealing code needs to look for instances near them to damage without having to check every single instance to see if it is close. NPC/critter visibility would probably also fall into this category.