From 925b3aabaa95a4a9693079f8d434ee137e0fa580 Mon Sep 17 00:00:00 2001 From: Pabloader Date: Mon, 4 May 2026 18:16:33 +0000 Subject: [PATCH] Obstacle is visible in the fov circles --- src/common/navigation/bresenham.ts | 4 ++-- src/common/navigation/fov.ts | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/common/navigation/bresenham.ts b/src/common/navigation/bresenham.ts index a53a586..aaf796a 100644 --- a/src/common/navigation/bresenham.ts +++ b/src/common/navigation/bresenham.ts @@ -263,7 +263,7 @@ export const bresenhamLine = ( * to that point and yields every cell along the ray. You can pass `breaker` * to signal an obstacle — the rest of that ray is then * skipped and the next outline point's ray begins. The obstacle cell itself - * is not yielded (obstacle is hidden). + * is yielded (obstacle is visible). * * **Bounds:** The outline is always generated without clipping so that rays * extend to the full circle perimeter. The individual rays are clipped to @@ -299,8 +299,8 @@ export function* bresenhamCircleGen( }; for (const { x: ox, y: oy } of bresenhamCircleGen(x, y, r, { fill: false })) { for (const linePoint of bresenhamLineGen(x, y, ox, oy, lineBounds)) { - if (options?.breaker?.(linePoint.x, linePoint.y)) break; yield linePoint; + if (options?.breaker?.(linePoint.x, linePoint.y)) break; } } return; diff --git a/src/common/navigation/fov.ts b/src/common/navigation/fov.ts index e8b47b2..4cef193 100644 --- a/src/common/navigation/fov.ts +++ b/src/common/navigation/fov.ts @@ -10,11 +10,9 @@ export function* shadowCast( const seen = new Set(); const keyOf = (px: number, py: number) => `${px},${py}`; - // Yield the source tile itself if it is not blocked. - if (!breaker(x, y)) { - seen.add(keyOf(x, y)); - yield { x, y }; - } + seen.add(keyOf(x, y)); + yield { x, y }; + if (breaker(x, y)) return; type Frame = { octant: number; @@ -68,7 +66,7 @@ export function* shadowCast( const opaque = breaker(mapX, mapY); - if (dx * dx + dy * dy <= radiusSq && !opaque) { + if (dx * dx + dy * dy <= radiusSq) { const key = keyOf(mapX, mapY); if (!seen.has(key)) { seen.add(key);