Need some help with my quadtree

Started by
0 comments, last by CRACK123 18 years, 9 months ago
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.
Advertisement
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.




The more applications I write, more I find out how less I know

This topic is closed to new replies.

Advertisement