mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-28 05:25:20 +01:00
Fixed polygon region edges being unprotected on certain edges. Thanks Droolio.
This commit is contained in:
parent
61a60ecdd6
commit
14dc868d45
@ -102,6 +102,7 @@ public boolean contains(Vector pt) {
|
|||||||
int xOld, zOld;
|
int xOld, zOld;
|
||||||
int x1, z1;
|
int x1, z1;
|
||||||
int x2, z2;
|
int x2, z2;
|
||||||
|
long crossproduct;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
xOld = points.get(npoints - 1).getBlockX();
|
xOld = points.get(npoints - 1).getBlockX();
|
||||||
@ -125,11 +126,15 @@ public boolean contains(Vector pt) {
|
|||||||
z1 = zNew;
|
z1 = zNew;
|
||||||
z2 = zOld;
|
z2 = zOld;
|
||||||
}
|
}
|
||||||
if ((xNew < targetX) == (targetX <= xOld)
|
if (x1 <= targetX && targetX <= x2) {
|
||||||
&& ((long) targetZ - (long) z1) * (long) (x2 - x1) <= ((long) z2 - (long) z1)
|
crossproduct = ((long) targetZ - (long) z1) * (long) (x2 - x1)
|
||||||
* (long) (targetX - x1)) {
|
- ((long) z2 - (long) z1) * (long) (targetX - x1);
|
||||||
|
if (crossproduct == 0) {
|
||||||
|
if ((z1 <= targetZ) == (targetZ <= z2)) return true; // on edge
|
||||||
|
} else if (crossproduct < 0 && (x1 != targetX)) {
|
||||||
inside = !inside;
|
inside = !inside;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
xOld = xNew;
|
xOld = xNew;
|
||||||
zOld = zNew;
|
zOld = zNew;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user