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

Allow Navigation to be more flexible #47024

Merged
merged 1 commit into from
Mar 17, 2021
Merged

Conversation

groud
Copy link
Member

@groud groud commented Mar 15, 2021

In the previous implementation, you needed two edges to be almost exactly similar for two regions to be connected (same length, close to each other and almost parallel. Now, the conditions are similar but two edges of different length can be connected too. This makes navigation a lot more flexible.

Peek 15-03-2021 13-56

I also implemented some changes:

  • Fixed a small bug where some places were not reachable in a polygon when calling map_get_path (the algorithm did not go over all of a polygon's faces).
  • Navigation polygon debug display now shows different polygons with a slight variation of color. Edges are usually the places where the path finding algorithm can have issues, so it's important to be able to see where they are.
  • Display doors connecting several regions, with the circles being the connection margin to connect two regions.

@groud groud added this to the 4.0 milestone Mar 15, 2021
@groud groud requested review from a team as code owners March 15, 2021 12:58
@Zireael07
Copy link
Contributor

Zireael07 commented Mar 15, 2021

What happens if the two polys (edges) overlap slightly? In the past, that would break navigation, too.

Also, is this for 2D only or also for 3D?

Copy link
Contributor

@AndreaCatania AndreaCatania left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR doesn't have the 3D editor, right?

modules/gdnavigation/gd_navigation_server.cpp Show resolved Hide resolved
modules/gdnavigation/gd_navigation_server.cpp Outdated Show resolved Hide resolved
modules/gdnavigation/gd_navigation_server.h Outdated Show resolved Hide resolved
modules/gdnavigation/nav_map.cpp Outdated Show resolved Hide resolved
modules/gdnavigation/nav_utils.h Outdated Show resolved Hide resolved
@drcucaracha
Copy link

Hello, could you give my idea of an improvement if it is not implemented? the idea would be to have a slider in the inspector when creating a navmesh and that will be used to extrude the nacmesh in to prevent it from always navigating overboard and make it look like a more natural movement

@groud
Copy link
Member Author

groud commented Mar 15, 2021

What happens if the two polys (edges) overlap slightly? In the past, that would break navigation, too. Also, is this for 2D only or also for 3D?

I don't know, it seems to work fine. Overlapping regions stil does not work, but if it's close enough to create a pathway it seems to work.

It's for both 3D and 2D, behind the scene the 2D servers calls the 3D version.

This PR doesn't have the 3D editor, right?

Nope, I am not familiar with the 3D editor enough. And without a working test project it's hard to test.

Hello, could you give my idea of an improvement if it is not implemented? the idea would be to have a slider in the inspector when creating a navmesh and that will be used to extrude the nacmesh in to prevent it from always navigating overboard and make it look like a more natural movement

Sorry that's out of the scope of this PR. You may open a proposal in the godot-proposal repository if you want.
Note that I don't plan to work on this anymore for now, I have to go back to working on the TileMap/TileSet editors.

@groud
Copy link
Member Author

groud commented Mar 15, 2021

@AndreaCatania I made the changes you requested, thanks!

@Cykyrios
Copy link
Contributor

Not sure how feasible it is, but would computing the boolean difference/intersection between overlapping regions help with said overlap breaking navigation? That way you could remove the difference from one region, or have the intersection as a separate region, and the edges would line up cleanly.

Copy link
Contributor

@AndreaCatania AndreaCatania left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@akien-mga akien-mga merged commit 08ca418 into godotengine:master Mar 17, 2021
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants