Skip to content
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

Problems with removed vertices at tile borders #64

Open
awgil opened this issue Mar 6, 2024 · 1 comment
Open

Problems with removed vertices at tile borders #64

awgil opened this issue Mar 6, 2024 · 1 comment

Comments

@awgil
Copy link
Contributor

awgil commented Mar 6, 2024

I've been investigating problems with incorrect pathing, e.g.
image

After some digging, I've found that the root cause is the logic that removes vertices on tile borders while building polymeshes.

There is a parameter that controls the max edge length while tracing contours, it correctly creates 'small' areas:
image

When later poly mesh is built, it builds a triangulation for each contour. However, there is a piece of code (see RcMeshs.BuildPolyMesh) that marks vertices on the tile borders for removal:

                    if ((cont.verts[v + 3] & RC_BORDER_VERTEX) != 0)
                    {
                        // This vertex should be removed.
                        vflags[indices[j]] = 1;
                    }

As a result, recast creates a huge polygons on tile borders:
image

Presumably this is done for better tile stitching? However, it creates problems for pathfinding (since the pathfinding considers edge midpoints, it thinks that going 'around' this polygon is 'shorter' than crossing long edge midpoint).

Removing this vertex removal bit fixes the triangulation (and consequently pathfinding), and doesn't seem to break stitching in my limited testing so far:
image

However, I don't quite understand all implications. I suspect this part is directly ported from recast?

@ikpil
Copy link
Owner

ikpil commented Mar 13, 2024

There are parts that I also haven't fully understood, so it's difficult for me to respond.
Firstly, the part that I don't understand from the perspective of porting is the technical porting.

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

No branches or pull requests

2 participants