diff --git a/src/main/java/com/seibel/lod/render/LodRenderer.java b/src/main/java/com/seibel/lod/render/LodRenderer.java index 853781c81..40e33b847 100644 --- a/src/main/java/com/seibel/lod/render/LodRenderer.java +++ b/src/main/java/com/seibel/lod/render/LodRenderer.java @@ -64,7 +64,7 @@ import net.minecraft.util.math.vector.Vector3d; * This is where LODs are draw to the world. * * @author James Seibel - * @version 10-13-2021 + * @version 10-19-2021 */ public class LodRenderer { @@ -281,14 +281,21 @@ public class LodRenderer int halfWidth = vbos.length / 2; int quarterWidth = vbos.length / 4; + // where the center of the built buffers is (needed when culling regions) + RegionPos vboCenterRegionPos = new RegionPos(vbosCenter); + + for (int x = 0; x < vbos.length; x++) { for (int z = 0; z < vbos.length; z++) { - RegionPos vboPos = new RegionPos(x + lodDim.getCenterRegionPosX() - lodDim.getWidth() / 2, z + lodDim.getCenterRegionPosZ() - lodDim.getWidth() / 2); + RegionPos vboPos = new RegionPos( + x + vboCenterRegionPos.x - (lodDim.getWidth() / 2), + z + vboCenterRegionPos.z - (lodDim.getWidth() / 2)); if (cullingDisabled || RenderUtil.isRegionInViewFrustum(renderInfo.getBlockPosition(), cameraDir, vboPos.blockPos())) { - if ((x > halfWidth - quarterWidth && x < halfWidth + quarterWidth) && (z > halfWidth - quarterWidth && z < halfWidth + quarterWidth)) + if ((x > halfWidth - quarterWidth && x < halfWidth + quarterWidth) + && (z > halfWidth - quarterWidth && z < halfWidth + quarterWidth)) setupFog(fogSettings.near.distance, fogSettings.near.quality); else setupFog(fogSettings.far.distance, fogSettings.far.quality); diff --git a/src/main/java/com/seibel/lod/render/RenderUtil.java b/src/main/java/com/seibel/lod/render/RenderUtil.java index 582bdc454..8835f4cda 100644 --- a/src/main/java/com/seibel/lod/render/RenderUtil.java +++ b/src/main/java/com/seibel/lod/render/RenderUtil.java @@ -31,7 +31,7 @@ import net.minecraft.util.math.vector.Vector3d; * to be used in the rendering process. * * @author James Seibel - * @version 10-10-2021 + * @version 10-19-2021 */ public class RenderUtil { @@ -97,10 +97,10 @@ public class RenderUtil int halfRegionWidth = LodUtil.REGION_WIDTH / 2; // calculate the 4 corners - Vector3d vboSeVec = new Vector3d(vboCenterVec.x + halfRegionWidth, vboCenterVec.y, vboCenterVec.z + halfRegionWidth);//.normalize(); - Vector3d vboSwVec = new Vector3d(vboCenterVec.x - halfRegionWidth, vboCenterVec.y, vboCenterVec.z + halfRegionWidth);//.normalize(); - Vector3d vboNwVec = new Vector3d(vboCenterVec.x - halfRegionWidth, vboCenterVec.y, vboCenterVec.z - halfRegionWidth);//.normalize(); - Vector3d vboNeVec = new Vector3d(vboCenterVec.x + halfRegionWidth, vboCenterVec.y, vboCenterVec.z - halfRegionWidth);//.normalize(); + Vector3d vboSeVec = new Vector3d(vboCenterVec.x + halfRegionWidth, vboCenterVec.y, vboCenterVec.z + halfRegionWidth); + Vector3d vboSwVec = new Vector3d(vboCenterVec.x - halfRegionWidth, vboCenterVec.y, vboCenterVec.z + halfRegionWidth); + Vector3d vboNwVec = new Vector3d(vboCenterVec.x - halfRegionWidth, vboCenterVec.y, vboCenterVec.z - halfRegionWidth); + Vector3d vboNeVec = new Vector3d(vboCenterVec.x + halfRegionWidth, vboCenterVec.y, vboCenterVec.z - halfRegionWidth); // if any corner is visible, this region should be rendered return isNormalizedVectorInViewFrustum(vboSeVec, cameraDir) ||