Struct NativeQuadtree<T>
A simple, burst compatible octree implementation that supports raycast and AABB overlap queries.
Implements
Inherited Members
Namespace: AnyPath.Graphs
Assembly: Assembly-CSharp.dll
Syntax
public struct NativeQuadtree<T> : INativeDisposable, IDisposable where T : struct
Type Parameters
Name | Description |
---|---|
T |
Constructors
| Improve this Doc View SourceNativeQuadtree(AABB2D, Int32, Int32, Int32, Allocator)
Declaration
public NativeQuadtree(AABB2D bounds, int objectsPerNode, int maxDepth, int initialObjectCapacity, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
AABB2D | bounds | |
System.Int32 | objectsPerNode | |
System.Int32 | maxDepth | |
System.Int32 | initialObjectCapacity | |
Unity.Collections.Allocator | allocator |
NativeQuadtree(AABB2D, Allocator)
Declaration
public NativeQuadtree(AABB2D bounds, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
AABB2D | bounds | |
Unity.Collections.Allocator | allocator |
Properties
| Improve this Doc View SourceBounds
Declaration
public readonly AABB2D Bounds { get; }
Property Value
Type | Description |
---|---|
AABB2D |
IsCreated
Declaration
public readonly bool IsCreated { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceClear()
Clear the tree and keep the bounds that were previously set
Declaration
public void Clear()
Clear(AABB2D)
Clear the tree and assign a new boundary
Declaration
public void Clear(AABB2D newBounds)
Parameters
Type | Name | Description |
---|---|---|
AABB2D | newBounds |
Collect<TCollector>(AABB2D, ref TCollector)
Collects all objects for which their AABB's overlap with the input AABB
Declaration
public void Collect<TCollector>(AABB2D aabb, ref TCollector collector)
where TCollector : struct, ITreeCollector<T>
Parameters
Type | Name | Description |
---|---|---|
AABB2D | aabb | The AABB to test against |
TCollector | collector | The collector |
Type Parameters
Name | Description |
---|---|
TCollector |
Remarks
Note that it is possible for the same object to appear multiple times if it's AABB spans multiple tree cells. If you need unique objects, consider adding them to a hashset in the collector.
Collect<TCollector>(Ray2D, ref TCollector)
Collects all objects that potentially intersect with a ray. These objects are pre filtered using their AABB's. Further testing for actual collision may be neccessary.
Declaration
public void Collect<TCollector>(Ray2D ray, ref TCollector collector)
where TCollector : struct, ITreeCollector<T>
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Ray2D | ray | The ray to test against |
TCollector | collector | The collector |
Type Parameters
Name | Description |
---|---|
TCollector | Type of custom collector that handles further testing against the ray. |
Remarks
Note that it is possible for the same object to appear multiple times (if it's not a point). Which shouldn't be a problem for raycasting since you should return the object that hit closest to the ray's origin.
Dispose()
Declaration
public void Dispose()
Dispose(JobHandle)
Declaration
public JobHandle Dispose(JobHandle inputDeps)
Parameters
Type | Name | Description |
---|---|---|
Unity.Jobs.JobHandle | inputDeps |
Returns
Type | Description |
---|---|
Unity.Jobs.JobHandle |
Insert(T, AABB2D)
Insert an object into the tree.
Declaration
public void Insert(T obj, AABB2D aabb)
Parameters
Type | Name | Description |
---|---|---|
T | obj | The object to insert |
AABB2D | aabb | The axis aligned bounding box of the object |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | This exception occurs if the provided AABB is not within the tree's bounds. |