Change PriorityRTreeIndex to use the R-tree for intersection queries.

This commit is contained in:
sk89q 2014-08-21 22:47:46 -07:00
parent f57afb2944
commit 2d147bb7e1

View File

@ -86,7 +86,21 @@ public void applyContaining(Vector position, Predicate<ProtectedRegion> consumer
@Override
public void applyIntersecting(ProtectedRegion region, Predicate<ProtectedRegion> consumer) {
super.applyIntersecting(region, consumer);
Vector min = region.getMinimumPoint().floor();
Vector max = region.getMaximumPoint().ceil();
Set<ProtectedRegion> candidates = new HashSet<ProtectedRegion>();
MBR pointMBR = new SimpleMBR(min.getX(), max.getX(), min.getY(), max.getY(), min.getZ(), max.getZ());
for (ProtectedRegion found : tree.find(pointMBR)) {
candidates.add(found);
}
for (ProtectedRegion found : region.getIntersectingRegions(candidates)) {
if (!consumer.apply(found)) {
break;
}
}
}
/**