feat: add opt-in 64-bit polygon references - #511
Open
xsploit wants to merge 3 commits into
Open
Conversation
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.
What
Adds an opt-in
DT_POLYREF64build mode to the WASM package and teaches the high-level core API to support either the existing 32-bitnumberreferences or 64-bitbigintreferences.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
RECASTNAVIGATION_DT_POLYREF64to the WASM CMake build;DT_POLYREF64and EmscriptenWASM_BIGINTtogether;PolyRef = number | bigintAPI with signed/unsigned normalization at the raw WASM boundary;Compatibility and packaging
numberrefs by default.webidl-dts-gendoes not parseunsigned 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:
yarn test: 5/5 Vitest tests plus both Node smoke examples pass;2^53, including the full unsigned 64-bit bit pattern: pass.yarn test:polyrefsnow 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.