diff --git a/prototype-server-vision/tests/tgeometry.nim b/prototype-server-vision/tests/tgeometry.nim index 5ea8bf4..56553a0 100644 --- a/prototype-server-vision/tests/tgeometry.nim +++ b/prototype-server-vision/tests/tgeometry.nim @@ -27,16 +27,26 @@ suite "visibility": let w = @[W(50, -50, 50, 0), W(50, 0, 100, 0)] check not sees(w, (0.0, -20.0), (70.0, -20.0)) check sees(w, (0.0, 20.0), (70.0, 20.0)) + # token on the line of the horizontal arm (restored phase-1 probe, with the right expectation): a point just + # below the line is visible past the arm's end-on edge, just above it is shadowed by the vertical arm + check sees(w, (0.0, 0.0), (70.0, 5.0)) + check not sees(w, (0.0, 0.0), (70.0, -5.0)) test "shared endpoint: closed corner of box has no crack": let w = box(-100, -100, 100, 100) check not sees(w, (0.0, 0.0), (130.0, 130.0), 1000) check not sees(w, (-90.0, -90.0), (-130.0, -130.0), 1000) + check sees(w, (0.0, 0.0), (95.0, 95.0), 1000) # the corner itself is visible from inside + check sees(w, (-90.0, -90.0), (90.0, 90.0), 1000) test "collinear walls act as one": let w = @[W(50, -50, 50, 0), W(50, 0, 50, 50)] check not sees(w, (0.0, 0.0), (80.0, 0.0)) # ray through the join check not sees(w, (0.0, 30.0), (80.0, 30.0)) + check sees(w, (0.0, 0.0), (40.0, 0.0)) # in front of the join + check sees(w, (0.0, 0.0), (-80.0, 0.0)) # behind the viewer + check sees(w, (0.0, 0.0), (80.0, 100.0)) # past the far end of the line + check not sees(w, (0.0, 0.0), (80.0, -30.0)) test "collinear walls with a gap let light through": let w = @[W(50, -50, 50, -5), W(50, 5, 50, 50)] @@ -50,6 +60,9 @@ suite "visibility": check not sees(w, (-30.0, -30.0), (-30.0, 30.0)) # base blocks check sees(w, (-30.0, -30.0), (-80.0, -60.0)) check not sees(w, (-30.0, -30.0), (10.0, -5.0), 500) + check sees(w, (-30.0, -30.0), (-10.0, -5.0)) # same side of the stem, above the base + check sees(w, (30.0, -30.0), (80.0, -60.0)) # mirror side + check not sees(w, (30.0, -30.0), (-10.0, -5.0)) test "pillar mid-room casts a shadow, sides visible": var w = box(-200, -200, 200, 200) @@ -70,15 +83,19 @@ suite "visibility": test "token exactly at wall endpoint": let w = @[W(0, 0, 100, 0), W(0, 0, 0, 100)] # corner, token on it let poly = visibilityPolygon((0.0, 0.0), w, 200) - check poly.len > 3 check poly.inside((-50.0, -50.0)) # open outward quadrant check poly.inside((100.0, -30.0)) + check poly.inside((50.0, 50.0)) # arms radiate from the token: the inner quadrant is open too + check poly.inside((-50.0, 50.0)) + check not poly.inside((150.0, 150.0)) # beyond the radius (212 > 200) + check not poly.inside((0.0, 250.0)) test "token at endpoint of free-standing wall sees along it": let w = @[W(0, 0, 100, 0)] check sees(w, (0.0, 0.0), (50.0, -20.0)) check sees(w, (0.0, 0.0), (-50.0, 20.0)) check sees(w, (0.0, 0.0), (50.0, 20.0)) + check not sees(w, (0.0, 0.0), (600.0, 0.0)) # beyond the 500 radius test "long thin corridor": # 1000 long, 20 wide, token at one end; radius 2000 @@ -93,6 +110,7 @@ suite "visibility": let w = box(600, 600, 680, 680) & @[W(1024, 256, 1024, 608)] check sees(w, (908.66, 672.03), (789.36, 584.65), 400) check sees(w, (789.36, 584.65), (908.66, 672.03), 400) + check not sees(w, (908.66, 672.03), (1100.0, 500.0), 400) # the x=1024 wall (y 256..608) is in the way test "radius clips": check not sees(@[], (0.0, 0.0), (300.0, 0.0), 200)