Second approach for generating padding around border. Still a not so great solution.

This commit is contained in:
Tobias Ottenweller 2013-06-09 19:14:49 +02:00
parent 50d165d3bb
commit 99b0e4a692

View File

@ -190,23 +190,61 @@ public class ChunkGenerator
protected static boolean chunkIsInsideBorder(int x, int z, World w, Border b) protected static boolean chunkIsInsideBorder(int x, int z, World w, Border b)
{ {
// FIXME: the following code makes round border not so round! // double xLoc = (double)(x << 4);
// double yLoc = 100.0;
double xLoc = (double)(x << 4); // double yLoc = 0.0;
double yLoc = 100.0; // double zLoc = (double)(z << 4);
double zLoc = (double)(z << 4); //
// Location center = b.getCenter();
// double centerX = center.getX();
// double centerZ = center.getZ();
//
// double padding = paddingChunksAroundBorder << 4;
//
// if (Math.abs(xLoc) < padding)
// {
// xLoc = centerX;
// }
// else
// {
// xLoc = centerX < xLoc ? xLoc-padding : xLoc+padding;
// xLoc = centerX < xLoc ? xLoc-padding : xLoc+padding;
// }
//
// if (Math.abs(zLoc) < padding)
// {
// zLoc = centerZ;
// }
// else
// {
// zLoc = centerZ < zLoc ? zLoc-padding : zLoc+padding;
// zLoc = centerZ < zLoc ? zLoc-padding : zLoc+padding;
// }
//
// Location chunkLocation = new Location(w, xLoc, yLoc, zLoc);
// return b.checkBorder(chunkLocation) == null;
//
// make the location to check the length of 'paddingChunksAroundBorder' closer to center of the border
Location center = b.getCenter(); Location center = b.getCenter();
double centerX = center.getX(); double vecX = center.getX() - (x << 4);
double centerZ = center.getZ(); double vecZ = center.getZ() - (z << 4);
double length = Math.sqrt(vecX*vecX + vecZ*vecZ);
double padding = paddingChunksAroundBorder << 4; double padding = paddingChunksAroundBorder << 4;
xLoc = centerX < xLoc ? xLoc-padding : xLoc+padding; if (Math.abs(length) < padding)
zLoc = centerZ < zLoc ? zLoc-padding : zLoc+padding; {
vecX = vecZ = 0.0; // avoid 'crossing' the center of the border
}
else
{
vecX -= vecX / length * padding;
vecZ -= vecZ / length * padding;
}
Location chunkLocation = new Location(w, xLoc, yLoc, zLoc); Location locationMinusPadding = new Location(w, center.getX()+vecX, 0.0, center.getZ()+vecZ);
return b.checkBorder(chunkLocation) == null; return b.checkBorder(locationMinusPadding) == null;
} }
protected static void loadSurroundingChunks(int x, int z, World w) protected static void loadSurroundingChunks(int x, int z, World w)
@ -217,7 +255,7 @@ public class ChunkGenerator
{ {
for (int j=-radius; j<radius; j++) for (int j=-radius; j<radius; j++)
{ {
if (j == 0 && i == 0) if (j == 0 && i == 0)
{ {
continue; continue;
} }