Skip to content

feat: add opt-in 64-bit polygon references - #511

Open
xsploit wants to merge 3 commits into
isaac-mason:mainfrom
xsploit:feat/dt-polyref64
Open

feat: add opt-in 64-bit polygon references#511
xsploit wants to merge 3 commits into
isaac-mason:mainfrom
xsploit:feat/dt-polyref64

Conversation

@xsploit

@xsploit xsploit commented Aug 5, 2026

Copy link
Copy Markdown

What

Adds an opt-in DT_POLYREF64 build mode to the WASM package and teaches the high-level core API to support either the existing 32-bit number references or 64-bit bigint references.

The default build and published ABI remain 32-bit.

Why

Large fine-grained tiled navmeshes can exhaust the 32-bit Detour polygon-reference bit budget even when JavaScript memory is otherwise sufficient. Recompiling Detour alone is not enough: polygon refs also cross the WebIDL/WASM boundary through scalar arguments, result refs, arrays, queries, Crowd targets, debug drawing, and direct-navmesh serialization.

Changes

  • adds RECASTNAVIGATION_DT_POLYREF64 to the WASM CMake build;
  • enables DT_POLYREF64 and Emscripten WASM_BIGINT together;
  • generates the appropriate 32-bit or 64-bit WebIDL scalar/ref/array surface;
  • exports a high-level PolyRef = number | bigint API with signed/unsigned normalization at the raw WASM boundary;
  • updates navmesh, query, Crowd, Detour, and debug-drawer ref paths;
  • gives 64-bit direct-navmesh serialization a distinct version so ABI-mismatched data fails closed;
  • keeps compressed TileCache data ABI-portable because it contains no polygon refs;
  • adds a changeset and CI coverage for both ABIs.

Compatibility and packaging

  • Existing consumers continue to receive the 32-bit build and number refs by default.
  • A 64-bit artifact is currently an opt-in source build.
  • webidl-dts-gen does not parse unsigned long long[], so publishing a separate prebuilt 64-bit raw WASM package will still require a BigInt-aware raw declaration generator or checked-in declarations. The high-level core wrapper uses a runtime structural shim and is tested against both builds.

Testing

On Windows with Emscripten, Git Bash, Node 22, and Yarn 4:

  • normal package build: pass;
  • normal yarn test: 5/5 Vitest tests plus both Node smoke examples pass;
  • raw WASM CTest in 32-bit mode: pass;
  • raw WASM CTest in 64-bit mode: pass;
  • high-level core smoke in 32-bit mode: pass;
  • high-level core smoke in 64-bit mode: pass;
  • exact 64-bit values above 2^53, including the full unsigned 64-bit bit pattern: pass.

yarn test:polyrefs now builds and exercises both ABIs in CI. It also avoids capturing Yarn's temporary Node shim by using Emscripten's stable cross-compiling emulator for CTest.

Downstream full-world evidence

This work was developed while testing H1Emu's fine full-world TileCache. A downstream superset branch, with separate TileCache import/native-region fixes that are intentionally not bundled into this PR, successfully materialized 104,935 layers across 100,289 columns into a single 64-bit navmesh with zero add/build failures. It was then exercised by a 2,000-agent benchmark, a 100-player two-hour-equivalent Crowd/obstacle soak, an installed-server startup, and real-client navigation testing.

The TileCache import-safety fixes, native intermediate-region widening, and downstream H1Emu integration will be proposed separately so this PR remains focused on the polygon-reference ABI and core API.

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.

1 participant