switch(type){
case FILL:
for(int x = minX; x <= maxX; x++) {
for(int y = maxY; y >= minY; y--) {
for(int z = minZ; z <= maxZ; z++) {
area.add(new ChunkPosition(x, y, z));
}
}
}
break;
case FRAME:
for(int x = minX; x <= maxX; x++) {
for(int y = minY; y <= maxY; y++) {
for(int z = minZ; z <= maxZ; z++) {
int axisRight = 0;
if(x == minX || x == maxX) axisRight++;
if(y == minY || y == maxY) axisRight++;
if(z == minZ || z == maxZ) axisRight++;
if(axisRight > 1) {
area.add(new ChunkPosition(x, y, z));
}
}
}
}
break;
case WALL:
for(int x = minX; x <= maxX; x++) {
for(int y = minY; y <= maxY; y++) {
for(int z = minZ; z <= maxZ; z++) {
if(x == minX || x == maxX || y == minY || y == maxY || z == minZ || z == maxZ) {
area.add(new ChunkPosition(x, y, z));
}
}
}
}
break;
case SPHERE:
double radius = areaPoints[1] != null ? PneumaticCraftUtils.distBetween(areaPoints[0], areaPoints[1]) : 0;
minX = (int)(areaPoints[0].chunkPosX - radius - 1);
minY = (int)(areaPoints[0].chunkPosY - radius - 1);
minZ = (int)(areaPoints[0].chunkPosZ - radius - 1);
maxX = (int)(areaPoints[0].chunkPosX + radius + 1);
maxY = (int)(areaPoints[0].chunkPosY + radius + 1);
maxZ = (int)(areaPoints[0].chunkPosZ + radius + 1);
for(int x = minX; x <= maxX; x++) {
for(int y = minY; y <= maxY; y++) {
for(int z = minZ; z <= maxZ; z++) {
if(PneumaticCraftUtils.distBetween(areaPoints[0], x + 0.5, y + 0.5, z + 0.5) <= radius) {
area.add(new ChunkPosition(x, y, z));
}
}
}
}
break;
case LINE:
if(areaPoints[1] != null) {
Vec3 lineVec = Vec3.createVectorHelper(areaPoints[1].chunkPosX - areaPoints[0].chunkPosX, areaPoints[1].chunkPosY - areaPoints[0].chunkPosY, areaPoints[1].chunkPosZ - areaPoints[0].chunkPosZ).normalize();
lineVec.xCoord /= 10;
lineVec.yCoord /= 10;
lineVec.zCoord /= 10;
double curX = areaPoints[0].chunkPosX + 0.5;
double curY = areaPoints[0].chunkPosY + 0.5;
double curZ = areaPoints[0].chunkPosZ + 0.5;
double totalDistance = 0;
double maxDistance = PneumaticCraftUtils.distBetween(areaPoints[0], areaPoints[1]);
while(totalDistance <= maxDistance) {
totalDistance += 0.1;
curX += lineVec.xCoord;
curY += lineVec.yCoord;
curZ += lineVec.zCoord;
ChunkPosition pos = new ChunkPosition((int)curX, (int)curY, (int)curZ);
if(!area.contains(pos)) area.add(pos);
}
}
break;
case X_WALL:
if(areaPoints[1] != null) {
Vec3 lineVec = Vec3.createVectorHelper(0, areaPoints[1].chunkPosY - areaPoints[0].chunkPosY, areaPoints[1].chunkPosZ - areaPoints[0].chunkPosZ).normalize();
lineVec.yCoord /= 10;
lineVec.zCoord /= 10;
double curY = areaPoints[0].chunkPosY + 0.5;
double curZ = areaPoints[0].chunkPosZ + 0.5;
double totalDistance = 0;
double maxDistance = Math.sqrt(Math.pow(areaPoints[0].chunkPosY - areaPoints[1].chunkPosY, 2) + Math.pow(areaPoints[0].chunkPosZ - areaPoints[1].chunkPosZ, 2));
while(totalDistance <= maxDistance) {
totalDistance += 0.1;
curY += lineVec.yCoord;
curZ += lineVec.zCoord;
for(int i = minX; i <= maxX; i++) {
ChunkPosition pos = new ChunkPosition(i, (int)curY, (int)curZ);
if(!area.contains(pos)) area.add(pos);
}
}
}
break;
case Y_WALL:
if(areaPoints[1] != null) {
Vec3 lineVec = Vec3.createVectorHelper(areaPoints[1].chunkPosX - areaPoints[0].chunkPosX, 0, areaPoints[1].chunkPosZ - areaPoints[0].chunkPosZ).normalize();
lineVec.xCoord /= 10;
lineVec.zCoord /= 10;
double curX = areaPoints[0].chunkPosX + 0.5;
double curZ = areaPoints[0].chunkPosZ + 0.5;
double totalDistance = 0;
double maxDistance = Math.sqrt(Math.pow(areaPoints[0].chunkPosX - areaPoints[1].chunkPosX, 2) + Math.pow(areaPoints[0].chunkPosZ - areaPoints[1].chunkPosZ, 2));
while(totalDistance <= maxDistance) {
totalDistance += 0.1;
curX += lineVec.xCoord;
curZ += lineVec.zCoord;
for(int i = minY; i <= maxY; i++) {
ChunkPosition pos = new ChunkPosition((int)curX, i, (int)curZ);
if(!area.contains(pos)) area.add(pos);
}
}
}
break;
case Z_WALL:
if(areaPoints[1] != null) {
Vec3 lineVec = Vec3.createVectorHelper(areaPoints[1].chunkPosX - areaPoints[0].chunkPosX, areaPoints[1].chunkPosY - areaPoints[0].chunkPosY, 0).normalize();
lineVec.xCoord /= 10;
lineVec.yCoord /= 10;
double curX = areaPoints[0].chunkPosX + 0.5;
double curY = areaPoints[0].chunkPosY + 0.5;
double totalDistance = 0;
double maxDistance = Math.sqrt(Math.pow(areaPoints[0].chunkPosX - areaPoints[1].chunkPosX, 2) + Math.pow(areaPoints[0].chunkPosY - areaPoints[1].chunkPosY, 2));
while(totalDistance <= maxDistance) {
totalDistance += 0.1;
curX += lineVec.xCoord;
curY += lineVec.yCoord;
for(int i = minZ; i <= maxZ; i++) {
ChunkPosition pos = new ChunkPosition((int)curX, (int)curY, i);
if(!area.contains(pos)) area.add(pos);
}
}
}
break;