feat(nav): 17.10's measure - paths asked for, found and cut short since the meshes loaded (nav_asked / nav_found / nav_short)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-27 22:05:07 +03:00
parent de9c92b360
commit 5e46afdb0f
3 changed files with 15 additions and 0 deletions

View file

@ -51,6 +51,7 @@ import "ludic.nav"
| `nav_next_corner(kind, filter, sx, sy, sz, ex, ey, ez) -> bool` | the next corner of that way, read back as the nearest point is (a walker's one question a frame) |
| `nav_straight(kind, filter, sx, sy, sz, ex, ez) -> bool` | does the straight line stay walkable |
| `nav_random_near(kind, filter, x, y, z, r, seed) -> bool`, `nav_near_x/y/z()` | a reachable point about r away, from the caller's seed |
| `nav_asked()`, `nav_found()`, `nav_short()` | paths asked for, found and cut short since the meshes loaded (a game's measure of how often its walkers had a way) |
| `nav_area_cost(kind, filter, area, cost)` | how dear a kind of ground is to cross by that filter |
## Tests

View file

@ -36,9 +36,17 @@ export function nav_path(nav_st: mut NavState, kind: int, filter: int, sx: float
nav_st.nv_count = 0
if h == null { return -1 }
let n = nvc_path(h, filter, sx, sy, sz, ex, ey, ez, nav_st.nv_out, NAV_CORNERS)
nav_st.nv_asked += 1
if n > 0 { nav_st.nv_count = n }
if n >= 2 { nav_st.nv_found += 1 }
if n > 0 and nvc_partial(h) == 1 { nav_st.nv_short += 1 }
return n
}
# how many paths were asked for, found, and cut short (the end out of reach) since the meshes loaded
export function nav_asked(nav_st: NavState) -> int { return nav_st.nv_asked }
export function nav_found(nav_st: NavState) -> int { return nav_st.nv_found }
export function nav_short(nav_st: NavState) -> int { return nav_st.nv_short }
export function nav_partial(nav_st: NavState, kind: int) -> bool {
let h = nv_mesh(nav_st, kind)
return h != null and nvc_partial(h) == 1

View file

@ -42,6 +42,9 @@ export state NavState {
nv_near: []float = floats(3)
nv_cfg: []float = floats(7) # the configuration handed to the shim, filled in place per build
nv_empty: []float = floats(1) # what the shim is handed for no cylinders or no footprints
nv_asked: int = 0 # paths asked for, found (two corners or more), and cut short
nv_found: int = 0
nv_short: int = 0
}
function nv_none() -> []pointer {
let m = new []pointer
@ -66,4 +69,7 @@ export function nav_drop(nav_st: mut NavState, kind: int) -> void { nv_set(nav_s
export function nav_reset(nav_st: mut NavState) -> void {
for k in 0 .. NAV_KINDS { nv_set(nav_st, k, null) }
nav_st.nv_count = 0
nav_st.nv_asked = 0
nav_st.nv_found = 0
nav_st.nv_short = 0
}