mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2025-01-08 17:38:24 +01:00
Optimize cuboid region contains
This commit is contained in:
parent
36f973e36c
commit
cf0bd96308
@ -397,10 +397,29 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Vector position) {
|
public boolean contains(Vector position) {
|
||||||
int x = position.getBlockX();
|
return contains(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
int y = position.getBlockY();
|
}
|
||||||
int z = position.getBlockZ();
|
|
||||||
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ && y >= this.minY && y <= this.maxY;
|
private int ly = Integer.MIN_VALUE;
|
||||||
|
private int lz = Integer.MIN_VALUE;
|
||||||
|
private boolean lr, lry, lrz;
|
||||||
|
|
||||||
|
public boolean contains(int x, int y, int z) {
|
||||||
|
// return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ && y >= this.minY && y <= this.maxY;
|
||||||
|
if (z != lz) {
|
||||||
|
lz = z;
|
||||||
|
lrz = z >= this.minZ && z <= this.maxZ;
|
||||||
|
if (y != ly) {
|
||||||
|
ly = y;
|
||||||
|
lry = y >= this.minY && y <= this.maxY;
|
||||||
|
}
|
||||||
|
lr = lrz && lry;
|
||||||
|
} else if (y != ly) {
|
||||||
|
ly = y;
|
||||||
|
lry = y >= this.minY && y <= this.maxY;
|
||||||
|
lr = lrz && lry;
|
||||||
|
}
|
||||||
|
return lr && (x >= this.minX && x <= this.maxX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user