Class Quadtree<TItem>

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

A quadtree. Dunno what you'd use it for, vegetation maybe.

public class Quadtree<TItem> : STree<Rect2, TItem>

Type Parameters

TItem
Inheritance
STree<Rect2, TItem>
Quadtree<TItem>
Inherited Members

Constructors

Quadtree(Rect2, IReadOnlyList<TItem>, IsInBoundFn, ShouldSubdivideFn, bool)

Constructs a quadtree.

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

Parameters

rootBound Rect2

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<Rect2, TItem>.IsInBoundFn

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

shouldSubdivideMethod STree<Rect2, 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.