views:

673

answers:

3

i am writing a game in C++ and have a level consisting of many seperate meshes, each with their own vertex buffer. i am using vmmlib ( brilliant free gl compat. vector/matrix library ) to create my frustum culler and testing it against the bounding sphere of every mesh in the level. sadly my level can consist of up to 800 meshes and iterating through all of them each frame is slow. what is the best way of optimizing the code so that i don't have to look at all of the meshes on every iteration? Bounding volumes inside the frustum?

+2  A: 

Binary space partitioning or its cousin Quadtree.

eed3si9n
+4  A: 

Yes bounding object is the way to go, you should take care in choosing an adequate bounding volume, for example for meshes that move about the scene like bots and dont lie down a cylinder is the best volume, other are better represented by cubes (axis aligned or not).

Then you create a quadtree or octree to hierarchically divide the mesh data.

This works very well for outdoor frustrum culling.

For indoors a BSP is the best way to go since you have lots of walls to partition your space. You should still volume bound your meshes that have more than 10 polygons.

Caerbanog
+2  A: 

I just wanted to add that now a days portals are generally preferred over or in conjunction with BSP's, but I don't have enough reputation to edit the original post.

BigSandwich