NewQuadtree creates a new quadtree for the given bounds. When setting usePool to true, the internal values will be taken from a sync.Pool which reduces the allocation overhead. maxObjects tells the tree how many objects should be stored within a level before the quadtree cell is split.
(bounds AABB, usePool bool, maxObjects int)
| 106 | // When setting usePool to true, the internal values will be taken from a sync.Pool which reduces the allocation overhead. |
| 107 | // maxObjects tells the tree how many objects should be stored within a level before the quadtree cell is split. |
| 108 | func NewQuadtree(bounds AABB, usePool bool, maxObjects int) *Quadtree { |
| 109 | qt := &Quadtree{MaxObjects: maxObjects, usePool: usePool} |
| 110 | qt.root = qt.newNode(bounds, 0) |
| 111 | qt.MaxLevels = calcMaxLevel(aabbWidth(bounds), aabbHeight(bounds)) |
| 112 | return qt |
| 113 | } |
| 114 | |
| 115 | // Destroy frees the nodes if the Quadtree uses the node pool |
| 116 | func (qt *Quadtree) Destroy() { |
nothing calls this directly
no test coverage detected