ikpil / DotRecast

DotRecast - a port of Recast & Detour, Industry-standard navigation mesh toolset for .NET, C#, Unity3D, games, servers
zlib License
441 stars 61 forks source link

Problem with contour simplification. #65

Open awgil opened 3 months ago

awgil commented 3 months ago

So I've got this error: rcBuildContours: Bad outline for region 6, contour simplification is likely too aggressive.

This is how raw vs simplified looks: image

So yeah, the simplified polygon is self-intersecting, which is a problem. Looking at the code, however, I see this bit (rcContours.SimplifyContour):

  1. We start with raw vertices, iterate over all pairs and look for changes in either neighbour region id or area border flag, and add them as initial 'seed' vertices in simplified list - this is reasonable.
  2. Then we iterate over pairs of simplified vertices, and for each pair see whether error (max distance between simplified edge and raw vertex) is bigger than threshold, if so split the simplified edge - this is reasonable.
  3. However, this error check is only done for vertices that are either bordering wall or other area - this is not done for 'interior' vertices (bordering different region with same area). As a result, the error for them can be arbitrarily large, and it can create self intersections. This leads to a misleading error message (it blames aggressive simplification, while in reality all the checks using passed simplification parameters are skipped).
ikpil commented 3 months ago

When comparing DotRecast and recastnavigation, I couldn't find any differences. Could this issue possibly be due to recastnavigation?

If so, it seems like it should be reported to recastnavigation. How should we proceed with this?