You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem or limitation you are having in your project
NavigationMesh and NavigationPolygon are Resources used to hold navigation mesh data inside the SceneTree.
Resources by default use shared data until made unique / duplicated in Godot.
If you have two NavigationRegion3D that use the same NavigationMesh resource you only have one data copy for both of them.
If you have a TileMap with 10000 cells that all use the same NavigationPolygon you still have only one data copy for all of them.
The problem is that Resource reuse and data sharing is not supported by the NavigationServer.
Every navigation region commits its NavigationMesh or NavigationPolygon to the server individually and creates its own unique data on the server. If you use the same TileMap with 10000 cells you end up with 10000 unique navigation polygons on the server.
While not the only reason it is one of the bigger reasons why larger TileMaps or GridMaps have so many performance issues with navigation runtime changes. They are currently creating a ton of redundant data on the NavigationServer that requires a lot of extra processing that is not needed.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The NavigationServer should support reuse of the same data from a shared NavigationMesh / NavigationPolygon resource.
Not only allows this the same data sharing as with the Resources but it also allows the NavigationServer to do internal optimizations when synchronizing or other processing, e.g. it only needs to process the polygons of a unique navmesh once cause every navmesh instance that uses a copy of the same navmesh will have the same polygons.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The NavigationServer should have a NavMesh and NavMeshInstance class with their own RID so it can hold navigation mesh data internally on the server with the NavMesh and share it with many other NavMeshInstances similar to how e.g. meshes are handled by the RenderingServer with base and instance.
The NavigationMesh and NavigationPolygon Resources will create the unique NavMesh RID so it can be received with the get_rid() function by users like with many other resources. The NavigationRegion2D or NavigationRegion3D will only create and use NavMeshInstances that use the NavigationMesh / NavigationPolygon RID as their base.
Both NavigationMesh and NavigationPolygon receive a commit_changes() function that syncs changes with the NavigationServer NavMesh. This will only be ever needed to be called manually when doing procedural navigation as all other functions or processes like 3D navigation mesh baking do this automatically.
Ideally both NavigationPolygon and NavigationMesh would stop using local vertices and polygon data arrays on the resources at runtime and instead only load them from the resource once, send it to the server and remove the now redundant local copy. This would make them work similar to how meshes store all data on the RenderingServer and GPU where it is actually needed and used. Large navmeshes can have a problematic memory footprint when constantly duplicated and especially the NavigationPolygon keeps even another data copy on top from the internal wrapped NavigationMesh.
Server and Resource API
For the most part this will be a copy how Godot already handles Mesh Resources.
The API for NavigationServer and NavigationMesh / NavigationPolygon could look like this.
Describe the project you are working on
Godot Navigation.
Describe the problem or limitation you are having in your project
NavigationMesh
andNavigationPolygon
areResources
used to hold navigation mesh data inside the SceneTree.Resources by default use shared data until made unique / duplicated in Godot.
If you have two NavigationRegion3D that use the same NavigationMesh resource you only have one data copy for both of them.
If you have a TileMap with 10000 cells that all use the same NavigationPolygon you still have only one data copy for all of them.
The problem is that Resource reuse and data sharing is not supported by the NavigationServer.
Every navigation region commits its NavigationMesh or NavigationPolygon to the server individually and creates its own unique data on the server. If you use the same TileMap with 10000 cells you end up with 10000 unique navigation polygons on the server.
While not the only reason it is one of the bigger reasons why larger TileMaps or GridMaps have so many performance issues with navigation runtime changes. They are currently creating a ton of redundant data on the NavigationServer that requires a lot of extra processing that is not needed.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The NavigationServer should support reuse of the same data from a shared NavigationMesh / NavigationPolygon resource.
Not only allows this the same data sharing as with the Resources but it also allows the NavigationServer to do internal optimizations when synchronizing or other processing, e.g. it only needs to process the polygons of a unique navmesh once cause every navmesh instance that uses a copy of the same navmesh will have the same polygons.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The NavigationServer should have a
NavMesh
andNavMeshInstance
class with their ownRID
so it can hold navigation mesh data internally on the server with theNavMesh
and share it with many otherNavMeshInstance
s similar to how e.g. meshes are handled by the RenderingServer withbase
andinstance
.The
NavigationMesh
andNavigationPolygon
Resources will create the unique NavMesh RID so it can be received with theget_rid()
function by users like with many other resources. TheNavigationRegion2D
orNavigationRegion3D
will only create and useNavMeshInstance
s that use the NavigationMesh / NavigationPolygon RID as their base.Both NavigationMesh and NavigationPolygon receive a
commit_changes()
function that syncs changes with the NavigationServer NavMesh. This will only be ever needed to be called manually when doing procedural navigation as all other functions or processes like 3D navigation mesh baking do this automatically.Ideally both NavigationPolygon and NavigationMesh would stop using local vertices and polygon data arrays on the resources at runtime and instead only load them from the resource once, send it to the server and remove the now redundant local copy. This would make them work similar to how meshes store all data on the RenderingServer and GPU where it is actually needed and used. Large navmeshes can have a problematic memory footprint when constantly duplicated and especially the NavigationPolygon keeps even another data copy on top from the internal wrapped NavigationMesh.
Server and Resource API
For the most part this will be a copy how Godot already handles Mesh Resources.
The API for NavigationServer and NavigationMesh / NavigationPolygon could look like this.
If this enhancement will not be used often, can it be worked around with a few lines of script?
No, those are server and resource internals that users have no access.
Is there a reason why this should be core and not an add-on in the asset library?
Navigation is core.
The text was updated successfully, but these errors were encountered: