Jump to content
  • Advertisement
Sign in to follow this  
Raeldor

QuadTree vs OctTree

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!