优化视锥体剔除
我正在用 C++ 编写一个游戏,并且有一个由许多单独的网格组成的关卡,每个网格都有自己的顶点缓冲区。 我正在使用 vmmlib (出色的免费 gl compat.vector/matrix 库)来创建我的平截头体剔除器,并针对关卡中每个网格的边界球体对其进行测试。 遗憾的是,我的关卡最多可以包含 800 个网格,并且每帧迭代所有网格的速度都很慢。 优化代码的最佳方法是什么,这样我就不必在每次迭代时查看所有网格? 截锥体内的边界体积?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,边界对象是要走的路,您应该注意选择足够的边界体积,例如,对于像机器人一样在场景中移动并且不躺下的网格物体,圆柱体是最好的体积,其他体积更好地用立方体(轴对齐或不对齐)。
然后创建四叉树或八叉树来分层划分网格数据。
这对于户外截头体剔除非常有效。
对于室内,BSP 是最好的选择,因为您有很多墙壁来分隔空间。 您仍然应该对具有超过 10 个多边形的网格进行体积限制。
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.
二进制空间分区或其同类四叉树。
Binary space partitioning or its cousin Quadtree.
我只是想补充一点,现在门户网站通常比 BSP 更受欢迎或与 BSP 结合使用,但我没有足够的声誉来编辑原始帖子。
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.