Skip to content

Fix an issue where concave polygons may be generated during the rcBuildPolyMesh stage. #734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

870751720
Copy link

Hello, after the mergeRegionHoles phase, we produced a contour as shown in the figure below.
image
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.
polygon_0
polygon_1
polygon_2
polygon_3
polygon_4
polygon_5
polygon_6
polygon_7
polygon_8
polygon_9
polygon_10

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!

int i1 = next(i, n);
int i2 = next(i1, n);
if (diagonal(i, i2, n, verts, indices))
indices[i1] |= 0x8000;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a small mixup with tilecache here and 2 lines down, shouldn't these feature the prevous constants (0x80000000 and 0x0fffffff)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my mistake. Sorry, I subconsciously assumed that the values of the two were the same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have submitted my modifications and thank you very much for pointing out my issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants