Fixed the artifacts (was caused by wrong array initialisation) and added the reset to while changing dimension
This commit is contained in:
@@ -31,7 +31,7 @@ public class DataPointUtil
|
||||
//public final static int MIN_DEPTH = -64;
|
||||
//public final static int MIN_HEIGHT = -64;
|
||||
public final static int EMPTY_DATA = 0;
|
||||
public final static int WORLD_HEIGHT = 256;
|
||||
public static int worldHeight = 256;
|
||||
|
||||
public final static int ALPHA_DOWNSIZE_SHIFT = 4;
|
||||
|
||||
@@ -279,14 +279,32 @@ public class DataPointUtil
|
||||
public static long[] mergeMultiData(long[] dataToMerge, int inputVerticalData, int maxVerticalData)
|
||||
{
|
||||
int size = dataToMerge.length / inputVerticalData;
|
||||
short[] projection = ThreadMapUtil.getProjectionShort((WORLD_HEIGHT) / 16 + 2);
|
||||
short[] heightAndDepth = ThreadMapUtil.getHeightAndDepth((WORLD_HEIGHT + 1) * 2);
|
||||
long[] singleDataToMerge = ThreadMapUtil.getSingleAddDataToMerge(size);
|
||||
long[] dataPoint = ThreadMapUtil.verticalDataArray(WORLD_HEIGHT + 1);
|
||||
Arrays.fill(projection, (short) 0);
|
||||
Arrays.fill(heightAndDepth, (short) 0);
|
||||
Arrays.fill(singleDataToMerge, EMPTY_DATA);
|
||||
Arrays.fill(dataPoint, EMPTY_DATA);
|
||||
|
||||
//We initialise the arrays that are going to be used
|
||||
short[] projection = ThreadMapUtil.getProjectionShort();
|
||||
short[] heightAndDepth = ThreadMapUtil.getHeightAndDepth();
|
||||
long[] singleDataToMerge = ThreadMapUtil.getSingleAddDataToMerge();
|
||||
long[] dataPoint = ThreadMapUtil.verticalDataArray();
|
||||
|
||||
if (projection == null || projection.length != (worldHeight) / 16 + 1)
|
||||
projection = new short[(worldHeight) / 16 + 1];
|
||||
else
|
||||
Arrays.fill(projection, (short) 0);
|
||||
|
||||
if (heightAndDepth == null || heightAndDepth.length != (worldHeight + 1) * 2)
|
||||
heightAndDepth = new short[(worldHeight + 1) * 2];
|
||||
else
|
||||
Arrays.fill(heightAndDepth, (short) 0);
|
||||
|
||||
if (singleDataToMerge == null || singleDataToMerge.length != size)
|
||||
singleDataToMerge = new long[size];
|
||||
else
|
||||
Arrays.fill(singleDataToMerge, EMPTY_DATA);
|
||||
|
||||
if (dataPoint == null || dataPoint.length != worldHeight + 1)
|
||||
dataPoint = new long[worldHeight + 1];
|
||||
else
|
||||
Arrays.fill(dataPoint, EMPTY_DATA);
|
||||
|
||||
int genMode = DistanceGenerationMode.SERVER.complexity;
|
||||
boolean allEmpty = true;
|
||||
@@ -355,7 +373,7 @@ public class DataPointUtil
|
||||
if (i == projection.length) //solid to WORLD_HEIGHT
|
||||
{
|
||||
heightAndDepth[count * 2] = depth;
|
||||
heightAndDepth[count * 2 + 1] = WORLD_HEIGHT - 1;
|
||||
heightAndDepth[count * 2 + 1] = (short) (worldHeight - 1);
|
||||
break;
|
||||
}
|
||||
while ((((projection[i] >>> ii) & 1) == 1)) ii++;
|
||||
@@ -370,7 +388,7 @@ public class DataPointUtil
|
||||
int j = 0;
|
||||
while (count > maxVerticalData)
|
||||
{
|
||||
ii = WORLD_HEIGHT;
|
||||
ii = worldHeight;
|
||||
for (i = 0; i < count - 1; i++)
|
||||
{
|
||||
if (heightAndDepth[(i + 1) * 2] - heightAndDepth[i * 2 + 1] < ii)
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ThreadMapUtil
|
||||
{
|
||||
if (!threadSingleUpdateMap.containsKey(Thread.currentThread().getName()) || (threadSingleUpdateMap.get(Thread.currentThread().getName()) == null))
|
||||
{
|
||||
threadSingleUpdateMap.put(Thread.currentThread().getName(), new long[4]);
|
||||
threadSingleUpdateMap.put(Thread.currentThread().getName(), new long[0]);
|
||||
}
|
||||
return threadSingleUpdateMap.get(Thread.currentThread().getName());
|
||||
}
|
||||
@@ -39,71 +39,70 @@ public class ThreadMapUtil
|
||||
if (!threadBuilderVerticalArrayMap.containsKey(Thread.currentThread().getName()) || (threadBuilderVerticalArrayMap.get(Thread.currentThread().getName()) == null))
|
||||
{
|
||||
long[][] array = new long[5][];
|
||||
for(int i = 0; i < array.length; i++)
|
||||
{
|
||||
int size = 1 << i;
|
||||
array[i] = new long[size * size * DataPointUtil.WORLD_HEIGHT];
|
||||
}
|
||||
threadBuilderVerticalArrayMap.put(Thread.currentThread().getName(), array);
|
||||
}
|
||||
return threadBuilderVerticalArrayMap.get(Thread.currentThread().getName());
|
||||
}
|
||||
|
||||
public static long[] verticalDataArray(int count)
|
||||
public static long[] verticalDataArray()
|
||||
{
|
||||
if (!threadVerticalAddDataMap.containsKey(Thread.currentThread().getName()) || (threadVerticalAddDataMap.get(Thread.currentThread().getName()) == null))
|
||||
{
|
||||
threadVerticalAddDataMap.put(Thread.currentThread().getName(), new long[count]);
|
||||
}
|
||||
for(int i = 0; i < threadVerticalAddDataMap.get(Thread.currentThread().getName()).length ; i++)
|
||||
{
|
||||
threadVerticalAddDataMap.get(Thread.currentThread().getName())[i] = DataPointUtil.EMPTY_DATA;
|
||||
threadVerticalAddDataMap.put(Thread.currentThread().getName(), new long[0]);
|
||||
}
|
||||
return threadVerticalAddDataMap.get(Thread.currentThread().getName());
|
||||
}
|
||||
|
||||
public static short[] getProjectionShort(int size){
|
||||
if(!projectionShortMap.containsKey(Thread.currentThread().getName()) || (projectionShortMap.get(Thread.currentThread().getName()) == null) || (projectionShortMap.get(Thread.currentThread().getName()).length != size))
|
||||
public static short[] getProjectionShort(){
|
||||
if(!projectionShortMap.containsKey(Thread.currentThread().getName()) || (projectionShortMap.get(Thread.currentThread().getName()) == null))
|
||||
{
|
||||
projectionShortMap.put(Thread.currentThread().getName(), new short[size]);
|
||||
projectionShortMap.put(Thread.currentThread().getName(), new short[0]);
|
||||
}
|
||||
return projectionShortMap.get(Thread.currentThread().getName());
|
||||
}
|
||||
|
||||
public static short[] getHeightAndDepth(int size){
|
||||
if(!heightAndDepthMap.containsKey(Thread.currentThread().getName()) || (heightAndDepthMap.get(Thread.currentThread().getName()) == null) || (heightAndDepthMap.get(Thread.currentThread().getName()).length != size))
|
||||
public static short[] getHeightAndDepth(){
|
||||
if(!heightAndDepthMap.containsKey(Thread.currentThread().getName()) || (heightAndDepthMap.get(Thread.currentThread().getName()) == null))
|
||||
{
|
||||
heightAndDepthMap.put(Thread.currentThread().getName(), new short[size]);
|
||||
heightAndDepthMap.put(Thread.currentThread().getName(), new short[0]);
|
||||
}
|
||||
return heightAndDepthMap.get(Thread.currentThread().getName());
|
||||
}
|
||||
|
||||
public static byte[] getSaveContainer(int size){
|
||||
if(!saveContainer.containsKey(Thread.currentThread().getName()) || (saveContainer.get(Thread.currentThread().getName()) == null) || (saveContainer.get(Thread.currentThread().getName()).length != size))
|
||||
public static byte[] getSaveContainer(){
|
||||
if(!saveContainer.containsKey(Thread.currentThread().getName()) || (saveContainer.get(Thread.currentThread().getName()) == null))
|
||||
{
|
||||
saveContainer.put(Thread.currentThread().getName(), new byte[size]);
|
||||
saveContainer.put(Thread.currentThread().getName(), new byte[0]);
|
||||
}
|
||||
return saveContainer.get(Thread.currentThread().getName());
|
||||
}
|
||||
|
||||
public static long[] getVerticalUpdateArray(byte detailLevel){
|
||||
if(!verticalUpdate.containsKey(Thread.currentThread().getName()) || (verticalUpdate.get(Thread.currentThread().getName()) == null) || (verticalUpdate.get(Thread.currentThread().getName())[detailLevel].length != 4*DetailDistanceUtil.getMaxVerticalData(detailLevel)))
|
||||
public static long[][] getVerticalUpdateArray(){
|
||||
if(!verticalUpdate.containsKey(Thread.currentThread().getName()) || (verticalUpdate.get(Thread.currentThread().getName()) == null))
|
||||
{
|
||||
long[][] array = new long[10][];
|
||||
for(int i = 0; i < array.length; i++)
|
||||
{
|
||||
array[i] = new long[4 * DetailDistanceUtil.getMaxVerticalData(detailLevel)];
|
||||
}
|
||||
verticalUpdate.put(Thread.currentThread().getName(), array);
|
||||
}
|
||||
return verticalUpdate.get(Thread.currentThread().getName())[detailLevel];
|
||||
return verticalUpdate.get(Thread.currentThread().getName());
|
||||
}
|
||||
|
||||
public static long[] getSingleAddDataToMerge(int size){
|
||||
if(!singleDataToMergeMap.containsKey(Thread.currentThread().getName()) || (singleDataToMergeMap.get(Thread.currentThread().getName()) == null) || (singleDataToMergeMap.get(Thread.currentThread().getName()).length != size))
|
||||
public static long[] getSingleAddDataToMerge(){
|
||||
if(!singleDataToMergeMap.containsKey(Thread.currentThread().getName()) || (singleDataToMergeMap.get(Thread.currentThread().getName()) == null))
|
||||
{
|
||||
singleDataToMergeMap.put(Thread.currentThread().getName(), new long[size]);
|
||||
singleDataToMergeMap.put(Thread.currentThread().getName(), new long[0]);
|
||||
}
|
||||
return singleDataToMergeMap.get(Thread.currentThread().getName());
|
||||
}
|
||||
|
||||
public static void clearMaps(){
|
||||
threadSingleUpdateMap.clear();
|
||||
threadBuilderArrayMap.clear();
|
||||
threadBuilderVerticalArrayMap.clear();
|
||||
threadVerticalAddDataMap.clear();
|
||||
saveContainer.clear();
|
||||
projectionShortMap.clear();
|
||||
heightAndDepthMap.clear();
|
||||
singleDataToMergeMap.clear();
|
||||
verticalUpdate.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user