[Proc Gen] BSP - Query methods (find, contains) #205

Open
opened 2026-01-12 00:10:05 +00:00 by john · 0 comments
Owner

Parent Issue: #192
Depends On: #202 (BSP core), #203 (BSPNode)

Overview

Add query methods to BSP for finding nodes.

Specification

def find(self, pos: tuple[int, int]) -> BSPNode

Find the smallest (deepest) node containing the position.

Example

bsp = mcrfpy.BSP(bounds=((0, 0), (100, 100)))
bsp.split_recursive(depth=4, min_size=(8, 8))

# Find which room contains a point
node = bsp.find((25, 30))
print(f"Point is in node: {node.bounds}")
print(f"Is leaf (room): {node.is_leaf}")

Implementation Notes

  • Maps to TCOD_bsp_find_node
  • pos accepts tuple, list, or mcrfpy.Vector
  • Returns the deepest node containing the position
  • If position is outside bounds, behavior TBD (return None or raise?)

Acceptance Criteria

  • find returns correct deepest node
  • Works with leaf and internal nodes
  • Position outside bounds handled gracefully
  • Unit tests verify correct node finding
**Parent Issue:** #192 **Depends On:** #202 (BSP core), #203 (BSPNode) ## Overview Add query methods to BSP for finding nodes. ## Specification ```python def find(self, pos: tuple[int, int]) -> BSPNode ``` Find the smallest (deepest) node containing the position. ### Example ```python bsp = mcrfpy.BSP(bounds=((0, 0), (100, 100))) bsp.split_recursive(depth=4, min_size=(8, 8)) # Find which room contains a point node = bsp.find((25, 30)) print(f"Point is in node: {node.bounds}") print(f"Is leaf (room): {node.is_leaf}") ``` ## Implementation Notes - Maps to `TCOD_bsp_find_node` - `pos` accepts tuple, list, or `mcrfpy.Vector` - Returns the deepest node containing the position - If position is outside bounds, behavior TBD (return None or raise?) ## Acceptance Criteria - [ ] `find` returns correct deepest node - [ ] Works with leaf and internal nodes - [ ] Position outside bounds handled gracefully - [ ] Unit tests verify correct node finding
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
john/McRogueFace#205
No description provided.