Repository navigation
Conversation
…l end find_next_point_in_straight_path keeps the portal at the start index as the initial funnel even when the apex (the point the caller is standing on) is one of that portal's ends. From a degenerate corner like that the funnel should restart at the apex, as in Mononen's simple stupid funnel: the portal constrains nothing there. Keeping both portal ends lets a later point that lies across the portal line from both ends bounce the apex between the two ends forever, so find_path's straight-path loop never advances and appends waypoints without bound (observed as an unbounded allocation on a large game map). Two changes: - path.rs: when the apex is an end of the start portal, start the funnel degenerate at the apex instead of the full portal, so the first processed portal can actually advance the funnel. - query.rs: bound the straight-path loop at two steps per portal (each step advances the path index, so a straight path never needs more), turning any future non-advancing step into NoPathFound instead of an endless allocation. Adds a regression test with two polygons sharing a short edge (a flat triangle and a raised quad beyond it, the target just past one end of the edge). On main the straight path alternates between the two ends of the edge and never reaches the target; with the fix it reaches the target in two steps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
find_next_point_in_straight_pathkeeps the portal at the start index as the initial funnel even when the apex (the point the caller is standing on) is one of that portal's ends. From a degenerate corner like that the funnel should restart at the apex, as in Mononen's simple stupid funnel: the portal constrains nothing there. Keeping both portal ends lets a later point that lies across the portal line from both ends bounce the apex between the two ends forever, sofind_path's straight-path loop never advances and appends waypoints without bound (observed as an unbounded allocation on a large game map).Two changes:
NoPathFoundinstead of an endless allocation.Adds a regression test with two polygons sharing a short edge (a flat triangle and a raised quad beyond it, the target just past one end of the edge). On
mainthe straight path alternates between the two ends of the edge and never reaches the target; with the fix it reaches the target in two steps.Note for running the tests locally: on my machine the workspace's
Cargo.lockneededgoogletest_macro0.14.4 → 0.14.2 to compile the test suite. That change is not part of this PR.I have used AI to assist me with this PR.