Safety improvements: - Generation counter detects stale BSPNode references after clear()/split_recursive() - GRID_MAX validation prevents oversized BSP trees - Depth parameter capped at 16 to prevent resource exhaustion - Iterator checks generation to detect invalidation during mutation API improvements: - Changed constructor from bounds=((x,y),(w,h)) to pos=(x,y), size=(w,h) - Added pos and size properties alongside bounds - BSPNode __eq__ compares underlying pointers for identity - BSP __iter__ as shorthand for leaves() - BSP __len__ returns leaf count Tests: - Added tests for stale node detection, GRID_MAX validation, depth cap - Added tests for __len__, __iter__, and BSPNode equality Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
8699bba9e6
commit
6caf3dcd05
4 changed files with 442 additions and 118 deletions
|
|
@ -5,7 +5,7 @@ import mcrfpy
|
|||
print("Step 1: Import complete")
|
||||
|
||||
print("Step 2: Creating BSP...")
|
||||
bsp = mcrfpy.BSP(bounds=((0, 0), (100, 80)))
|
||||
bsp = mcrfpy.BSP(pos=(0, 0), size=(100, 80))
|
||||
print("Step 2: BSP created:", bsp)
|
||||
|
||||
print("Step 3: Getting bounds...")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue