MCPcopy Create free account
hub / github.com/EngoEngine/engo / NewQuadtree

Function NewQuadtree

quadtree.go:108–113  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
108func 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
116func (qt *Quadtree) Destroy() {

Callers

nothing calls this directly

Calls 4

newNodeMethod · 0.95
calcMaxLevelFunction · 0.85
aabbWidthFunction · 0.85
aabbHeightFunction · 0.85

Tested by

no test coverage detected