remove deprecated RenderDataPointUtil logic
This commit is contained in:
+1
-1
@@ -353,7 +353,7 @@ public class FullDataToRenderDataTransformer
|
||||
|
||||
if (isColumnVoid)
|
||||
{
|
||||
renderColumnData.set(0, RenderDataPointUtil.createVoidDataPoint());
|
||||
renderColumnData.set(0, RenderDataPointUtil.EMPTY_DATA);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -829,7 +829,7 @@ public class RenderDataPointReducingList
|
||||
int size = view.size();
|
||||
if (size <= 0)
|
||||
{
|
||||
return RenderDataPointUtil.createVoidDataPoint();
|
||||
return RenderDataPointUtil.EMPTY_DATA;
|
||||
}
|
||||
|
||||
long highestDataPoint;
|
||||
@@ -849,7 +849,7 @@ public class RenderDataPointReducingList
|
||||
}
|
||||
}
|
||||
//no visible segments, return void.
|
||||
return RenderDataPointUtil.createVoidDataPoint();
|
||||
return RenderDataPointUtil.EMPTY_DATA;
|
||||
}
|
||||
|
||||
//second loop: merge the rest of the segments.
|
||||
@@ -889,7 +889,7 @@ public class RenderDataPointReducingList
|
||||
// so, if we didn't set any data points, add a void data point.
|
||||
if (writeIndex == 0)
|
||||
{
|
||||
view.set(writeIndex++, RenderDataPointUtil.createVoidDataPoint());
|
||||
view.set(writeIndex++, RenderDataPointUtil.EMPTY_DATA);
|
||||
}
|
||||
|
||||
for (int size = view.size(); writeIndex < size; writeIndex++)
|
||||
|
||||
@@ -110,8 +110,6 @@ public class RenderDataPointUtil
|
||||
// datapoint manipulation //
|
||||
//========================//
|
||||
|
||||
public static long createVoidDataPoint() { return EMPTY_DATA; }
|
||||
|
||||
public static long createDataPoint(int height, int depth, int color, int lightSky, int lightBlock, int irisBlockMaterialId)
|
||||
{
|
||||
return createDataPoint(
|
||||
@@ -303,352 +301,6 @@ public class RenderDataPointUtil
|
||||
list.reduce(output.verticalSize());
|
||||
list.copyTo(output);
|
||||
}
|
||||
|
||||
|
||||
//old logic left here in case it's ever needed again.
|
||||
/*
|
||||
if (output.dataCount() != 1)
|
||||
{
|
||||
throw new IllegalArgumentException("output must be only reserved for one datapoint!");
|
||||
}
|
||||
|
||||
int inputVerticalSize = sourceData.verticalSize();
|
||||
int outputVerticalSize = output.verticalSize();
|
||||
output.fill(0);
|
||||
|
||||
//dataCount indicate how many position we are merging in one position
|
||||
int dataCount = sourceData.dataCount();
|
||||
|
||||
// We initialize the arrays that are going to be used
|
||||
int heightAndDepthLength = (MAX_WORLD_Y_SIZE / 2 + 16) * 2;
|
||||
short[] heightAndDepth = tLocalHeightAndDepth.get();
|
||||
if (heightAndDepth == null || heightAndDepth.length != heightAndDepthLength)
|
||||
{
|
||||
heightAndDepth = new short[heightAndDepthLength];
|
||||
tLocalHeightAndDepth.set(heightAndDepth);
|
||||
}
|
||||
|
||||
byte genMode = getGenerationMode(sourceData.get(0));
|
||||
if (genMode == 0)
|
||||
{
|
||||
genMode = 1; // FIXME: Hack to make the version 10 genMode never be 0.
|
||||
}
|
||||
|
||||
boolean allEmpty = true;
|
||||
boolean allVoid = true;
|
||||
boolean limited = false;
|
||||
boolean allDefault;
|
||||
long singleData;
|
||||
|
||||
short yMin;
|
||||
short yMax;
|
||||
int count = 0;
|
||||
int i;
|
||||
int ii;
|
||||
|
||||
int[] indices = tLocalIndices.get();
|
||||
if (indices == null || indices.length != dataCount)
|
||||
{
|
||||
indices = new int[dataCount];
|
||||
tLocalIndices.set(indices);
|
||||
}
|
||||
Arrays.fill(indices, 0);
|
||||
|
||||
boolean[] increaseIndex = tLocalIncreaseIndex.get();
|
||||
if (increaseIndex == null || increaseIndex.length != dataCount)
|
||||
{
|
||||
increaseIndex = new boolean[dataCount];
|
||||
tLocalIncreaseIndex.set(increaseIndex);
|
||||
}
|
||||
|
||||
boolean[] indexHandled = tLocalIndexHandled.get();
|
||||
if (indexHandled == null || indexHandled.length != dataCount)
|
||||
{
|
||||
indexHandled = new boolean[dataCount];
|
||||
tLocalIndexHandled.set(indexHandled);
|
||||
}
|
||||
|
||||
long tempData;
|
||||
for (int index = 0; index < dataCount; index++)
|
||||
{
|
||||
tempData = sourceData.get(index * inputVerticalSize);
|
||||
allVoid = allVoid && RenderDataPointUtil.isVoid(tempData);
|
||||
allEmpty = allEmpty && !RenderDataPointUtil.doesDataPointExist(tempData);
|
||||
}
|
||||
|
||||
//We check if there is any data that's not empty or void
|
||||
if (allEmpty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (allVoid)
|
||||
{
|
||||
output.set(0, createVoidDataPoint(genMode));
|
||||
return;
|
||||
}
|
||||
|
||||
//this check is used only to see if we have checked all the values in the array
|
||||
boolean stillHasDataToCheck = true;
|
||||
short prevDepth;
|
||||
|
||||
while (stillHasDataToCheck)
|
||||
{
|
||||
Arrays.fill(indexHandled, false);
|
||||
boolean connected = true;
|
||||
int newHeight = -10000;
|
||||
int newDepth = -10000;
|
||||
int tempYMax;
|
||||
int tempYMin;
|
||||
while (connected)
|
||||
{
|
||||
Arrays.fill(increaseIndex, false);
|
||||
for (int index = 0; index < dataCount; index++)
|
||||
{
|
||||
if (indices[index] < inputVerticalSize)
|
||||
{
|
||||
tempData = sourceData.get(index * inputVerticalSize + indices[index]);
|
||||
if (!RenderDataPointUtil.isVoid(tempData) && RenderDataPointUtil.doesDataPointExist(tempData))
|
||||
{
|
||||
tempYMax = RenderDataPointUtil.getYMax(tempData);
|
||||
tempYMin = RenderDataPointUtil.getYMin(tempData);
|
||||
if (tempYMin >= newHeight)
|
||||
{
|
||||
//First case
|
||||
//the column we are checking is higher than the current column
|
||||
newDepth = tempYMin;
|
||||
newHeight = tempYMax;
|
||||
Arrays.fill(increaseIndex, false);
|
||||
Arrays.fill(indexHandled, false);
|
||||
increaseIndex[index] = true;
|
||||
indexHandled[index] = true;
|
||||
}
|
||||
else if ((tempYMin >= newDepth) && (tempYMax <= newHeight))
|
||||
{
|
||||
//the column we are checking is contained in the current column
|
||||
//we simply increase this index
|
||||
increaseIndex[index] = true;
|
||||
indexHandled[index] = true;
|
||||
}
|
||||
else if (tempYMax > newHeight && tempYMin <= newDepth)
|
||||
{
|
||||
newDepth = tempYMin;
|
||||
newHeight = tempYMax;
|
||||
increaseIndex[index] = true;
|
||||
indexHandled[index] = true;
|
||||
}
|
||||
else if (tempYMax > newDepth && tempYMax <= newHeight)
|
||||
{
|
||||
//the column we are checking touches the current column from the bottom
|
||||
//for this reason we extend what's below
|
||||
|
||||
//We want to avoid to expend this column if it has already been expanded by
|
||||
//this index
|
||||
if (!indexHandled[index])
|
||||
{
|
||||
newDepth = tempYMin;
|
||||
increaseIndex[index] = true;
|
||||
indexHandled[index] = true;
|
||||
}
|
||||
|
||||
}
|
||||
else if (tempYMin < newHeight && tempYMin > newDepth)
|
||||
{
|
||||
//the column we are checking touches the current column from the top
|
||||
//for this reason we extend the top
|
||||
newHeight = tempYMax;
|
||||
increaseIndex[index] = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
indexHandled[index] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if we added any new data there is a chance that we could add more
|
||||
//for this reason we would continue
|
||||
//if no data is added than the column hasn't changed.
|
||||
//for this reason we can start working on a new column
|
||||
connected = false;
|
||||
for (int index = 0; index < dataCount; index++)
|
||||
{
|
||||
if (increaseIndex[index])
|
||||
{
|
||||
connected = true;
|
||||
indices[index]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Now we add the height and depth data we extracted to the heightAndDepth array
|
||||
if (newDepth != newHeight)
|
||||
{
|
||||
if (count != 0)
|
||||
{
|
||||
prevDepth = heightAndDepth[(count - 1) * 2 + 1];
|
||||
if (newHeight > prevDepth)
|
||||
{
|
||||
newHeight = (short) Math.min(newHeight, prevDepth);
|
||||
}
|
||||
}
|
||||
heightAndDepth[count * 2] = (short) newHeight;
|
||||
heightAndDepth[count * 2 + 1] = (short) newDepth;
|
||||
count++;
|
||||
}
|
||||
|
||||
//Here we check the condition that makes the loop continue
|
||||
//We stop the loop only if there is no more data to check
|
||||
stillHasDataToCheck = false;
|
||||
for (int index = 0; index < dataCount; index++)
|
||||
{
|
||||
if (indices[index] < inputVerticalSize)
|
||||
{
|
||||
tempData = sourceData.get(index * inputVerticalSize + indices[index]);
|
||||
stillHasDataToCheck |= !RenderDataPointUtil.isVoid(tempData) && RenderDataPointUtil.doesDataPointExist(tempData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//we limit the vertical portion to maxVerticalData
|
||||
int j = 0;
|
||||
while (count > outputVerticalSize)
|
||||
{
|
||||
limited = true;
|
||||
ii = MAX_WORLD_Y_SIZE;
|
||||
for (i = 0; i < count - 1; i++)
|
||||
{
|
||||
if (heightAndDepth[i * 2 + 1] - heightAndDepth[(i + 1) * 2] <= ii)
|
||||
{
|
||||
ii = heightAndDepth[i * 2 + 1] - heightAndDepth[(i + 1) * 2];
|
||||
j = i;
|
||||
}
|
||||
}
|
||||
|
||||
heightAndDepth[j * 2 + 1] = heightAndDepth[(j + 1) * 2 + 1];
|
||||
for (i = j + 1; i < count - 1; i++)
|
||||
{
|
||||
heightAndDepth[i * 2] = heightAndDepth[(i + 1) * 2];
|
||||
heightAndDepth[i * 2 + 1] = heightAndDepth[(i + 1) * 2 + 1];
|
||||
}
|
||||
|
||||
//System.arraycopy(heightAndDepth, j + 1, heightAndDepth, j, count - j - 1);
|
||||
count--;
|
||||
}
|
||||
//As standard the vertical lods are ordered from top to bottom
|
||||
|
||||
if (!limited && dataCount == 1) // This mean source vertSize < output vertSize AND both dataCount == 1
|
||||
{
|
||||
sourceData.copyTo(output.data, output.offset, output.vertSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//We want to efficiently memorize indexes
|
||||
int[] dataIndexesCache = tDataIndexCache.get();
|
||||
if (dataIndexesCache == null || dataIndexesCache.length != dataCount)
|
||||
{
|
||||
dataIndexesCache = new int[dataCount];
|
||||
tDataIndexCache.set(dataIndexesCache);
|
||||
}
|
||||
Arrays.fill(dataIndexesCache, 0);
|
||||
|
||||
|
||||
//For each lod height-depth value we have found we now want to generate the rest of the data
|
||||
//by merging all lods at lower level that are contained inside the new ones
|
||||
for (j = 0; j < count; j++)
|
||||
{
|
||||
//We firstly collect height and depth data
|
||||
//this will be added to each realtive long DataPoint
|
||||
yMax = heightAndDepth[j * 2];
|
||||
yMin = heightAndDepth[j * 2 + 1];
|
||||
|
||||
//if both height and depth are at 0 then we finished
|
||||
if ((yMin == 0 && yMax == 0) || j >= heightAndDepth.length / 2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//We initialize data useful for the merge
|
||||
int numberOfChildren = 0;
|
||||
allEmpty = true;
|
||||
allVoid = true;
|
||||
|
||||
//We initialize all the new values that we are going to put in the dataPoint
|
||||
int tempAlpha = 0;
|
||||
int tempRed = 0;
|
||||
int tempGreen = 0;
|
||||
int tempBlue = 0;
|
||||
int tempLightBlock = 0;
|
||||
int tempLightSky = 0;
|
||||
long data = 0;
|
||||
|
||||
//For each position that we want to merge
|
||||
for (int index = 0; index < dataCount; index++)
|
||||
{
|
||||
//we scan the lods in the position from top to bottom
|
||||
while (dataIndexesCache[index] < inputVerticalSize)
|
||||
{
|
||||
singleData = sourceData.get(index * inputVerticalSize + dataIndexesCache[index]);
|
||||
if (doesDataPointExist(singleData) && !isVoid(singleData))
|
||||
{
|
||||
dataIndexesCache[index]++;
|
||||
if ((yMin <= getYMin(singleData) && getYMin(singleData) < yMax)
|
||||
|| (yMin < getYMax(singleData) && getYMax(singleData) <= yMax))
|
||||
{
|
||||
data = singleData;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!doesDataPointExist(data))
|
||||
{
|
||||
data = createVoidDataPoint(genMode);
|
||||
}
|
||||
|
||||
if (doesDataPointExist(data))
|
||||
{
|
||||
allEmpty = false;
|
||||
if (!isVoid(data))
|
||||
{
|
||||
numberOfChildren++;
|
||||
allVoid = false;
|
||||
tempAlpha = Math.max(getAlpha(data), tempAlpha);
|
||||
tempRed += getRed(data) * getRed(data);
|
||||
tempGreen += getGreen(data) * getGreen(data);
|
||||
tempBlue += getBlue(data) * getBlue(data);
|
||||
tempLightBlock += getLightBlock(data);
|
||||
tempLightSky += getLightSky(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//we have at least 1 child
|
||||
if (dataCount != 1)
|
||||
{
|
||||
tempRed = tempRed / numberOfChildren;
|
||||
tempGreen = tempGreen / numberOfChildren;
|
||||
tempBlue = tempBlue / numberOfChildren;
|
||||
tempLightBlock = tempLightBlock / numberOfChildren;
|
||||
tempLightSky = tempLightSky / numberOfChildren;
|
||||
}
|
||||
|
||||
//data = createDataPoint(tempAlpha, tempRed, tempGreen, tempBlue, height, depth, tempLightSky, tempLightBlock, tempGenMode, allDefault);
|
||||
//if (j > 0 && getColor(data) == getColor(dataPoint[j]))
|
||||
//{
|
||||
// add simplification at the end due to color
|
||||
//}
|
||||
|
||||
output.set(j, createDataPoint(tempAlpha, (int) Math.sqrt(tempRed), (int) Math.sqrt(tempGreen), (int) Math.sqrt(tempBlue), yMax, yMin, tempLightSky, tempLightBlock, genMode));
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user