What's New
QuadTree Spatial Partitioning
- Added
QuadTree data structure for efficient 2D spatial queries
- Added
Rectangle struct with contains() and intersects() methods
- Added
QuadTreeNode struct for entity storage
- Operations:
insert, query, queryNearest, clear, count
- Optimized
findNearest with quadrant pruning
Testing Infrastructure
- Added zspec testing framework
- BDD-style test organization with nested structs
- 21 tests covering Vector2, Rectangle, and QuadTree
CI/CD
- Added GitHub Actions workflow for automated testing
- Runs on push/PR to main branch
Usage
const zig_utils = @import("zig_utils");
const QuadTree = zig_utils.QuadTree;
const Rectangle = zig_utils.Rectangle;
var qt = QuadTree.init(allocator, .{ .x = 0, .y = 0, .width = 100, .height = 100 });
defer qt.deinit();
try qt.insert(.{ .entity = 1, .x = 10, .y = 10 });
var result: std.ArrayListUnmanaged(zig_utils.QuadTreeNode) = .empty;
defer result.deinit(allocator);
try qt.query(.{ .x = 0, .y = 0, .width = 50, .height = 50 }, &result, allocator);