Optimieren Sie das Frustum -Keulen
-
05-07-2019 - |
Frage
Ich schreibe ein Spiel in C ++ und habe ein Level, das aus vielen separaten Maschen besteht, die jeweils ihren eigenen Scheitelpunktpuffer haben. Ich verwende VMMLIB (Brilliant Free GL Compat. Vektor/Matrixbibliothek), um meinen maklerischen Culler zu erstellen und ihn gegen die Grenzkugel jedes Netzes in der Ebene zu testen. Leider kann mein Level aus bis zu 800 meshs bestehen und durch alle, die jeder Rahmen durch sie iteriert, ist langsam. Was ist der beste Weg, um den Code zu optimieren, damit ich nicht alle Netze bei jeder Iteration betrachten muss? Begrenzungsvolumina im Frustum?
Lösung
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.
Andere Tipps
Binary space partitioning or its cousin Quadtree.
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.