quadtrees and moving objects

Hi,

I need a pointer on the whole quadtree thing… Imagine there is a 2d space shooter game consisting of a lot of asteroids, ships, baseships and so on. The whole “world” is at least, say 100 x 100 Screens big, the user can fly around as he likes. My first thought was to divide the space with a quadtree to optimize the amount of draw calls. In every node would be a couple of game objects. Due to the nature of space shooter the objects move. If one object leaves a node I just have to delete it from the old and move it to a new one and so on. Thats not the problem. But what happens if I got a big baseship or something similiar that moves from one node to another ( see attachment)

There is a point in time, when I have to move the object from one node to another. At first glance I would say that is when the center of the object is now in the new node. But if I move the ship in that moment, it is clipped from screen but it should be seen a bit longer.

So my question is: How do you handle this, and is a quadtree the right tool for moving objects?

Put the item that overlaps nodes, in the ‘parent’ node (recursively, until it fits in 1 node) - then not only leafs have objects stored.

Sounds like a problem for scenegraphy engine.

Just check every node that’s adjacent to the screen for sprites in them that need to be drawn.

Even if you used the top-left corner (or whatever) instead of the center of the sprite for determining which node the sprite is in, you would still have the same problem in some cases.

If the item overlaps X nodes, you’d have to render a LOT of nodes outside the screen. To prevent that, use my previously posted solution.

Thanks for your comments.
I will try to implement the method Riven suggested.

Recently I thought about another tree to implement a scenegraph: R Tree The wiki entry is not so good, so if you want to know more read this paper.
This tree is made to handle spatial data in multiple dimensions… in this case it’s only 2 dimensional and would hold rectangles. The nodes itself can overlap and their boundaries can grow, if you add new items to a node. The tree supports searching in areas for example questions like: which nodes are inside this arbitrary rectangle. If a nodes covered area gets to big, it’s splitted up in smaller nodes similiar to quadtrees.
Advantages: moving objects just cause a node to grow, the don’t leave the node -> this means you have to check the size from time to time, if it’s to big -> split nodes
Disadvantages: I guess collision detection doesn’t work so well, or is harder to implement

I didn’t test this kind of tree yet, I just had spend a couple of moments to think about it… what do you guys think?