void GridDatabase::findObjects(TestFunc testFunc, Vector &fillVector, const Rect *extents, S32 minx, S32 miny, S32 maxx, S32 maxy) 0.01s { mQueryId++; // Used to prevent the same item from being found in multiple buckets 0.03s for(S32 x = minx; maxx - x >= 0; x++) 0.01s for(S32 y = miny; maxy - y >= 0; y++) 0.19s for(BucketEntry *walk = mBuckets[x & BucketMask][y & BucketMask]; walk; walk = walk->nextInBucket) { 0.06s DatabaseObject *theObject = walk->theObject; if(theObject->mLastQueryId != mQueryId && // Object hasn't been queried; and (testFunc(theObject->getObjectTypeNumber())) && // is of the right type; and 5.10s (!extents || theObject->mExtent.intersects(*extents)) ) // overlaps our extents (if passed) { walk->theObject->mLastQueryId = mQueryId; // Flag the object so we know we've already visited it 0.03s fillVector.push_back(walk->theObject); // And save it as a found item } } }