TheGrimsey / oxidized_navigation

A runtime Nav-Mesh generation plugin for Bevy Engine in Rust.
Apache License 2.0
178 stars 14 forks source link

Generated Navmesh has holes #33

Closed mnett82 closed 2 months ago

mnett82 commented 2 months ago

Trying out this library together with Bevy and Rapier3D for the first time.

Scene consists of a board of size-1-by-1 rectangular tiles (see attached screenshots), each with a NavMeshAffector and a Collider components (as per example).

Generated Path

The generator NavMesh seems to have some inexplicable holes around some tile-to-tile intersections (see highlighted part of the attached screenshot).

Close-up of hole in navmesh

Any idea what is causing this?

mnett82 commented 2 months ago

Forgot to mention: I don't see any errors reported in the terminal.

TheGrimsey commented 2 months ago

What are your NavMeshSettings set to?

mnett82 commented 2 months ago

I initialize the plug-in with the settings of NavMeshSettings::from_agent_and_bounds(0.1, 0.1, 250.0, -1.0). Slapping some dbg! statements onto it, right after creation, it looks as follows:

[survivors/src/main.rs:50:5] nav_mesh_settings.cell_width = 0.05
[survivors/src/main.rs:51:5] nav_mesh_settings.cell_height = 0.025
[survivors/src/main.rs:52:5] nav_mesh_settings.tile_width = 120
[survivors/src/main.rs:53:5] nav_mesh_settings.world_half_extents = 250.0
[survivors/src/main.rs:54:5] nav_mesh_settings.world_bottom_bound = -1.0
[survivors/src/main.rs:55:5] nav_mesh_settings.max_traversable_slope_radians = 0.87266463
[survivors/src/main.rs:56:5] nav_mesh_settings.walkable_height = 4
[survivors/src/main.rs:57:5] nav_mesh_settings.walkable_radius = 2
[survivors/src/main.rs:58:5] nav_mesh_settings.step_height = 3
[survivors/src/main.rs:59:5] nav_mesh_settings.min_region_area = 100
[survivors/src/main.rs:60:5] nav_mesh_settings.max_region_area_to_merge_into = 500
[survivors/src/main.rs:61:5] nav_mesh_settings.max_edge_length = 80
[survivors/src/main.rs:62:5] nav_mesh_settings.max_contour_simplification_error = 1.1
[survivors/src/main.rs:63:5] nav_mesh_settings.max_tile_generation_tasks = Some(
    8,
)

I found #2 about problems caused when walkable radius is set to 0, but this doesn't seem to apply here (plus it seems to be fixed).

TheGrimsey commented 2 months ago

Hmmm, that is an interesting issue. And right at the edge of a nav tile.

The tiles don't overlap quite enough for it to generate correct geometry.

TheGrimsey commented 2 months ago

Could you try with a decreased max_contour_simplification_error? Since this is a bunch of squares, it might work better with less allowed simplifiation.

mnett82 commented 2 months ago

After decreasing the value down to 0.1, this issue seemingly becomes non-reproducible :smiley: I didn't properly bisect to test for the maximum value of max_contour_simplification_error that fixes the issue, but it's interesting that 0.1 works (same as the actor size set up in the NavMeshSettings).

For reference, I've uploaded the code I used to initially reproduce this issue here.

What do you want to do with this issue? Should this be closed, or is there anything I can help to dig into?

TheGrimsey commented 2 months ago

I'll probably update the docs for max_contour_simplification_error to note this case but otherwise, I think this can be closed 🫡