QuadTree<T extends Hitbox<T>> class

QuadTree calculation class not bound to Flame. Could be used anywhere outside of Flame, for example in isolates to calculate background logic.

Usage:

  1. Create new instance.
  2. Use add to add hitboxes to simulation.
  3. Use query to get list of hitboxes that potentially collide.
  4. Use remove to remove a hitbox from the tree.
  5. Use sequence of remove and add to simulate hitbox movement.
  6. Use hasMoved to determine if a hitbox ever changed its position.
  7. Call clear to remove all data.

Use optimize to scan the tree and remove unused quadrants.

Constructors

QuadTree({int maxObjects = 25, int maxDepth = 10, Rect mainBoxSize = Rect.zero})

Properties

hashCode int
The hash code for this object.
no setterinherited
hitboxes List<T>
no setter
mainBoxSize Rect
getter/setter pair
maxDepth int
final
maxObjects int
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(T hitbox) → void
clear() → void
hasMoved(T hitbox) bool
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
optimize() → void
query(T value) Map<int, List<T>>
remove(T hitbox, {bool keepOldPosition = false}) → void
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited