A spatial data structure for quick point queries suited for moving or concentrated positions in 2D space. The sparse variant uses less memory, but is slightly slower for insertions and removals than the dense variant. More...
Public Member Functions | |
void | Clear () |
Clears and resets the tree without deallocating memory. | |
void | Dispose () |
void | DisposeIfCreated () |
float3 | GetBottomLeftPosition () |
bool | GetCell (float3 position, out uint code) |
int2 | GetCellCoordinates (float3 position) |
JobHandle | GetCellsInRadii (NativeArray< float2 > centers, NativeArray< float > radii, ref NativeParallelHashSet< uint > result, JobHandle dependsOn=default, int innerLoopBatchCount=1) |
Searches for all cells that lie within a list of circles (center + radius) and writes the morton code (cell ids) to a result-list. | |
JobHandle | GetCellsInRadius (float2 center, float radius, ref NativeList< uint > result, JobHandle dependsOn=default) |
Searches for all cells within a given circle (center + radius) and writes the morton code (cell ids) to a result-list. | |
JobHandle | GetCellsInRectangle (Rect rect, ref NativeList< uint > result, JobHandle dependsOn=default) |
Searches for all cells within the given rectangle and writes the morton code (cell ids) to a result-list. | |
JobHandle | GetCellsInRectangles (NativeArray< Rect > rectangles, ref NativeParallelHashSet< uint > result, JobHandle dependsOn=default, int innerLoopBatchCount=1) |
Searches for all cells that lie within the given list of rectangles and writes the morton code (cell ids) to a result-list. | |
NativeParallelMultiHashMap< uint, T > | GetDataBuckets () |
int | GetMaxDepth () |
NativeList< QuadtreeNode > | GetNodes () |
QuadtreeNode * | GetRoot () |
float2 | GetScale () |
void | Insert (float3 position, T value) |
Inserts a value at a given position into the tree. | |
NativeSparseQuadtree (float3 position, float2 scale, int maxDepth, int capacity, Allocator allocator) | |
NativeSparseQuadtree (Rect bounds, int maxDepth, int capacity, Allocator allocator) | |
bool | Remove (float3 position, T value) |
bool | Update (T value, float3 oldPosition, float3 newPosition) |
Important Note: If you have a lot of things moving in the quadtree, it will be a lot cheaper performance-wise to recreate the whole tree by calling Clear() and then reinserting each element. | |
![]() |
Properties | |
int | Count [get] |
bool | IsCreated [get] |
![]() |
A spatial data structure for quick point queries suited for moving or concentrated positions in 2D space. The sparse variant uses less memory, but is slightly slower for insertions and removals than the dense variant.
T |
T | : | unmanaged | |
T | : | IEquatable<T> |
NativeSparseQuadtree | ( | Rect | bounds, |
int | maxDepth, | ||
int | capacity, | ||
Allocator | allocator ) |
bounds | Bounds of the quadtree |
maxDepth | Maximum depth / height of the quadtree - also determines the number of cells |
capacity | |
allocator |
NativeSparseQuadtree | ( | float3 | position, |
float2 | scale, | ||
int | maxDepth, | ||
int | capacity, | ||
Allocator | allocator ) |
position | Center of the quadtree |
scale | The size of the quadtree in meters |
maxDepth | Maximum depth / height of the quadtree - also determines the number of cells |
capacity | |
allocator |
void Clear | ( | ) |
Clears and resets the tree without deallocating memory.
Implements IQuadtree< T >.
float3 GetBottomLeftPosition | ( | ) |
Implements IQuadtree< T >.
bool GetCell | ( | float3 | position, |
out uint | code ) |
position | |
code |
Implements IQuadtree< T >.
int2 GetCellCoordinates | ( | float3 | position | ) |
position |
Implements IQuadtree< T >.
JobHandle GetCellsInRadii | ( | NativeArray< float2 > | centers, |
NativeArray< float > | radii, | ||
ref NativeParallelHashSet< uint > | result, | ||
JobHandle | dependsOn = default, | ||
int | innerLoopBatchCount = 1 ) |
Searches for all cells that lie within a list of circles (center + radius) and writes the morton code (cell ids) to a result-list.
centers | |
radii | |
result | |
dependsOn | |
innerLoopBatchCount |
Implements IQuadtree< T >.
JobHandle GetCellsInRadius | ( | float2 | center, |
float | radius, | ||
ref NativeList< uint > | result, | ||
JobHandle | dependsOn = default ) |
Searches for all cells within a given circle (center + radius) and writes the morton code (cell ids) to a result-list.
center | |
radius | |
result | |
dependsOn |
Implements IQuadtree< T >.
JobHandle GetCellsInRectangle | ( | Rect | rect, |
ref NativeList< uint > | result, | ||
JobHandle | dependsOn = default ) |
Searches for all cells within the given rectangle and writes the morton code (cell ids) to a result-list.
rect | |
result | |
dependsOn |
Implements IQuadtree< T >.
JobHandle GetCellsInRectangles | ( | NativeArray< Rect > | rectangles, |
ref NativeParallelHashSet< uint > | result, | ||
JobHandle | dependsOn = default, | ||
int | innerLoopBatchCount = 1 ) |
Searches for all cells that lie within the given list of rectangles and writes the morton code (cell ids) to a result-list.
rectangles | |
result | |
dependsOn | |
innerLoopBatchCount |
Implements IQuadtree< T >.
NativeParallelMultiHashMap< uint, T > GetDataBuckets | ( | ) |
Implements IQuadtree< T >.
int GetMaxDepth | ( | ) |
Implements IQuadtree< T >.
NativeList< QuadtreeNode > GetNodes | ( | ) |
Implements IQuadtree< T >.
QuadtreeNode * GetRoot | ( | ) |
Implements IQuadtree< T >.
float2 GetScale | ( | ) |
Implements IQuadtree< T >.
void Insert | ( | float3 | position, |
T | value ) |
Inserts a value at a given position into the tree.
position | |
value |
Implements IQuadtree< T >.
bool Remove | ( | float3 | position, |
T | value ) |
position | |
value |
Implements IQuadtree< T >.
bool Update | ( | T | value, |
float3 | oldPosition, | ||
float3 | newPosition ) |
Important Note: If you have a lot of things moving in the quadtree, it will be a lot cheaper performance-wise to recreate the whole tree by calling Clear() and then reinserting each element.
value | |
oldPosition | |
newPosition |
Implements IQuadtree< T >.
|
get |
Implements IQuadtree< T >.
|
get |
Implements IQuadtree< T >.