#include <boost/foreach.hpp>
#include <simgear/debug/logstream.hxx>
+#include <simgear/structure/exception.hxx>
+#include <simgear/timing/timestamp.hxx>
namespace flightgear
{
for (; it != end; ++it) {
FGPositioned* p = cache->loadById(it->second);
- assert(intersects(_box, p->cart()));
double d = dist(aPos, p->cart());
if (d > aCutoff) {
continue;
}
}
-void findAllWithinRange(const SGVec3d& aPos, double aRangeM, FGPositioned::Filter* aFilter, FGPositioned::List& aResults)
+bool findAllWithinRange(const SGVec3d& aPos, double aRangeM, FGPositioned::Filter* aFilter, FGPositioned::List& aResults, int aCutoffMsec)
{
aResults.clear();
FindNearestPQueue pq;
pq.push(Ordered<Node*>(global_spatialOctree, 0));
double rng = aRangeM;
- while (!pq.empty()) {
+ SGTimeStamp tm;
+ tm.stamp();
+
+ while (!pq.empty() && (tm.elapsedMSec() < aCutoffMsec)) {
Node* nd = pq.top().get();
pq.pop();
for (unsigned int r=0; r<numResults; ++r) {
aResults[r] = results[r].get();
}
+
+ return !pq.empty();
}
} // of namespace Octree