godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.13k stars 90 forks source link

Add NavigationMesh source geometry group excluding #9347

Open brennennen opened 6 months ago

brennennen commented 6 months ago

Describe the project you are working on

A 3D procedurally generated sci fi space station first person action/horror game.

Describe the problem or limitation you are having in your project

Baking navigation meshes for agents to traverse between procedurally generated rooms/hallways with doors between them. image

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

Add an "Exclude Group" field to NavigationMesh Geometry which allows excluding certain groups during navigation mesh baking.

Following suite with the include group system, there could also be a "Exclude Source Geometry Mode" added to support excluding groups with or without their children.

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

The developer will provide a "Exclude Group" group name in the NavigationMesh's "Geometry" section. This group name will then be used to filter out certain meshes from the source geometry before baking the navmesh.

image

image

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

This can't be worked around in a few lines of script, but there are work arounds.

For my scenario, I'll probably resort to spawning doors in an open state without the door mesh visible or having a collision shape. Then generate the navmesh, and then eventually close the doors.

Folks can also probably use "Source Geometry Mode: Group Explicit" and add groups with more fine tuned control, but this gets very time consuming and tedious with complex scenes.

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

This improves the usability of NavigationMeshes out of the box for a common problem.

AThousandShips commented 6 months ago

For workarounds there's a very simple one that works in most cases: Use a collision layer for navigation

brennennen commented 6 months ago

For workarounds there's a very simple one that works in most cases: Use a collision layer for navigation

Thanks, I've been giving this a shot. One difference is that groups can be applied to the top level node and collision layers need to be applied to each child StaticBody3D which may be imported and not easily modifiable.

This ends up being an issue because of bugs and workflow issues around importing and updating 3d assets. If you import a glft/blend file scene that has collision data in the scene through "-colonly" named meshes. There is no good way to edit the collision layer data of these meshes. If you make scenes editable or inherit and then edit them through the editor, the collision layer data gets lost on re-importing sometimes when you update the asset source file or fails to re-import sometimes. I guess writing an import script and setting the collision layers based off some naming convention or meta data might be the route I'll have to go. I don't consider this very simple though.