[Proc Gen] BSPNode - Lightweight node reference #203

Open
opened 2026-01-12 00:09:59 +00:00 by john · 0 comments
Owner

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

Overview

Implement BSPNode as a lightweight, read-only reference to a node in a BSP tree.

Specification

Properties

Property Type Description
bounds ((x, y), (w, h)) Position and size of this node.
level int Depth in tree (0 for root).
index int Unique index within the tree.
is_leaf bool True if this node has no children.
split_horizontal bool | None Split orientation. None if leaf.
split_position int | None Split coordinate. None if leaf.

Navigation Properties

Property Type Description
left BSPNode | None Left child, or None if leaf.
right BSPNode | None Right child, or None if leaf.
parent BSPNode | None Parent node, or None if root.
sibling BSPNode | None Other child of parent, or None.

Methods

def contains(self, pos: tuple[int, int]) -> bool

Check if position is inside this node's bounds.

def center(self) -> tuple[int, int]

Return the center point of this node's bounds.

Implementation Notes

  • BSPNode is a lightweight wrapper around a pointer to TCODBsp node
  • Should not own the node, just reference it
  • pos accepts tuple, list, or mcrfpy.Vector
  • center is (x + w//2, y + h//2)

Acceptance Criteria

  • All properties return correct values
  • Navigation properties work correctly
  • contains checks bounds correctly
  • center returns center point
  • BSPNode remains valid as long as BSP exists
**Parent Issue:** #192 **Depends On:** #202 (BSP core) ## Overview Implement `BSPNode` as a lightweight, read-only reference to a node in a BSP tree. ## Specification ### Properties | Property | Type | Description | |----------|------|-------------| | `bounds` | `((x, y), (w, h))` | Position and size of this node. | | `level` | `int` | Depth in tree (0 for root). | | `index` | `int` | Unique index within the tree. | | `is_leaf` | `bool` | True if this node has no children. | | `split_horizontal` | `bool \| None` | Split orientation. None if leaf. | | `split_position` | `int \| None` | Split coordinate. None if leaf. | ### Navigation Properties | Property | Type | Description | |----------|------|-------------| | `left` | `BSPNode \| None` | Left child, or None if leaf. | | `right` | `BSPNode \| None` | Right child, or None if leaf. | | `parent` | `BSPNode \| None` | Parent node, or None if root. | | `sibling` | `BSPNode \| None` | Other child of parent, or None. | ### Methods ```python def contains(self, pos: tuple[int, int]) -> bool ``` Check if position is inside this node's bounds. ```python def center(self) -> tuple[int, int] ``` Return the center point of this node's bounds. ## Implementation Notes - BSPNode is a lightweight wrapper around a pointer to TCODBsp node - Should not own the node, just reference it - `pos` accepts tuple, list, or `mcrfpy.Vector` - `center` is `(x + w//2, y + h//2)` ## Acceptance Criteria - [ ] All properties return correct values - [ ] Navigation properties work correctly - [ ] `contains` checks bounds correctly - [ ] `center` returns center point - [ ] BSPNode remains valid as long as BSP exists
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#203
No description provided.