Class STree<TBound, TItem>
- Namespace
- Elegy.Common.SpatialCollections
- Assembly
- Elegy.Common.dll
N-dimensional spatial tree (s-tree) that stores TItems inside a TBound.
public class STree<TBound, TItem> where TBound : struct
Type Parameters
- Inheritance
-
STree<TBound, TItem>
- Derived
- Inherited Members
Constructors
STree(TBound, IReadOnlyList<TItem>, int, IsInBoundFn, ShouldSubdivideFn, GetChildVolumeFn, CollectIntersectionsFn)
The constructor for this thing.
public STree(TBound rootBound, IReadOnlyList<TItem> items, int dimensions, STree<TBound, TItem>.IsInBoundFn isInBound, STree<TBound, TItem>.ShouldSubdivideFn shouldSubdivide, STree<TBound, TItem>.GetChildVolumeFn getChildVolume, STree<TBound, TItem>.CollectIntersectionsFn collectIntersections)
Parameters
rootBoundTBoundThe bounding volume of the root node.
itemsIReadOnlyList<TItem>dimensionsintisInBoundSTree<TBound, TItem>.IsInBoundFnshouldSubdivideSTree<TBound, TItem>.ShouldSubdivideFngetChildVolumeSTree<TBound, TItem>.GetChildVolumeFncollectIntersectionsSTree<TBound, TItem>.CollectIntersectionsFn
Fields
mBound
protected TBound mBound
Field Value
- TBound
mDimensions
protected int mDimensions
Field Value
mItems
protected List<TItem> mItems
Field Value
- List<TItem>
mLeaves
protected List<STreeNode<TBound, TItem>> mLeaves
Field Value
mNodes
protected List<STreeNode<TBound, TItem>> mNodes
Field Value
Properties
Bound
Bounding volume of this tree.
public TBound Bound { get; }
Property Value
- TBound
CollectIntersections
public STree<TBound, TItem>.CollectIntersectionsFn CollectIntersections { get; init; }
Property Value
- STree<TBound, TItem>.CollectIntersectionsFn
Combinations
Usually the number of children that must be had. Technically the max number of children that this node may have.
public int Combinations { get; }
Property Value
Dimensions
Dimensionality of this tree (2 or 3 usually).
public int Dimensions { get; }
Property Value
GetChildVolume
public STree<TBound, TItem>.GetChildVolumeFn GetChildVolume { get; init; }
Property Value
- STree<TBound, TItem>.GetChildVolumeFn
IsInBound
public STree<TBound, TItem>.IsInBoundFn IsInBound { get; init; }
Property Value
- STree<TBound, TItem>.IsInBoundFn
Items
This tree's items.
public IReadOnlyList<TItem> Items { get; }
Property Value
- IReadOnlyList<TItem>
Leaves
A subset of Nodes which are leaf nodes.
public IReadOnlyList<STreeNode<TBound, TItem>> Leaves { get; }
Property Value
- IReadOnlyList<STreeNode<TBound, TItem>>
Nodes
All of the nodes belonging to this tree.
public IReadOnlyList<STreeNode<TBound, TItem>> Nodes { get; }
Property Value
- IReadOnlyList<STreeNode<TBound, TItem>>
ShouldSubdivide
public STree<TBound, TItem>.ShouldSubdivideFn ShouldSubdivide { get; init; }
Property Value
- STree<TBound, TItem>.ShouldSubdivideFn
Methods
Add(TItem)
Adds an item into the octree, without linking. If you'd like to rebuild the octree, call Build
public void Add(TItem item)
Parameters
itemTItem
Build()
Builds the tree.
public void Build()
BuildNode(STreeNode<TBound, TItem>)
Builds nodes recursively.
protected void BuildNode(STreeNode<TBound, TItem> node)
Parameters
nodeSTreeNode<TBound, TItem>
Clear()
Clears the tree.
public void Clear()