-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
NavigationServer : regions removing linked NavigationMesh automatically? #75704
Comments
All the NavigationServer function In an ancient time this was necessary due to dependency issues in the Godot init change. The NavigationMeshGenerator was not ready when required by certain objects so the NavigationServer acted as a router. All 3 functions will be changed / removed should pr #70724 be merged. At that point you use the NavigationMeshGenerator directly to (re)bake navigation meshes. The NavigationMesh resources are just data container for the vertices and polygons. They have no connection to the NavigationServer. While there are plans to change that at some point for now you can't "link" navigation meshes in the sense that they auto-update the NavigationServer internal NavRegion when the navigation mesh is changed. Hence why you need to use the region_set_navigation_mesh() again for the region after (re)baking the navigation mesh. When you call region_set_navigation_mesh() all you are doing is placing this NavigationMesh ref in the waiting room and activating the dirty flag for the next NavigationServer sync phase. On sync the NavigationServer copies the vertices and polygons from the NavigationMesh resource to the internal NavRegion and rebuilds the navigation map. The NavigationMesh is completely meaningless for the NavigationServer after that so theoretical might as well be deleted until the next region update is required. |
Thank you for your explanations. |
Performance problems when the navigation map changes can have many issues. I don't know how detailed you navigation meshes are build or how large your world and chunks are. If you don't have performance issue while baking and you don't have any NavigationAgent in use most likely it is properly the navigation map synchronization alone after changing a navigation mesh. In that case pr #75601 that allows to disable the costly edge connections might help soon with larger navigation maps that have many navigation mesh polygons and edges. In general try to have as few edges as possible for runtime update performance. |
My chunks are 64x64 "meters" I just have a few low-poly trees on each chunks (no more than 20) and i use the partition_layer method on static colliders that are in explicit group. Changing partition type doesn't really change anything. The thing is i have currently 2 different maps for the different enemy sizes, so i bake and attach each chunk double time with different agent_radius (was planing on 3 maps originally). For numbers, if that means anything to you, i have currently 4 chunks with navmeshes and Navigation monitor numbers are : Also using the NavigationServer3D Directly i can't see any visual debug of navmeshes, like i can do with NavigationRegion3D. "Visible Navigation" is checked and set_debug_enabled is set to true in script but nothing draw. PS: After rereading i though about make sure no static decors was at the edge of any chunks so the navmeshes edges are a straight line. The numbers now are: It's a bit better at start but as the nav_maps grow bigger the frame drop become longer. EDIT: Numbers of agents (from a few to none) on the map doesn't change anything |
The navigation debug in Godot is all attached to nodes. No nodes, no debug visuals. Same with physics. I don't see too much out of the ordinary with your stats except that having hundreds of free edges is properly what costs you so much performance on navigation map changes due to the costly edge connection calculations for each free edge. The thing is the way the NavigationServer currently does update navigation maps any tiny change triggers a full rebuild of the navigation map. So the more your navigation map grows the more unavoidable performance issues you will encounter when doing runtime changes. The only way for now is to keep the amount of navigation polygon edges as small as possible. If that does not help with performance enough the only workaround is to slice your world into chunks that each use a different navigation map and switch your agents between them. |
Closing this in favor of #68642 as the issues left here are the same navigation map sync and update performance issue with large maps already tracked in that other issue. Feel free to comment if there is something else still unresolved and not tracked by that other issue. |
Godot version
4.0.1 Stable
System information
Windows 10
Issue description
First of, sorry if it's not an issue, i'm reading the cpp for the navigation server and i don't understand why something is happening (or not happening) in my project.
Here is my use of the NavigationServer3D (nodeless, i only show the relevant code):
Context: I'm generating a map randomly and divide it into chunks. (3D but top-down so only 2D chunks). I generate the starting chunks navmeshes in _ready and the other on the fly in another thread
Then i generate the map (randomly) and bake the first navigation meshes:
From there it's working fine.
Now when the player move around the navmeshes are generated on the fly with the same function but in a thread. The only way for the navigation meshes generated at runtime to work is to un-comment the line with "region_set_navigation_mesh" method: but the navmesh is already linked in _ready(), and the navmeshes generated at runtime are fine without re-linking them to the region.
So i wondered if the server flush the empty meshes after the first physic frame, i went to see the source files and in nav_region.cpp and nav_map.cpp, i see the the update_polygon function first do nothing when the mesh is empty but when "sync" get called and the navigation mesh is now baked and should update the polygons.
So i wonder if i missed something, or if it's the intended usage to link the navmesh after baking it?
Steps to reproduce
See code
Minimal reproduction project
See code
The text was updated successfully, but these errors were encountered: