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

TBound

For example: Box3 or Rect2.

TItem

For example: Vector3 or anything, really!

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

rootBound TBound

The bounding volume of the root node.

items IReadOnlyList<TItem>
dimensions int
isInBound STree<TBound, TItem>.IsInBoundFn
shouldSubdivide STree<TBound, TItem>.ShouldSubdivideFn
getChildVolume STree<TBound, TItem>.GetChildVolumeFn
collectIntersections STree<TBound, TItem>.CollectIntersectionsFn

Fields

mBound

protected TBound mBound

Field Value

TBound

mDimensions

protected int mDimensions

Field Value

int

mItems

protected List<TItem> mItems

Field Value

List<TItem>

mLeaves

protected List<STreeNode<TBound, TItem>> mLeaves

Field Value

List<STreeNode<TBound, TItem>>

mNodes

protected List<STreeNode<TBound, TItem>> mNodes

Field Value

List<STreeNode<TBound, TItem>>

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

int

Dimensions

Dimensionality of this tree (2 or 3 usually).

public int Dimensions { get; }

Property Value

int

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

item TItem

Build()

Builds the tree.

public void Build()

BuildNode(STreeNode<TBound, TItem>)

Builds nodes recursively.

protected void BuildNode(STreeNode<TBound, TItem> node)

Parameters

node STreeNode<TBound, TItem>

Clear()

Clears the tree.

public void Clear()