// MIT License - Copyright (c) 2025 wallstop // Full license text: https://github.com/wallstop/unity-helpers/blob/main/LICENSE namespace WallstopStudios.UnityHelpers.Core.DataStructure { using System.Collections.Generic; using UnityEngine; /// /// Contract for 3D spatial trees (octrees, kd-trees, etc.) that expose range, bounds, and nearest-neighbor queries. /// Lets gameplay systems pick the most suitable spatial index without changing their query logic. /// /// /// tree = new OctTree3D(worldBounds); /// List results = new List(); /// tree.GetElementsInRange(playerPosition, 10f, results); /// ]]> /// /// The type of elements stored in the tree. /// /// ⚠️ EXPERIMENTAL: 3D spatial trees are currently experimental and under active development. /// APIs may change, and performance characteristics may vary. Use with caution in production environments. /// Result buffers: Every query method clears the supplied before writing results. Pass a reusable buffer when you want to minimize allocations. /// public interface ISpatialTree3D { Bounds Boundary { get; } List GetElementsInRange( Vector3 position, float range, List elementsInRange, float minimumRange = 0f ); List GetElementsInBounds(Bounds bounds, List elementsInBounds); List GetApproximateNearestNeighbors( Vector3 position, int count, List nearestNeighbors ); } }