Add distanceGenerationMode when generating nodes
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package com.seibel.lod.builders;
|
||||
|
||||
import com.seibel.lod.enums.DistanceGenerationMode;
|
||||
|
||||
/**
|
||||
* This is used to easily configure how LodChunks are generated.
|
||||
* Generally this will only be used if we want to generate a
|
||||
@@ -24,7 +26,7 @@ package com.seibel.lod.builders;
|
||||
* work best for a fully generated chunk (IE has correct surface blocks).
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 6-27-2021
|
||||
* @version 8-14-2021
|
||||
*/
|
||||
public class LodBuilderConfig
|
||||
{
|
||||
@@ -34,28 +36,61 @@ public class LodBuilderConfig
|
||||
public boolean useBiomeColors;
|
||||
/** default true */
|
||||
public boolean useSolidBlocksInColorGen;
|
||||
/** default server */
|
||||
public DistanceGenerationMode distanceGenerationMode;
|
||||
|
||||
/** default settings for a normal chunk <br>
|
||||
* useHeightmap = false <br>
|
||||
* useBiomeColors = false <br>
|
||||
* useSolidBlocksInColorGen = true <br>
|
||||
* generationMode = Server <br>
|
||||
*/
|
||||
public LodBuilderConfig()
|
||||
{
|
||||
useHeightmap = false;
|
||||
useBiomeColors = false;
|
||||
useSolidBlocksInColorGen = true;
|
||||
distanceGenerationMode = DistanceGenerationMode.SERVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param newUseHeightmap default = false
|
||||
* @param newUseBiomeColors default = false
|
||||
* @param newUseSolidBlocksInBiomeColor default = true
|
||||
* @param newDistanceGenerationMode default = Server
|
||||
*/
|
||||
public LodBuilderConfig(boolean newUseHeightmap, boolean newUseBiomeColors, boolean newUseSolidBlocksInBiomeColor)
|
||||
public LodBuilderConfig(boolean newUseHeightmap, boolean newUseBiomeColors,
|
||||
boolean newUseSolidBlocksInBiomeColor, DistanceGenerationMode newDistanceGenerationMode)
|
||||
{
|
||||
useHeightmap = newUseHeightmap;
|
||||
useBiomeColors = newUseBiomeColors;
|
||||
useSolidBlocksInColorGen = newUseSolidBlocksInBiomeColor;
|
||||
distanceGenerationMode = newDistanceGenerationMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param newUseHeightmap default = false
|
||||
* @param newUseBiomeColors default = false
|
||||
* @param newUseSolidBlocksInBiomeColor default = true
|
||||
* @param newDistanceGenerationMode default = Server
|
||||
*/
|
||||
public LodBuilderConfig(boolean newUseHeightmap, boolean newUseBiomeColors, boolean newUseSolidBlocksInBiomeColor)
|
||||
{
|
||||
this();
|
||||
useHeightmap = newUseHeightmap;
|
||||
useBiomeColors = newUseBiomeColors;
|
||||
useSolidBlocksInColorGen = newUseSolidBlocksInBiomeColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param newUseHeightmap default = false
|
||||
* @param newUseBiomeColors default = false
|
||||
* @param newUseSolidBlocksInBiomeColor default = true
|
||||
* @param newDistanceGenerationMode default = Server
|
||||
*/
|
||||
public LodBuilderConfig(DistanceGenerationMode newDistanceGenerationMode)
|
||||
{
|
||||
this();
|
||||
distanceGenerationMode = newDistanceGenerationMode;
|
||||
}
|
||||
}
|
||||
@@ -51,8 +51,9 @@ import net.minecraft.world.gen.Heightmap;
|
||||
* This object is in charge of creating Lod related objects. (specifically: Lod
|
||||
* World, Dimension, Region, and Chunk objects)
|
||||
*
|
||||
* @author Leonardo Amato
|
||||
* @author James Seibel
|
||||
* @version 8-10-2021
|
||||
* @version 8-14-2021
|
||||
*/
|
||||
public class LodNodeBuilder
|
||||
{
|
||||
@@ -73,6 +74,11 @@ public class LodNodeBuilder
|
||||
}
|
||||
|
||||
public void generateLodNodeAsync(IChunk chunk, LodQuadTreeWorld lodWorld, IWorld world)
|
||||
{
|
||||
generateLodNodeAsync(chunk, lodWorld, world, DistanceGenerationMode.SERVER);
|
||||
}
|
||||
|
||||
public void generateLodNodeAsync(IChunk chunk, LodQuadTreeWorld lodWorld, IWorld world, DistanceGenerationMode generationMode)
|
||||
{
|
||||
if (lodWorld == null || !lodWorld.getIsWorldLoaded())
|
||||
return;
|
||||
@@ -89,7 +95,7 @@ public class LodNodeBuilder
|
||||
{
|
||||
DimensionType dim = world.dimensionType();
|
||||
|
||||
List<LodQuadTreeNode> nodeList = generateLodNodeFromChunk(chunk);
|
||||
List<LodQuadTreeNode> nodeList = generateLodNodeFromChunk(chunk, new LodBuilderConfig(generationMode));
|
||||
|
||||
LodQuadTreeDimension lodDim;
|
||||
|
||||
@@ -102,6 +108,7 @@ public class LodNodeBuilder
|
||||
{
|
||||
lodDim = lodWorld.getLodDimension(dim);
|
||||
}
|
||||
|
||||
for (LodQuadTreeNode node : nodeList)
|
||||
{
|
||||
lodDim.addNode(node);
|
||||
@@ -134,7 +141,6 @@ public class LodNodeBuilder
|
||||
/**
|
||||
* Creates a LodChunk for a chunk in the given world.
|
||||
*
|
||||
* @return
|
||||
* @throws IllegalArgumentException thrown if either the chunk or world is null.
|
||||
*/
|
||||
public List<LodQuadTreeNode> generateLodNodeFromChunk(IChunk chunk, LodBuilderConfig config)
|
||||
@@ -142,8 +148,11 @@ public class LodNodeBuilder
|
||||
{
|
||||
LodDetail detail = LodConfig.CLIENT.maxGenerationDetail.get();
|
||||
List<LodQuadTreeNode> lodNodeList = new ArrayList<>();
|
||||
|
||||
if (chunk == null)
|
||||
throw new IllegalArgumentException("generateLodFromChunk given a null chunk");
|
||||
|
||||
|
||||
for (int i = 0; i < detail.dataPointLengthCount * detail.dataPointLengthCount; i++)
|
||||
{
|
||||
int startX = detail.startX[i];
|
||||
@@ -151,9 +160,6 @@ public class LodNodeBuilder
|
||||
int endX = detail.endX[i];
|
||||
int endZ = detail.endZ[i];
|
||||
|
||||
// TODO startX/Z and endX/Z are relative coordinates
|
||||
// getMin/Max appear to return world block coordinates
|
||||
|
||||
Color color = generateLodColorForArea(chunk, config, startX, startZ, endX, endZ);
|
||||
|
||||
short height;
|
||||
@@ -170,10 +176,11 @@ public class LodNodeBuilder
|
||||
startZ, endX, endZ);
|
||||
depth = 0;
|
||||
}
|
||||
|
||||
lodNodeList.add(new LodQuadTreeNode((byte) detail.detailLevel,
|
||||
LodUtil.convertLevelPos(chunk.getPos().getMinBlockX() + startX, 0, detail.detailLevel),
|
||||
LodUtil.convertLevelPos(chunk.getPos().getMinBlockZ() + startZ, 0, detail.detailLevel),
|
||||
new LodDataPoint(height, depth, color), DistanceGenerationMode.SERVER));
|
||||
new LodDataPoint(height, depth, color), config.distanceGenerationMode));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -568,7 +568,7 @@ public class LodQuadTree
|
||||
* setter for lodNodeData, to maintain a correct relationship between worlds
|
||||
* this method forces an update on all parent nodes.
|
||||
*
|
||||
* @param newLodQuadTreeNode data to set
|
||||
* @param newLodQuadTreeNode data to set
|
||||
*/
|
||||
public void setLodNodeData(LodQuadTreeNode newLodQuadTreeNode)
|
||||
{
|
||||
|
||||
@@ -283,13 +283,10 @@ public class LodQuadTreeNode
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO use the average height/depth, otherwise some areas look flat
|
||||
// when they shouldn't.
|
||||
|
||||
// get the lowest height from the all the given LodQuadTreeNodes
|
||||
short height = (short) dataList.stream().mapToInt(x -> (int) x.getLodDataPoint().height).min().getAsInt();
|
||||
short height = (short) (dataList.stream().mapToInt(x -> (int) x.getLodDataPoint().height).sum() / dataList.size());
|
||||
// get the highest depth
|
||||
short depth = (short) dataList.stream().mapToInt(x -> (int) x.getLodDataPoint().depth).max().getAsInt();
|
||||
short depth = (short) (dataList.stream().mapToInt(x -> (int) x.getLodDataPoint().depth).sum() / dataList.size());
|
||||
|
||||
// get the average color
|
||||
int red = dataList.stream().mapToInt(x -> x.getLodDataPoint().color.getRed()).sum() / dataList.size();
|
||||
@@ -297,7 +294,7 @@ public class LodQuadTreeNode
|
||||
int blue = dataList.stream().mapToInt(x -> x.getLodDataPoint().color.getBlue()).sum() / dataList.size();
|
||||
Color color = new Color(red,green,blue);
|
||||
|
||||
lodDataPoint = new LodDataPoint(height,depth,color);
|
||||
lodDataPoint = new LodDataPoint(height, depth, color);
|
||||
|
||||
|
||||
// the new complexity is equal to the lowest complexity of the list
|
||||
|
||||
@@ -160,10 +160,10 @@ public class ClientProxy
|
||||
// LodConfig.CLIENT.drawLODs.set(true);
|
||||
// LodConfig.CLIENT.debugMode.set(false);
|
||||
|
||||
LodConfig.CLIENT.maxDrawDetail.set(LodDetail.SINGLE);
|
||||
LodConfig.CLIENT.maxGenerationDetail.set(LodDetail.SINGLE);
|
||||
LodConfig.CLIENT.maxDrawDetail.set(LodDetail.FULL);
|
||||
LodConfig.CLIENT.maxGenerationDetail.set(LodDetail.FULL);
|
||||
|
||||
LodConfig.CLIENT.lodChunkRadiusMultiplier.set(16);
|
||||
LodConfig.CLIENT.lodChunkRadiusMultiplier.set(12);
|
||||
LodConfig.CLIENT.fogDistance.set(FogDistance.FAR);
|
||||
LodConfig.CLIENT.fogDrawOverride.set(FogDrawOverride.NEVER_DRAW_FOG);
|
||||
LodConfig.CLIENT.shadingMode.set(ShadingMode.DARKEN_SIDES);
|
||||
@@ -184,7 +184,7 @@ public class ClientProxy
|
||||
@SubscribeEvent
|
||||
public void chunkLoadEvent(ChunkEvent.Load event)
|
||||
{
|
||||
lodNodeBuilder.generateLodNodeAsync(event.getChunk(), lodWorld, event.getWorld());
|
||||
lodNodeBuilder.generateLodNodeAsync(event.getChunk(), lodWorld, event.getWorld(), DistanceGenerationMode.SERVER);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
Reference in New Issue
Block a user