Added a few methods to CuboidCoord

This commit is contained in:
Chicken-Bomes committed 2014-02-11 19:56:02 +10:00
1 parent eac0727165
commit e274d1c512
2 files changed
+29 -12

No files matched your search

+2 -2
View File
@@ -447,13 +447,13 @@ public class QBImporter
for(int s = 0; s < 6; s++) {
CuboidCoord slice = c.copy();
slice.shrink(s^1, slice.size(s)-1);
slice.expand(s^1, -(slice.size(s)-1));
slice.expand(s, 1);
while(slice.getSide(s) >= 0 && slice.getSide(s) < size.getSide(s)) {
if(!voxelFull(solid, slice))
break;
slice.shrink(s ^ 1, 1);
slice.expand(s ^ 1, -1);
slice.expand(s, 1);
c.expand(s, 1);
}
+27 -10
View File
@@ -36,22 +36,25 @@ public class CuboidCoord implements Iterable<BlockCoord>
this(new BlockCoord(x1, y1, z1), new BlockCoord(x2, y2, z2));
}
public void expand(int side, int amount)
public CuboidCoord expand(int amount) {
return expand(amount, amount, amount);
}
public CuboidCoord expand(int x, int y, int z) {
max.add(x, y, z);
min.sub(x, y, z);
return this;
}
public CuboidCoord expand(int side, int amount)
{
if(side%2 == 0)//negative side
min = min.offset(side, amount);
else
max = max.offset(side, amount);
return this;
}
public void shrink(int side, int amount)
{
if(side%2 == 0)//negative side
min = min.inset(side, amount);
else
max = max.inset(side, amount);
}
public int size(int s)
{
switch(s)
@@ -171,6 +174,20 @@ public class CuboidCoord implements Iterable<BlockCoord>
return set(ia[0], ia[1], ia[2], ia[3], ia[4], ia[5]);
}
public CuboidCoord include(BlockCoord coord) {
return include(coord.x, coord.y, coord.z);
}
public CuboidCoord include(int x, int y, int z) {
if(x < min.x) min.x = x;
else if(x > max.x) max.x = x;
if(y < min.y) min.y = y;
else if(y > max.y) max.y = y;
if(z < min.z) min.z = z;
else if(z > max.z) max.z = z;
return this;
}
public Iterator<BlockCoord> iterator() {
return new Iterator<BlockCoord>() {
BlockCoord b = null;
@@ -195,7 +212,7 @@ public class CuboidCoord implements Iterable<BlockCoord>
}
}
}
return b;
return b.copy();
}
public void remove() {