A data structure based on the R-Tree: creating new child nodes when a node is full, but what if I ha

Posted by Tom on Stack Overflow See other posts from Stack Overflow or by Tom
Published on 2010-05-24T09:57:14Z Indexed on 2010/05/24 10:01 UTC
Read the original article Hit count: 166

I realize my title is not very clear, but I am having trouble thinking of a better one. If anyone wants to correct it, please do.

I'm developing a data structure for my 2 dimensional game with an infinite universe. The data structure is based on a simple (!) node/leaf system, like the R-Tree.

This is the basic concept: you set howmany childs you want a node (a container) to have maximum. If you want to add a leaf, but the node the leaf should be in is full, then it will create a new set of nodes within this node and move all current leafs to their new (more exact) node. This way, very populated areas will have a lot more subdivisions than a very big but rarely visited area.

This works for normal objects. The only problem arises when I have more than maxChildsPerNode objects with the exact same X,Y location: because the node is full, it will create more exact subnodes, but the old leafs will all be put in the exact same node again because they have the exact same position -- resulting in an infinite loop of creating more nodes and more nodes.

So, what should I do when I want to add more leafs than maxChildsPerNode with the exact same position to my tree?

PS. if I failed to explain my problem, please tell me, so I can try to improve the explanation.

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about data-structures