I need some pointers on how to store/render my terrain. I am developing a game in which the key aspects are realistic physics and dynamic scenery/objects. For example, a bomb explodes and makes a crater in the terrain or bends a pipe. Large area is also important because almost all of the game will be outside. The terrain and various features will be auto-generated.
Currently I have verticies stored in a list, and triangles in a list. The triangles are structures and have 3 pointers, a,b,c, that point to the cooresponding verts. Many tris share verts, and that is important. When I deform the object/terrain, I can just reposition the vertex(es) and the tris will automatically be changed.
I have a quadtree class (C/C++) but I am unsure how to use it exactly. Each leaf is a fixed size, and each node contains 4 subnodes or 4 leaves. When I expand the map size, it creates a new ‘master’, or top-level, node.
The reason I used lists (actually, my own list implementation) is that they can easily be added or removed without large realloc’s. I don’t think I need to reference them by index. The triangles are similar; each quadtree leaf has a list of pointers to tris. Lists are slow to iterate, though, so I was thinking of doing a dynamic array for the triangle pointers in each leaf. Would a display list or vertex array type thing work efficiently if I only included one leaf in each?
I get around 50-60 fps with 64k tris in the list.
The problem is that I need an efficient way to render my terrain, probably with LOD. I need to know the best way to store the triangle/vertex data to work well with both graphics and physics (which needs actual triangles for accurate collision).
I am willing to use an existing engine, as long as I can easily manipulate the data dynamically. Any pointers at all would be helpful.