Several chages to converto to quadTree
This commit is contained in:
@@ -155,113 +155,8 @@ public class LodNodeBufferBuilder
|
||||
|
||||
// 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
|
||||
for (int j = 0; j < numbChunksWide; j++)
|
||||
{
|
||||
int chunkX = i + (startX / LodChunk.WIDTH);
|
||||
int chunkZ = j + (startZ / LodChunk.WIDTH);
|
||||
|
||||
// skip any chunks that Minecraft is going to render
|
||||
if(isCoordInCenterArea(i, j, (numbChunksWide / 2))
|
||||
&& renderer.vanillaRenderedChunks.contains(new ChunkPos(chunkX, chunkZ)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// set where this square will be drawn in the world
|
||||
double xOffset = (LodChunk.WIDTH * i) + // offset by the number of LOD blocks
|
||||
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);
|
||||
|
||||
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
|
||||
if (lod == null && numberOfChunksWaitingToGenerate < maxChunkGenRequests)
|
||||
{
|
||||
ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||
|
||||
// determine if this position is closer to the player
|
||||
// than the previous
|
||||
int newDistance = playerChunkPos.getChessboardDistance(pos);
|
||||
|
||||
if (newDistance < minChunkDist)
|
||||
{
|
||||
// this chunk is closer, clear any previous
|
||||
// positions and update the new minimum distance
|
||||
minChunkDist = newDistance;
|
||||
chunksToGenReserve = chunksToGen;
|
||||
|
||||
chunkGenIndex = 0;
|
||||
chunksToGen = new ChunkPos[maxChunkGenRequests];
|
||||
chunksToGen[chunkGenIndex] = pos;
|
||||
chunkGenIndex++;
|
||||
}
|
||||
else if (newDistance <= minChunkDist)
|
||||
{
|
||||
// this chunk position is as close or closers than the
|
||||
// minimum distance
|
||||
if(chunkGenIndex < maxChunkGenRequests)
|
||||
{
|
||||
// we are still under the number of chunks to generate
|
||||
// add this position to the list
|
||||
chunksToGen[chunkGenIndex] = pos;
|
||||
chunkGenIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// don't render this null chunk
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
// TODO add a way for a server side mod to generate chunks requested here
|
||||
/*
|
||||
if(mc.hasSingleplayerServer())
|
||||
{
|
||||
ServerWorld serverWorld = LodUtil.getServerWorldFromDimension(lodDim.dimension);
|
||||
|
||||
// make sure we have as many chunks to generate as we are allowed
|
||||
if (chunkGenIndex < maxChunkGenRequests)
|
||||
{
|
||||
for(int i = chunkGenIndex, j = 0; i < maxChunkGenRequests; i++, j++)
|
||||
{
|
||||
chunksToGen[i] = chunksToGenReserve[j];
|
||||
}
|
||||
}
|
||||
|
||||
// start chunk generation
|
||||
for(ChunkPos chunkPos : chunksToGen)
|
||||
{
|
||||
if(chunkPos == null)
|
||||
break;
|
||||
|
||||
numberOfChunksWaitingToGenerate++;
|
||||
|
||||
LodChunkGenWorker.java genWorker = new LodChunkGenWorker.java(chunkPos, renderer, lodChunkBuilder, this, lodDim, serverWorld, biomeContainer);
|
||||
WorldWorkerManager.addWorker(genWorker);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// finish the buffer building
|
||||
buildableNearBuffer.end();
|
||||
buildableFarBuffer.end();
|
||||
|
||||
@@ -93,8 +93,8 @@ public class QuadTreeImage extends JPanel {
|
||||
frame.setLocationByPlatform(true);
|
||||
frame.setVisible(true);
|
||||
List<List<LodNodeData>> listOfList = new ArrayList<>();
|
||||
//OverworldBiomeSource biomeSource = new OverworldBiomeSource(MCVersion.v1_16_5, 1000);
|
||||
EndBiomeSource biomeSource = new EndBiomeSource(MCVersion.v1_16_5, 1000);
|
||||
OverworldBiomeSource biomeSource = new OverworldBiomeSource(MCVersion.v1_16_5, 1000);
|
||||
//EndBiomeSource biomeSource = new EndBiomeSource(MCVersion.v1_16_5, 1000);
|
||||
int[] distances = {100000,8000,4000,2000,1000,500,250,100,50,25};
|
||||
for (int i = 0; i <= (9 - 2); i++) {
|
||||
for (int j = 0; j < 1; j++) {
|
||||
@@ -159,7 +159,7 @@ public class QuadTreeImage extends JPanel {
|
||||
}
|
||||
|
||||
|
||||
int timerDelay = 5000;
|
||||
int timerDelay = 0;
|
||||
System.out.println("STARTING");
|
||||
System.out.println(dim.getWidth());
|
||||
System.out.println(dim.getCenterX());
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.seibel.lod.objects.quadTree;
|
||||
|
||||
import com.seibel.lod.builders.LodNodeBuilder;
|
||||
import com.seibel.lod.objects.LodDimension;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.DimensionType;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class UsesExamples {
|
||||
public static void main(String[] args){
|
||||
//THIS CODE DOESN'T WORK AT THE MOMENT
|
||||
/**TODO
|
||||
* Complete all the new Lod objects
|
||||
* Complete the getNodeToGenerate in LodQuadTreeDimension
|
||||
* Complete the getNodeToRender in LodQuadTreeDimension
|
||||
* Complete the node builder
|
||||
* Complete the new renderer
|
||||
* add everything to ClientProxy for the first test
|
||||
* */
|
||||
/*
|
||||
LodQuadTreeWorld lodWorld = new LodQuadTreeWorld();
|
||||
LodQuadTreeDimension newLodDimension = new LodQuadTreeDimension(Minecraft.getInstance().world.getDimensionType(), Minecraft.getInstance().world, 10);
|
||||
lodWorld.addLodDimension(newLodDimension);
|
||||
|
||||
LodQuadTreeDimension lodDimension = lodWorld.getLodDimension(Minecraft.getInstance().world.getDimensionType());
|
||||
lodDimension.move(0,0);
|
||||
|
||||
//I will now generate some fake LodNodeData. This in the final implementation will be generated by a builder
|
||||
//this lodNodeData will be put at level 6 of the QuadTree. This LodNodeData represent a block of width
|
||||
|
||||
LodNodeData lodNodeData1 = new LodNodeData((byte) 6, 4, 4, 64, 0, new Color(0,200,0),true);
|
||||
LodNodeData lodNodeData2 = new LodNodeData((byte) 6, 4, 5, 64, 0, new Color(0,200,0),true);
|
||||
LodNodeData lodNodeData3 = new LodNodeData((byte) 6, 5, 4, 64, 0, new Color(0,0,200),true);
|
||||
|
||||
//add like this
|
||||
|
||||
lodDimension.addNode(lodNodeData1);
|
||||
lodDimension.addNode(lodNodeData2);
|
||||
lodDimension.addNode(lodNodeData3);
|
||||
|
||||
//Automatic generation
|
||||
|
||||
List nodeToGenerate = (List) lodDimension.getRegion(0,0).getNodeToGenerate(0,0, (byte) 3,1000,0);
|
||||
Collections.sort(nodeToGenerate, Map.Entry.<LodNodeData, Integer>comparingByValue());
|
||||
|
||||
|
||||
// Call the builder to generate all the useful node
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user