MCPcopy Index your code
hub / github.com/EngoEngine/engo / split

Method split

quadtree.go:174–197  ·  view source on GitHub ↗

split - split the node into 4 subnodes

()

Source from the content-addressed store, hash-verified

172
173// split - split the node into 4 subnodes
174func (qt *quadtreeNode) split() {
175 if qt.hasNodes {
176 return
177 }
178 qt.hasNodes = true
179
180 nextLevel := qt.Level + 1
181 subWidth := aabbWidth(qt.Bounds) / 2
182 subHeight := aabbHeight(qt.Bounds) / 2
183 x := qt.Bounds.Min.X
184 y := qt.Bounds.Min.Y
185
186 //top right node (0)
187 qt.Nodes[0] = qt.Tree.newNode(aabbRect(x+subWidth, y, subWidth, subHeight), nextLevel)
188
189 //top left node (1)
190 qt.Nodes[1] = qt.Tree.newNode(aabbRect(x, y, subWidth, subHeight), nextLevel)
191
192 //bottom left node (2)
193 qt.Nodes[2] = qt.Tree.newNode(aabbRect(x, y+subHeight, subWidth, subHeight), nextLevel)
194
195 //bottom right node (3)
196 qt.Nodes[3] = qt.Tree.newNode(aabbRect(x+subWidth, y+subHeight, subWidth, subHeight), nextLevel)
197}
198
199func (qt *quadtreeNode) isEmpty() bool {
200 return len(qt.Objects) == 0 && !qt.hasNodes

Callers 1

InsertMethod · 0.95

Calls 4

aabbWidthFunction · 0.85
aabbHeightFunction · 0.85
aabbRectFunction · 0.85
newNodeMethod · 0.80

Tested by

no test coverage detected