Add navigation path simplification #90434
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds navigation path simplification for NavigationServer and NavigationAgent.
Resolves #60277
Resolves #19011 (the oldest navigation issue back from 2018 ... weeee!)
This adds a variant of Ramer-Douglas-Peucker algorithm for 2D and 3D to simplify navigation paths.
With this simplification enabled and a higher epsilon all the path points that are not critical points (like a corner or steep ground obstacle) will be removed from the path. The epsilon is in world units, so meters for 3D and pixels for 2D.
This helps with all kinds of agent movement problems in "open fields" and also helps with "steering" agents because they only have more critical path points to aim for.
Note that this simplification is a post-processing of the path query, so it does not help with path query performance, it adds performance cost.
NavigationAgents
The
NavigationAgent2D
andNavigationAgent3D
have 2 new properties added to enable the simplification and control the epsilon.NavigationPathQueryParameters
The
NavigationPathQueryParameters2D
andNavigationPathQueryParameters3D
also have these 2 new properties added.NavigationServer
The
NavigationServer2D
andNavigationServer3D
have a newsimplify_path()
function added.Because this NavigationServer function is not specific to navigation it can also be used with "any" path arrays.
E.g. it can also be used with point arrays commonly used in other nodes and classes like Line2D, Path2D, or Path3D.