The last time we talked about how to fix the crack.
Let's take a closer look at why cracks are generated ., For two back-to-back triangles, if one of them is split but the other is not split, cracks are very likely to occur.
Note that if there is a crack in the new vertex in the middle, it will only generate once, that is, only one triangle will split and generate new vertex, and the other will not make any changes.
Then there is a natural idea to fill this crack, that is, to generate a newly generated triangle composed of the top and the other two vertices, that is, a triangle consisting of V1, V2, and V3.
Then how can we get all these triangles under the current level of the dashboard? How can we know the number of times an intermediate vertex is generated? The natural idea is to use hashtable to record and search by the index of the intermediate vertex, that is, V2. Each time a new intermediate vertex is created, after the index is calculated, the key value in the hash table corresponding to the index is added with 1. Then, the corresponding value of the index is 1, the corresponding value of the vertex that does not produce cracks is greater than 1. Finally, you can access this hashtable to fix all the cracks. Naturally, the corresponding two vertices must be recorded when the index with cracks is recorded. In this way, we have these triangles. The memory consumption of this method is a hash table that stores the corresponding other vertices. In this way, there is no limit on splitting or the cost of storing critical vertices.