My experience on triangle Binary Tree terrain (2)

Source: Internet
Author: User

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.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.