bool CQuadTree::RRemove(CEntity* pEnt, QTNode* pStart) { // Leaf node? if(pStart->pChildren == nullptr) { // Iterate over the entities and remove a match (if any). for(auto i : pStart->nodeObjects) { // Is this the object we are looking for? if(*i == pEnt) { // Erase and break out. nodeObjects.erase(i); return true; } } // No match :( return false; } // Branch with children. else { // Recurse on all children. for(size_t i = 0; i < 4; ++i) { // Only break out if there was a match found, because if // we broke out regardless we wouldn't get to all the kids! if(this->RRemove(pBody, pStart->pChildren[i])) return true; } } // No match found ever. return false; }