Fix an issue where concave polygons may be generated during the rcBuildPolyMesh stage. #734
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, after the mergeRegionHoles phase, we produced a contour as shown in the figure below.

Points 23, 24, and 25 form a hole. In the case of the hole depicted above, we will produce a concave polygon during the rcBuildPolyMesh stage, which is not as expected.
I will provide a series of images demonstrating the results produced during each iteration of the triangulate function, where each image represents the shape of the remaining contour at that moment, along with the convexity status of each point. Large red dots indicate convex points, while small red dots indicate concave points.











It can be observed that when we reach Figure 6, point 25 is incorrectly judged as a convex point, which does not satisfy the definition of the ear clipping method. Subsequently, the convex information of point 25 persists into Figure 9, and then it is erroneously removed because it is a convex point that meets the removal criteria, as shown in Figure 10.
This ultimately leads to the generation of a concave polygon during the rcBuildPolyMesh stage.
The reason for this issue is that in Figure 5, when point 22 was removed, we only checked the convexity of points 20 and 23, without refreshing the convexity of point 25. The removal of point 22 caused a change in the convexity of point 25. To resolve this issue, I suggest that after each point removal, we perform a convexity check on all points to ensure that we do not mistakenly generate a concave polygon.
If you have better handling suggestions, I would appreciate discussing them with you. Thank you very much!