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

Add more detailed Debug Visualization for 3D Navigation #4507

Closed
smix8 opened this issue May 7, 2022 · 3 comments
Closed

Add more detailed Debug Visualization for 3D Navigation #4507

smix8 opened this issue May 7, 2022 · 3 comments

Comments

@smix8
Copy link

smix8 commented May 7, 2022

Describe the project you are working on

Navigation, AI and Features like Navmesh Weights, Modifiers and Jumplinks in Videogames.

Describe the problem or limitation you are having in your project

Godot 3D Navigation currently has only a simple debug mesh to visualize navmesh in the editor or at runtime.
(2D was improved a lot more recently in Godot 4.0 but uses canvas draw options not available in 3D)

It works with default light and environment and a near empty scene but on a busy 3D scene with other transparent objects it is very much impossible to see the debug mesh or get useful information.

current_visuals

Individual mesh faces and edges are not visible. Users have no idea how well or bad the mesh face layout was baked with current settings and geometry. All the possible connections made between different navigation regions due to merging are also not visible.

All this information is critical for navigation debug and issue reporting.

I experience the Godot user frustations all the time as a parttime first responder for navigation issues in the Godot community ;)
Many issues are related to how the navigion mesh was baked or how mesh edges are placed to connect (or not connect). Users are often clueless why a navigation region did not merge properly. Especially physics agents like to get stuck and dance around badly baked mesh edges.

Issue for another time:
There is also the issue that no information exists if irritating pathfinding from agents is related to wacky navmesh or RVO avoidance. Both exist in their own space and often work against each others instead of complementing making debug harder than it should be.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

A more detailed debug mesh is build for each NavigationRegion3D on demand that updates with mesh (re)bake changes both in editor as well as at runtime. e.g. a mesh that has materials that shows edges and faces with optional different colors for each face.

A separate debug mesh is created for each navigation Map that shows all connections due to edge merges. This mesh should be separated from the navmesh debug mesh as it will require far more updates everytime map elements change.

A simple flat rect mesh that sits over start and end position and has the height of the map edge connection margin should do.

edge_connection

Add option for edge lines xray / no_depth_test as it is often hard to see in complex 3D scenes.

xray_edge_lines

Disable material transparency flag if not needed or change render priority as the debug often clashes with other transparent objects in a 3D scene.

Add different color options to projectsettings for mesh faces and edges. For people with impaired eyesight a single color for the entire navigation debug is hard to see especially if a lot is going on in a 3D scene.

with_better_mesh

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Add ProjectSettings for

  • Color - navmesh debug face color
  • Color - navmesh debug edge color
  • Color - navmesh debug region connection color
  • bool - navmesh debug enable edge lines
  • bool - navmesh debug enable edge lines xray / no_depth_test
  • bool - navmesh debug enable random face color

Add distinct SceneTree Materials for face / edge / connection meshes.

Create a debug mesh for each NavigationRegion3D on demand only.
e.g. if Editor Navigation Debug is on or get function is called the first time.
Link and update navmesh debugmesh only with navmesh change e.g. (re)bake.

Link and update debugmesh navigation map connections with any navigation map changed signals or notifications
e.g. when any navigation map region / navmesh, transform, region_layers or map changes as all those could change connections.

All changes through ProjectSettings or scripting should reflect in the Scene immediately.

navmesh_debug

If this enhancement will not be used often, can it be worked around with a few lines of script?

It can as I made first attempt in GDScript before porting to a Godot custom build but Navigation is a core feature.

Is there a reason why this should be core and not an add-on in the asset library?

Navigation is a core feature.

@Calinou
Copy link
Member

Calinou commented May 7, 2022

Looks good to me. Feel free to open a pull request for this if you manage to port this to C++ 🙂

@smix8
Copy link
Author

smix8 commented May 10, 2022

I will make a draft pr soon. Turned out to be far more work (2D debug part depends largely on 3D part) and I am stuck with small "bugs" and issues. e.g. Basis::looking_at() returns a very different result in C++ compared to GDScript. I guess I am just missing some information or encountered a bug.

@akien-mga
Copy link
Member

Implemented by godotengine/godot#62601.

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

3 participants