   Render Queue, Octree, Entity
  Hello,I was trying to store triangles in an octree node. I thought that, with my entity system design its not possible because i am storing indices to 3 vertices in my triangle structure not the pointers to vertices. So, i thought its better to store entities in octree and create a render queue which stores the "not-culled" entities. If the entity is in multiple octrees it is splitted to culled and not-culled ones. And the not-culled ones are added to render queue. Then the Renderer renders the entities from Render Queue. Please advice my idea/design. And, one more thing. Which of them is efficient for destructible environment (like palms in Crysis): storing both vertices and triangles in sub-entities only or storing vertices in a parent entity and storing triangles in Sub-Entities. (I think the latter one is more efficient but i want to know your thoughts)Thanks,Kasya   
  Anyone?   ;  You dont need to cull at the triangle level. You need to cull at the draw call level, a draw call being a bunch of triangles.Your primary scene octree should only store the renderable entities. They should not be split up, if they overlap octree node boundaries then they are inserted into the parent node. Your render queue should only collect/store pointers to the renderable entities.You're not still using glVertex are you?   ;Quote:Your primary scene octree should only store the renderable entities. They should not be split up, if they overlap octree node boundaries then they are inserted into the parent node.Then that means i won't cull these entities at all if the camera is at the child node of the parent node.Quote:You're not still using glVertex are you?Of course not! :)   ;  How are you drawing your triangles? What are you using to draw the indices that you've queried? (that's the opposite of culling)Things are always going to overlap the AABB boundaries of tree nodes. Imagine that the player is moving across the boundary of the Nth layer of the tree. (maybe N is three or something) You would not want to register the player mesh with both tree nodes that it is intersecting or it will be drawn twice. Instead you register the mesh with the node that contains both the nodes that it's intersecting. This may likely be N-1, but could potentially be N=0.Then your query function looks like this:Node::Query( shape, results ){  if( Intersects( shape, mMyAABB )  {    results.Add( mItemsContainedInMe );    for( i = 0 to 7 ) mChildNodes.Query( shape, results );<br>  }<br>}<br></pre>;Quote:Original post by KasyaQuote:Your primary scene octree should only store the renderable entities. They should not be split up, if they overlap octree node boundaries then they are inserted into the parent node.Then that means i won't cull these entities at all if the camera is at the child node of the parent node.You can still throw a view frustum  test in there after you have your basic working set.As to what level of granularity you use for that is another matter; you might want to test everything or you might want to tag the cells which isn't completely in the view and only test objects in those cells.However, depending on the complexity of your objects and target hardware it might be just as good to render them anyway and let the gpu reject them itself.;Quote:How are you drawing your triangles? What are you using to draw the indices that you've queried? (that's the opposite of culling)i merge triangle indices in one index array, then i just do glDrawElements(GL_TRIANGLE_LIST, tris.size() * 3, GL_UNSIGNED_INT, 0);Thanks for the help on that.What do you think about my second question:Which of them is efficient for destructible environment (like palms in Crysis): storing both vertices and triangles in sub-entities only or storing vertices in a parent entity and storing triangles in sub-entities. (I think the latter one is more efficient but i want to know your thoughts)?Thanks,Kasya   