Table of Contents

Class SwiftOctree<TKey, TVolume>

Namespace
SwiftCollections.Query
Assembly
SwiftCollections.dll

Represents a mutable octree that stores keyed bounding volumes within immutable world bounds.

public class SwiftOctree<TKey, TVolume> where TKey : notnull where TVolume : struct, IBoundVolume<TVolume>

Type Parameters

TKey

The key used to identify each stored entry.

TVolume

The volume type used for octree registration and queries.

Inheritance
SwiftOctree<TKey, TVolume>
Derived
Inherited Members

Constructors

SwiftOctree(TVolume, SwiftOctreeOptions, IOctreeBoundsPartitioner<TVolume>)

Initializes a new instance of the SwiftOctree<TKey, TVolume> class.

public SwiftOctree(TVolume worldBounds, SwiftOctreeOptions options, IOctreeBoundsPartitioner<TVolume> boundsPartitioner)

Parameters

worldBounds TVolume

The immutable world bounds covered by the octree.

options SwiftOctreeOptions

Subdivision options for the octree.

boundsPartitioner IOctreeBoundsPartitioner<TVolume>

The backend-owned partitioner that maps bounds into octants.

Properties

Count

Gets the number of active entries stored in the octree.

public int Count { get; }

Property Value

int

Options

Gets the subdivision options used by this octree.

public SwiftOctreeOptions Options { get; }

Property Value

SwiftOctreeOptions

WorldBounds

Gets the immutable world bounds covered by this octree.

public TVolume WorldBounds { get; }

Property Value

TVolume

Methods

Clear()

Removes all entries from the octree while preserving the configured world bounds.

public void Clear()

Contains(TKey)

Determines whether the octree contains the specified key.

public bool Contains(TKey key)

Parameters

key TKey

Returns

bool

Insert(TKey, TVolume)

Inserts a new entry or replaces the bounds of an existing key.

public bool Insert(TKey key, TVolume bounds)

Parameters

key TKey

The entry key.

bounds TVolume

The entry bounds.

Returns

bool

true when a new key was added; false when an existing key was replaced.

Query(TVolume, ICollection<TKey>)

Queries the octree and returns only entries whose bounds intersect the supplied query volume.

public void Query(TVolume queryBounds, ICollection<TKey> results)

Parameters

queryBounds TVolume

The bounds used to test for intersection.

results ICollection<TKey>

The collection that receives intersecting keys.

Remove(TKey)

Removes an entry from the octree.

public bool Remove(TKey key)

Parameters

key TKey

The entry key.

Returns

bool

true when the key existed and was removed; otherwise, false.

TryGetBounds(TKey, out TVolume)

Attempts to retrieve the bounds registered for the supplied key.

public bool TryGetBounds(TKey key, out TVolume bounds)

Parameters

key TKey
bounds TVolume

Returns

bool

UpdateEntryBounds(TKey, TVolume)

Updates the bounds for an existing entry.

public bool UpdateEntryBounds(TKey key, TVolume newBounds)

Parameters

key TKey

The entry key.

newBounds TVolume

The replacement bounds.

Returns

bool

true when the key existed; otherwise, false.