DirectionalNavigationMap no longer caches AutoDirectionalNavigation node connections
#22194
+135
−133
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.
Objective
Solution
At the suggestion of @viridia and affirmed by @ickshonpe on Discord, the directional navigation map should no longer contain any
AutoDirectionalNavigationnode connections. This PR:AutoDirectionalNavigationnodes within thenavigatefunction of theDirectionalNavigationsystem parameter.navigatewill prefer to find a destination within the map of manual edges first before conducting the brute force search.Testing
There are two relevant examples that I tested to ensure there were no regressions:
cargo run --example directional_navigation: manually defined edges are respected. Navigating east and west along the same row loops correctly, and navigating north and south along a column works without looping as specified in the example.cargo run --example auto_directional_navigation: Navigation also works as expected here.However, I did not manually test whether removing an
AutoDirectionalNavigationnode during execution of an app results in the navigation system adapting, but I assume it would be evident since the algorithm is no longer using a cached map of those types of edges.I wanted to have a go at writing an automated test for the “automatic” portion of it, but I got stuck trying to get the spawned nodes to have valid values for their
ComputedNodeandUiGlobalTransform(values that didn't represent zero sized content or no translation despite my attempts at specifying so). I just stuck to validating that behavior via the auto_directional_navigation example.It would be nice to have a test with both automatic and manual navigation would be nice to have, but may be overkill. It’s just relatively simple if/else logic there.
You can test out the examples to make sure that the directional navigation behaves as expected. If you’d like to go above and beyond, you could try removing some
AutoDirectionalNavigationnodes during execution and seeing if navigation adapts.I’ve only run the examples on MacOS