Obstacle is visible in the fov circles
This commit is contained in:
parent
0077def410
commit
925b3aabaa
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -10,11 +10,9 @@ export function* shadowCast(
|
|||
const seen = new Set<string>();
|
||||
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 };
|
||||
}
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue