2dgeospatialspatialquadtree

Problem with huge objects in a quad tree


Let's say I have circular objects. Each object has a diameter of 64 pixels.

The cells of my quad tree are let's say 96x96 pixels.

Everything will be fine and working well when I check collision from the cell a circle is residing in + all it's neighbor cells.

BUT what if I have one circle that has a diameter of 512 pixels? It would cover many cells and thus this would be a problem when checking only the neighbor cells. But I can't re-size my quad-tree-grid every time a much larger object is inserted into the tree...


Solution

  • This an interesting problem. Maybe you can extend the node or the cell with a tree height information? If you have an object bigger then the smallest cell nest it with the tree height. That's what map's application like google or bing maps does.

    Here a link to a similar solution: http://www.gamedev.net/topic/588426-2d-quadtree-collision---variety-in-size. I was confusing the screen with the quadtree. You can check collision with a simple recusion.