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:
parent
3915af34c2
commit
e807fd556c
12 changed files with 229 additions and 6 deletions
|
|
@ -63,4 +63,35 @@ program TilesTest {
|
|||
expect_eq(a, b)
|
||||
expect_near(last_x(nav_st), ax, 0.0001)
|
||||
}
|
||||
|
||||
test "a saved mesh as an index: only the tiles near a player are in, and they come and go" (nav_st: mut NavState) {
|
||||
expect_eq(map(nav_st, false), 0)
|
||||
let path = Os.temp_dir() + "/ludic_nav_resident.navmesh"
|
||||
expect(nav_save_file(nav_st, NAV_PERSON, path))
|
||||
nav_reset(nav_st)
|
||||
expect(nav_load_index(nav_st, NAV_PERSON, path))
|
||||
expect_eq(nav_tiles_in(nav_st, NAV_PERSON), 0)
|
||||
expect(not nav_nearest(nav_st, NAV_PERSON, 20.0, 0.0, 20.0))
|
||||
let xs = floats(1)
|
||||
let zs = floats(1)
|
||||
xs[0] = 20.0
|
||||
zs[0] = 20.0
|
||||
expect_eq(nav_tiles_keep(nav_st, NAV_PERSON, xs, zs, 1, 60.0, 90.0), 1)
|
||||
expect_eq(nav_tiles_in(nav_st, NAV_PERSON), 1)
|
||||
expect(nav_nearest(nav_st, NAV_PERSON, 20.0, 0.0, 20.0))
|
||||
expect(not nav_nearest(nav_st, NAV_PERSON, 100.0, 0.0, 100.0))
|
||||
xs[0] = 64.0
|
||||
zs[0] = 64.0
|
||||
expect_eq(nav_tiles_keep(nav_st, NAV_PERSON, xs, zs, 1, 60.0, 90.0), 3)
|
||||
expect_eq(nav_tiles_in(nav_st, NAV_PERSON), 4)
|
||||
expect(nav_path(nav_st, NAV_PERSON, 0, 10.0, 0.0, 20.0, 120.0, 0.0, 20.0) >= 3)
|
||||
expect(not nav_partial(nav_st, NAV_PERSON))
|
||||
xs[0] = 110.0
|
||||
zs[0] = 110.0
|
||||
expect_eq(nav_tiles_keep(nav_st, NAV_PERSON, xs, zs, 1, 60.0, 90.0), 1)
|
||||
expect_eq(nav_tiles_in(nav_st, NAV_PERSON), 3)
|
||||
expect(not nav_nearest(nav_st, NAV_PERSON, 20.0, 0.0, 20.0))
|
||||
nav_reset(nav_st)
|
||||
expect_eq(nav_tiles_in(nav_st, NAV_PERSON), 0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue