ludic.nav (23.5b): a baked mesh resident by chunk

nav_load_index indexes a saved mesh's tiles (cell, offset, size, ref) from their headers and keeps the file open, with no tile in. nav_tiles_keep reads in the tiles within rin of any player and removes those past rout of all; the file is read through Ludic's pack-aware file_open. The file format is unchanged. tiles_test: tiles come and go with the point, a path works across the seams once they are in, and a reset closes all. Measured on the baked maps (the 900 / 1100 m ring round the start): Maroon 617 of 1807 tiles in, 8.9 MB instead of about 27 MB for a person and 5.4 MB of about 14 for a large walker; Lamar 391 of 1147. Both libraries are rebuilt; nav 17/17 on the Mac and the PC, DLL KERNEL32 only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 11:07:27 +03:00
parent 3915af34c2
commit e807fd556c
12 changed files with 229 additions and 6 deletions

View file

@ -47,6 +47,8 @@ export state NavState {
nv_short: int = 0
nv_crowds: []pointer = nv_none() # a crowd per kind, on that kind's mesh (crowd.ludic)
nv_agent: []float = floats(6) # the last walker read: position, velocity
nv_files: []pointer = nv_none() # a file-backed mesh's file, kept open for its tiles (resident.ludic)
nv_tile: []float = floats(4) # the last tile asked about: centre x, z, in, bytes
}
function nv_none() -> []pointer {
let m = new []pointer
@ -60,6 +62,8 @@ function nv_mesh(nav_st: NavState, kind: int) -> pointer {
function nv_set(nav_st: mut NavState, kind: int, h: pointer) -> bool {
if kind < 0 or kind >= NAV_KINDS { return false }
nv_crowd_drop(nav_st, kind)
if nav_st.nv_files[kind] != null { file_close(nav_st.nv_files[kind]) }
nav_st.nv_files[kind] = null
if nav_st.nv_meshes[kind] != null { nvc_free(nav_st.nv_meshes[kind]) }
nav_st.nv_meshes[kind] = h
return h != null