Skip to content

Nav: a navmesh for hand-made levels (nav: true in a level definition) - #130

Merged
larelgit merged 2 commits into
mainfrom
claude/level-navmesh
Nov 21, 2026
Merged

larelgit merged 2 commits into
mainfrom
claude/level-navmesh

Conversation

@larelgit

Copy link
Copy Markdown
Owner

What

A navmesh for hand-made levels. A level definition takes nav: true; while no region is loaded, the levels placed by id that say so are baked in memory as they are placed and are one NavRegion, so NPC routes, plain_sight, nav_path, path_to, move_to path=true and clearance work in a game built of level files as they do in a region.

Why

A game whose world is level files placed by id (spawn_level_by_id) has no region and so no tiles to bake. Its NPCs planned on the local grid, which plans in the plane: an NPC under a player on a walkway stood under him, and one on the floor never found the stairs up.

How

  • What is baked: the static solids of the levels that ask. Movers and what has Health are left out and carve the navmesh, as does everything that is not the levels' own: a shut door closes its doorway and gives it back when it rests open; a crate gives its ground back the tick it is broken, with nothing built again.
  • Chunks: squares of 32 columns (LEVEL_CHUNK) on a world-aligned grid, one bake per body class of the nav settings, each from the solids within the body's reach of it, through the same sampler as a tile (bake_chunk), stitched across every edge as a voxel region's chunks are.
  • Kept bakes: a chunk is kept under a ChunkKey whose hash is its solids and the grid's corner, in NavBakes and in a process-wide store, so levels placed again (a chapter restarted, a snapshot loaded, the next test) bake nothing twice.
  • Kept up to date: refresh makes it again when PlacedLevels or content changes, or when a baked solid goes or moves (only its chunks are baked). The body classes are built at once on the compute pool.
  • Nothing is written to assets/nav/; --check-content and --bake-nav do not see it. Only machines that simulate bake.

Compatibility

A level without nav builds nothing: refresh remembers that the levels placed ask for none and returns. LevelDef::nav is not serialized when false, so definition hashes do not change. With a region loaded the navmesh is the region's, as before.

Checks

  • New: crates/shards_npc/tests/npc/level_nav.rs (7 tests): the stairs are taken and a goal overhead is not in plain sight; a level that does not ask keeps the local grid; a door carves its doorway; a baked solid that goes bakes only its chunk; a solid with Health carves and gives its ground back; two levels are one navmesh and levels placed again bake nothing; an NPC climbs the stairs to a player on a walkway.
  • Local: cargo clippy --workspace --all-targets -- -D warnings, cargo test -p shards_npc, cargo test -p shards_level. The whole workspace and the template were not run locally (the machine ran out of memory building them next to other work); CI runs them.
  • Docs: the manual ("The navmesh of hand-made levels"), docs/agents/world-regions-nav.md, CHANGELOG.md, docs/engine-progress.md.

🤖 Generated with Claude Code

A game whose world is level files placed by id has no region, so its NPCs planned on the local grid, in the
plane: one under a player on a walkway stood under him, and one on the floor never found the stairs up. A
`level` definition now takes `nav: true`. While no region is loaded, the levels placed that say so are baked
in memory as they are placed, from their own static solids, in chunks of 32 columns on a world-aligned grid,
once per body class of the nav settings, and are one NavRegion: routes, plain_sight, nav_path, path_to,
move_to path=true and clearance use it.

Movers and what has Health are left out of the bake and carve it, as does everything that is not the levels'
own: a shut door closes its doorway, a crate gives its ground back when it is broken. Chunk bakes are kept by
what they are made from, in the world and in the process, so levels placed again bake nothing twice, and a
baked solid that goes bakes only its chunks again. The body classes are built at once on the compute pool.
Nothing is written to assets/nav/.

A level without `nav` builds nothing, so a game that does not ask plays, and replays, as it did.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

NoLevelNav (the note that the levels placed ask for no navmesh) is outside the simulation: a function of the levels placed and content, made again by the snapshot rebuild. The levels' bake reads the levels' own static colliders, only where no region is loaded, so a voxel field cannot be what it reads.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@larelgit
larelgit merged commit 3e6d7d9 into main Nov 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants