SpatialTree

Description

abstract class Tinman.Terrain.Util.SpatialTree
<TEntity val>
<TBounds val>
<TCoords val>
<TEntityTrait ref : ISpatialEntityTrait<TEntity, TBounds>>
<TBoundsTrait val : ISpatialBoundsTrait<TCoords, TBounds>>
<TDistanceTrait val : ISpatialDistanceTrait<TEntity, TCoords>>

Derived from

SpatialTreeBase<TBounds> abstract

Extended by

SpatialOctree abstract
SpatialQuadtree2 abstract

A generic tree data structure for storing spatial entities.

Public / Methods

Add


public method Add → (1)

entity in : TEntity

The entity to add.

Adds the given spatial entity to the tree.

Clear


public method Clear → ()

Clears the tree.

Deserialize


public method Deserialize → (2)

data in : ISerializer

[not-null]
The serializer object.

entity in : ITypeSerializer<TEntity>

[not-null]
The type serializer for tree nodes.

Deserializes the tree nodes.

IOException

If an I/O error has occurred.

Distance

2 overloads


[Pure]
public abstract method Distance1 → (2)

coords in : TCoords

Coordinates of point.

nearest opt : float64 = Maths.MaxDouble

The maximum value to return.

returns → float64

The smallest distance.

Finds the smallest distance from the given point to any spatial entity in the tree.


[Pure]
public abstract method Distance2 → (4)

coords in : TCoords

Coordinates of point.

vertices out : Vec3I

Vertex indices that describe the location of the nearest spatial entity feature.

weights out : Vec3D

Location of the nearest spatial entity feature, given as relative weights (i.e. the weight sum is 1) of vertices out. The weights are sorted in descending order, i.e. Vec3D.X always holds the greatest weight and Vec3D.Z always holds the smallest weight.

nearest opt : float64 = Maths.MaxDouble

The maximum value to return.

returns → float64

The smallest distance.

Finds the smallest distance from the given point to any spatial entity in the tree.

Grow


public method Grow → (1)

bounds in : TBounds

To bounds to cover.

Grows the tree until it contains the given bounds.

Serialize


public method Serialize → (2)

data in : ISerializer

[not-null]
The serializer object.

entity in : ITypeSerializer<TEntity>

[not-null]
The type serializer for tree nodes.

Serializes the tree nodes.

IOException

If an I/O error has occurred.

Public / Attributes

Root


public attribute Root → (get)

value : SpatialTreeNode<TBounds>

The root node.

Returns the root node of the tree.

Protected / Constructors

SpatialTree


protected constructor SpatialTree → (5)

childCount in : int32

[pow2]
The maximum number of children per tree node.

bounds in : TBounds

The initial spatial bounds.

boundsSerializer in : ITypeSerializer<TBounds>

[not-null]
The serializer for tree bounds.

entityTrait in : TEntityTrait

The entity trait.

distanceTrait in : TDistanceTrait

The distance trait.

Creates a new instance of SpatialTree.

Protected / Attributes

bounds


protected attribute bounds → (TBounds)

The tree bounds.

boundsTrait


protected readonly attribute boundsTrait → (TBoundsTrait)

The spatial tree node bounds trait.

distanceTrait


protected readonly attribute distanceTrait → (TDistanceTrait)

The distance trait.

entity


protected attribute entity → (TEntity [ ])

The spatial entity slots.

entityNext


protected attribute entityNext → (int32 [ ])

Next spatial entity slot.

nodeChildren


protected attribute nodeChildren → (int32 [ ])

Child pointers per tree node.

This array is indexed as follows:

children[idx * childCount + n] := n-th child

where idx is the tree node index and n is the child node ordinal.

nodeFirst


protected attribute nodeFirst → (int32 [ ])

First spatial entity per tree node.

If a tree node idx has no spatial entities, nodeFirst[idx] will be -1. If nodeFirst[idx] is greater than or equal to zero, the node is a leaf.

nodeFixed


protected attribute nodeFixed → (int32 [ ])

First fixed spatial entity per tree node.

If a tree node idx has no fixed spatial entities, nodeFixed[idx] will be -1.