优化视锥体剔除

发布于 2024-07-06 11:27:12 字数 229 浏览 9 评论 0原文

我正在用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

忘东忘西忘不掉你 2024-07-13 11:27:12

是的,边界对象是要走的路,您应该注意选择足够的边界体积,例如,对于像机器人一样在场景中移动并且不躺下的网格物体,圆柱体是最好的体积,其他体积更好地用立方体(轴对齐或不对齐)。

然后创建四叉树或八叉树来分层划分网格数据。

这对于户外截头体剔除非常有效。

对于室内,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.

囍孤女 2024-07-13 11:27:12

我只是想补充一点,现在门户网站通常比 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文