Repository navigation
Conversation
Array curves need their size at compile time, which does not fit containers sized at runtime, e.g. the pathfinder's cost fields. Vector tracks each element over time like Array, but takes its default values, and thereby its number of elements, on construction. Changing the number of elements over time is not supported. Unlike BaseCurve and Array, set_last appends the new keyframe after the remaining same-time keyframe, so the new value is the one returned at t, and never erases the default keyframe at -inf. Part of #1677. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cost changes overwrote the previous values, so earlier states of the grid could not be restored, e.g. to roll back changes. CostField now records every cell change in a curve::Vector at the time passed to set_cost/set_costs, separate from the current values to keep lookups fast. A change erases the later recorded changes of its cell, so the latest recorded costs always match the current ones. The curve needs an event loop, which is passed down through Grid, Sector and Map. Fixes #1680. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Portal creation, portal connections and path requests had no automated tests; only the interactive demo exercised them. The portals test checks every portal of two small maps, including split sector regions, single-cell portals, blocked edges and portals that are only connected through a winding corridor. The pathfinder test requests paths from several starts to every cell and checks the result against a flood fill of the map: reachable targets must be found with valid waypoints, unreachable and impassable ones must not, and targets outside the grid must be out of bounds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
path: record the history of cost field changes
Cost changes overwrote the previous values, so earlier states of the
pathfinding grid could not be looked up, e.g. to roll back changes in
multiplayer matches.
CostField now records every cell change in a curve, separate from the
current values to keep cost lookups fast. Changes are recorded at the
time passed to set_cost/set_costs. A change erases the later recorded
changes of its cell, so the latest recorded costs always match the
current ones.
curve::Array needs its size at compile time, but cost fields are
sized at runtime. A new curve::Vector container therefore tracks each
element over time like Array, with the number of elements set on
construction. Its set_last always makes the new value the one
returned at t, and never erases the default keyframe at -inf.
The curve needs an event loop, which is passed down through Game, Map,
Grid and Sector.
New tests cover the Vector container, the cost history, portal
creation and path requests. The portal and path tests run on
hand-made maps and are checked against a flood fill of each map.
Fixes #1680.