About binary tree, quadtree and eight-fork tree
A tree is a common data structure. It is a finite set T consisting of one or more nodes, which has a specific node and becomes the root node. The remaining nodes are divided into m (m greater than or equal to 0) disjoint finite set t0,t1,...,tm-1, each of which is a tree called t0~tm-1 as the root node subtree. The types of tree structure are two fork tree (binary Space partitioning Trees), Quadtree, eight-fork Tree (octree), 16-fork tree, etc. In order to meet the needs of various application problems, many different storage structures are also set up accordingly.
A binary tree is a tree structure that represents the simplest and easiest to operate. Abbreviated to the BSP tree, which is a subdivision of two-tree space. The BSP tree divides a space into two regions through a subdivision plane. The leaf nodes of the tree represent the spatial body elements, and the branch points represent the subdivision planes of the subdivided spaces. For the real-time rendering of virtual scene, the biggest advantage of BSP tree is that it can construct a good equilibrium tree, especially when the objects in the scene are unevenly distributed, thus reducing the depth of the tree. In this real-time rendering, you can quickly traverse the entire scene to speed up scene rendering. However, for dynamic object rendering in a scene, it takes a costly tree-structure update, and each time a dynamic object is rendered, it is added to the static tree structure and then moved back to the dynamic object.
Quadtree is a method of data processing expression technology for many years, especially the terrain rendering engine can use his very effective as a mechanism, quadtree is described by corresponding to each parent node passed four sub-nodes, in a terrain rendering context, the root node will be expressed as the surrounding terrain of the square area set, Since nodes are represented as top left, top right, bottom left, and bottom right quadrants, these quadrants consist of root nodes and each is defined by a four-byte-point recursion.
The eight-fork tree structure (Figure 4-39) is to decompose the space area into eight sub-regions of the same size (a cube of six polygons is decomposed into eight smaller cubes of the same size), and the more the number of decomposition, the smaller the sub-region, until the same-zone attribute is single.
In the way of bottom merging, it is to divide the space into three-dimensional grid by the resolution of the study area first, and then compare the 3 adjacent raster cells in the order of each other, and then merge them if their attribute values are the same, otherwise they will be recorded. Recursively until each sub-region is a single value. The eight-fork tree is mainly used to solve three-dimensional problems in GIS.
The eight-fork tree can be divided into conventional eight-fork tree and linear eight-fork tree. The nodes of the regular octal tree are to record 10 bits, which are eight pointers to the child nodes, a pointer to the parent node, and an attribute value (or identification number). The linear octal tree only needs to record the address code and the attribute value of the leaf node. It has two advantages: one, save storage space; Two, the linear eight-tree can be directly addressed, through its coordinate value can be calculated any input node location code (called code), without actually establishing an eight-fork tree, and the location code itself is another form of coordinates, do not have to intentionally to store the coordinate value; third, in terms of operations, The resulting positioning code is easy to store and execute, easy to real phenomenon set, add and so on combined operation.
The eight-fork tree uses a similar two-dimensional four-fork tree structure to subdivide the scene, and the whole three-dimensional space is subdivided into small cubes. These cubes are organized into hierarchies by using recursive tables to subdivide the objects contained in each area until the desired resolution is met. The eight-fork tree hierarchy of the scene is generated in the preprocessing stage, and the tree structure is modified adaptively according to the change of viewpoint in real-time drawing. The tree structure can also be used to calculate the visual field of the scene and other visibility calculations, as well as collision detection of the virtual scene. The subdivision of the eight-fork tree in the scene can well support the geometric subdivision of the architectural scene space. The figure shows the use of the eight-fork tree to subdivide the terrain model, where yellow lines represent spatial division and green represents the terrain model. As shown in figure (a), the distance between the two vertices farthest from the terrain model as the edge length of the outsourced cube, using a single cut, the cube is divided into the average up and down, front and back, about 8 fast, using two split time, the inclusion of a terrain model of each small block then split, will produce subdivision squares, and so on, Using a three-time split, the entire space is separated into more granular squares, as shown in figure (b).
In fact, the eight-fork tree is an extension of the quadtree in the height space, and there are many similarities between them. Quadtree is a "space surface" form to describe the 3D terrain, and the eight-fork tree is a "space cube" in the form of a description of the 3D terrain. From the complexity of the topography, the eight-fork tree is better, but the cost is the reduction of efficiency. To some extent, the eight-tree can fully realize both indoor and outdoor terrain, and can combine the two, for this point, foreign researchers have achieved. But because of the efficiency of the consideration, still feel that should be based on the different types of game scenes to choose their own different management mode and connected together.
In general, the binary tree is probably in the 80 's, because there is no support for the "z_buffer" hardware, in order to avoid repainting, people use a binary tree to achieve the indoor scene of various polygon depth sequence, in order to achieve "from the back to draw" role. These years, because of the support of "z_buffer" hardware, the role of the binary tree gradually reduced; now, its main purpose is for "visibility judgment" and "Collision detection", and for indoor scene management, it is very suitable for "static indoor scene" of the rendering management, for the dynamic scene, It still has a lot of flaws, because when a polygon is added or deleted dynamically in an indoor scene, the binary tree is reconstructed once, which is greatly reduced in efficiency. Why reconstruct it once again. I think it may be because the split surface of the binary tree is based on the polygon, and from this point, the eight-fork tree is a good choice, because the cross-section of the eight-fork tree is not based on the polygon plane.