nav, physics: Recast's and Detour's memory counted (nav_heap_bytes / _peak / _allocs, a counted allocator registered at load, tile bytes staged from it); package tests that crossing the map and back holds the native bytes

The user's walk showed the footprint rising outside the Ludic heap. Jolt's bytes were already counted;
the navmesh's were not, so nothing could see them. Now:
- ludic.nav nav_heap_test: fifty crossings of a four-tile map by the resident index hold the tiles in and
  the native bytes to the first crossing's; a thousand crowd walkers in and out grow nothing; a reset
  gives back every byte the mesh took.
- ludic.physics cross_heap_test: a 1 km map of 64 m chunks kept to a ring round a player crossing
  corner to corner and back, each chunk a heightfield, twelve owned posts and six owned scaled hulls
  as the game makes them: six more crossings hold the bodies, the shapes and Jolt's bytes and peak
  exactly. (A post made as an offset of a cylinder, with only the offset owned, leaked the cylinder
  every time: the game's solid_pillar owns its cylinder directly.)

lib/macos-arm64 rebuilt; lib/windows-x64 needs native/build.sh run on the PC for the new exports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 13:32:18 +03:00
parent 7b91300962
commit b368912c78
9 changed files with 226 additions and 7 deletions

View file

@ -37,3 +37,11 @@ extern function nvc_index_size(h: pointer, i: int) -> int = "nav_index_size"
extern function nvc_index_in(h: pointer, i: int, data: pointer, size: int) -> int = "nav_index_in"
extern function nvc_index_out(h: pointer, i: int) -> int = "nav_index_out"
extern function nvc_load_staged(buf: pointer, size: int) -> pointer = "nav_load_staged"
extern function nvc_heap_bytes() -> long = "nav_heap_bytes"
extern function nvc_heap_peak() -> long = "nav_heap_peak"
extern function nvc_heap_allocs() -> long = "nav_heap_allocs"
# the bytes Recast and Detour hold now (every tile in, the queries, the crowds), the most they ever
# held, and how many blocks they asked for: counted in the shim, apart from the game's heap
export function nav_heap_bytes() -> long { return nvc_heap_bytes() }
export function nav_heap_peak() -> long { return nvc_heap_peak() }
export function nav_heap_allocs() -> long { return nvc_heap_allocs() }