Merge remote-tracking branch 'origin/1.16.5' into 1.16.5

This commit is contained in:
Leonardo
2021-09-20 14:01:28 +02:00
8 changed files with 85 additions and 98 deletions
@@ -390,8 +390,6 @@ public class LodBufferBuilder
});
mainGenThread.execute(thread);
return;
}
//===============================//
@@ -318,7 +318,7 @@ public class LodBuilder
//If the lod is at default, then we set this as void data
if (height == DEFAULT_HEIGHT)
{
dataToMerge[index * verticalData + 0] = DataPointUtil.createVoidDataPoint(generation);
dataToMerge[index * verticalData] = DataPointUtil.createVoidDataPoint(generation);
break;
}
@@ -417,9 +417,7 @@ public class LodBuilder
}
}
if (!voidData)
{
break;
}
}
}
return height;
@@ -884,14 +882,10 @@ public class LodBuilder
}
}
if (blockState.getBlock() != Blocks.AIR
&& blockState.getBlock() != Blocks.CAVE_AIR
&& blockState.getBlock() != Blocks.BARRIER)
{
return true;
}
return blockState.getBlock() != Blocks.AIR
&& blockState.getBlock() != Blocks.CAVE_AIR
&& blockState.getBlock() != Blocks.BARRIER;
}
return false;
}
}
@@ -1,5 +1,6 @@
package com.seibel.lod.builders.lodTemplates;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -164,10 +165,7 @@ public class Box
{
for (int i = 0; i < box.length; i++)
{
for (int j = 0; j < box[i].length; j++)
{
box[i][j] = 0;
}
Arrays.fill(box[i], 0);
}
for (Direction direction : DIRECTIONS)
@@ -175,8 +173,7 @@ public class Box
colorMap.get(direction)[0] = 0;
}
for(int i = 0; i < order.length; i++)
order[i] = DataPointUtil.EMPTY_DATA;
Arrays.fill(order, DataPointUtil.EMPTY_DATA);
for (Direction direction : ADJ_DIRECTIONS)
{
if(isCulled(direction)){
@@ -274,66 +271,64 @@ public class Box
height = DataPointUtil.getHeight(singleAdjDataPoint);
depth = DataPointUtil.getDepth(singleAdjDataPoint);
if (depth > maxY)
{//the adj data is higher than the current data
//we continue since there could be some other data that intersect the current
continue;
} else if (height < minY)
{//the adj data is lower than the current data
//we break since all the other data will be lower
if (depth <= maxY) {
if (height < minY)
{//the adj data is lower than the current data
//we break since all the other data will be lower
if (firstFace)
{
adjHeightAndDepth.get(direction)[0][0] = getMaxY();
adjHeightAndDepth.get(direction)[0][1] = getMinY();
} else
{
adjHeightAndDepth.get(direction)[faceToDraw][1] = getMinY();
}
faceToDraw++;
toFinish = false;
break;
} else if (depth <= minY && height >= maxY)
{//the adj data contains the current
//we do not draw the face
adjHeightAndDepth.get(direction)[0][0] = VOID_FACE;
adjHeightAndDepth.get(direction)[0][1] = VOID_FACE;
break;
} else if (depth <= minY && height < maxY)
{//the adj data intersect the lower part of the current data
//if this is the only face we use the maxY and break
//if there was other face we finish the last one and break
if (firstFace)
{
adjHeightAndDepth.get(direction)[0][0] = getMaxY();
adjHeightAndDepth.get(direction)[0][1] = height;
} else
{
if (firstFace)
{
adjHeightAndDepth.get(direction)[0][0] = getMaxY();
adjHeightAndDepth.get(direction)[0][1] = getMinY();
} else
{
adjHeightAndDepth.get(direction)[faceToDraw][1] = getMinY();
}
faceToDraw++;
toFinish = false;
break;
} else if (depth <= minY && height >= maxY)
{//the adj data contains the current
//we do not draw the face
adjHeightAndDepth.get(direction)[0][0] = VOID_FACE;
adjHeightAndDepth.get(direction)[0][1] = VOID_FACE;
break;
} else if (depth <= minY)//&& height < maxY
{//the adj data intersect the lower part of the current data
//if this is the only face we use the maxY and break
//if there was other face we finish the last one and break
if (firstFace)
{
adjHeightAndDepth.get(direction)[0][0] = getMaxY();
adjHeightAndDepth.get(direction)[0][1] = height;
} else
{
adjHeightAndDepth.get(direction)[faceToDraw][1] = height;
}
toFinish = false;
faceToDraw++;
break;
} else if (height >= maxY)//depth > minY &&
{//the adj data intersect the higher part of the current data
//we start the creation of a new face
adjHeightAndDepth.get(direction)[faceToDraw][0] = depth;
firstFace = false;
toFinish = true;
} else {//if (depth > minY && height < maxY)
//the adj data is contained in the current data
if (firstFace)
{
adjHeightAndDepth.get(direction)[0][0] = getMaxY();
}
adjHeightAndDepth.get(direction)[faceToDraw][1] = height;
faceToDraw++;
adjHeightAndDepth.get(direction)[faceToDraw][0] = depth;
firstFace = false;
toFinish = true;
}
toFinish = false;
faceToDraw++;
break;
} else if (depth > minY && height >= maxY)
{//the adj data intersect the higher part of the current data
//we start the creation of a new face
adjHeightAndDepth.get(direction)[faceToDraw][0] = depth;
firstFace = false;
toFinish = true;
continue;
} else if (depth > minY && height < maxY)
{//the adj data is contained in the current data
if (firstFace)
{
adjHeightAndDepth.get(direction)[0][0] = getMaxY();
}
adjHeightAndDepth.get(direction)[faceToDraw][1] = height;
faceToDraw++;
adjHeightAndDepth.get(direction)[faceToDraw][0] = depth;
firstFace = false;
toFinish = true;
continue;
}
} //else {//the adj data is higher than the current data
//we continue since there could be some other data that intersect the current
//}
}
if (toFinish)
{
@@ -401,10 +396,7 @@ public class Box
{
if (direction == Direction.UP || direction == Direction.DOWN)
{
if (adjIndex == 0)
return true;
else
return false;
return adjIndex == 0;
}
return !(adjHeightAndDepth.get(direction)[adjIndex][0] == VOID_FACE && adjHeightAndDepth.get(direction)[adjIndex][1] == VOID_FACE);
@@ -224,9 +224,9 @@ public class LodNodeGenWorker implements IWorker
// System.out.println(endTime - startTime);
}// if in range
else{
//else{
}
//}
}
catch (Exception e)
{
@@ -584,16 +584,11 @@ public class LodNodeGenWorker implements IWorker
private BlockClusterFeatureConfig cloneBlockClusterFeatureConfig(BlockClusterFeatureConfig config)
{
WeightedBlockStateProvider provider = new WeightedBlockStateProvider();
for(Entry<BlockState> state : ((WeightedBlockStateProvider) config.stateProvider).weightedList.entries)
provider.weightedList.entries.add(state);
provider.weightedList.entries.addAll(((WeightedBlockStateProvider) config.stateProvider).weightedList.entries);
HashSet<Block> whitelist = new HashSet<>();
for(Block block : config.whitelist)
whitelist.add(block);
HashSet<Block> whitelist = new HashSet<>(config.whitelist);
HashSet<BlockState> blacklist = new HashSet<>();
for(BlockState state : config.blacklist)
blacklist.add(state);
HashSet<BlockState> blacklist = new HashSet<>(config.blacklist);
BlockClusterFeatureConfig.Builder builder = new BlockClusterFeatureConfig.Builder(provider, config.blockPlacer);
@@ -286,16 +286,16 @@ public class LodDimensionFileHandler
ex.printStackTrace();
}
// check if this file can be written to by the file handler
if (fileVersion <= LOD_SAVE_FILE_VERSION)
{
// we are good to continue and overwrite the old file
} else // if(fileVersion > LOD_SAVE_FILE_VERSION)
{
if (fileVersion > LOD_SAVE_FILE_VERSION) {
// the file we are reading is a newer version,
// don't write anything, we don't want to accidently
// delete anything the user may want.
return;
}
} // if(fileVersion > LOD_SAVE_FILE_VERSION)
//else {
// we are good to continue and overwrite the old file
//}
}
// the old file is good, now create a new save file
@@ -137,7 +137,7 @@ public class SingleLevelContainer implements LevelContainer
{
int index = 0;
int tempIndex;
byte[] tempData = new byte[1 + (size * size * 8)];
byte[] tempData = ThreadMapUtil.getSaveContainer(1 + (size * size * 8));
tempData[index] = detailLevel;
index++;
for (int x = 0; x < size; x++)
@@ -152,7 +152,7 @@ public class VerticalLevelContainer implements LevelContainer
{
int index = 0;
int tempIndex;
byte[] tempData = new byte[2 + (size * size * maxVerticalData * 8)];
byte[] tempData = ThreadMapUtil.getSaveContainer(2 + (size * size * maxVerticalData * 8));
tempData[index] = detailLevel;
index++;
tempData[index] = (byte) maxVerticalData;
@@ -19,7 +19,7 @@ public class ThreadMapUtil
public static final ConcurrentMap<String, long[]> threadAdjData = new ConcurrentHashMap<>();
public static final ConcurrentMap<String, byte[]> saveContainer = new ConcurrentHashMap<>();
public static final ConcurrentMap<String, short[]> projectionShortMap = new ConcurrentHashMap<>();
public static final ConcurrentMap<String, short[]> heightAndDepthMap = new ConcurrentHashMap<>();
public static final ConcurrentMap<String, long[]> singleDataToMergeMap = new ConcurrentHashMap<>();
@@ -101,6 +101,14 @@ public class ThreadMapUtil
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))
{
saveContainer.put(Thread.currentThread().getName(), new byte[size]);
}
return saveContainer.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))
{