Partially fix LodNode rendering

This commit is contained in:
James Seibel
2021-08-05 07:56:00 -05:00
parent 73e318ee38
commit 781aa339bc
5 changed files with 22 additions and 25 deletions
@@ -177,7 +177,7 @@ public class LodNodeBufferBuilder
startX; // offset so the center LOD block is centered underneath the player
double yOffset = 0;
double zOffset = (LodQuadTreeNode.CHUNK_WIDTH * j) + startZ;
LodQuadTreeNode lod = lodDim.getLodFromCoordinates(chunkX, chunkZ, LodQuadTreeNode.CHUNK_LEVEL);
if (lod == null || lod.getComplexity() == DistanceGenerationMode.NONE)
@@ -220,7 +220,6 @@ public class LodNodeBufferBuilder
// this chunk is closer, clear any previous
// positions and update the new minimum distance
minChunkDist = newDistance;
chunksToGenReserve = chunksToGen;
// move all the old chunks into the reserve
ChunkPos[] newReserve = new ChunkPos[maxChunkGenRequests];
@@ -50,17 +50,15 @@ public class CubicLodNodeTemplate extends AbstractLodNodeTemplate
// Add this LOD to the BufferBuilder
int halfWidth = lod.width / 2;
int startX = lod.startX;
int startZ = lod.startZ;
// returns null if the lod is empty at the given location
bbox = generateBoundingBox(
lod.lodDataPoint.height,
lod.lodDataPoint.depth,
lod.width,
xOffset - halfWidth + startX,
xOffset - halfWidth,
yOffset,
zOffset - halfWidth + startZ);
zOffset - halfWidth);
if (bbox != null) {
addBoundingBoxToBuffer(buffer, bbox, lod.lodDataPoint.color);
@@ -356,9 +356,8 @@ public class LodQuadTreeDimension
if (detailLevel > LodQuadTreeNode.REGION_LEVEL)
throw new IllegalArgumentException("getLodFromCoordinates given a level of \"" + detailLevel + "\" when \"" + LodQuadTreeNode.REGION_LEVEL + "\" is the max.");
LodQuadTree region = getRegion(
(Math.floorDiv(posX, (int) (LodQuadTreeNode.REGION_WIDTH/Math.pow(detailLevel,2)))),
(Math.floorDiv(posZ, (int) (LodQuadTreeNode.REGION_WIDTH/Math.pow(detailLevel,2)))));
RegionPos regionPos = LodUtil.convertChunkPosToRegionPos(new ChunkPos(posX, posZ));
LodQuadTree region = getRegion(regionPos.x, regionPos.z);
if(region == null)
{
@@ -225,7 +225,7 @@ public class LodNodeRenderer
farPlaneDistance = renderDistWidth * LodQuadTreeNode.CHUNK_WIDTH;
// set how big the LODs will be and how far they will go
int totalLength = (int) farPlaneDistance * LodConfig.CLIENT.lodChunkRadiusMultiplier.get() * 10;
int totalLength = (int) farPlaneDistance * LodConfig.CLIENT.lodChunkRadiusMultiplier.get() * 2;
int numbChunksWide = (totalLength / LodQuadTreeNode.CHUNK_WIDTH);
// determine which LODs should not be rendered close to the player
+15 -14
View File
@@ -20,6 +20,7 @@ package com.seibel.lod.util;
import java.awt.Color;
import java.io.File;
import com.seibel.lod.objects.LodQuadTreeNode;
import com.seibel.lod.objects.RegionPos;
import net.minecraft.client.Minecraft;
@@ -95,21 +96,21 @@ public class LodUtil
public static RegionPos convertChunkPosToRegionPos(ChunkPos pos)
{
RegionPos rPos = new RegionPos();
rPos.x = pos.x / 512;
rPos.z = pos.z / 512;
// rPos.x = pos.x / 512;
// rPos.z = pos.z / 512;
//
// // prevent issues if X/Z is negative and less than 16
// if (pos.x < 0)
// {
// rPos.x = (Math.abs(rPos.x) * -1) - 1;
// }
// if (pos.z < 0)
// {
// rPos.z = (Math.abs(rPos.z) * -1) - 1;
// }
// prevent issues if X/Z is negative and less than 16
if (pos.x < 0)
{
rPos.x = (Math.abs(rPos.x) * -1) - 1;
}
if (pos.z < 0)
{
rPos.z = (Math.abs(rPos.z) * -1) - 1;
}
//rPos.x = (Math.floorDiv(pos.x, (int) (512/Math.pow(LodQuadTreeNode.CHUNK_LEVEL,2))));
//rPos.z = (Math.floorDiv(pos.z, (int) (512/Math.pow(LodQuadTreeNode.CHUNK_LEVEL,2))));
rPos.x = (Math.floorDiv(pos.x, (int) (512/Math.pow(LodQuadTreeNode.CHUNK_LEVEL,2))));
rPos.z = (Math.floorDiv(pos.z, (int) (512/Math.pow(LodQuadTreeNode.CHUNK_LEVEL,2))));
return rPos;
}