如何测试给定的 BSP 树是否最优?

发布于 2024-07-06 18:13:58 字数 303 浏览 10 评论 0原文

我有一个三角形的多边形汤,我想为其构建一个 BSP 树。 我当前的程序只是通过从模型中一次插入一个随机三角形来构建一棵 BSP 树,直到所有三角形都被消耗为止,然后它检查树的深度和广度并记住它获得的最佳分数(最低深度、最低宽度) )。

根据定义,最佳深度为 log2(n)(或者如果共面三角形分组则更小?),其中 n 是模型中三角形的数量,最佳宽度为 n(意味着没有发生分裂)。 但是,某些三角形的配置永远无法达到这个顶峰。

是否有有效的测试来检查 BSP 树的质量? 具体来说,我试图找到一种方法让我的程序知道它应该停止寻找更优化的结构。

I have a polygon soup of triangles that I would like to construct a BSP tree for. My current program simply constructs a BSP tree by inserting a random triangle from the model one at a time until all the triangles are consumed, then it checks the depth and breadth of the tree and remembers the best score it achieved (lowest depth, lowest breadth).

By definition, the best depth would be log2(n) (or less if co-planar triangles are grouped?) where n is the number of triangles in my model, and the best breadth would be n (meaning no splitting has occurred). But, there are certain configurations of triangles for which this pinnacle would never be reached.

Is there an efficient test for checking the quality of my BSP tree? Specifically, I'm trying to find a way for my program to know it should stop looking for a more optimal construction.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

我早已燃尽 2024-07-13 18:13:58

最优树的构建是一个NP完全问题。 确定给定的树是否是最优的本质上是同一个问题。

从这个 BSP 常见问题

问题是分裂与
树平衡。 这些都是相互的
独家要求。 你应该
选择你的策略来构建
好树取决于你的意图
使用树。

Construction of an optimal tree is an NP-complete problem. Determining if a given tree is optimal is essentially the same problem.

From this BSP faq:

The problem is one of splitting versus
tree balancing. These are mutually
exclusive requirements. You should
choose your strategy for building a
good tree based on how you intend to
use the tree.

花开浅夏 2024-07-13 18:13:58

在找到一棵好的 BSP 树之前随机构建 BSP 树的效率真的非常低。

您不想随机选择一个三角形用作分割平面,而是想尝试几个(可能是全部,或者可能是随机采样)并根据某种启发式选择一个。 启发式通常基于 (a) 结果子节点的平衡程度,以及 (b) 它将分割多少个三元组。

您可以通过考虑较小或较大的 tris 样本作为候选分割平面来权衡性能和质量。

但最终,您不能希望为任何现实世界的数据获得完全最佳的树,因此您可能不得不满足于“足够好”。

Randomly building BSP trees until you chance upon a good one will be really, really inefficient.

Instead of choosing a tri at random to use as a split-plane, you want to try out several (maybe all of them, or maybe a random sampling) and pick one according to some heuristic. The heuristic is typically based on (a) how balanced the resulting child nodes would be, and (b) how many tris it would split.

You can trade off performance and quality by considering a smaller or larger sampling of tris as candidate split-planes.

But in the end, you can't hope to get a totally optimal tree for any real-world data so you might have to settle for 'good enough'.

檐上三寸雪 2024-07-13 18:13:58
  • 尝试选择(可能)被最多平面分割的平面作为分割平面。 分割平面无法分割。
  • 尝试选择一架前后飞机数量接近相同的飞机。
  • 尝试选择不会造成太多裂缝的平面。
  • 尝试选择一个与许多其他表面共面的平面。

您必须对这个标准进行采样,并提出一个评分系统来决定哪一个最有可能成为分割平面的良好选择。 例如,越失去平衡,失去的分数就越多。 如果它导致 20 次分裂,则惩罚为 -5 * 20(例如)。 选择得分最高的一项。 您不必对每个多边形进行采样,只需搜索一个相当好的多边形即可。

  • Try to pick planes that (could potentially) get split by the most planes as splitting planes. Splitting planes can't be split.
  • Try to pick a plane that has close to the same number of planes in front as in back.
  • Try to pick a plane that doesn't cause too many splits.
  • Try to pick a plane that is coplanar with a lot of other surfaces

You'll have to sample this criteria and come up with a scoring system to decide which one is most likely to be a good choice for a splitting plane. For example, the further off balance, the more score it loses. If it causes 20 splits, then penalty is -5 * 20 (for example). Choose the one that scores best. You don't have to sample every polygon, just search for a pretty good one.

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