You're on the right track, you definitely only want to be drawing things in the immediate vicinity if at all possible.
Quadtrees and octrees are data structures designed to slice up 2D/3D space respectively to make finding objects in a given area very easy. Sounds like this is what you are looking for.
You could use either, depending on what you wanted your definition of "nearby" to be. If you wanted to achieve the same as Minecraft, then what Minecraft does is display entire columns of blocks, so you could get away with a quadtree used to manage things on the X/Z coordinates and always show everything on the Y. If you wanted to do a 3D based definition of nearby, then you'd need a octree.
The way these work is by partitioning space using a tree structure. Each branch in the tree represents a quadrant (or octant in the case of an octree) of the available space, and each subsequent branch is a quadrant of that quadrant. Hence, it is very easy to drill down to a specific area. The leafs of the tree hold the actual data, ie. the blocks that make up your world.
发布评论
评论(1)
你走在正确的轨道上,如果可能的话,你肯定只想在附近画东西。
四叉树 和 八叉树是一种数据结构,旨在分别分割 2D/3D 空间,以便在给定区域中查找对象变得非常容易。听起来这就是您正在寻找的东西。
您可以使用其中任何一个,具体取决于您希望对“附近”的定义是什么。如果您想实现与 Minecraft 相同的效果,那么 Minecraft 所做的就是显示整个块列,因此您可以使用四叉树来管理 X/Z 坐标上的内容,并始终在 Y 上显示所有内容。如果您想要要对附近进行基于 3D 的定义,那么您需要一个八叉树。
这些工作的方式是使用树结构来划分空间。树中的每个分支代表可用空间的一个象限(或者在八叉树的情况下为八分圆),并且每个后续分支都是该象限的一个象限。因此,很容易深入到特定区域。树的叶子保存实际数据,即。构成你的世界的块。
You're on the right track, you definitely only want to be drawing things in the immediate vicinity if at all possible.
Quadtrees and octrees are data structures designed to slice up 2D/3D space respectively to make finding objects in a given area very easy. Sounds like this is what you are looking for.
You could use either, depending on what you wanted your definition of "nearby" to be. If you wanted to achieve the same as Minecraft, then what Minecraft does is display entire columns of blocks, so you could get away with a quadtree used to manage things on the X/Z coordinates and always show everything on the Y. If you wanted to do a 3D based definition of nearby, then you'd need a octree.
The way these work is by partitioning space using a tree structure. Each branch in the tree represents a quadrant (or octant in the case of an octree) of the available space, and each subsequent branch is a quadrant of that quadrant. Hence, it is very easy to drill down to a specific area. The leafs of the tree hold the actual data, ie. the blocks that make up your world.