Added tree generator and new tree cutter
This commit is contained in:
@@ -28,7 +28,6 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -41,7 +40,7 @@ import com.seibel.lod.objects.LodDimension;
|
||||
import com.seibel.lod.objects.RegionPos;
|
||||
import com.seibel.lod.proxy.ClientProxy;
|
||||
import com.seibel.lod.render.LodRenderer;
|
||||
import com.seibel.lod.util.DetailUtil;
|
||||
import com.seibel.lod.util.DetailDistanceUtil;
|
||||
import com.seibel.lod.util.LodThreadFactory;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
|
||||
@@ -66,7 +65,8 @@ public class LodBufferBuilder
|
||||
/** This holds the thread used to generate new LODs off the main thread. */
|
||||
private ExecutorService mainGenThread = Executors.newSingleThreadExecutor(new LodThreadFactory(this.getClass().getSimpleName() + " - main"));
|
||||
/** This holds the threads used to generate buffers. */
|
||||
private ExecutorService bufferBuilderThreads = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new LodThreadFactory(this.getClass().getSimpleName() + " - builder"));
|
||||
//private ExecutorService bufferBuilderThreads = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new LodThreadFactory(this.getClass().getSimpleName() + " - builder"));
|
||||
private ExecutorService bufferBuilderThreads = Executors.newFixedThreadPool(2, new LodThreadFactory(this.getClass().getSimpleName() + " - builder"));
|
||||
|
||||
private LodBuilder LodQuadTreeNodeBuilder;
|
||||
|
||||
@@ -129,8 +129,10 @@ public class LodBufferBuilder
|
||||
|
||||
public LodBufferBuilder(LodBuilder newLodBuilder)
|
||||
{
|
||||
System.out.println("start building con");
|
||||
mc = Minecraft.getInstance();
|
||||
LodQuadTreeNodeBuilder = newLodBuilder;
|
||||
System.out.println("end building con");
|
||||
}
|
||||
|
||||
|
||||
@@ -149,6 +151,7 @@ public class LodBufferBuilder
|
||||
public void generateLodBuffersAsync(LodRenderer renderer, LodDimension lodDim,
|
||||
BlockPos playerBlockPos, int numbChunksWide)
|
||||
{
|
||||
System.out.println("start building process");
|
||||
// only allow one generation process to happen at a time
|
||||
if (generatingBuffers)
|
||||
return;
|
||||
@@ -174,13 +177,15 @@ public class LodBufferBuilder
|
||||
{
|
||||
bufferLock.lock();
|
||||
|
||||
long treeStart = System.currentTimeMillis();
|
||||
lodDim.treeCutter(playerBlockPosRounded.getX(), playerBlockPosRounded.getZ());
|
||||
|
||||
long treeEnd = System.currentTimeMillis();
|
||||
|
||||
try
|
||||
{
|
||||
long treeStart = System.currentTimeMillis();
|
||||
lodDim.treeGenerator(playerBlockPosRounded.getX(), playerBlockPosRounded.getZ());
|
||||
lodDim.treeCutter(playerBlockPosRounded.getX(), playerBlockPosRounded.getZ());
|
||||
System.out.println("memory needed " + lodDim.getMinMemoryNeeded() + " byte");
|
||||
long treeEnd = System.currentTimeMillis();
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
ArrayList<GenerationRequest> chunksToGen = new ArrayList<>(maxChunkGenRequests);
|
||||
@@ -226,8 +231,8 @@ public class LodBufferBuilder
|
||||
regionPos,
|
||||
playerBlockPosRounded.getX(),
|
||||
playerBlockPosRounded.getZ(),
|
||||
DetailUtil.getDistanceRendering(detail),
|
||||
DetailUtil.getDistanceRendering(detail + 1),
|
||||
DetailDistanceUtil.getDistanceRendering(detail),
|
||||
DetailDistanceUtil.getDistanceRendering(detail + 1),
|
||||
detail));
|
||||
}
|
||||
|
||||
@@ -335,13 +340,13 @@ public class LodBufferBuilder
|
||||
posListToGenerate = lodDim.getDataToGenerate(
|
||||
playerBlockPosRounded.getX(),
|
||||
playerBlockPosRounded.getZ(),
|
||||
DetailUtil.getDistanceGeneration(detailGen),
|
||||
DetailUtil.getDistanceGeneration(detailGen + 1),
|
||||
DetailDistanceUtil.getDistanceGeneration(detailGen),
|
||||
DetailDistanceUtil.getDistanceGeneration(detailGen + 1),
|
||||
LodConfig.CLIENT.distanceGenerationMode.get().complexity,
|
||||
(byte) 9,
|
||||
requesting);
|
||||
requesting/2);
|
||||
for(LevelPos levelPos : posListToGenerate){
|
||||
generationRequestList.add(new GenerationRequest(levelPos,LodConfig.CLIENT.distanceGenerationMode.get(), DetailUtil.getLodDetail(detailGen)));
|
||||
generationRequestList.add(new GenerationRequest(levelPos,LodConfig.CLIENT.distanceGenerationMode.get(), DetailDistanceUtil.getLodDetail(detailGen)));
|
||||
}
|
||||
requesting = maxChunkGenRequests - generationRequestList.size();
|
||||
|
||||
@@ -354,13 +359,13 @@ public class LodBufferBuilder
|
||||
posListToGenerate = lodDim.getDataToGenerate(
|
||||
playerBlockPosRounded.getX(),
|
||||
playerBlockPosRounded.getZ(),
|
||||
DetailUtil.getDistanceGeneration(detailGen),
|
||||
DetailUtil.getDistanceGeneration(detailGen + 1),
|
||||
DetailDistanceUtil.getDistanceGeneration(detailGen),
|
||||
DetailDistanceUtil.getDistanceGeneration(detailGen + 1),
|
||||
LodConfig.CLIENT.distanceGenerationMode.get().complexity,
|
||||
LodConfig.CLIENT.maxGenerationDetail.get().detailLevel,
|
||||
DetailDistanceUtil.getLodDetail(detailGen).detailLevel,
|
||||
maxChunkGenRequests);
|
||||
for(LevelPos levelPos : posListToGenerate){
|
||||
generationRequestList.add(new GenerationRequest(levelPos,LodConfig.CLIENT.distanceGenerationMode.get(), DetailUtil.getLodDetail(detailGen)));
|
||||
generationRequestList.add(new GenerationRequest(levelPos,LodConfig.CLIENT.distanceGenerationMode.get(), DetailDistanceUtil.getLodDetail(detailGen)));
|
||||
}
|
||||
requesting = maxChunkGenRequests - generationRequestList.size();
|
||||
}
|
||||
|
||||
@@ -114,12 +114,11 @@ public class LodDimensionFileHandler
|
||||
* Return the LodRegion region at the given coordinates.
|
||||
* (null if the file doesn't exist)
|
||||
*/
|
||||
public LodRegion loadRegionFromFile(LevelPos levelPos)
|
||||
public LodRegion loadRegionFromFile(RegionPos regionPos, byte detailLevel)
|
||||
{
|
||||
RegionPos regionPos = levelPos.getRegionPos();
|
||||
int regionX = regionPos.x;
|
||||
int regionZ = regionPos.z;
|
||||
String fileName = getFileNameAndPathForRegion(regionX, regionZ, levelPos.detailLevel);
|
||||
String fileName = getFileNameAndPathForRegion(regionX, regionZ, detailLevel);
|
||||
|
||||
// if the fileName was null that means the folder is inaccessible
|
||||
// for some reason
|
||||
@@ -219,17 +218,22 @@ public class LodDimensionFileHandler
|
||||
|
||||
private Thread saveDirtyRegionsThread = new Thread(() ->
|
||||
{
|
||||
for (int i = 0; i < loadedDimension.getWidth(); i++)
|
||||
{
|
||||
for (int j = 0; j < loadedDimension.getWidth(); j++)
|
||||
{
|
||||
if (loadedDimension.isRegionDirty[i][j] && loadedDimension.regions[i][j] != null)
|
||||
{
|
||||
saveRegionToFile(loadedDimension.regions[i][j]);
|
||||
loadedDimension.isRegionDirty[i][j] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < loadedDimension.getWidth(); i++)
|
||||
{
|
||||
for (int j = 0; j < loadedDimension.getWidth(); j++)
|
||||
{
|
||||
if (loadedDimension.isRegionDirty[i][j] && loadedDimension.regions[i][j] != null)
|
||||
{
|
||||
saveRegionToFile(loadedDimension.regions[i][j]);
|
||||
loadedDimension.isRegionDirty[i][j] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.seibel.lod.objects;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -26,10 +27,8 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.seibel.lod.enums.DistanceGenerationMode;
|
||||
import com.seibel.lod.handlers.LodConfig;
|
||||
import com.seibel.lod.handlers.LodDimensionFileHandler;
|
||||
import com.seibel.lod.proxy.ClientProxy;
|
||||
import com.seibel.lod.util.DetailUtil;
|
||||
import com.seibel.lod.util.DetailDistanceUtil;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -76,6 +75,7 @@ public class LodDimension
|
||||
*/
|
||||
public LodDimension(DimensionType newDimension, LodWorld lodWorld, int newWidth)
|
||||
{
|
||||
System.out.println("start lod dim");
|
||||
dimension = newDimension;
|
||||
width = newWidth;
|
||||
halfWidth = (int) Math.floor(width / 2);
|
||||
@@ -123,6 +123,7 @@ public class LodDimension
|
||||
isRegionDirty[i][j] = false;
|
||||
|
||||
center = new RegionPos(0, 0);
|
||||
System.out.println("end lod dim");
|
||||
}
|
||||
|
||||
|
||||
@@ -224,6 +225,29 @@ public class LodDimension
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return needed memory in byte
|
||||
*/
|
||||
public int getMinMemoryNeeded()
|
||||
{
|
||||
int regionX;
|
||||
int regionZ;
|
||||
int count = 0;
|
||||
LodRegion region;
|
||||
|
||||
for (int x = 0; x < regions.length; x++)
|
||||
{
|
||||
for (int z = 0; z < regions.length; z++)
|
||||
{
|
||||
region = regions[x][z];
|
||||
if(region != null){
|
||||
count += region.getMinMemoryNeeded();
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the region at the given X and Z
|
||||
* <br>
|
||||
@@ -232,28 +256,35 @@ public class LodDimension
|
||||
*/
|
||||
public LodRegion getRegion(LevelPos levelPos)
|
||||
{
|
||||
|
||||
RegionPos regionPos = levelPos.getRegionPos();
|
||||
int xIndex = (regionPos.x - center.x) + halfWidth;
|
||||
int zIndex = (regionPos.z - center.z) + halfWidth;
|
||||
|
||||
if (!regionIsInRange(regionPos.x, regionPos.z))
|
||||
// out of range
|
||||
return null;
|
||||
throw new ArrayIndexOutOfBoundsException("Region for level pos " + levelPos + " out of range");
|
||||
else if (regions[xIndex][zIndex] == null)
|
||||
throw new InvalidParameterException("Region for level pos " + levelPos + " not currently initialized");
|
||||
else if (regions[xIndex][zIndex].getMinDetailLevel() > levelPos.detailLevel)
|
||||
throw new InvalidParameterException("Region for level pos " + levelPos + " currently only reach level " + regions[xIndex][zIndex].getMinDetailLevel());
|
||||
return regions[xIndex][zIndex];
|
||||
}
|
||||
|
||||
if (regions[xIndex][zIndex] == null || regions[xIndex][zIndex].getMinDetailLevel() > levelPos.detailLevel)
|
||||
{
|
||||
|
||||
regions[xIndex][zIndex] = getRegionFromFile(levelPos);
|
||||
if (regions[xIndex][zIndex] == null)
|
||||
{
|
||||
/**TODO the value is currently 0 but should be determinated by the distance of the player)*/
|
||||
regions[xIndex][zIndex] = new LodRegion(LodConfig.CLIENT.maxGenerationDetail.get().detailLevel, regionPos);
|
||||
}else if (regions[xIndex][zIndex].getMinDetailLevel() > levelPos.detailLevel)
|
||||
{
|
||||
regions[xIndex][zIndex].expand(levelPos.detailLevel);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the region at the given X and Z
|
||||
* <br>
|
||||
* Returns null if the region doesn't exist
|
||||
* or is outside the loaded area.
|
||||
*/
|
||||
public LodRegion getRegion(RegionPos regionPos)
|
||||
{
|
||||
int xIndex = (regionPos.x - center.x) + halfWidth;
|
||||
int zIndex = (regionPos.z - center.z) + halfWidth;
|
||||
|
||||
if (!regionIsInRange(regionPos.x, regionPos.z))
|
||||
throw new ArrayIndexOutOfBoundsException("Region " + regionPos + " out of range");
|
||||
else if (regions[xIndex][zIndex] == null)
|
||||
throw new InvalidParameterException("Region " + regionPos + " not currently initialized");
|
||||
return regions[xIndex][zIndex];
|
||||
}
|
||||
|
||||
@@ -269,16 +300,15 @@ public class LodDimension
|
||||
|
||||
if (!regionIsInRange(newRegion.regionPosX, newRegion.regionPosZ))
|
||||
// out of range
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
throw new ArrayIndexOutOfBoundsException("Region " + newRegion.regionPosX + ", " + newRegion.regionPosZ + " out of range");
|
||||
|
||||
regions[xIndex][zIndex] = newRegion;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* this method creates all null regions
|
||||
*/
|
||||
public void treeCutter(int posX, int posZ)
|
||||
public void treeCutter(int playerPosX, int playerPosZ)
|
||||
{
|
||||
int regionX;
|
||||
int regionZ;
|
||||
@@ -292,10 +322,20 @@ public class LodDimension
|
||||
regionX = (x + center.x) - halfWidth;
|
||||
regionZ = (z + center.z) - halfWidth;
|
||||
levelPos = new LevelPos(LodUtil.REGION_DETAIL_LEVEL, regionX, regionZ);
|
||||
//we start checking from the first circle. If the whole region is in the circle
|
||||
//we proceed to cut all the level lower than the level of circle 1 and we break
|
||||
//if this is not the case w
|
||||
for(byte index = LodUtil.BLOCK_DETAIL_LEVEL; index <= LodUtil.REGION_DETAIL_LEVEL; index++){
|
||||
if(DetailUtil.getDistanceGeneration(index+1) > levelPos.minDistance(posX, posZ)){
|
||||
region = getRegion(levelPos.convert(DetailUtil.getLodDetail(index).detailLevel));
|
||||
region.cuteTree(DetailUtil.getLodDetail(index-1).detailLevel);
|
||||
if(DetailDistanceUtil.getDistanceCut(index + 1) > levelPos.minDistance(playerPosX, playerPosZ)){
|
||||
region = regions[x][z];
|
||||
|
||||
byte cutDetailLevel = DetailDistanceUtil.getCutLodDetail(index).detailLevel;
|
||||
|
||||
if(region != null && cutDetailLevel > 0)
|
||||
{
|
||||
region.cutTree(cutDetailLevel);
|
||||
}
|
||||
//once we
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -303,6 +343,57 @@ public class LodDimension
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void treeGenerator(int playerPosX, int playerPosZ)
|
||||
{
|
||||
int regionX;
|
||||
int regionZ;
|
||||
LevelPos levelPos;
|
||||
RegionPos regionPos;
|
||||
LodRegion region;
|
||||
byte targetDetailLevel;
|
||||
|
||||
for (int x = 0; x < regions.length; x++)
|
||||
{
|
||||
for (int z = 0; z < regions.length; z++)
|
||||
{
|
||||
regionX = (x + center.x) - halfWidth;
|
||||
regionZ = (z + center.z) - halfWidth;
|
||||
levelPos = new LevelPos(LodUtil.REGION_DETAIL_LEVEL, regionX, regionZ);
|
||||
regionPos = new RegionPos(regionX, regionZ);
|
||||
|
||||
for(byte index = LodUtil.BLOCK_DETAIL_LEVEL; index <= LodUtil.REGION_DETAIL_LEVEL; index++){
|
||||
|
||||
//As soon as we find in which circle the region should be we analyze it
|
||||
if(DetailDistanceUtil.getDistanceGeneration(index + 1) > levelPos.minDistance(playerPosX, playerPosZ)){
|
||||
|
||||
region = regions[x][z];
|
||||
//We require that the region we are checking is loaded with at least this level
|
||||
targetDetailLevel = DetailDistanceUtil.getLodDetail(index).detailLevel;
|
||||
|
||||
if (region == null)
|
||||
{
|
||||
//First case, region has to be initialized
|
||||
|
||||
//We check if there is a file at the target level
|
||||
region = getRegionFromFile(regionPos, targetDetailLevel);
|
||||
|
||||
//if there is no file we initialize the region
|
||||
if (region == null)
|
||||
regions[x][z] = new LodRegion(targetDetailLevel, regionPos);
|
||||
|
||||
}else if(region.getMinDetailLevel() > targetDetailLevel){
|
||||
//Second case, region has been initialized but at a higher level
|
||||
//We expand the region by introducing the missing layer
|
||||
region.expand(targetDetailLevel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given LOD to this dimension at the coordinate
|
||||
@@ -367,6 +458,8 @@ public class LodDimension
|
||||
int xIndex;
|
||||
int zIndex;
|
||||
LodRegion region;
|
||||
RegionPos regionPos;
|
||||
LevelPos regionLevelPos;
|
||||
List<Map.Entry<LevelPos, Integer>> listOfData = new ArrayList<>();
|
||||
for (int xRegion = 0; xRegion < n; xRegion++)
|
||||
{
|
||||
@@ -374,9 +467,14 @@ public class LodDimension
|
||||
{
|
||||
xIndex = (xRegion + center.x) - halfWidth;
|
||||
zIndex = (zRegion + center.z) - halfWidth;
|
||||
RegionPos regionPos = new RegionPos(xIndex, zIndex);
|
||||
region = getRegion(new LevelPos(LodUtil.REGION_DETAIL_LEVEL, regionPos.x, regionPos.z).convert(detailLevel));
|
||||
listOfData.addAll(region.getDataToGenerate(playerPosX, playerPosZ, start, end, generation, detailLevel, dataNumber));
|
||||
regionPos = new RegionPos(xIndex, zIndex);
|
||||
regionLevelPos = new LevelPos(LodUtil.REGION_DETAIL_LEVEL, regionPos.x, regionPos.z);
|
||||
if(end >= regionLevelPos.minDistance(playerPosX, playerPosZ) &&
|
||||
start <= regionLevelPos.maxDistance(playerPosX, playerPosZ))
|
||||
{
|
||||
region = getRegion(new LevelPos(LodUtil.REGION_DETAIL_LEVEL, regionPos.x, regionPos.z).convert(detailLevel));
|
||||
listOfData.addAll(region.getDataToGenerate(playerPosX, playerPosZ, start, end, generation, detailLevel, dataNumber));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,21 +503,28 @@ public class LodDimension
|
||||
int xIndex;
|
||||
int zIndex;
|
||||
LodRegion region;
|
||||
RegionPos regionPos;
|
||||
LevelPos regionLevelPos;
|
||||
for (int xRegion = 0; xRegion < n; xRegion++)
|
||||
{
|
||||
for (int zRegion = 0; zRegion < n; zRegion++)
|
||||
{
|
||||
xIndex = (xRegion + center.x) - halfWidth;
|
||||
zIndex = (zRegion + center.z) - halfWidth;
|
||||
RegionPos regionPos = new RegionPos(xIndex, zIndex);
|
||||
region = getRegion(new LevelPos(LodUtil.REGION_DETAIL_LEVEL, regionPos.x, regionPos.z).convert(detailLevel));
|
||||
if (region == null)
|
||||
regionPos = new RegionPos(xIndex, zIndex);
|
||||
regionLevelPos = new LevelPos(LodUtil.REGION_DETAIL_LEVEL, regionPos.x, regionPos.z);
|
||||
if(end >= regionLevelPos.minDistance(playerPosX, playerPosZ) &&
|
||||
start <= regionLevelPos.maxDistance(playerPosX, playerPosZ))
|
||||
{
|
||||
//region = new LodRegion(DetailUtil.getLodDetail(detailLevel).detailLevel, regionPos);
|
||||
//addOrOverwriteRegion(region);
|
||||
} else
|
||||
{
|
||||
listOfData.addAll(region.getDataToRender(playerPosX, playerPosZ, start, end, detailLevel));
|
||||
region = getRegion(new LevelPos(LodUtil.REGION_DETAIL_LEVEL, regionPos.x, regionPos.z).convert(detailLevel));
|
||||
if (region == null)
|
||||
{
|
||||
//region = new LodRegion(DetailUtil.getLodDetail(detailLevel).detailLevel, regionPos);
|
||||
//addOrOverwriteRegion(region);
|
||||
} else
|
||||
{
|
||||
listOfData.addAll(region.getDataToRender(playerPosX, playerPosZ, start, end, detailLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -434,9 +539,13 @@ public class LodDimension
|
||||
public List<LevelPos> getDataToRender(RegionPos regionPos, int playerPosX, int playerPosZ, int start, int end, byte detailLevel)
|
||||
{
|
||||
List<LevelPos> listOfData = new ArrayList<>();
|
||||
LodRegion region = getRegion(new LevelPos(LodUtil.REGION_DETAIL_LEVEL, regionPos.x, regionPos.z).convert(detailLevel));
|
||||
if (region == null)
|
||||
LevelPos regionLevelPos = new LevelPos(LodUtil.REGION_DETAIL_LEVEL, regionPos.x, regionPos.z);
|
||||
if(end >= regionLevelPos.minDistance(playerPosX, playerPosZ) &&
|
||||
start <= regionLevelPos.maxDistance(playerPosX, playerPosZ))
|
||||
{
|
||||
LodRegion region = getRegion(new LevelPos(LodUtil.REGION_DETAIL_LEVEL, regionPos.x, regionPos.z).convert(detailLevel));
|
||||
if (region == null)
|
||||
{
|
||||
/*
|
||||
try
|
||||
{
|
||||
@@ -449,11 +558,11 @@ public class LodDimension
|
||||
return listOfData; // this list should be empty
|
||||
}
|
||||
*/
|
||||
return listOfData;
|
||||
}
|
||||
else
|
||||
{
|
||||
listOfData.addAll(region.getDataToRender(playerPosX, playerPosZ, start, end, detailLevel));
|
||||
return listOfData;
|
||||
} else
|
||||
{
|
||||
listOfData.addAll(region.getDataToRender(playerPosX, playerPosZ, start, end, detailLevel));
|
||||
}
|
||||
}
|
||||
return listOfData;
|
||||
}
|
||||
@@ -554,10 +663,10 @@ public class LodDimension
|
||||
* Get the region at the given X and Z coordinates from the
|
||||
* RegionFileHandler.
|
||||
*/
|
||||
public LodRegion getRegionFromFile(LevelPos levelPos)
|
||||
public LodRegion getRegionFromFile(RegionPos regionPos, byte detailLevel)
|
||||
{
|
||||
if (fileHandler != null)
|
||||
return fileHandler.loadRegionFromFile(levelPos);
|
||||
return fileHandler.loadRegionFromFile(regionPos, detailLevel);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -602,7 +602,7 @@ public class LodRegion implements Serializable
|
||||
/**
|
||||
* @param detailLevel
|
||||
*/
|
||||
public void cuteTree(byte detailLevel)
|
||||
public void cutTree(byte detailLevel)
|
||||
{
|
||||
if(minDetailLevel < detailLevel)
|
||||
{
|
||||
@@ -635,6 +635,30 @@ public class LodRegion implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return RegionPos of this lod region
|
||||
*/
|
||||
public RegionPos getRegionPos()
|
||||
{
|
||||
return new RegionPos(regionPosX, regionPosZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* return needed memory in byte
|
||||
*/
|
||||
public int getMinMemoryNeeded()
|
||||
{
|
||||
int count = 0;
|
||||
for(byte tempLod = LodUtil.REGION_DETAIL_LEVEL; tempLod > minDetailLevel; tempLod--){
|
||||
//i'm doing a upper limit of the minimum
|
||||
//Color should be just 3 byte but i'm gonna calculate as 12 byte
|
||||
//Height and depth should be just 4 byte but i'm gonna calculate as 8 byte
|
||||
//count += Math.pow(2,LodUtil.REGION_DETAIL_LEVEL-tempLod) * (8 + 3 + 2 + 2 + 1 + 1)
|
||||
count += Math.pow(2,LodUtil.REGION_DETAIL_LEVEL-tempLod) * (24 + 8 + 8 + 8 + 8 + 8);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return getLevel(LodUtil.REGION_DETAIL_LEVEL).toString();
|
||||
|
||||
@@ -139,8 +139,8 @@ 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.fogDistance.set(FogDistance.FAR);
|
||||
LodConfig.CLIENT.fogDrawOverride.set(FogDrawOverride.ALWAYS_DRAW_FOG_FANCY);
|
||||
@@ -150,7 +150,7 @@ public class ClientProxy
|
||||
|
||||
LodConfig.CLIENT.distanceGenerationMode.set(DistanceGenerationMode.SURFACE);
|
||||
LodConfig.CLIENT.allowUnstableFeatureGeneration.set(false);
|
||||
LodConfig.CLIENT.lodChunkRenderDistance.set(512);
|
||||
LodConfig.CLIENT.lodChunkRenderDistance.set(128);
|
||||
LodConfig.CLIENT.lodDistanceCalculatorType.set(DistanceCalculatorType.LINEAR);
|
||||
LodConfig.CLIENT.lodQuality.set(1);
|
||||
LodConfig.CLIENT.allowUnstableFeatureGeneration.set(false);
|
||||
@@ -243,7 +243,6 @@ public class ClientProxy
|
||||
{
|
||||
lodWorld.saveAllDimensions();
|
||||
lodDim.move(worldRegionOffset);
|
||||
|
||||
//LOGGER.info("offset: " + worldRegionOffset.x + "," + worldRegionOffset.z + "\t center: " + lodDim.getCenterX() + "," + lodDim.getCenterZ());
|
||||
}
|
||||
}
|
||||
|
||||
+39
-4
@@ -4,14 +4,15 @@ import com.seibel.lod.enums.DistanceGenerationMode;
|
||||
import com.seibel.lod.enums.LodDetail;
|
||||
import com.seibel.lod.handlers.LodConfig;
|
||||
|
||||
public class DetailUtil
|
||||
public class DetailDistanceUtil
|
||||
{
|
||||
private static double genMultiplier = 1.5;
|
||||
private static double genMultiplier = 1.25;
|
||||
private static double cutMultiplier = 1.5;
|
||||
private static final int minDetail = LodConfig.CLIENT.maxGenerationDetail.get().detailLevel;
|
||||
private static final int maxDetail = LodUtil.REGION_DETAIL_LEVEL + 1;
|
||||
private static final int minDistance = 0;
|
||||
private static final int maxDistance = LodConfig.CLIENT.lodChunkRenderDistance.get() * 16 * 2;
|
||||
private static DistanceGenerationMode[] distancesGenerators = {
|
||||
private static final DistanceGenerationMode[] distancesGenerators = {
|
||||
DistanceGenerationMode.SURFACE,
|
||||
DistanceGenerationMode.SURFACE,
|
||||
DistanceGenerationMode.SURFACE,
|
||||
@@ -23,7 +24,7 @@ public class DetailUtil
|
||||
DistanceGenerationMode.SURFACE,
|
||||
DistanceGenerationMode.SURFACE};
|
||||
|
||||
private static LodDetail[] lodDetails = {
|
||||
private static final LodDetail[] lodDetails = {
|
||||
LodDetail.FULL,
|
||||
LodDetail.HALF,
|
||||
LodDetail.QUAD,
|
||||
@@ -36,6 +37,19 @@ public class DetailUtil
|
||||
LodDetail.SINGLE,
|
||||
LodDetail.SINGLE};
|
||||
|
||||
private static final LodDetail[] lodDetailsCut = {
|
||||
LodDetail.FULL,
|
||||
LodDetail.FULL,
|
||||
LodDetail.HALF,
|
||||
LodDetail.QUAD,
|
||||
LodDetail.DOUBLE,
|
||||
LodDetail.DOUBLE,
|
||||
LodDetail.DOUBLE,
|
||||
LodDetail.DOUBLE,
|
||||
LodDetail.DOUBLE,
|
||||
LodDetail.DOUBLE,
|
||||
LodDetail.DOUBLE};
|
||||
|
||||
public static int getDistanceRendering(int detail)
|
||||
{
|
||||
int distance = 0;
|
||||
@@ -58,6 +72,10 @@ public class DetailUtil
|
||||
{
|
||||
return (int) (getDistanceRendering(detail) * genMultiplier);
|
||||
}
|
||||
public static int getDistanceCut(int detail)
|
||||
{
|
||||
return (int) (getDistanceRendering(detail) * cutMultiplier);
|
||||
}
|
||||
|
||||
public static DistanceGenerationMode getDistanceGenerationMode(int detail)
|
||||
{
|
||||
@@ -67,8 +85,25 @@ public class DetailUtil
|
||||
public static LodDetail getLodDetail(int detail)
|
||||
{
|
||||
if(detail < minDetail)
|
||||
{
|
||||
return lodDetails[minDetail];
|
||||
}
|
||||
else
|
||||
{
|
||||
return lodDetails[detail];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static LodDetail getCutLodDetail(int detail)
|
||||
{
|
||||
if(detail < minDetail)
|
||||
{
|
||||
return lodDetailsCut[minDetail];
|
||||
}
|
||||
else
|
||||
{
|
||||
return lodDetailsCut[detail];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user