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
|
||||
public boolean contains(Vector position) {
|
||||
int x = position.getBlockX();
|
||||
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;
|
||||
return contains(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
}
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user