I am creating a quadtree and I get in some trouble with the retrieve function. This function gets down to the nodes that store objects and puts the objects in a vector called relevantObjects. After this, it returns the relevantObjects vector. But, when it tries to do this, I see in the debugger that the vector gets wiped of its elements (goes from 4 to 0).
I don't see where I am wrong.
std::vector<PTR> Tree::retrieveObjects(PTR p, std::vector<PTR> relevantObjects) {
int quadrant = getQuadrant(p);
if (quadrant != -1 && nodes[0] != nullptr)
{
nodes[quadrant]->retrieveObjects(p, relevantObjects);
}
relevantObjects.insert(relevantObjects.end(), storedObjects.begin(), storedObjects.end());
return relevantObjects; }