getNodesInRange method

List<Node<E>> getNodesInRange(
  1. Offset center,
  2. double radius,
  3. Size nodeSize
)

Returns all nodes within the specified circular range

center - The center point of the search radius - The search radius nodeSize - The size of nodes for intersection calculation

Implementation

List<Node<E>> getNodesInRange(Offset center, double radius, Size nodeSize) {
  final results = <Node<E>>[];
  final radiusSquared = radius * radius;

  _collectNodesInRange(center, radiusSquared, nodeSize, results);

  // Limit results to prevent memory issues
  if (results.length > QuadTreeConstants.maxQueryResults) {
    results.sort((a, b) {
      final distA = (a.position - center).distanceSquared;
      final distB = (b.position - center).distanceSquared;
      return distA.compareTo(distB);
    });
    return results.take(QuadTreeConstants.maxQueryResults).toList();
  }

  return results;
}