Several chages to converto to quadTree
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.seibel.lod.builders;
|
||||
|
||||
import com.seibel.lod.builders.worldGeneration.LodChunkGenWorker;
|
||||
import com.seibel.lod.handlers.LodConfig;
|
||||
import com.seibel.lod.objects.LodChunk;
|
||||
import com.seibel.lod.objects.LodDimension;
|
||||
@@ -8,6 +7,7 @@ import com.seibel.lod.objects.NearFarBuffer;
|
||||
import com.seibel.lod.objects.quadTree.LodNodeData;
|
||||
import com.seibel.lod.objects.quadTree.LodQuadTree;
|
||||
import com.seibel.lod.objects.quadTree.LodQuadTreeDimension;
|
||||
import com.seibel.lod.render.LodNodeRenderer;
|
||||
import com.seibel.lod.render.LodRenderer;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -19,6 +19,8 @@ import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.WorldWorkerManager;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@@ -35,7 +37,7 @@ public class LodNodeBufferBuilder
|
||||
/** This holds the thread used to generate new LODs off the main thread. */
|
||||
private ExecutorService genThread = Executors.newSingleThreadExecutor();
|
||||
|
||||
private LodChunkBuilder lodChunkBuilder;
|
||||
private LodNodeBuilder lodChunkBuilder;
|
||||
|
||||
/** The buffers that are used to create LODs using near fog */
|
||||
public volatile BufferBuilder buildableNearBuffer;
|
||||
@@ -61,7 +63,7 @@ public class LodNodeBufferBuilder
|
||||
public int maxChunkGenRequests = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
|
||||
public LodNodeBufferBuilder(LodChunkBuilder newLodBuilder)
|
||||
public LodNodeBufferBuilder(LodNodeBuilder newLodBuilder)
|
||||
{
|
||||
mc = Minecraft.getInstance();
|
||||
lodChunkBuilder = newLodBuilder;
|
||||
@@ -69,7 +71,7 @@ public class LodNodeBufferBuilder
|
||||
|
||||
|
||||
private BiomeContainer biomeContainer = null;
|
||||
private LodDimension previousDimension = null;
|
||||
private LodQuadTreeDimension previousDimension = null;
|
||||
|
||||
|
||||
/**
|
||||
@@ -81,7 +83,7 @@ public class LodNodeBufferBuilder
|
||||
* After the buildable buffers have been generated they must be
|
||||
* swapped with the drawable buffers in the LodRenderer to be drawn.
|
||||
*/
|
||||
public void generateLodBuffersAsync(LodRenderer renderer, LodQuadTreeDimension lodDim,
|
||||
public void generateLodBuffersAsync(LodNodeRenderer renderer, LodQuadTreeDimension lodDim,
|
||||
double playerX, double playerZ, int numbChunksWide)
|
||||
{
|
||||
// only allow one generation process to happen at a time
|
||||
@@ -130,8 +132,35 @@ public class LodNodeBufferBuilder
|
||||
// generate our new buildable buffers
|
||||
buildableNearBuffer.begin(GL11.GL_QUADS, LodRenderer.LOD_VERTEX_FORMAT);
|
||||
buildableFarBuffer.begin(GL11.GL_QUADS, LodRenderer.LOD_VERTEX_FORMAT);
|
||||
|
||||
|
||||
|
||||
List<LodNodeData> lodList = new ArrayList<>();
|
||||
lodList.addAll(lodDim.getNodeToRender((int) playerX,(int)playerZ,(byte) 9, 100000,8000));
|
||||
lodList.addAll(lodDim.getNodeToRender((int)playerX,(int)playerZ,(byte) 8, 8000,4000));
|
||||
lodList.addAll(lodDim.getNodeToRender((int)playerX,(int)playerZ,(byte) 7, 4000,2000));
|
||||
lodList.addAll(lodDim.getNodeToRender((int)playerX,(int)playerZ,(byte) 6, 2000,1000));
|
||||
lodList.addAll(lodDim.getNodeToRender((int)playerX,(int)playerZ,(byte) 5, 1000,500));
|
||||
lodList.addAll(lodDim.getNodeToRender((int)playerX,(int)playerZ,(byte) 4, 500,250));
|
||||
lodList.addAll(lodDim.getNodeToRender((int)playerX,(int)playerZ,(byte) 3, 250,0));
|
||||
|
||||
for(LodNodeData data : lodList){
|
||||
BufferBuilder currentBuffer = null;
|
||||
/*
|
||||
if (isCoordinateInNearFogArea(i, j, numbChunksWide / 2))
|
||||
currentBuffer = buildableNearBuffer;
|
||||
else
|
||||
currentBuffer = buildableFarBuffer;
|
||||
*/
|
||||
currentBuffer = buildableFarBuffer;
|
||||
|
||||
// get the desired LodTemplate and
|
||||
// add this LOD to the buffer
|
||||
LodConfig.CLIENT.lodTemplate.get().
|
||||
template.addLodToBuffer(currentBuffer, lodDim, data,
|
||||
data.startX, 0, data.startZ, renderer.debugging);
|
||||
}
|
||||
// x axis
|
||||
/*
|
||||
for (int i = 0; i < numbChunksWide; i++)
|
||||
{
|
||||
// z axis
|
||||
@@ -153,10 +182,10 @@ public class LodNodeBufferBuilder
|
||||
startX; // offset so the center LOD block is centered underneath the player
|
||||
double yOffset = 0;
|
||||
double zOffset = (LodChunk.WIDTH * j) + startZ;
|
||||
|
||||
LodNodeData lod = lodDim.getLodFromCoordinates(chunkX, chunkZ, LodNodeData.CHUNK_LEVEL);
|
||||
|
||||
LodChunk lod = lodDim.getLodFromCoordinates(chunkX, chunkZ, LodNodeData.CHUNK_LEVEL);
|
||||
|
||||
if (lod == null || lod.isLodEmpty())
|
||||
if (lod == null || lod.voidNode)
|
||||
{
|
||||
// generate a new chunk if no chunk currently exists
|
||||
// and we aren't waiting on any other chunks to generate
|
||||
@@ -197,23 +226,15 @@ public class LodNodeBufferBuilder
|
||||
// don't render this null chunk
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BufferBuilder currentBuffer = null;
|
||||
if (isCoordinateInNearFogArea(i, j, numbChunksWide / 2))
|
||||
currentBuffer = buildableNearBuffer;
|
||||
else
|
||||
currentBuffer = buildableFarBuffer;
|
||||
|
||||
// get the desired LodTemplate and
|
||||
// add this LOD to the buffer
|
||||
LodConfig.CLIENT.lodTemplate.get().
|
||||
template.addLodToBuffer(currentBuffer, lodDim, lod,
|
||||
xOffset, yOffset, zOffset, renderer.debugging);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
// TODO add a way for a server side mod to generate chunks requested here
|
||||
/*
|
||||
if(mc.hasSingleplayerServer())
|
||||
{
|
||||
ServerWorld serverWorld = LodUtil.getServerWorldFromDimension(lodDim.dimension);
|
||||
@@ -235,10 +256,11 @@ public class LodNodeBufferBuilder
|
||||
|
||||
numberOfChunksWaitingToGenerate++;
|
||||
|
||||
LodChunkGenWorker genWorker = new LodChunkGenWorker(chunkPos, renderer, lodChunkBuilder, this, lodDim, serverWorld, biomeContainer);
|
||||
LodChunkGenWorker.java genWorker = new LodChunkGenWorker.java(chunkPos, renderer, lodChunkBuilder, this, lodDim, serverWorld, biomeContainer);
|
||||
WorldWorkerManager.addWorker(genWorker);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// finish the buffer building
|
||||
buildableNearBuffer.end();
|
||||
|
||||
@@ -440,9 +440,6 @@ public class LodQuadTree {
|
||||
return (lodNodeData != null);
|
||||
}
|
||||
|
||||
public LodNodeData getLodFromCoordinate(int x, int z, byte level){
|
||||
|
||||
}
|
||||
|
||||
public boolean isCoordinateInLevel(int x, int z){
|
||||
return !(lodNodeData.startX > x || lodNodeData.startZ > z || lodNodeData.endX < x || lodNodeData.endZ < z);
|
||||
|
||||
@@ -297,10 +297,10 @@ public class LodQuadTreeDimension {
|
||||
*/
|
||||
public LodNodeData getLodFromCoordinates(int posX, int posZ, byte level)
|
||||
{
|
||||
LodQuadTree region = getRegion(posX/(512/Math.pow(level,2)),posZ/(512/Math.pow(level,2)));
|
||||
LodQuadTree region = getRegion((int) (posX/(512/Math.pow(level,2))),(int) (posZ/(512/Math.pow(level,2))));
|
||||
if(region == null)
|
||||
return null;
|
||||
return region.getLodFromCoordinate(posX, posZ, level);
|
||||
return region.getNodeAtLevelPosition(posX, posZ, level);
|
||||
/*
|
||||
RegionPos pos = LodUtil.convertChunkPosToRegionPos(new ChunkPos(chunkX, chunkZ));
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.seibel.lod.objects.LodDimension;
|
||||
import com.seibel.lod.objects.NearFarBuffer;
|
||||
import com.seibel.lod.objects.NearFarFogSettings;
|
||||
import com.seibel.lod.objects.quadTree.LodNodeData;
|
||||
import com.seibel.lod.objects.quadTree.LodQuadTreeDimension;
|
||||
import com.seibel.lod.proxy.ClientProxy;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
@@ -132,7 +133,7 @@ public class LodNodeRenderer
|
||||
* @param newDimension The dimension to draw, if null doesn't replace the current dimension.
|
||||
* @param partialTicks how far into the current tick this method was called.
|
||||
*/
|
||||
public void drawLODs(LodDimension lodDim, float partialTicks, IProfiler newProfiler)
|
||||
public void drawLODs(LodQuadTreeDimension lodDim, float partialTicks, IProfiler newProfiler)
|
||||
{
|
||||
if (lodDim == null)
|
||||
{
|
||||
@@ -234,7 +235,7 @@ public class LodNodeRenderer
|
||||
// replace the buffers used to draw and build,
|
||||
// this is only done when the createLodBufferGenerationThread
|
||||
// has finished executing on a parallel thread.
|
||||
if (lodBufferBuilder.newBuffersAvaliable())
|
||||
if (lodNodeBufferBuilder.newBuffersAvaliable())
|
||||
{
|
||||
swapBuffers();
|
||||
}
|
||||
@@ -549,7 +550,7 @@ public class LodNodeRenderer
|
||||
/**
|
||||
* setup the lighting to be used for the LODs
|
||||
*/
|
||||
private void setupLighting(LodDimension lodDimension, float partialTicks)
|
||||
private void setupLighting(LodQuadTreeDimension lodDimension, float partialTicks)
|
||||
{
|
||||
float sunBrightness = lodDimension.dimension.hasSkyLight() ? mc.level.getSkyDarken(partialTicks) : 0.2f;
|
||||
float gammaMultiplyer = (float)mc.options.gamma - 0.5f;
|
||||
@@ -771,7 +772,7 @@ public class LodNodeRenderer
|
||||
* Get a HashSet of all ChunkPos within the normal render distance
|
||||
* that should not be rendered.
|
||||
*/
|
||||
private HashSet<ChunkPos> getNearbyLodChunkPosToSkip(LodDimension lodDim, BlockPos playerPos)
|
||||
private HashSet<ChunkPos> getNearbyLodChunkPosToSkip(LodQuadTreeDimension lodDim, BlockPos playerPos)
|
||||
{
|
||||
int chunkRenderDist = mc.options.renderDistance;
|
||||
int blockRenderDist = chunkRenderDist * 16;
|
||||
@@ -786,10 +787,10 @@ public class LodNodeRenderer
|
||||
{
|
||||
for(int z = centerChunk.z - chunkRenderDist; z < centerChunk.z + chunkRenderDist; z++)
|
||||
{
|
||||
LodNodeData lod = lodDim.getLodFromCoordinates(x, z);
|
||||
LodNodeData lod = lodDim.getLodFromCoordinates(x, z, (byte) 4);
|
||||
if (lod != null)
|
||||
{
|
||||
short lodHighestPoint = lod.height();
|
||||
short lodHighestPoint = lod.height;
|
||||
|
||||
if (playerPos.getY() < lodHighestPoint)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user