Skip to content

v0.4.0

Choose a tag to compare

@apotema apotema released this 07 Dec 17:54
· 12 commits to main since this release

What's New

Breaking Changes

  • QuadTree is now generic over ID type: QuadTree(T) instead of fixed u32
  • QuadTree uses EntityPoint(T) with Position field instead of separate x/y coordinates
  • Removed QuadTreeNode export (now internal type)

New Features

  • Sweep and Prune: O(n log n) broad-phase collision detection

    • SweepAndPrune(T) - generic over ID type
    • findCollisions() - find all overlapping AABB pairs
    • queryRect() and queryRadius() - spatial queries
    • AABB and CollisionPair helper types
  • QuadTree enhancements:

    • queryRadius(center, radius, buffer) - circular queries
    • remove(id) - remove entities by ID
    • update(id, new_pos) - update entity positions
    • hasPointInRect(range) - existence check without collecting results
    • resetWithBoundaries(positions) - reset with auto-computed bounds
  • Rectangle improvements:

    • fromPosition(pos, w, h) - create from Position
    • centered(pos, w, h) - create centered on Position
    • center() - get center Position
    • position() - get top-left Position
    • containsPosition(pos) - Position-based containment

Improvements

  • QuadTree uses flat array storage for better cache efficiency
  • All spatial queries now use Position type consistently
  • Both QuadTree and SweepAndPrune support generic ID types
  • 45 tests covering all functionality