基于MC位置的复杂深度排序问题

发布于 2024-12-08 11:14:44 字数 914 浏览 4 评论 0原文

我需要帮助拯救一个涉及极端深度管理的项目。我们没有主意了!

该项目涉及堆叠各种尺寸的盒子,每个盒子都是等距的 - 所以这就是深度发挥作用的地方(我们需要将这个盒子编织在那个盒子前面,但在两个盒子的顶部和另一个盒子的下面,等等 - 任何事情都可以!)

这是该项目的现状:

http://clearlytrained.com/depth/

您可以拖动框然后放开网格,如果网格空间是绿色的 - 如果你要拿两个高一个网格空间的盒子,然后将它们放在一起,然后拿一个更宽的盒子(2x2)并将其放在两个盒子上(因此两个较低盒子中的间隙位于放置在顶部的框的中间)您会看到最右下方的框的深度现在更高并且高于顶部的框。我完全理解为什么会发生这种情况,但无论我们如何按顺序扫描网格,这在某种程度上都会以目前的方式发生。

我们当前对深度进行排序的方式是扫描网格数组,该数组存储屏幕上每个框的名称,根据我们扫描行和列的方向,我们得到一个顺序,然后设置每个框的深度。问题是,即使一个盒子可能占用 6 个网格空间,我们也不会设置深度 6 次 - 我们只在第一次到达数组中的实例名称时设置它 - 所以如果我们扫描网格从下到上、从左到右,一个盒子物理上位于另一个盒子下方,但更靠右的位置总是具有更高的深度。不好!

我能看到解决这个问题的唯一方法是找出某种先 X 然后 Y 值的框与框比较,设置某种双 for 循环/if 语句条件,并且或多或少,以编程方式手动放置每个框的每次我们移动或放置新盒子时的深度。因此,复杂性从按框实例名称的顺序设置深度,到将此框与每个其他框进行比较,然后将每个其他框与每个其他框进行比较,并得出我们需要堆叠其深度的实际顺序。在某些情况下,我们可能会从左到右,然后从下到上,然后从左到右——没有平滑的模式。

请尝试使用提供的链接,如果您有任何其他问题或需要更多信息,请告诉我,我很绝望!

I need help rescuing a project concerning some extreme depth management. We're out of ideas!

The project concerns stacking boxes of various sizes, each box is isometric - so thats where the depth comes in to play (we need to weave this box in front of that box, but on top of two boxes and below another, etc - anything goes!)

Here's the project as it stands:

http://clearlytrained.com/depth/

You can drag the boxes then let go over the grid if the grid space is green - if you were to take the two boxes that are one grid space high, place then next to eachother, then take a wider box (2x2) and place it over both (so the gap in the two lower boxes is in the middle of the box you placed on top) you'll see that the far right lower box's depth is now higher and above the box on top. I completley understand why this happens, but no matter how we sweep through the grid in order, this will happen to some extent the way it currently stands.

The way we're currently sorting depth, is sweeping through the grid array, which stores the name of every box on screen, based on the direction we sweep through the rows and columns we get an order to which we then set each box's depth. The problem is that even though a box might take up 6 grid spaces, we don't set the depth 6 times - we only set it the first time we come to its instance name in the array - so if we're sweeping through the grid bottom to top, left to right, a box that's physically under another box, yet further to the right will always have a higher depth. not good!

The only way i can see to fix this is to figure out some sort of box to box comparison of first X then Y values, setting up some sort of double for loop/if statemenet conditions, and more or less, programatically hand place each boxe's depth every time we move or place a new box. So the complexity goes from setting depth by order of box instance name, to comparing this box to every other box, then every other box to every other box, and coming up with the real order we need to stack their depth. In some cases we might go left to right, then bottom to top, then back to left to right - there's no smooth pattern.

Please play around with the link provided, let me know if you have any other questions or need more info, I'm desperate!

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

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

发布评论

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

评论(1

醉态萌生 2024-12-15 11:14:44

我会将所有框添加到一个数组中,并按 X 和 Y 值(平铺 X 和 Y)对其进行排序。这不是一个很大的集合,所以你不必担心性能。

按X排序,然后如果X相同,则按Y排序。这应该可以解决它,除非我错过了一些明显的东西。

I would add all boxes to an array and sort that by both X and Y value (tile X and Y). It's not a large set, so you don't really have to worry about performance.

Sort by X, then if X is the same, sort by Y. That shoooould solve it, unless I missed something obvious.

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