Document architecture checkpoint and restore original task callback order

This commit is contained in:
UnixNight committed 2026-10-25 12:56:17 -04:00
1 parent 69d0187a21
commit 531883aaac
45 files changed
+2935 -43

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
"""Source camera predicate priorities/order, including deliberately non-nearest hits."""
import importlib.util
from pathlib import Path
import sys
import unittest
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'tools' / 'binary'))
spec = importlib.util.spec_from_file_location('checkpoint_camera_ray',
ROOT / 'tools' / 'binary' / 'checkpoint_camera_ray.py')
ray = importlib.util.module_from_spec(spec)
spec.loader.exec_module(ray)
class CameraRayCheckpointTests(unittest.TestCase):
def test_source_and_route_data(self):
data = ray.recover(ROOT.parent / 'Original')
self.assertEqual(len(ray.ANCHORS), len(data['anchors']))
expected = {'level1b.omt': (2851, 2483, 18), 'VR04.omt': (508, 420, 0),
'level1.omt': (5231, 3860, 24)}
for name, (polygons, walls, excluded) in expected.items():
entry = data['route_geometry'][name]
self.assertEqual({3: polygons}, entry['registered_polygon_corner_counts'])
self.assertEqual(walls, entry['wall_grid_polygons'])
self.assertEqual(excluded, entry['nc_polygons_excluded'])
self.assertEqual(0, entry['checkpoint_polygons_excluded'])
self.assertTrue(entry['shape_ids_ascending'])
def test_grid_rectangle_order_and_negative_truncation(self):
self.assertEqual(129, ray.cell_coordinate(-1))
self.assertEqual(130, ray.cell_coordinate(0))
expected = [(130, 130), (130, 131), (131, 130), (131, 131)]
self.assertEqual(expected, list(ray.cells_between((0, 0, 0), (501, 0, 501))))
self.assertEqual(expected, list(ray.cells_between((501, 100, 501), (0, -100, 0))))
self.assertEqual([], list(ray.cells_between((1e6, 0, 1e6), (1e6, 0, 1e6))))
def test_first_wall_hit_overrides_nearer_all_grid_hit(self):
wall = {(130, 130): ['far', 'near']}
all_grid = {(130, 130): ['nearest_floor']}
distances = {'far': 80, 'near': 20, 'nearest_floor': 10}
query = lambda p, a, b, sides: distances[p]
self.assertEqual(('far', 80), ray.first_hit((0, 0, 0), (100, 0, 0), wall, all_grid, query))
def test_cell_priority_duplicate_tests_fallback_and_gate(self):
seen = []
wall = {(130, 130): ['miss'], (130, 131): ['miss']}
all_grid = {(130, 130): ['hit']}
def accept(p, start, end, sides):
seen.append((p, sides))
return 1 if p == 'hit' else None
self.assertEqual(('hit', 1), ray.first_hit((0, 0, 0), (0, 0, 501), wall, all_grid, accept))
self.assertEqual([('miss', False), ('miss', False), ('hit', False)], seen)
seen.clear()
self.assertIsNone(ray.first_hit((0, 0, 0), (0, 0, 501), wall, all_grid, accept, enabled=False))
self.assertEqual([], seen)
if __name__ == '__main__':
unittest.main()