TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

class SpatialQuadtree in Tinman.Terrain.Util

A generic quadtree data structure for storing spatial entities.

abstract class SpatialQuadtree with <TEntity>  

Public / Attributes

Count

Returns the number of quadtree nodes.

public property Count { get }
type int32
value [>0] The number of quadtree nodes.

Public / Methods

Add

Adds the given spatial entity to the quadtree.

public method Add (TEntity entity)
params entity The entity to add.

Clear

Clears the quadtree.

public method Clear ()

Deserialize

Deserializes the quadtree nodes.

public method Deserialize (ISerializer data, ITypeSerializer<TEntity> entity)
params data [not-null] The serializer object.
  entity [not-null] The type serializer for quadtree nodes.

Grow

Grows the quadtree until it contains the given bounds.

public method Grow (Box2D bounds)
params bounds To bounds to cover.

Nearest

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

public method Nearest (float64 x, float64 y, float64 nearest = Maths.MaxDouble)
type float64
params x X-coordinate of point.
  y Y-coordinate of point.
  nearest The maximum value to return. Defaults to MaxDouble.
returns The smallest distance.

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

public method Nearest (float64 x, float64 y, out Vec3I vertices, out Vec3D weights, float64 nearest = Maths.MaxDouble)
type float64
params x X-coordinate of point.
  y Y-coordinate of point.
  vertices Vertex indices that describe the location of the nearest spatial entity feature.
  weights Location of the nearest spatial entity feature, given as relative weights (i.e. the weight sum is 1) of vertices. The weights are sorted in descending order, i.e. X always holds the greatest weight and Z always holds the smallest weight.
  nearest The maximum value to return. Defaults to MaxDouble.
returns The smallest distance.

Serialize

Serializes the quadtree nodes.

public method Serialize (ISerializer data, ITypeSerializer<TEntity> entity)
params data [not-null] The serializer object.
  entity [not-null] The type serializer for quadtree nodes.

Protected / Constructors

SpatialQuadtree

Creates a new instance of SpatialQuadtree.

protected constructor SpatialQuadtree ()

Protected / Methods

CheckIntersection

Checks if the given spatial entity intersects with the specified bounds.

protected abstract method CheckIntersection (TEntity entity, Box2D bounds)
type int32
params entity The spatial entity.
  bounds The axis-aligned bounds.
returns -1 if entity and bounds are disjoint.
0 if entity and bounds intersect.
1 if bounds fully contains entity.
2 if entity fully contains bounds.

DistanceTo

Computes the nearest distance from the given point to the spatial entity.

protected abstract method DistanceTo (float64 x, float64 y, float64 distance, TEntity entity)
type float64
params x X-coordinate of point.
  y Y-coordinate of point.
  distance The current nearest distance.
  entity The spatial entity.
returns The nearest distance.

Computes the nearest distance from the given point to the spatial entity.

[EmptyBody]
protected virtual method DistanceTo (float64 x, float64 y, float64 distance, TEntity entity, out Vec3I vertices, out Vec3D weights)
type float64
params x X-coordinate of point.
  y Y-coordinate of point.
  distance The current nearest distance.
  entity The spatial entity.
  vertices Vertex indices that describe the location of the nearest spatial entity feature. If the spatial entity does not have any vertices, Zero is returned. Vertex index values with a weight of zero are ignored, but their value is retained.
  weights Location of the nearest spatial entity feature, given as relative weights (i.e. the weight sum is 1) of vertices. The weights are sorted in descending order, i.e. X always holds the greatest weight and Z always holds the smallest weight. The sum of all weights is 1. If the spatial entity does not have any vertices, Zero is returned.
returns The nearest distance.

Remarks:

The default implementation forwards to DistanceTo and sets vertices to Zero and weights to Zero.

Equals

Checks if the given spatial entities are equal.

protected abstract method Equals (TEntity a, TEntity b)
type bool
params a First entity.
  b Second entity.
returns true if entities are equal, false if not.

Remarks:

Two spatial entities are considered to be equal if CheckIntersection returns the same value for both entities, given any bounds.