Class Octree<TItem>

Namespace
Elegy.Common.SpatialCollections
Assembly
Elegy.Common.dll

An octree container. Elegy.MapCompiler uses them to quickly and roughly subdivide a level.

public class Octree<TItem> : STree<Box3, TItem>

Type Parameters

TItem
Inheritance
STree<Box3, TItem>
Octree<TItem>
Inherited Members

Constructors

Octree(Box3, IReadOnlyList<TItem>, IsInBoundFn, ShouldSubdivideFn, bool)

Constructs an octree.

public Octree(Box3 rootBound, IReadOnlyList<TItem> items, STree<Box3, TItem>.IsInBoundFn isInBoundMethod, STree<Box3, TItem>.ShouldSubdivideFn shouldSubdivideMethod, bool onlyFirstIntersection = false)

Parameters

rootBound Box3

The bounding box of the tree's root.

items IReadOnlyList<TItem>

A list of items of the tree. Can be empty for a start, as the tree is only constructed later.

isInBoundMethod STree<Box3, TItem>.IsInBoundFn

A method that checks whether or not an AABB of an octree node intersects with an item. Look at IsInBoundVector3().

shouldSubdivideMethod STree<Box3, TItem>.ShouldSubdivideFn

A method that says whether or not a given node should subdivide. Look at ShouldSubdivideThreshold<TBound, TItem>(int).

onlyFirstIntersection bool

When collecting intersections, one (true) or multiple (false) children will receive a reference to a given item. If you have geometric objects that happen to be inside multiple nodes, this is pretty relevant.