Quadtree dilemma

Started by
12 comments, last by CC Ricers 11 years, 3 months ago
How many objects are you likely to have that can move freely between nodes?

You can either have all objects at the leaf nodes and allow them to belong to up to 4 nodes, or only allow them to belong to one and if they happen to be spanning nodes, then move them up the tree until they are enclosed by only one. If your quadtree is only 2 levels deep (i.e.the root node and its children) then that will mean the objects will go into the root, but I would imagine that if your camera can move around the whole scene and it's fairly sizeable, you'd want far more levels.

If your game area is quite big and your objects are small, then the chances of them straddling nodes is pretty minimal. It all depends on how busy your scene is and how much depth you have in your quadtree. You can set this up fairly painlessly and just do some tests to see which way works best for you...
Advertisement
Wait, is this where frustum culling kicks in? I think I see how this works now. The worst case isn't drawing a large amount of objects from the root, it's culling all those objects, and then drawing just the ones inside the frustum.
Yes, the ideal situation is that you are able to split your world into 'manageable' chunks and only draw what's in that 'conceptual' chunk if any part of it is in the frustum.

The quadtree concept works like this:

Check if the root node 'box' is in the camera frustum - if it isn't, then you draw nothing and rendering is complete.

If any part of it is in the frustum, you then look at it's 4 children recursively and check to see if any part of them are in the frustum, you then continue down the tree until you've either reached the smallest box (the leaf node), in which case you draw all of the objects within it, or just ignore it if it's empty.

You can quickly see that large parts of the game world can be ignored very quickly. The whole notion is "if I can't see a box on the screen, then ill never be able to see any of its 4 children (this happens recursively), and hence any of the objects that live in that box."

A quick side note that someone pointed out the other day on a similar topic, if a quad node at any particular level is contained entirely within the frustum, you know that all its children will also be in the frustum so you can stop drilling down and draw everything below that node.
Wait, is this where frustum culling kicks in? I think I see how this works now. The worst case isn't drawing a large amount of objects from the root, it's culling all those objects, and then drawing just the ones inside the frustum.
Now you’ve got it.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Wait, is this where frustum culling kicks in? I think I see how this works now. The worst case isn't drawing a large amount of objects from the root, it's culling all those objects, and then drawing just the ones inside the frustum.
Now you’ve got it.


L. Spiro

Great, I can get started with populating the tree. I think the worst case won't be as bad as I thought. On older hardware, I've culled around 10,000 objects by brute force before noticing any slowdown.

New game in progress: Project SeedWorld

My development blog: Electronic Meteor

This topic is closed to new replies.

Advertisement