mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-20 08:07:55 +01:00
55: ProtectedPolygonalRegion should now handle edges better.
This commit is contained in:
parent
d5a9b0c65f
commit
4b72805a69
@ -71,20 +71,23 @@ public BlockVector getMaximumPoint() {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Vector pt) {
|
public boolean contains(Vector pt) {
|
||||||
int targetX = pt.getBlockX();
|
int targetX = pt.getBlockX(); //wide
|
||||||
int targetY = pt.getBlockY();
|
int targetY = pt.getBlockY(); //height
|
||||||
int targetZ = pt.getBlockZ();
|
int targetZ = pt.getBlockZ(); //depth
|
||||||
|
|
||||||
if (targetY < minY || targetY > maxY) {
|
if (targetY < minY || targetY > maxY) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//Quick and dirty check.
|
||||||
|
if(targetX < min.getBlockX() || targetX > max.getBlockX() || targetZ < min.getBlockZ() || targetZ > max.getBlockZ()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
boolean inside = false;
|
boolean inside = false;
|
||||||
int npoints = points.size();
|
int npoints = points.size();
|
||||||
int xNew, zNew;
|
int xNew, zNew;
|
||||||
int xOld, zOld;
|
int xOld, zOld;
|
||||||
int x1, y1;
|
int x1, z1;
|
||||||
int x2, y2;
|
int x2, z2;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
xOld = points.get(npoints - 1).getBlockX();
|
xOld = points.get(npoints - 1).getBlockX();
|
||||||
@ -96,16 +99,16 @@ public boolean contains(Vector pt) {
|
|||||||
if (xNew > xOld) {
|
if (xNew > xOld) {
|
||||||
x1 = xOld;
|
x1 = xOld;
|
||||||
x2 = xNew;
|
x2 = xNew;
|
||||||
y1 = zOld;
|
z1 = zOld;
|
||||||
y2 = zNew;
|
z2 = zNew;
|
||||||
} else {
|
} else {
|
||||||
x1 = xNew;
|
x1 = xNew;
|
||||||
x2 = xOld;
|
x2 = xOld;
|
||||||
y1 = zNew;
|
z1 = zNew;
|
||||||
y2 = zOld;
|
z2 = zOld;
|
||||||
}
|
}
|
||||||
if ((xNew < targetX) == (targetX <= xOld)
|
if ((xNew < targetX) == (targetX <= xOld)
|
||||||
&& ((long) targetZ - (long) y1) * (long) (x2 - x1) < ((long) y2 - (long) y1)
|
&& ((long) targetZ - (long) z1) * (long) (x2 - x1) <= ((long) z2 - (long) z1)
|
||||||
* (long) (targetX - x1)) {
|
* (long) (targetX - x1)) {
|
||||||
inside = !inside;
|
inside = !inside;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user