Updating terrain lod and rendering a terrain quadtree

Started by
2 comments, last by Charon 18 years, 1 month ago
What is the best way to update a quadtree for lod, and render it? Should I go through the quadtree once for updating and then again for rendering, or is it best to have a flag be sent in the update and during render, I just have to go through my Quadtree and just look for anything with a flag set to true and render that? Currently my quadtree ends at the size of my terrain patches, should I make a new quadtree and fill it with objects, or use the same quadtree, but just make it go smaller?
There is no life without honor
Advertisement
I'm currently having it this way.

During render, I check if a chunk is in the frustum.
If it is, a "IsVisible" bool gets true else "IsVisible" = false.

each game object has a parent chunk, and if that chunk is !IsVisible, then the object doesn't get drawn either :)


To answer your question: Don't loop through the terrain twice, simply update it as you go. :)
"Game Maker For Life, probably never professional thou." =)
I found this article most useful when setting up my quadtree and frustum culling.

The optimisations he suggests do in fact make a difference so it is well worth trying them out [smile]

With regards to the boolean isVisible. I personally use an integer equal to the frame number. So if I find a node to be within the frustum, I set it's frame integer equal to the current frame counter. Then, when looping through to determine lods and then again to render. I have a check for if(node.frame == frameCounter) etc.
The benefits of this were outlined in a flipcode thread a while ago but I cant find the link [wink] I just find it to be a lot more robust than a boolean yes/no and definately helps during debugging. I then reset to frame counter back to 0 after it reaches a certain value.

Regards,
ViLiO
Richard 'ViLiO' Thomasv.net | Twitter | YouTube
you could also put a pointer to every visible node into a special "renderqueue" (i.e. a vector or list).
this way you only have to traverse the scenegraph only once and have the added benefit that you can now easily sort your renderable objects (to minimize state-changes and back-to-front rendering for translucent objects)

chaos, panic and disorder - my work here is finished

This topic is closed to new replies.

Advertisement