Skip to content

Nav resolves walls per connected graph and cuts door walls from their trimmed bands (WOR-876) - #418

Open
kcjonson wants to merge 14 commits into
mainfrom
fix/WOR-876-nav-wall-graphs
Open

kcjonson wants to merge 14 commits into
mainfrom
fix/WOR-876-nav-wall-graphs

Conversation

@kcjonson

@kcjonson kcjonson commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

WOR-876. Two faults in how navigation reads built walls:

  • nav::extractWalls put every Built wall into one resolveWallBands call. If any connected wall graph in the colony was rejected by the offsetter, every wall fell back to a raw band and no corner junction was emitted anywhere: one bad wall stripped every corner in the colony, and every door with them.
  • Any wall segment hosting a door was redrawn from its untrimmed band, so its rings overlapped the junction polygons at its ends.

What changes

In two steps, the first with no behaviour change:

  1. Shared geometry (libs/geometry/offset/WallOffset): connectedWallGraphs(segments) groups walls that share an endpoint; wallSpans(segments, gaps, bands) tiles each wall's trimmed band into solid spans and gap spans. wallPiecesAndOutline takes its pieces from the same code, and the render cache uses the shared grouping in place of its own union-find.
  2. Nav (libs/sim/nav/NavInputBuilder): walls are grouped and each graph resolved on its own; a rejected graph keeps the old raw-band path for its own walls only. In an accepted graph a wall with doors takes its rings from wallSpans (doors only; windows stay solid): solid spans carry no opening, each door span carries its door's opening id. Gaps are whole millimetres from one shared construction::openingGaps (libs/sim/construction/OpeningGeometry), moved out of the render cache, which now calls it.

Unchanged: provenance tags, the junction list, portals, when the mesh rebuilds (a construction version change) and what it patches (only rings that changed). Sight's code is untouched; two comments there now say what its door gap matches.

The invariant

For a layout where every wall graph is accepted and no built door sits on a wall with a corner trim, nav's wall input is byte-identical to before. A door on a wall with free ends may move its rings by at most 1 mm (fractions of the wall became whole millimetres).

ExtractWallsReference.test.cpp states it layout by layout against a verbatim copy of the old function:

  • Identical: an L, a T, a closed room, a near-straight join of two thicknesses, two separate graphs, a window on a free wall, a door on a rejected graph.
  • Door rings within 1 mm: a door on a free wall, two doors on one wall, a door and a window on one wall, a door on a wall drawn from its larger endpoint, a door on a diagonal wall (worst measured: 1 mm per axis over seven slopes).
  • Changed on purpose, with the new properties asserted: a room with a door beside a corner, a room with two doors on one wall, a door whose jamb lands 3 mm past the corner trim (the sliver of wall between goes to the door span), and a door reaching into a corner trim (each door span sits between its jambs clamped to the trimmed band; the spans tile the trimmed band exactly, in integer mm2; no ring overlaps a junction beyond the seam tolerance; every other polygon, junction, and portal identical); a rejected graph beside a healthy one (each graph comes out as the old function draws it alone).

Every layout with a door on an accepted graph must also give nav at least one polygon carrying that door's opening id.

wallPiecesAndOutline is compared exactly against a copy of the pre-refactor function over 1,000 inputs with random gaps, on top of the existing sweep.

How checked

  • Tests, with main (PRs 419 and 420) merged in: geometry-tests 498 passed, sim-tests 1207 passed, world-sim-tests 61 passed, each whole. New beside the pin test: NavWallTest.RejectedGraphElsewhere_LeavesRoomPolygonsUnchanged, NavigationSystemTest.RejectedGraphElsewhereKeepsRoomCornersAndDoor, NavigationSystemTest.DoorBesideCornerRoutesThroughDoorNotFlanks, WallProperties.PiecesFromSpansMatchTheReferenceWithGaps, and the WallGraphs tests. The rejected-graph tests fail on the old code. The route test passes on the old code too (the mesh tolerated the overlapping rings, so routes through doors were already right) and is kept as a guard. The door-position check was seen to fire with a door's gap mirrored to the wrong end.
  • In game: a 5 x 5 m built room with a door at t = 0.18 on a wall beside a corner (the dev verb refuses nearer spots). A colonist ordered inside walked in through the door, crossing the wall inside the door's gap; with a rejected wall graph then stamped nearby, the colonist still walked out and back in through it.

Not checked: timing.

Perf: what could move is a construction edit, which rebuilds nav's wall input (twice per construction version: navigation and player visibility) and the render cache. Per graph instead of all at once, the same total resolve work; door walls now go through wallSpans. Nothing here runs per frame. Nothing was timed: builds were running on the machine throughout.

Behaviour to know about

What a player gains is the first fault: one rejected wall no longer breaks corners and doors colony-wide. Door routing itself was already right.

wallSpans given bands that did not resolve returns no spans for any segment (it asserted before). Its callers check the status first, so this only guards a release build. The gaps passed for one wall must not overlap; the header says what the spans are if they do.

The render cache now groups walls with the shared connectedWallGraphs in place of its own union-find, so the order graphs are drawn in can differ from before. It could show only where two separate wall graphs overlap each other. Not checked: whether placement lets two graphs overlap without joining.

Known, on WOR-877: a door on a wall graph that is itself rejected is still solid to nav (old behaviour, now limited to that graph); a door sitting inside a corner trim has a portal but no walkable span.

…pin a backwards and a diagonal door wall (WOR-876)
…graphs

# Conflicts:
#	libs/geometry/offset/WallOffset.test.cpp
wallSpans indexed the trims of bands it only asserted were resolved, so a release build handed a rejected graph would read past them. It now gives every segment an empty list, which keeps its one-list-per-segment shape for callers. The header also states that one segment's gaps must not overlap, and how the spans are tagged when they do.
l, r, dir, and h in the span and graph code and its tests become whole words, as the coding standards ask. Names that were already on main stay as they are, and so does the reference copy of extractWalls.
…ore door walls (WOR-876)

LayoutsHoldWhatTheirNamesSay could pass with a door layout that put no polygon on the door's opening; it now asks for one per door, except on the rejected graph, whose raw bands carry none. Two layouts join the trimmed-band checks: two doors on one room wall, and a door whose jamb lands 3 mm past the corner trim, where the door span takes the sliver. The trimmed-band check now expects that, moving a door span's end to the band's end when the run between is under the 6 mm the offsetter keeps.
…hort names

wallSpans returns empty for bands that are not Ok, which is a legitimate input. Bands that are Ok but whose trims do not match the segments can only be a caller passing bands for other segments, so that case now asserts in a debug build; the release guard stays.

In extractWalls, prov becomes provenance and ji becomes junctionIndex.
@kcjonson
kcjonson marked this pull request as ready for review November 16, 2026 03:44
Copilot AI balanced review requested due to automatic review settings November 16, 2026 03:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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