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
TKeyThe key used to identify each stored entry.
TVolumeThe 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
worldBoundsTVolumeThe immutable world bounds covered by the octree.
optionsSwiftOctreeOptionsSubdivision options for the octree.
boundsPartitionerIOctreeBoundsPartitioner<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
Options
Gets the subdivision options used by this octree.
public SwiftOctreeOptions Options { get; }
Property Value
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
keyTKey
Returns
Insert(TKey, TVolume)
Inserts a new entry or replaces the bounds of an existing key.
public bool Insert(TKey key, TVolume bounds)
Parameters
keyTKeyThe entry key.
boundsTVolumeThe entry bounds.
Returns
- bool
truewhen a new key was added;falsewhen 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
queryBoundsTVolumeThe bounds used to test for intersection.
resultsICollection<TKey>The collection that receives intersecting keys.
Remove(TKey)
Removes an entry from the octree.
public bool Remove(TKey key)
Parameters
keyTKeyThe entry key.
Returns
- bool
truewhen 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
keyTKeyboundsTVolume
Returns
UpdateEntryBounds(TKey, TVolume)
Updates the bounds for an existing entry.
public bool UpdateEntryBounds(TKey key, TVolume newBounds)
Parameters
keyTKeyThe entry key.
newBoundsTVolumeThe replacement bounds.
Returns
- bool
truewhen the key existed; otherwise,false.