Quadtree

class Quadtree<T>(val bounds: Rectangle, val maxObjects: Int = 10, val mapper: (T) -> Vector2) : IQuadtree<T> (source)

Quadtree

Parameters

T

Constructors

Link copied to clipboard
constructor(bounds: Rectangle, maxObjects: Int = 10, mapper: (T) -> Vector2)

Properties

Link copied to clipboard
val bounds: Rectangle

the tree's bounding box

Link copied to clipboard
var depth: Int
Link copied to clipboard
val mapper: (T) -> Vector2
Link copied to clipboard

maximum number of objects per node

Link copied to clipboard

The 4 nodes of the tree

Link copied to clipboard

Functions

Link copied to clipboard
fun batch(batchBuilder: RectangleBatchBuilder)

Draw the quadtree using batching

Link copied to clipboard
open override fun clear()

Clears the whole tree

Link copied to clipboard
fun draw(drawer: Drawer)

Draw the quadtree

Link copied to clipboard
open override fun findNode(element: T): Quadtree<T>?

Finds which node the element is within (but not necessarily belonging to)

Link copied to clipboard
open override fun insert(element: T): Boolean

Inserts the element in the appropriate node

Link copied to clipboard
open override fun nearest(element: T, radius: Double): QuadtreeQuery<T>?

Finds the nearest and neighbouring points within a radius

Link copied to clipboard
open override fun nearestToPoint(point: Vector2, radius: Double): QuadtreeQuery<T>?

Finds the nearest and neighbouring objects within a radius (needs to have a different name so there is no ambiguity when the generic object type is Vector2)

Link copied to clipboard
open override fun remove(element: T): Boolean

Remove the given element

Link copied to clipboard
open override fun toString(): String