A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(nav): apply grid obstacle changes without bake throttling
yhh0a9d9d3f5416
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9606c65bd..f9e740f7d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,8 @@ published separately; it ships inside the editor.### Fixed+- **2D navigation doors close without the mesh bake delay.** Grid obstacle marking runs on the next navigation tick even when the previous obstacle update was less than 200 ms ago. Closing and reopening a passage immediately invalidates cached connectivity; polygon mesh baking keeps its existing throttle.+- **Couriers can pass occupied intermediate grid waypoints.** A parked agent no longer traps a follower at an intermediate cell centre. The follower may join the next route segment only when its full body fits the connection through the static grid; final destinations still use the existing arrival rules.- **Finished Web audio handles release their runtime references.** Stopped and naturally completed voices drop decoded buffers, sources, pool nodes and contexts after releasing their pool slot. Retaining a finished handle keeps its ID and duration available without pinning PCM; terminal controls remain harmless, while paused voices retain the state needed to resume and natural completion still notifies once.diff --git a/docs/astro/src/content/docs/gameplay/ai/navigation.mdx b/docs/astro/src/content/docs/gameplay/ai/navigation.mdxindex 773b3a63a..a86b83135 100644--- a/docs/astro/src/content/docs/gameplay/ai/navigation.mdx+++ b/docs/astro/src/content/docs/gameplay/ai/navigation.mdx@@ -175,8 +175,9 @@ geometry, or what stops blocking without moving:Blocking is a **bake input**, not a filter over the answer: an obstacle takes itsground away *before* the walkable area is eroded, so routes keep the agent's fullwidth clear of it rather than scraping along its face. Changing one — moving it,-resizing it, switching it on or off — rebuilds the navigable world, at most a few-times a second.+resizing it, switching it on or off — rebuilds the mesh at most once per 200 ms.+The 2D grid marks obstacle changes on the next navigation tick without that bake+delay, so a newly closed passage is excluded before agents plan or move.```typescript// A door swinging open, from any system with world access:diff --git a/docs/astro/src/content/docs/zh-cn/gameplay/ai/navigation.mdx b/docs/astro/src/content/docs/zh-cn/gameplay/ai/navigation.mdxindex 395aeb2ea..b5528ca15 100644--- a/docs/astro/src/content/docs/zh-cn/gameplay/ai/navigation.mdx+++ b/docs/astro/src/content/docs/zh-cn/gameplay/ai/navigation.mdx@@ -151,7 +151,8 @@ export const setupNav = defineSystem([Res(Nav)], (nav) => {阻挡是**烘焙的输入**,不是对答案的过滤:障碍在可走区域被腐蚀**之前**就把地面拿走,所以路线离它的距离是完整的 agent 宽度,而不是贴着它的面蹭过去。改动一个障碍——移动、-改尺寸、开关——都会重建可走世界,每秒最多几次。+改尺寸、开关——都会重烘焙网格,两次烘焙至少间隔 200 毫秒。2D 格子在下一次导航更新时+立即重标记障碍,不等待这段烘焙节流;刚关闭的通道会在代理规划和移动之前排除。```typescript// 门打开了,在任何能访问 world 的系统里:diff --git a/sdk/src/ai/nav/NavPlugin.ts b/sdk/src/ai/nav/NavPlugin.tsindex c35d822a9..1ef44becd 100644--- a/sdk/src/ai/nav/NavPlugin.ts+++ b/sdk/src/ai/nav/NavPlugin.ts@@ -133,7 +133,7 @@ export function bakeVolumes(* Take the obstacles as they are now, and say whether the surface had to be* rebuilt for them. Blocking is a bake input, not a query filter — one marked* after the erosion would leave routes scraping its face — so a door opening is a- * bake, throttled to one per NAV_REBAKE_MS. `state` is carried across frames.+ * mesh bake, throttled to one per NAV_REBAKE_MS. Grids mark blockers immediately.*/export function updateObstacles(nav: Navigation, obstacles: readonly NavObstacleBox[], state: ObstacleState, now: number,@@ -145,7 +145,7 @@ export function updateObstacles(// however long they have stood still.const unmarked = grid !== null && grid !== state.grid;if (!changed && !unmarked) return false;- if (changed && now - state.at < NAV_REBAKE_MS) {+ if (changed && !grid && now - state.at < NAV_REBAKE_MS) {// Something is still moving. Say so ONCE: an obstacle that never settles// rebuilds the world several times a second, which is a scene to fix// rather than a cost to absorb.diff --git a/sdk/tests/nav-obstacles.test.ts b/sdk/tests/nav-obstacles.test.tsindex 244bad590..48adb5337 100644--- a/sdk/tests/nav-obstacles.test.ts+++ b/sdk/tests/nav-obstacles.test.ts@@ -148,17 +148,31 @@ describe('updateObstacles', () => {expect(grid.isWalkable(4, 4)).toBe(false);});- // A rebuild is the most expensive thing a running game can ask of navigation,- // so something that changes every frame must not get one every frame.- it('will not rebuild twice inside its own interval', () => {+ it('will not rebake a mesh twice inside its own interval', () => {const nav = new Navigation();- nav.setSurface(new NavGrid({ width: 9, height: 9, cellSize: 10 }));+ nav.setSurface(bake([]));const s = state();expect(updateObstacles(nav, [blocker()], s, 10_000)).toBe(true);expect(updateObstacles(nav, [blocker({ center: { x: 10, y: 0, z: 0 } })], s, 10_050)).toBe(false);expect(updateObstacles(nav, [blocker({ center: { x: 10, y: 0, z: 0 } })], s, 10_400)).toBe(true);});+ it('closes and reopens a grid passage without the mesh bake delay', () => {+ const nav=new Navigation(),grid=new NavGrid({width:11,height:9,cellSize:10});+ for(let y=0;y<9;y++)if(y!==4)grid.setWalkable(5,y,false);+ nav.setSurface(grid);const s=state();+ const from={x:20,y:40},to={x:80,y:40},opts={radius:3};+ updateObstacles(nav,[],s,10_000);+ expect(nav.queryWorldPath(from,to,opts).status).toBe('complete');+ const gate=blocker({center:{x:50,y:40,z:0},halfExtents:{x:4,y:4,z:10}});+ expect(updateObstacles(nav,[gate],s,10_001)).toBe(true);+ expect(grid.isNavigable({x:50,y:40},opts)).toBe(false);+ expect(nav.queryWorldPath(from,to,opts).status).toBe('partial');+ expect(updateObstacles(nav,[],s,10_002)).toBe(true);+ expect(grid.isNavigable({x:50,y:40},opts)).toBe(true);+ expect(nav.queryWorldPath(from,to,opts).status).toBe('complete');+ });+// The obstacles were already standing there; the grid is the new thing.it('marks a grid the game has only just installed', () => {const nav = new Navigation();diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 75ef34f57..d9bd4d2f1 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -28,6 +28,8 @@ export const NOTES_FLOOR = 'v0.65.0';* the reader recognises anyway.*/export const NOTED = {+ 'fix(nav): apply grid obstacle changes without bake throttling':+ { note: '2D navigation doors close without the mesh bake delay.' },'fix(nav): pass occupied intermediate grid waypoints safely':{ note: 'Couriers can pass occupied intermediate grid waypoints.' },'test(nav): sample trusted keys before paused frame cleanup':diff --git a/tools/verify-navigation-workshop.mjs b/tools/verify-navigation-workshop.mjsindex dafca90aa..a5bfc92e4 100644--- a/tools/verify-navigation-workshop.mjs+++ b/tools/verify-navigation-workshop.mjs@@ -53,7 +53,7 @@ try {const box = await page.evaluate(name => window.__estellaCooked.probe([name]).at[name], name);assert(box, 'Missing '+name);await page.mouse.click(512+box.x,360-box.y);- await page.waitForTimeout(350); // The real obstacle-change throttle is 200 ms.+ await page.waitForTimeout(350); // Run the real UI event and navigation ticks before pausing.await paused(true);};const snapshot = async name => {