DOTS Geometry
 
Loading...
Searching...
No Matches
NativeDenseQuadtree< T > Struct Template Reference

A spatial data structure for quick point queries suited for moving or concentrated positions in 2D space. The dense variant uses much more memory, but is slightly faster for insertions and removals than the sparse 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)
 Calculates a list of cell indices in the tree which are contained within the given circles.
 
JobHandle GetCellsInRadius (float2 center, float radius, ref NativeList< uint > result, JobHandle dependsOn=default)
 Calculates all the cell indices in the tree which are contained within the given circle.
 
JobHandle GetCellsInRectangle (Rect rect, ref NativeList< uint > result, JobHandle dependsOn=default)
 Calculates a list of cell indices in the tree which are contained within the given rectangle.
 
JobHandle GetCellsInRectangles (NativeArray< Rect > rectangles, ref NativeParallelHashSet< uint > result, JobHandle dependsOn=default, int innerLoopBatchCount=1)
 Calculates a list of cell indices in the tree which are contained within the given rectangles.
 
NativeParallelMultiHashMap< uint, T > GetDataBuckets ()
 
int GetMaxDepth ()
 
NativeList< QuadtreeNodeGetNodes ()
 
QuadtreeNodeGetRoot ()
 
float2 GetScale ()
 
void Insert (float3 position, T value)
 Inserts a value at a given position into the tree.
 
 NativeDenseQuadtree (float3 position, float2 scale, int maxDepth, int capacity, Allocator allocator)
 
 NativeDenseQuadtree (Rect bounds, int maxDepth, int capacity, Allocator allocator)
 
bool Remove (float3 position, T value)
 
bool Update (T value, float3 oldPosition, float3 newPosition)
 
- Public Member Functions inherited from IQuadtree< T >

Properties

int Count [get]
 
bool IsCreated [get]
 
- Properties inherited from IQuadtree< T >

Detailed Description

A spatial data structure for quick point queries suited for moving or concentrated positions in 2D space. The dense variant uses much more memory, but is slightly faster for insertions and removals than the sparse variant.

Template Parameters
T
Type Constraints
T :unmanaged 
T :IEquatable<T> 

Constructor & Destructor Documentation

◆ NativeDenseQuadtree() [1/2]

NativeDenseQuadtree ( Rect bounds,
int maxDepth,
int capacity,
Allocator allocator )
Parameters
boundsBounds of the quadtree
maxDepthMaximum depth / height of the quadtree - also determines the number of cells
capacity
allocator

◆ NativeDenseQuadtree() [2/2]

NativeDenseQuadtree ( float3 position,
float2 scale,
int maxDepth,
int capacity,
Allocator allocator )
Parameters
positionCenter of the quadtree
scaleThe size of the quadtree in meters
maxDepthMaximum depth / height of the quadtree - also determines the number of cells
capacity
allocator

Member Function Documentation

◆ Clear()

void Clear ( )

Clears and resets the tree without deallocating memory.

Implements IQuadtree< T >.

◆ GetBottomLeftPosition()

float3 GetBottomLeftPosition ( )

Implements IQuadtree< T >.

◆ GetCell()

bool GetCell ( float3 position,
out uint code )
Parameters
position
code
Returns
The morton code (cell id) for the closest cell to the given position. If the position is outside the bounds of this quadtree or the cell does not exist, false is returned

Implements IQuadtree< T >.

◆ GetCellCoordinates()

int2 GetCellCoordinates ( float3 position)
Parameters
position
Returns
The cell coordinates in the tree of a given position. The position is clamped to be within the bounds of the quadtree

Implements IQuadtree< T >.

◆ GetCellsInRadii()

JobHandle GetCellsInRadii ( NativeArray< float2 > centers,
NativeArray< float > radii,
ref NativeParallelHashSet< uint > result,
JobHandle dependsOn = default,
int innerLoopBatchCount = 1 )

Calculates a list of cell indices in the tree which are contained within the given circles.

Parameters
center
radius
result
dependsOn
Returns

Implements IQuadtree< T >.

◆ GetCellsInRadius()

JobHandle GetCellsInRadius ( float2 center,
float radius,
ref NativeList< uint > result,
JobHandle dependsOn = default )

Calculates all the cell indices in the tree which are contained within the given circle.

Parameters
center
radius
result
dependsOn
Returns

Implements IQuadtree< T >.

◆ GetCellsInRectangle()

JobHandle GetCellsInRectangle ( Rect rect,
ref NativeList< uint > result,
JobHandle dependsOn = default )

Calculates a list of cell indices in the tree which are contained within the given rectangle.

Parameters
rect
result
dependsOn
Returns

Implements IQuadtree< T >.

◆ GetCellsInRectangles()

JobHandle GetCellsInRectangles ( NativeArray< Rect > rectangles,
ref NativeParallelHashSet< uint > result,
JobHandle dependsOn = default,
int innerLoopBatchCount = 1 )

Calculates a list of cell indices in the tree which are contained within the given rectangles.

Parameters
rect
result
dependsOn
Returns

Implements IQuadtree< T >.

◆ GetDataBuckets()

NativeParallelMultiHashMap< uint, T > GetDataBuckets ( )

Implements IQuadtree< T >.

◆ GetMaxDepth()

int GetMaxDepth ( )

Implements IQuadtree< T >.

◆ GetNodes()

NativeList< QuadtreeNode > GetNodes ( )

Implements IQuadtree< T >.

◆ GetRoot()

QuadtreeNode * GetRoot ( )

Implements IQuadtree< T >.

◆ GetScale()

float2 GetScale ( )

Implements IQuadtree< T >.

◆ Insert()

void Insert ( float3 position,
T value )

Inserts a value at a given position into the tree.

Parameters
position
value

Implements IQuadtree< T >.

◆ Remove()

bool Remove ( float3 position,
T value )
Parameters
position
value
Returns
True, if the value was found in the bucket that represents the given position. False otherwise. Note, that if the function returns false, that does not necessarily mean the value is not present somewhere else in the quadtree,, just that it is not in the bucket at the given position

Implements IQuadtree< T >.

◆ Update()

bool Update ( T value,
float3 oldPosition,
float3 newPosition )
Parameters
value
oldPosition
newPosition
Returns
Returns false if the value was not found at the old position or the new position is outside the quadtree

Implements IQuadtree< T >.

Property Documentation

◆ Count

int Count
get

Implements IQuadtree< T >.

◆ IsCreated

bool IsCreated
get

Implements IQuadtree< T >.