godot: Navigation design does not align with the rest of the engine

Tested versions

4.x

System information

Issue description

The current design of the navigation system exhibits significant inconsistencies compared to the rest of the engine. These inconsistencies hinder flexibility, extensibility, and alignment with established patterns in the engine’s architecture. Below are the key issues and proposed resolutions.

1. NavigationServer

The NavigationServer is implemented in a way that discourages modularity and alternative implementations. The core implementation resides in a module, but it doesn’t allow for easy substitution or extensibility. Unlike other servers, which permit registration of alternatives, the NavigationServerXDManager only supports a default navigation server. Custom implementations require deactivating the default module during the build process and can not be implemented via GDExtension. This should be brought in line with other servers such as the PhysicsServer.

2. NavigationMesh

TheNavigationMesh API forces the navigation system to conform strictly to the recast paradigm. Custom implementations (e.g., navigation volumes, voxel octrees, or simple navigation graphs) are impractical due to the hard dependency on the NavigationMesh. Even replacing the NavigationServer with a custom implementation still requires inheriting from the default NavigationMesh. In contrast the PhysicsServer for example just uses a generic Shape RID and does not rely on any specific Shape in its API.

3. NavigationRegion

In it’s current form this is really just a NavigationMeshInstance seeing as a region can not have more than one mesh assigned in any case, based on point 2 this should just be a generic resource like Shape that does not rely on any specific underlying implementation.

4. NavigationObstacle and NavigationLink

These nodes deviate from the engine’s resource management conventions. The rest of the engine always keeps the data in a Resource class and then adds it to the scene tree with an instance class that holds the resource. See MeshInstanceXD and Mesh, CollisionShapeXD and ShapeXD, PathXD and CurveXD etc.

5. source_geometry_parser_create and source_geometry_parser_set_callback

The newly implemented geometry parsing mechanism is overly complicated and diverges from established systems. Functions like source_geometry_parser_create and source_geometry_parser_set_callback require static functions and resource management and are inconsistent with the design of similar systems in the engine. This could be much simpler by adding a virtual function _parse_source_geometry to Node2D and Node3D similar to https://github.com/godotengine/godot/blob/9ee1873ae1e09c217ac24a5800007f63cb895615/scene/3d/visual_instance_3d.h#L205 or https://github.com/godotengine/godot/blob/9ee1873ae1e09c217ac24a5800007f63cb895615/scene/3d/visual_instance_3d.h#L65 and additionally a navigation_layer property similar to https://github.com/godotengine/godot/blob/9ee1873ae1e09c217ac24a5800007f63cb895615/scene/3d/physics/collision_object_3d.h#L48 to decide in which navigation meshes/regions the geometry of the node should actually be included in. This way a custom node just needs to override/implement _parse_source_geometry and be done with it.

Conclusion

The navigation system would greatly benefit from adopting the engine’s established design principles. Refactoring these components to align with the rest of the engine will improve modularity, flexibility, and developer experience.

Steps to reproduce

Minimal reproduction project (MRP)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 17 (17 by maintainers)

Most upvoted comments

You received the wrong msg.

I asked you to structure your points in a way and place where they fit so they can be discussed individually and moved forward piece by piece. The issue tracker is the wrong place for monolithic 10-things-into-one posts. Nearly each point you raise is such a big discussion point that it would deserve its entire own post.

It also has practical reasons as those single-wall-of-text posts are bound to get stuck with the majority of contributers not even finding time to read them or understanding them when they fly over 10 different topics. Not everyone is super familiar with the entire system to keep an overview what is what.

Even if more people would participate the issue template on git buries everything after a few posts. That is why everything that requires more discussions or has need for sub discussions with specific parts was moved to proposal discussions that has a better gui interface.

What I would liked to have seen is:

  • Create a proposal for exposing the NavigationServer for extension.
  • Create a proposal for each of all the pathfinding options that you mentioned, some may already exist (e.g. voxel).
  • Create a proposal for adding multiple NavigationMeshInstances to a NavigationRegion.
  • Create a proposal to move the NavigationObstacle vertices to a reusable data resource.
  • Create a proposal discussion for the source geometry parser to discuss the pros and cons and why things are as they are.
  • …

You can still do that and help actually move things forward.

Please move to a proposal discussions. This has no qualifiers for being in the issue tracker.

You are asking for extension and override exposing the NavigationServer (a major undertaking with endless amounts of longterm baggage), adding new geometry types that are completely outside of scope of navmesh that the NavigationServer is currently designed for, and other stuff causing major api breakages and new feature baggage. Maybe this is a perception problem but if that is not all clear feature proposal territory I dont know what is.