From 7c1f878610e2dece720ce17bad2c8683280c798e Mon Sep 17 00:00:00 2001 From: Eric Puidokas Date: Mon, 17 Oct 2011 19:54:36 -0700 Subject: [PATCH] Fixed ProtectedCuboidRegion->ProtectedCuboidRegion intersection checking --- .../regions/ProtectedCuboidRegion.java | 30 ++++++------------- .../protection/RegionIntersectTest.java | 2 -- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedCuboidRegion.java b/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedCuboidRegion.java index 68e21a53..637ae813 100644 --- a/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedCuboidRegion.java +++ b/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedCuboidRegion.java @@ -145,12 +145,15 @@ public List getIntersectingRegions(List 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 getIntersectingRegions(List 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."); } diff --git a/src/test/java/com/sk89q/worldguard/protection/RegionIntersectTest.java b/src/test/java/com/sk89q/worldguard/protection/RegionIntersectTest.java index 9388a305..afd4b9e2 100644 --- a/src/test/java/com/sk89q/worldguard/protection/RegionIntersectTest.java +++ b/src/test/java/com/sk89q/worldguard/protection/RegionIntersectTest.java @@ -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));