This article is a turn, the original http://blianchen.blog.163.com/blog/static/131056299201031293039882/
Here cannot send the source code, this series complete source code can go to http://bbs.9ria.com/thread-49841-1-1.html under.
See, the optimal path should be to bypass the middle block from above, and the actual path of the road is actually the following. This is because, when the grid area is too large or there is an edge length is too long, because the cost of a * is to calculate the distance between the midpoint of the grid and not the actual path length, so the resulting path deviation is large. So in the general grid generation algorithm will be added to the grid minimum area and maximum area limit, if the resulting mesh is less than the minimum area is discarded, if greater than the maximum area is split.
An island is created in a general map, such as a two block area crossing, which creates an island in the middle Crimson region after merging. In accordance with the clipping algorithm described above, the middle Island polygons are stored in a counterclockwise direction (other clockwise), so in this step it is possible to determine whether to create an island. For the isolated islands, if the game allows people to enter the island through the way of transient, then the island also need to generate a nav grid, but the island's Nav grid and other areas of the grid can best be divided into different regions, so that in the pathfinding can be optimized (starting point and end of the same region, can be directly determined to not pass).
Nav nav mesh pathfinding (7)-code and some optimizations