Repository navigation
Keep the costs inside untouched chunks when the navmesh is carved again - #135
Merged
Merged
Conversation
A door, a shutter or a lift that starts or stops changes the static solids, and carving rebuilt every body class's tile graph from scratch, one class after another, measuring the costs inside every tile or chunk again. On a game with four hand-made levels (44 chunks, four classes) each such tick took ~200 ms. - `NavRegion::build_graph` keeps each instance's key-to-key costs (`InstanceCosts`) and measures again only an instance whose bake, switched-off nodes or graph nodes changed. - The compressed rows are made node by node (`adjacency`) instead of sorting every edge at once. - `refresh` carves the classes at once on the compute pool. The graph is the same as before, so routes, replays and snapshots do not change. A door's tick on those levels: ~200 ms -> ~9-11 ms; three doors at once 214 -> 19 ms. Tests: a_navmesh_carved_again_routes_as_one_built_now (fails when the cache ignores the switched-off nodes), rows_sorted_one_by_one_are_every_edge_sorted_at_once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
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.
A door, a shutter or a lift that starts or stops no longer stalls the tick on a large navmesh.
A mover is static at rest and kinematic in motion, so its start and its stop each change the static solids
refreshtracks. Carving then rebuilt every body class's tile graph, one class after another. Nearly all of that time (about 40 of 45 ms per class) went intobuild_graphrunning Dijkstra between the key nodes of every instance, even the ones the door never touched. On Cranium's four placed levels (44 chunks, four classes), every such tick took about 200 ms, which players felt as a hitch at each door.Changes in
shards_npc::nav::region:NavRegionkeeps each instance's key-to-key costs (InstanceCosts).build_graphmeasures again only the instances whose bake (Arcidentity), switched-off nodes or graph key nodes changed. Positions are global ids, andbaseis fixed for a region's life, so every new region starts with an empty cache.adjacency): count, scatter, then sort each row on its own. The old code sorted every edge at once. The result is the same: rows byto, the cheaper of two duplicates.refreshcarves the classes at once on the compute pool, asbuildalready makes them. Nothing on the carve path reads another class.The graph is the same as before, so routes, replays and snapshots do not change.
Measured on Cranium, headless release at Level 1's hall:
Tests:
a_navmesh_carved_again_routes_as_one_built_nowuses a 2×2 grid. Walls are put up and taken down one by one, and after each change the routes must equal those of a region built with the same walls from the start. It was checked against a broken cache that ignored the switched-off nodes: it fails there, because a stale cost sends a route through the walled tile.rows_sorted_one_by_one_are_every_edge_sorted_at_oncecomparesadjacencyagainst the old global sort on 5000 random edges.Checked locally:
cargo test -p shards_npc: 72 unit and 225 integration tests pass.cargo clippy -p shards_npc --all-targets -- -D warningsis clean.The workspace and sandbox suites were left to CI.
🤖 Generated with Claude Code