reworked mergeMultiData to take in long[] instead of long[][]

This commit is contained in:
cola98765
2021-09-19 22:59:15 +02:00
parent cffb17aeb1
commit ca940d5a36
@@ -276,27 +276,29 @@ public class DataPointUtil
}
}
public static long[] mergeMultiData(long[][] dataToMerge)
public static long[] mergeMultiData(long[] dataToMerge, int inputVerticalData,int maxVerticalData)
{
int size = dataToMerge.length / inputVerticalData;
short[] projection = ThreadMapUtil.getProjectionShort((WORLD_HEIGHT + 1) / 16);
short[][] heightAndDepth = ThreadMapUtil.getHeightAndDepth((WORLD_HEIGHT / 2) + 1);
short[][] heightAndDepth = ThreadMapUtil.getHeightAndDepth(inputVerticalData);
long[] singleDataToMerge = ThreadMapUtil.getSingleAddDataToMerge(dataToMerge.length);
int genMode = DistanceGenerationMode.SERVER.complexity;
boolean allEmpty = true;
boolean allVoid = true;
long singleData;
int test = 0;
for(int k=0; k < projection.length; k++)
for(int k=0; k < projection.length; k++) //probably can remove
projection[k] = 0;
short depth = 0;
short height = 0;
//We collect the indexes of the data, ordered by the depth
for (int index = 0; index < dataToMerge.length; index++)
for (int index = 0; index < size; index++)
{
for (int dataIndex = 0; dataIndex < dataToMerge[index].length; dataIndex++)
for (int dataIndex = 0; dataIndex < inputVerticalData; dataIndex++)
{
singleData = dataToMerge[index][dataIndex];
singleData = dataToMerge[index * inputVerticalData + dataIndex];
if (doesItExist(singleData))
{
genMode = Math.min(genMode, getGenerationMode(singleData));
@@ -319,6 +321,7 @@ public class DataPointUtil
if (allVoid)
return new long[]{createVoidDataPoint(genMode)};
//We extract the merged data
int count = 0;
int i = 0;
int ii = 0;
@@ -352,24 +355,42 @@ public class DataPointUtil
}
height = (short)(i * 16 + ii - 1);
heightAndDepth[count][0] = depth;
heightAndDepth[count][1] = height;
heightAndDepth[count][1] = height;
count++;
}
//we limit the vertical portion to maxVerticalData
int j = 0;
while (count > maxVerticalData)
{
ii = WORLD_HEIGHT;
for (i = 0; i < count - 1; i++)
{
if (heightAndDepth[i][1] - heightAndDepth[i + 1][0] < ii)
{
ii = heightAndDepth[i][1] - heightAndDepth[i + 1][0];
j = i;
}
}
heightAndDepth[j][1] = heightAndDepth[j + 1][1];
System.arraycopy(heightAndDepth,j + 1, heightAndDepth, j,count - j - 1);
count--;
}
//As standard the vertical lods are ordered from top to bottom
long[] dataPoint = new long[count];
for (int j = count - 1; j >= 0; j--)
for (j = count - 1; j >= 0; j--)
{
depth = heightAndDepth[j][0];
height = heightAndDepth[j][1];
for(int k = 0; k < dataToMerge.length; k++){
singleDataToMerge[k] = 0;
}
for (int index = 0; index < dataToMerge.length; index++)
for (int index = 0; index < size; index++)
{
for (int dataIndex = 0; dataIndex < dataToMerge[index].length; dataIndex++)
for (int dataIndex = 0; dataIndex < inputVerticalData; dataIndex++)
{
singleData = dataToMerge[index][dataIndex];
singleData = dataToMerge[index * inputVerticalData + dataIndex];
if (doesItExist(singleData) && !isItVoid(singleData))
{
if ((depth <= getDepth(singleData) && getDepth(singleData) <= height)
@@ -386,7 +407,6 @@ public class DataPointUtil
long data = mergeSingleData(singleDataToMerge);
dataPoint[j] = createDataPoint(height, depth, getColor(data), getLightSky(data), getLightBlock(data), getGenerationMode(data));
}
return dataPoint;
}