feat(walls): windows — see-through barrier, movement follows blocks_movement (#57)
- geometry.Wall carries the stored blocks_sight/blocks_movement switches; sight asks blocksSight, movement and the status rules ask blocks (open door passes both). - worldmap translates both switches; moverules only pushes on a movement barrier. - leakcheck and the tile oracle read blocks_sight independently. - Walls/token-details/tiles groups prove both forms, sight-through, stuck, push and the locked-window open refusal; existing scenes stay byte-identical. Ref #57 # Conflicts: # server/geometry.nim # server/world.nim # server/worldmap.nim # tools/leakcheck.nim
This commit is contained in:
+15
-2
@@ -28,15 +28,28 @@ type
|
||||
wdRight = "right"
|
||||
|
||||
Wall* = object
|
||||
## The wall as geometry sees it. The two barrier fields are the stored switches (#57): a
|
||||
## `window` stores `sightBarrier:false, movementBarrier:true`, so sight passes along its whole
|
||||
## drawn length while movement and the status rules still treat it as a barrier. An open door
|
||||
## passes both ways whatever the switches say (DESIGN 5.8). Both default to `true` so a wall
|
||||
## built without switches (tests, fixtures) keeps the historic solid-wall behaviour.
|
||||
a*, b*: Vec
|
||||
door*, open*: bool
|
||||
sightDir*: WallDir
|
||||
sightBarrier*: bool = true
|
||||
movementBarrier*: bool = true
|
||||
|
||||
const
|
||||
Eps* = 1e-9 # geometric tolerance (px)
|
||||
RayEps = 1e-4 # angular nudge past endpoints (rad)
|
||||
|
||||
proc blocks*(w: Wall): bool = not (w.door and w.open)
|
||||
proc blocks*(w: Wall): bool =
|
||||
## The movement rule: a wall blocks movement unless it is an open door or its switch is off.
|
||||
w.movementBarrier and not (w.door and w.open)
|
||||
|
||||
proc blocksSight*(w: Wall): bool =
|
||||
## The sight rule: a wall blocks sight unless it is an open door or its switch is off.
|
||||
w.sightBarrier and not (w.door and w.open)
|
||||
|
||||
proc cross*(a, b: Vec): float = a.x * b.y - a.y * b.x
|
||||
proc `-`*(a, b: Vec): Vec = (a.x - b.x, a.y - b.y)
|
||||
@@ -76,7 +89,7 @@ proc visibilityPolygon*(o: Vec, walls: openArray[Wall], radius: float,
|
||||
(o.x + radius * cos a1, o.y + radius * sin a1)))
|
||||
angles.add arctan2(sin a0, cos a0) # same (-pi,pi] range as the wall angles, else the sort scrambles the fan
|
||||
for w in walls:
|
||||
if not w.blocks: continue
|
||||
if not w.blocksSight: continue
|
||||
# shortcut: walls beyond the circle are only culled by ray clipping, O(rays*walls); upgrade: spatial grid
|
||||
if max(w.a.x, w.b.x) < o.x - radius or min(w.a.x, w.b.x) > o.x + radius or
|
||||
max(w.a.y, w.b.y) < o.y - radius or min(w.a.y, w.b.y) > o.y + radius: continue
|
||||
|
||||
Reference in New Issue
Block a user