From f65eda8b47fa66c0d81cd778abbb044a88cb6a89 Mon Sep 17 00:00:00 2001 From: Orkuncakilkaya Date: Sun, 27 Sep 2026 22:41:30 +0300 Subject: [PATCH] ludic.nav (17.10): the time paths take, counted in the shim nav_us() gives the microseconds spent in nav_path across the loaded meshes. The shim times each path with the OS's monotonic clock (clock_gettime, or QueryPerformanceCounter from KERNEL32), so the DLL still needs no C++ runtime. Both libraries are rebuilt, and 13 tests pass on the Mac and the PC. Co-Authored-By: Claude Opus 5.5 --- packages/ludic.nav/README.md | 2 +- .../lib/macos-arm64/libludicnav.dylib | 4 ++-- .../ludic.nav/lib/windows-x64/ludicnav.dll | 4 ++-- .../ludic.nav/lib/windows-x64/ludicnav.lib | 4 ++-- packages/ludic.nav/native.ludic | 1 + packages/ludic.nav/native/shim/nav_query.inl | 12 +++++++++-- packages/ludic.nav/native/shim/nav_shim.cpp | 21 +++++++++++++++++++ packages/ludic.nav/query.ludic | 9 ++++++++ packages/ludic.nav/tests/nav_test.ludic | 10 +++++++++ 9 files changed, 58 insertions(+), 9 deletions(-) diff --git a/packages/ludic.nav/README.md b/packages/ludic.nav/README.md index 0f6eba1f..70d99108 100644 --- a/packages/ludic.nav/README.md +++ b/packages/ludic.nav/README.md @@ -51,7 +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_asked()`, `nav_found()`, `nav_short()`, `nav_us()` | paths asked for, found and cut short since the meshes loaded, and the microseconds they took (timed in the shim by the OS clock: a game's measure of how often its walkers had a way, and what it cost) | | `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/lib/macos-arm64/libludicnav.dylib b/packages/ludic.nav/lib/macos-arm64/libludicnav.dylib index 3941b8a7..7d84075a 100755 --- a/packages/ludic.nav/lib/macos-arm64/libludicnav.dylib +++ b/packages/ludic.nav/lib/macos-arm64/libludicnav.dylib @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:10555b7baa5958700f0ce4599e85fc4fc18b9c92afbbacfa64f04b630f42f583 -size 176816 +oid sha256:969c1ee0010c0fe88abcdfceb1a166031a8f6519b9e77a27c27331cbe2036e0b +size 176912 diff --git a/packages/ludic.nav/lib/windows-x64/ludicnav.dll b/packages/ludic.nav/lib/windows-x64/ludicnav.dll index 7a9c6695..0bdc9341 100644 --- a/packages/ludic.nav/lib/windows-x64/ludicnav.dll +++ b/packages/ludic.nav/lib/windows-x64/ludicnav.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:99671e7df79802010fbf132f736d1b5e2681f0cd72ab71e3aa6e7026b837c97c -size 337408 +oid sha256:0ef49349d93dbc3b94c3743f80fa56f2acf4f5e02f16faba6ec13823b5705aaa +size 337920 diff --git a/packages/ludic.nav/lib/windows-x64/ludicnav.lib b/packages/ludic.nav/lib/windows-x64/ludicnav.lib index 9e1bdfe3..6bcfe136 100644 --- a/packages/ludic.nav/lib/windows-x64/ludicnav.lib +++ b/packages/ludic.nav/lib/windows-x64/ludicnav.lib @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c3e4f7ae19a6113829feffe2ed99e4a8f6b8fb2831c90115f489d1ecf646216a -size 3866 +oid sha256:0ea766bfe59613b41a1566f41de772d49602191ad7e188bef3bcf453c55d6114 +size 4022 diff --git a/packages/ludic.nav/native.ludic b/packages/ludic.nav/native.ludic index 71d02ce1..190af731 100644 --- a/packages/ludic.nav/native.ludic +++ b/packages/ludic.nav/native.ludic @@ -11,6 +11,7 @@ extern function nvc_nearest(h: pointer, x: float, y: float, z: float, out: point extern function nvc_area_cost(h: pointer, f: int, area: int, cost: float) -> void = "nav_area_cost" extern function nvc_path(h: pointer, f: int, sx: float, sy: float, sz: float, ex: float, ey: float, ez: float, out: pointer, max: int) -> int = "nav_path" extern function nvc_partial(h: pointer) -> int = "nav_partial" +extern function nvc_us(h: pointer) -> int = "nav_us" extern function nvc_raycast(h: pointer, f: int, sx: float, sy: float, sz: float, ex: float, ez: float) -> int = "nav_raycast" extern function nvc_random_near(h: pointer, f: int, x: float, y: float, z: float, r: float, seed: int, out: pointer) -> int = "nav_random_near" extern function nvc_stage(size: int) -> pointer = "nav_stage" diff --git a/packages/ludic.nav/native/shim/nav_query.inl b/packages/ludic.nav/native/shim/nav_query.inl index c3a8fdf3..9eb476a6 100644 --- a/packages/ludic.nav/native/shim/nav_query.inl +++ b/packages/ludic.nav/native/shim/nav_query.inl @@ -22,8 +22,7 @@ NAV_SHIM void nav_area_cost(void *h, int f, int area, float cost) { // the corners of a path from one point to another, at most max of them, into out: the count, or // -1 when either end is off the mesh. One that cannot reach the end stops as near it as the mesh // allows, and nav_partial says so -NAV_SHIM int nav_path(void *h, int f, float sx, float sy, float sz, float ex, float ey, float ez, float *out, int max) { - Nav *n = static_cast