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

baked navigationmesh is incomplete #77695

Closed
FrankLeeC opened this issue May 31, 2023 · 10 comments
Closed

baked navigationmesh is incomplete #77695

FrankLeeC opened this issue May 31, 2023 · 10 comments

Comments

@FrankLeeC
Copy link

Godot version

4.0.3.stable

System information

Windows 11, CPU: 1th Gen Intel Core i7-11700F, Renderer: Forward+, GPU: NVIDIA GeForce RTX 3060

Issue description

using NavigationRegion3D, the baked navmesh for a 'mountain terrain' is incomplete,
the navmesh cannot cover all area, even if 'agent max slope' set to 90 degree.
otherwise, some area is wired, see blow picture.
incomplete_navmesh

Steps to reproduce

1.open project
2.open res://terrain/nav.tscn
3.bake navmesh using $Node3D/NavigationRegion3D
4.incompleted navigation area

Minimal reproduction project

minimal reproduction project
testnavmesh.zip

@smix8
Copy link
Contributor

smix8 commented May 31, 2023

Adjust the properties on the NavigationMesh to your terrain.
The agent slope is just one parameters of many that affect the result.

Your terrain needs to go through a voxelization stage in the baking process where vertices get mapped to a voxel grid the size of your cell size and cell height. If the cells are too large the elevation differences between the voxel cells will be too much to count as traversable.

In general, even if the baking would not fail on the slopes, your terrain mesh looks way to complex around them to gain any reasonable navigation pathfinding performance out of it. Consider excluding that entire part and / or the use of a more simplified representation of your level as the source geometry for baking navmesh. Prefer collision shapes over visual meshes as the source geometry for the baking as those are faster and already more simplified compared to visual meshes.

@FrankLeeC
Copy link
Author

Adjust the properties on the NavigationMesh to your terrain.

The agent slope is just one parameters of many that affect the result.

Your terrain needs to go through a voxelization stage in the baking process where vertices get mapped to a voxel grid the size of your cell size and cell height. If the cells are too large the elevation differences between the voxel cells will be too much to count as traversable.

In general, even if the baking would not fail on the slopes, your terrain mesh looks way to complex around them to gain any reasonable navigation pathfinding performance out of it. Consider excluding that entire part and / or the use of a more simplified representation of your level as the source geometry for baking navmesh. Prefer collision shapes over visual meshes as the source geometry for the baking as those are faster and already more simplified compared to visual meshes.

so i should use a smaller cell_size/cell_height? godot will crash.😫
maybe i can split into small chunks and bake for each chunk.

@smix8
Copy link
Contributor

smix8 commented May 31, 2023

If the baking crashes because ReCast runs out of memory that is also a clear hint that the source geometry is too large and complex for a single navmesh. Under such conditions, even if the baking would not fail, the resulting navmesh would be unusable for pathfinding performance.

Another possibility is that the terrain mesh is downscaled (e.g. FBX imports) so the real voxel grid ends up way larger than you think and runs against the cell or float limit.

@FrankLeeC
Copy link
Author

does cell_size corresponds to face size in blender? e.g. 1000x1000 plane subdivided to 10000 faces, then cell_size is 100.

@smix8
Copy link
Contributor

smix8 commented Jun 1, 2023

The voxel grid size is determined by the Godot world dimensions of your mesh at scale 1.0.
A world unit in Godot is 1.0 meter and the default cell_size and cell_height is 0.25.

@FrankLeeC
Copy link
Author

FrankLeeC commented Jun 1, 2023

i have downscaled and reduce faces, then use mesh->create navigation mesh on editor menu, result cover area perfectly. what's difference with NavigationRegion3D bake? pic2 is baked by NavigationRegion3D Node with default setting
无标题

无标题2

@smix8
Copy link
Contributor

smix8 commented Jun 1, 2023

Create from Mesh option only copies the vertices and indices from the visual Mesh to the NavigationMesh with zero validation if the data makes any sense for navigation and pathfinding.

@FrankLeeC
Copy link
Author

Create from Mesh option only copies the vertices and indices from the visual Mesh to the NavigationMesh with zero validation if the data makes any sense for navigation and pathfinding.

is there any risk using Create from mesh, unavailable pathfinding or stuck or anything else?

@smix8
Copy link
Contributor

smix8 commented Jun 1, 2023

Depends on your mesh.

In case of your currently used mesh it lacks any consideration for agents so everything will clip and move where it is not supposed to be, it will properly cause a lot of navigation map synchronization issues due to a mismatch of cell layouts, and it is also poorly optimized e.g. look at the valley section, it is basically turned into a navigation grid with hundreds of grid cells what could be a single polygon. That will really tank the pathfinding performance.

@smix8
Copy link
Contributor

smix8 commented Jun 23, 2023

If there are no further questions I think we can close this issue.

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