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

Navigation2D (Godot 3.5 beta2) - Error: "sync: Attempted to merge a navigation mesh triangle edge with another already-merged edge", not present in Godot 3.4.3 #59182

Closed
Ranoller opened this issue Mar 15, 2022 · 8 comments

Comments

@Ranoller
Copy link
Contributor

Godot version

3.5 beta 2

System information

Windows 7 and 10, GLES2 and GLES 3

Issue description

Bug submited in #57254 and supposedly fixed by #56879 and #56600 in still present in Navigation2D. Error spams in console, but NavigationPolygon is created and working. Error spams with polygons with hundreds of points, close to each other, when triangulating the big polygon by code. I attach reproduction project.

Error message:

E 0:00:00.999   sync: Attempted to merge a navigation mesh triangle edge with another already-merged edge. Either the Navigation's `cell_size` is different from the one used to generate the navigation mesh or `detail/sample_max_error` is too small. This will cause navigation problem.
  <C++ Source>  modules/navigation/nav_map.cpp:605 @ sync()

This is not a breaking bug per se, but a inconvenient spam in console message.

Other significant change since new navigation system is that you can´t use Navigation2D in the _ready() function when you are building polygons from code, and you have to workaround with the first frame in _physics_process to handle "Navigation2D.get_simple_path()". I made the changes in my project because i want to migrate to 3.5, but is a breaking change that should be documented.

Steps to reproduce

Run attached project in 3.4.3 and 3.5 beta 2 and see output console.

Minimal reproduction project

NavigationMeshBug.zip

@SkanerSoft
Copy link

3.5 Beta 3 in 3D

E 0:00:01.942   sync: Attempted to merge a navigation mesh triangle edge with another already-merged edge. Either the Navigation's `cell_size` is different from the one used to generate the navigation mesh or `detail/sample_max_error` is too small. This will cause navigation problem.
  <Исходный код C++>modules/navigation/nav_map.cpp:605 @ sync()

At the same time, I use the basic NavigationMeshInstance without programming, I set everything up in the editor.

@Scony
Copy link
Contributor

Scony commented Apr 3, 2022

Well, this won't be fixed too soon I presume as there are some fundamental problems in the implementation/recast library.
For now, you can try increasing detail/sample_max_error

@Ranoller
Copy link
Contributor Author

SkanerSoft can try this. I can´t increase detail/sample_max_error because this is a property of NavigationMesh, not available in Navigation2D, NavigationPolygonInstance or NavigationPolygon...

@akien-mga
Copy link
Member

CC @AndreaCatania

@Scony
Copy link
Contributor

Scony commented Apr 29, 2022

Now that I read it a second time I can see that this issue is regarding 2D. In that case, having the error as OP mentioned may only be due to polygon points being too dense in relation to Navigation2D's cell_size.

In general, for the purpose of joining separate navigation polygons, a grid of cells of size Navigation2D::cell_size x Navigation2D::cell_size each is being introduced. Such a grid is necessary to unify points so that we can check if they are in the same position or not. So, assuming cell_size=1, the points like (1.0, 1.0), (1.1, 1.1), (1.3, 1.7) will be mapped to point (1.0, 1.0). In other words - we will treat them as the same point. This way we can reason whether to join the polygons they represent or not.

The problem reported by OP happens basically if two points representing the polygon edge are being mapped to the same point i.e. they are so close that they are being mapped to the same cell due to the cell_size setting. One can experiment with that e.g. by changing Navi2D.cell_size in the MRP delivered by OP. If we set Navi2D.cell_size = 10 we will get 45 errors. If we set Navi2D.cell_size = 15 we will get 94 errors. If we set Navi2D.cell_size = 0.001 we will still get 6 errors which means that likely some edges AB have points such that A==B.

So to sum up, OP should check if some points are not overlapping. Removing them should make the errors disappear.

If I'm right and some points in the polygon are overlapping, then maybe we can introduce some mechanism that would filter duplicated points so that polygon like (0,0), (1,1), (1,1), (1,1), (1,0), (0,0) would be treated as (0,0), (1,1), (1,0), (0,0)

@smix8
Copy link
Contributor

smix8 commented May 22, 2022

Need to also backport the more recent Navigation changes from Godot 4.0 that included a lot of edge merging fixes from groud. I can hardly get any navigation merged in Godot 3.5 that works perfectly in Godot 4.0.

@akien-mga
Copy link
Member

Fixed by #61996.

@Flavelius
Copy link
Contributor

Is this fix in 3.5-RC4? If it should be, then i still have this problem in RC4.

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

No branches or pull requests

6 participants