Sign in to follow this  

Need some help with my quadtree

This topic is 4545 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

Well I've got my heightmap data into a quadtree. Now i'd like to do some simple culling. My plan is to have a recursive function that take in an axis-aligned rectangle and a nodeid. with the function in the form of:(pseudocode)
void CullbyRect(boundingRect, nodeid)
{

static Uint currentVert;
if(IntersectAARect(quadtree[nodeid].bounding, boundingRect)
{
   if(quadtree[nodeid].isleaf)
   { 
      //add data to a list of sorts, problem A.
   }
   else //its not a leaf
   {
      CullbyRect(boundingRect, quadtree[nodeid].children[0]);
      //etc...
   }
}

}
The problems im having are: Not sure howto calculate how many leaves(or node) would be visible for a given bounding rect. and I can't figure out howto store and move the data, right now im storing it in the leaves of my quadtree and memcpy'ing it out which is an access violation nightmare for me. I was thinkin storing only indices to a master array of sorts in the quadtree, is this a better solution? Edit: I have a few somewhat related Q's so ill ask them here. Are there any real benefits to using triangle strips as opposed to quadstrips? Are strips faster than full primitives significantly(it seems it should be since the amount of data is reduced)? Im using opengl btw. I also have some ogl questions, Ill probably start a thread about them in OpenGL subforum. Between glDrawArrays() and glInterleavedArrays() which is better(coding time/difficulty not important) and if ya could whats the point of glInterleavedArrays.

Share this post


Link to post
Share on other sites
Hi,

Use a std::vector and push back the list of indices into the node once u know they exist. This should solve problem A. However if you seperate indices for normals, textures and vector then its a different story.

With glInterleavedArrays you can specify everything at once - ie color, vertex, normals etc. However I think glVertexPointer, normalPointer etc and glDrawElements allow for more flexibility.




Share this post


Link to post
Share on other sites

This topic is 4545 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this