From 5e46afdb0f040782f079b3397c1bbf5e80cb2ecc Mon Sep 17 00:00:00 2001 From: Orkuncakilkaya Date: Sun, 27 Sep 2026 22:05:07 +0300 Subject: [PATCH] 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 --- packages/ludic.nav/README.md | 1 + packages/ludic.nav/query.ludic | 8 ++++++++ packages/ludic.nav/state.ludic | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/packages/ludic.nav/README.md b/packages/ludic.nav/README.md index ca214a46..0f6eba1f 100644 --- a/packages/ludic.nav/README.md +++ b/packages/ludic.nav/README.md @@ -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 diff --git a/packages/ludic.nav/query.ludic b/packages/ludic.nav/query.ludic index 94684688..21e6ef6f 100644 --- a/packages/ludic.nav/query.ludic +++ b/packages/ludic.nav/query.ludic @@ -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 diff --git a/packages/ludic.nav/state.ludic b/packages/ludic.nav/state.ludic index 23a1ba8e..cf0f240c 100644 --- a/packages/ludic.nav/state.ludic +++ b/packages/ludic.nav/state.ludic @@ -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 }