mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-27 05:00:08 +08:00
Remove error-prone redundancy in Polygonal2D min/max management
This commit is contained in:
parent
f3ab90f72b
commit
bbda908093
@ -39,8 +39,8 @@
|
|||||||
*/
|
*/
|
||||||
public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||||
private List<BlockVector2D> points;
|
private List<BlockVector2D> points;
|
||||||
private BlockVector min;
|
private Vector2D min;
|
||||||
private BlockVector max;
|
private Vector2D max;
|
||||||
private int minY;
|
private int minY;
|
||||||
private int maxY;
|
private int maxY;
|
||||||
private boolean hasY = false;
|
private boolean hasY = false;
|
||||||
@ -99,8 +99,10 @@ public List<BlockVector2D> getPoints() {
|
|||||||
*/
|
*/
|
||||||
protected void recalculate() {
|
protected void recalculate() {
|
||||||
if (points.size() == 0) {
|
if (points.size() == 0) {
|
||||||
min = new BlockVector(0, 0, 0);
|
min = new Vector2D(0, 0);
|
||||||
max = new BlockVector(0, 0, 0);
|
minY = 0;
|
||||||
|
max = new Vector2D(0, 0);
|
||||||
|
maxY = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,8 +128,8 @@ protected void recalculate() {
|
|||||||
minY = Math.min(Math.max(0, minY), world == null ? 255 : world.getMaxY());
|
minY = Math.min(Math.max(0, minY), world == null ? 255 : world.getMaxY());
|
||||||
maxY = Math.min(Math.max(0, maxY), world == null ? 255 : world.getMaxY());
|
maxY = Math.min(Math.max(0, maxY), world == null ? 255 : world.getMaxY());
|
||||||
|
|
||||||
min = new BlockVector(minX, minY, minZ);
|
min = new Vector2D(minX, minZ);
|
||||||
max = new BlockVector(maxX, maxY, maxZ);
|
max = new Vector2D(maxX, maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,7 +208,7 @@ public void setMaximumY(int y) {
|
|||||||
* @return min. point
|
* @return min. point
|
||||||
*/
|
*/
|
||||||
public Vector getMinimumPoint() {
|
public Vector getMinimumPoint() {
|
||||||
return min;
|
return min.toVector(minY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,7 +217,7 @@ public Vector getMinimumPoint() {
|
|||||||
* @return max. point
|
* @return max. point
|
||||||
*/
|
*/
|
||||||
public Vector getMaximumPoint() {
|
public Vector getMaximumPoint() {
|
||||||
return max;
|
return max.toVector(maxY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,7 +254,7 @@ public int getWidth() {
|
|||||||
* @return height
|
* @return height
|
||||||
*/
|
*/
|
||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
return max.getBlockY() - min.getBlockY();
|
return maxY - minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user