Skip to content

tools: decode navmesh +0xB8 paired obstacle footprint records (ASSET-281) - #3609

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
eyyun:feat/asset-281-navmesh-b8-volumes
Nov 23, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
eyyun:feat/asset-281-navmesh-b8-volumes

Conversation

@eyyun

@eyyun eyyun commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements ASSET-281 (claimed in #3381 at #3381 (comment)) by decoding and verifying the 6,246,890 96-byte obstacle footprint records at +0xB8 (count = u32@0xDC, non-null across 9,425 of 27,644 0x00010015 navmesh pages) in navmeshes.rpf.

Full-Corpus Layout (6,246,890 records = 3,123,445 pairs across 9,425 tiles)

Across all 9,425 +0xB8-bearing tiles in retail navmeshes.rpf, u32@0xDC is always even (9,425 / 9,425) and the array consists of u32@0xDC / 2 consecutive (outer, inner) record pairs (rec[2*p], rec[2*p + 1]):

Offset Type Meaning Corpus Verification (6,246,890 records / 3,123,445 pairs)
+0x00..+0x07 u64 64-bit obstacle/object UID (also shared across adjacent 128 m tiles when a footprint spans a sector boundary) Identical between rec[2*p] and rec[2*p + 1] on 3,123,445 / 3,123,445 pairs
+0x08..+0x13 f32[3] Finite world-space anchor (x, y, z) (x in [-6165.6, 5146.9], y in [-6491.3, 8117.1], z in [-99.1, 297.2]) Finite and identical between rec[2*p] and rec[2*p + 1] on 3,123,445 / 3,123,445 pairs
+0x14 u8 Contour role / flags byte rec[2*p] is 0x00 (2,750,542) or 0x04 (372,903); rec[2*p + 1] is 0x08 (3,123,445) on 3,123,445 / 3,123,445 pairs
+0x15 u8 2D polygon vertex count N (4 or 8) (rec[2*p].N, rec[2*p + 1].N) is (8, 4) on 3,123,012 pairs (chamfered octagon around an inner quad, typically expanded by 128 fixed-point units) and (4, 4) on 433 pairs (3,123,445 / 3,123,445)
+0x16..+0x55 i16[32] Up to 16 relative 2D (dx, dy) footprint vertices in signed 16-bit fixed point around (x, y) Trailing unused slots +0x16 + 4*N .. +0x55 are 0 on 6,246,890 / 6,246,890 records
+0x56..+0x59 u16, u16 Two 16-bit vertical / extent parameters (u16@0x56 in 0..65,535, u16@0x58 in 3..65,534) Shared across each pair on 3,121,671 / 3,123,445 pairs (99.94%)
+0x5A..+0x5F u8[6] Trailing zero padding 0 on 6,246,890 / 6,246,890 records

Changes

  • tools/navmesh_decode.py:
    • Added _walk_volumes to validate the paired 96-byte +0xB8 schema under --deep, recording checks.navmesh.volumes_valid and navmesh.volumes (pairs, flags, and vertex_counts histograms).
  • docs/navmesh.md:
    • Updated the +0xB8 row in the 0x00010015 header table, added the Paired 96-byte obstacle footprint records (+0xB8, 6,246,890 records) section, and updated Remaining unknowns item 4.
  • tests/test_navmesh_decode.py:
    • Updated build_navmesh to emit valid paired (outer N=8, inner N=4) 96-byte records and added assertions for checks.navmesh.volumes_valid and navmesh.volumes.

Disclosure & Testing

  • AI-assisted.
  • Tested on Windows 11 (NVIDIA GeForce RTX 4050 Laptop GPU, driver 32.0.16.1088; Intel(R) UHD Graphics, driver 32.0.101.6874):
    • python -I tests/test_navmesh_decode.py (13/13 pass)
    • python -I tests/test_text_write_line_endings.py (2/2 pass)
    • python -m compileall -q make_game.py tools tests
    • Full-archive verification on retail Xbox Series 1.0.2.1 navmeshes.rpf: checks.navmesh.volumes_valid = {"pass": 27644, "fail": 0}, navmesh.volumes = {"pairs": 3123445, "flags": {"0": 2750542, "4": 372903, "8": 3123445}, "vertex_counts": {"4": 3123878, "8": 3123012}}.

@rafaelpssz

Copy link
Copy Markdown
Contributor

An independent field census of the +0xB8 records, written before I saw this PR and without its code. It ran over all of navmeshes.rpf on my own 1.0.2.1 copy, counts only, and agrees with the layout here:

  • 9,425 pages and 6,246,890 records, matching your totals.
  • +08/+0C/+10 are finite f32 on every record and fall inside the page's tile on X 86%, Y 87% and Z 99% of records. That fits a world anchor, with some anchors outside their own tile, which suits footprints shared across a sector boundary.
  • +38..+50 and +5C are zero on 6,246,890 / 6,246,890 records.
  • +24..+34 split the records almost exactly in half (3,114,438 / 3,123,878 / 8,574 by whether +28 and +34 are zero), which is your outer/inner pairing seen from the field side.
  • No 64-bit word at +00/+14/+1C/+24/+2C is a resource pointer. +00 is zero on 1,700,954 records and never points into the record array, which is consistent with a UID rather than a link.

I haven't run your tool or checked the polygon decode itself.

@UNYTIX

UNYTIX commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

I found an order-dependent count in navmesh.volumes at f0a6adb0. _walk_volumes() updates the shared counters as it walks the tile, then returns False on the first malformed pair without undoing updates for earlier pairs.

I reproduced it on Windows 11, Python 3.15.2 (python -I -B probe.py), using only build_navmesh(n_volumes=4) from the PR's synthetic tests. For each run, use a fresh new_stats()['navmesh']. Read the record array start with nd.offset_of(struct.unpack_from('<Q', tile, 0xB8)[0]), set the inner record's role byte (start + (2 * pair + 1) * 96 + 0x14) to 7, and call nd.decode_navmesh(tile, 1, stats, True).

  • Both pairs valid: volumes_valid=True, pairs=2.
  • Invalid first pair: volumes_valid=False, pairs=0.
  • Invalid second pair: volumes_valid=False, pairs=1 and one entry for each role 0 and 8.

The two failing tiles have one valid pair each, but the output depends on its position. If these are counts for validated tiles, accumulate locally and merge only after the whole array passes. A test with the second pair malformed would catch the partial update. Synthetic inputs only. AI-assisted (Codex).

@eyyun

eyyun commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the independent full-archive census confirming the layout, @rafaelpssz, and great catch on the partial counter accumulation when a later pair fails validation, @UNYTIX!

Updated _walk_volumes in tools/navmesh_decode.py to accumulate flags and vertex_counts locally and merge into stats["volumes"] only after all dc // 2 pairs pass validation, and added a regression assertion in tests/test_navmesh_decode.py::test_malformed_and_adversarial_inputs for a malformed second pair (n_volumes=4).

Re-ran python -I tests/test_navmesh_decode.py (13/13 OK).

@zneel

zneel commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Reviewed and tested 63c56623 on Windows 11 Pro 10.0.26300, AMD Ryzen 7 9800X3D CPU (64 GB RAM), AMD Radeon RX 9070 XT (AMD 26.11.2), Python 3.12.10: looks good, one question.

run result
pytest tests/test_navmesh_decode.py 13 passed, 3 subtests passed in 2.05s
python -m compileall -q make_game.py tools tests clean

Review: I read _walk_volumes (tools/navmesh_decode.py:629-661), the call site under --deep and the new stats/summary keys, then probed it with the PR's own build_navmesh (synthetic only). Valid tiles count as expected, a (4, 4) pair is accepted, and a bad role byte in the first or second pair now gives volumes_valid=False with all counters at 0. This confirms the fix for the partial-count bug UNYTIX reported. With the head test file against f0a6adb0's tool, test_malformed_and_adversarial_inputs fails (1 != 0), so the new regression assertion catches that bug. The doc's histogram totals match the PR's full-archive numbers (3,123,445 + 433 = 3,123,878 N=4 records), and rafaelpssz's independent census agrees with the field layout. Note: #3834 rewrites the same "Remaining unknowns" item 4 lines (docs/navmesh.md:282-284), so whichever merges second will have a small text conflict.

  1. Question, docs/navmesh.md:250: the +0x56 / +0x58 row gives the type as `i16`, `u16`, but the same row describes u16@0x56 with range 0..65,535 and a high-bit count, and the PR description's table calls it u16, u16. Is +0x56 meant to be signed? If not, the type column should say u16, u16.

AI-assisted (Claude Code); I checked the results.

@sds-228 sds-228 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.

Code review of 63c5662: no issues found. The footprint decoder validates paired records only after the whole pair passes, so malformed input does not partially update counters; docs findings were narrowed accordingly. Targeted suite: 13 tests OK.

AI-assisted (OpenCode).

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.

6 participants