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

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)
 
int3 GetCellCoordinates (float3 position)
 
JobHandle GetCellsInBounds (Bounds bounds, ref NativeList< uint > result, JobHandle dependsOn=default)
 Searches for all cells within the given bounds and writes the morton code (cell ids) to a result-list.
 
JobHandle GetCellsInBounds (NativeArray< Bounds > bounds, ref NativeParallelHashSet< uint > result, JobHandle dependsOn=default, int innerLoopBatchCount=1)
 Searches for all cells within all given bounds and writes the morton code (cell ids) to a result-list.
 
JobHandle GetCellsInRadii (NativeArray< float3 > centers, NativeArray< float > radii, ref NativeParallelHashSet< uint > result, JobHandle dependsOn=default, int innerLoopBatchCount=1)
 Searches for all cells within multiple spheres (center + radius) and writes the morton code (cell ids) to a result-list.
 
JobHandle GetCellsInRadius (float3 center, float radius, ref NativeList< uint > result, JobHandle dependsOn=default)
 Searches for all cells within a given sphere (center + radius) and writes the morton code (cell ids) to a result-list.
 
NativeParallelMultiHashMap< uint, T > GetDataBuckets ()
 
int GetMaxDepth ()
 
NativeList< OctreeNodeGetNodes ()
 
OctreeNodeGetRoot ()
 
float3 GetScale ()
 
void Insert (float3 position, T value)
 Inserts a value at a given position into the tree.
 
 NativeSparseOctree (Bounds bounds, int maxDepth, int capacity, Allocator allocator)
 
 NativeSparseOctree (float3 position, float3 scale, 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 octree, it will be a lot cheaper performance-wise to recreate the whole tree by calling Clear() and then reinserting each element.
 
- Public Member Functions inherited from IOctree< T >

Properties

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

Constructor & Destructor Documentation

◆ NativeSparseOctree() [1/2]

NativeSparseOctree ( Bounds bounds,
int maxDepth,
int capacity,
Allocator allocator )
Parameters
boundsBounds of the octree
maxDepthMaximum depth / height of the octree - also determines the number of cells
capacity
allocator

◆ NativeSparseOctree() [2/2]

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

Member Function Documentation

◆ Clear()

void Clear ( )

Clears and resets the tree without deallocating memory.

Implements IOctree< T >.

◆ GetBottomLeftPosition()

float3 GetBottomLeftPosition ( )

Implements IOctree< 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 octree or the cell does not exist, false is returned

◆ GetCellCoordinates()

int3 GetCellCoordinates ( float3 position)
Parameters
position
Returns
The coordinates of the cell closest to the given position. They are unchecked (might be negative or bigger than the number of cells in the tree)

Implements IOctree< T >.

◆ GetCellsInBounds() [1/2]

JobHandle GetCellsInBounds ( Bounds bounds,
ref NativeList< uint > result,
JobHandle dependsOn = default )

Searches for all cells within the given bounds and writes the morton code (cell ids) to a result-list.

Parameters
bounds
result
dependsOn
Returns

Implements IOctree< T >.

◆ GetCellsInBounds() [2/2]

JobHandle GetCellsInBounds ( NativeArray< Bounds > bounds,
ref NativeParallelHashSet< uint > result,
JobHandle dependsOn = default,
int innerLoopBatchCount = 1 )

Searches for all cells within all given bounds and writes the morton code (cell ids) to a result-list.

Parameters
bounds
result
dependsOn
Returns

Implements IOctree< T >.

◆ GetCellsInRadii()

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

Searches for all cells within multiple spheres (center + radius) and writes the morton code (cell ids) to a result-list.

Parameters
center
radius
result
dependsOn
Returns

Implements IOctree< T >.

◆ GetCellsInRadius()

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

Searches for all cells within a given sphere (center + radius) and writes the morton code (cell ids) to a result-list.

Parameters
center
radius
result
dependsOn
Returns

Implements IOctree< T >.

◆ GetDataBuckets()

NativeParallelMultiHashMap< uint, T > GetDataBuckets ( )

Implements IOctree< T >.

◆ GetMaxDepth()

int GetMaxDepth ( )

Implements IOctree< T >.

◆ GetNodes()

NativeList< OctreeNode > GetNodes ( )

Implements IOctree< T >.

◆ GetRoot()

OctreeNode * GetRoot ( )

Implements IOctree< T >.

◆ GetScale()

float3 GetScale ( )

Implements IOctree< T >.

◆ Insert()

void Insert ( float3 position,
T value )

Inserts a value at a given position into the tree.

Parameters
position
value

Implements IOctree< 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 octree, just that it is not in the bucket at the given position

Implements IOctree< T >.

◆ Update()

bool Update ( T value,
float3 oldPosition,
float3 newPosition )

Important Note: If you have a lot of things moving in the octree, it will be a lot cheaper performance-wise to recreate the whole tree by calling Clear() and then reinserting each element.

Parameters
value
oldPosition
newPosition
Returns
Returns false if the value was not found at the old position or the new position is outside the octree

Implements IOctree< T >.

Property Documentation

◆ Count

int Count
get

Implements IOctree< T >.

◆ IsCreated

bool IsCreated
get

Implements IOctree< T >.