Fixed ProtectedCuboidRegion->ProtectedCuboidRegion intersection checking

This commit is contained in:
Eric Puidokas 2011-10-17 19:54:36 -07:00 committed by TomyLobo
parent e8c4c9b218
commit 7c1f878610
2 changed files with 9 additions and 23 deletions

View File

@ -145,12 +145,15 @@ public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> region
// Check whether the region is outside the min and max vector
if ((rMinPoint.getBlockX() < min.getBlockX() && rMaxPoint.getBlockX() < min.getBlockX())
|| (rMinPoint.getBlockX() > max.getBlockX() && rMaxPoint.getBlockX() > max.getBlockX())
&& ((rMinPoint.getBlockY() < min.getBlockY() && rMaxPoint.getBlockY() < min.getBlockY())
|| (rMinPoint.getBlockY() > max.getBlockY() && rMaxPoint.getBlockY() > max.getBlockY()))
&& ((rMinPoint.getBlockZ() < min.getBlockZ() && rMaxPoint.getBlockZ() < min.getBlockZ())
|| (rMinPoint.getBlockZ() > max.getBlockZ() && rMaxPoint.getBlockZ() > max.getBlockZ())) ) {
//intersectingRegions.add(regions.get(i));
|| (rMinPoint.getBlockX() > max.getBlockX() && rMaxPoint.getBlockX() > max.getBlockX())
|| ((rMinPoint.getBlockY() < min.getBlockY() && rMaxPoint.getBlockY() < min.getBlockY())
|| (rMinPoint.getBlockY() > max.getBlockY() && rMaxPoint.getBlockY() > max.getBlockY()))
|| ((rMinPoint.getBlockZ() < min.getBlockZ() && rMaxPoint.getBlockZ() < min.getBlockZ())
|| (rMinPoint.getBlockZ() > max.getBlockZ() && rMaxPoint.getBlockZ() > max.getBlockZ())) )
continue;
if (region instanceof ProtectedCuboidRegion) {
intersectingRegions.add(regions.get(i));
continue;
}
@ -181,21 +184,6 @@ public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> region
continue;
}
}
} else if (region instanceof ProtectedCuboidRegion) {
BlockVector ptcMin = region.getMinimumPoint();
BlockVector ptcMax = region.getMaximumPoint();
if (this.contains(new Vector(ptcMin.getBlockX(), ptcMin.getBlockY(), ptcMin.getBlockZ()))
|| this.contains(new Vector(ptcMin.getBlockX(), ptcMin.getBlockY(), ptcMax.getBlockZ()))
|| this.contains(new Vector(ptcMin.getBlockX(), ptcMax.getBlockY(), ptcMax.getBlockZ()))
|| this.contains(new Vector(ptcMin.getBlockX(), ptcMax.getBlockY(), ptcMin.getBlockZ()))
|| this.contains(new Vector(ptcMax.getBlockX(), ptcMax.getBlockY(), ptcMax.getBlockZ()))
|| this.contains(new Vector(ptcMax.getBlockX(), ptcMax.getBlockY(), ptcMin.getBlockZ()))
|| this.contains(new Vector(ptcMax.getBlockX(), ptcMin.getBlockY(), ptcMin.getBlockZ()))
|| this.contains(new Vector(ptcMax.getBlockX(), ptcMin.getBlockY(), ptcMax.getBlockZ())) ) {
intersectingRegions.add(regions.get(i));
continue;
}
} else {
throw new UnsupportedOperationException("Not supported yet.");
}

View File

@ -3,7 +3,6 @@
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
@ -13,7 +12,6 @@
public class RegionIntersectTest {
@Test
@Ignore
public void testCuboidGetIntersectingRegions() {
ProtectedRegion region = new ProtectedCuboidRegion("square",
new BlockVector(100, 40, 0), new BlockVector(140, 128, 40));