This topic is 4528 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ok, so I have my game coding working at the moment using a quadtree, but the fact it has no height is a bit of a pain in the a since everything else sits in three dimensions. I was thinking of coding an OctTree, but I don't want to have to maintain both. OctTree would certainly be nicer since my terrains will soon be getting bigger and taller. I was wondering if it's normal just to have an OctTree that is coded in such a way that it can also be used as a QuadTree? Is it normal for the QuadTree to be redundant after implementation of a QuadTree? Thanks!

##### Share on other sites
u can do a hybrib for a terrain say an quadtree thats 2 leafs high
an octree is way overkill

##### Share on other sites
It's okay to combine separate techniques and data structures for different parts of your code. For example, if you wanted to render your terrain which is stored as a Quadtree and render other objects as part of a Scene Graph or Octree or any other data structure, you could make a first pass by rendering the terrain, then make a second pass (without clearing certian buffers, such as the color or depth buffers) and both will end up in the rendered frame.

You can do this with several modules, as many as you'd like, (think about your GUI elements as another rendering pass) and maybe even go as far as considering the physics simulation and state machine as separate elements. The way you're going about it sounds good - you've finished coding the quadtree and you're thinking of coding a different data structure. They don't have to be exclusive in the sense that they can both be used *and* by doing them separately so that they can be as independent from each other as possible.
But, if you're worried about having to maintain them both, be sure to get the Quadtree finished and well tested (and used!) before moving on to the Octree.

A general hint: if you find yourself copying and pasting any code between separate implementations of techniques or data structures, consider encapsulating it so all you have to do later is copy an entire source file(s) (or object file, etc.) and you'll save time later if (when) you need it again.

• 40
• 15
• 10
• 23
• 19