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

Method Retrieve

quadtree.go:313–337  ·  view source on GitHub ↗

Retrieve returns all objects that could collide with the given bounding box

(pRect AABB)

Source from the content-addressed store, hash-verified

311
312// Retrieve returns all objects that could collide with the given bounding box
313func (qt *quadtreeNode) Retrieve(pRect AABB) []AABBer {
314 index := qt.getIndex(pRect)
315
316 // Array with all detected objects
317 result := make([]AABBer, len(qt.Objects))
318 for i, o := range qt.Objects {
319 result[i] = o.Value
320 }
321
322 //if we have subnodes ...
323 if qt.hasNodes {
324 //if pRect fits into a subnode ..
325 if index != -1 {
326 result = append(result, qt.Nodes[index].Retrieve(pRect)...)
327 } else {
328 //if pRect does not fit into a subnode, check it against all subnodes
329 for i := 0; i < 4; i++ {
330 result = append(result, qt.Nodes[i].Retrieve(pRect)...)
331 }
332 }
333 }
334
335 return result
336
337}
338
339// Retrieve returns all objects that could collide with the given bounding box and passing the given filter function.
340func (qt *Quadtree) Retrieve(find AABB, filter func(aabb AABBer) bool) []AABBer {

Callers

nothing calls this directly

Calls 2

getIndexMethod · 0.95
RetrieveMethod · 0.45

Tested by

no test coverage detected