Struct NativeOctree<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 NativeOctree<T> : INativeDisposable, IDisposable where T : struct
Type Parameters
Name | Description |
---|---|
T |
Constructors
| Improve this Doc View SourceNativeOctree(AABB, Int32, Int32, Int32, Allocator)
Declaration
public NativeOctree(AABB bounds, int objectsPerNode, int maxDepth, int initialObjectCapacity, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
AABB | bounds | |
System.Int32 | objectsPerNode | |
System.Int32 | maxDepth | |
System.Int32 | initialObjectCapacity | |
Unity.Collections.Allocator | allocator |
NativeOctree(AABB, Allocator)
Declaration
public NativeOctree(AABB bounds, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
AABB | bounds | |
Unity.Collections.Allocator | allocator |
Methods
| Improve this Doc View SourceClear()
Clear the tree and keep the bounds that were previously set
Declaration
public void Clear()
Clear(AABB)
Clear the tree and assign a new boundary
Declaration
public void Clear(AABB newBounds)
Parameters
Type | Name | Description |
---|---|---|
AABB | newBounds |
Collect<TCollector>(AABB, ref TCollector)
Collects all objects for which their AABB's overlap with the input AABB
Declaration
public void Collect<TCollector>(AABB aabb, ref TCollector collector)
where TCollector : struct, ITreeCollector<T>
Parameters
Type | Name | Description |
---|---|---|
AABB | 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>(Ray, 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>(Ray ray, ref TCollector collector)
where TCollector : struct, ITreeCollector<T>
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Ray | 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. 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, AABB)
Insert an object into the tree.
Declaration
public void Insert(T obj, AABB aabb)
Parameters
Type | Name | Description |
---|---|---|
T | obj | The object to insert |
AABB | 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. |