diff --git a/src/main/java/com/seibel/lod/core/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java b/src/main/java/com/seibel/lod/core/builders/bufferBuilding/CubicLodTemplate.java
similarity index 81%
rename from src/main/java/com/seibel/lod/core/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java
rename to src/main/java/com/seibel/lod/core/builders/bufferBuilding/CubicLodTemplate.java
index 43aa6169c..f8916d5a9 100644
--- a/src/main/java/com/seibel/lod/core/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java
+++ b/src/main/java/com/seibel/lod/core/builders/bufferBuilding/CubicLodTemplate.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package com.seibel.lod.core.builders.bufferBuilding.lodTemplates;
+package com.seibel.lod.core.builders.bufferBuilding;
import java.util.Map;
@@ -25,25 +25,20 @@ import com.seibel.lod.core.enums.LodDirection;
import com.seibel.lod.core.enums.rendering.DebugMode;
import com.seibel.lod.core.objects.VertexOptimizer;
import com.seibel.lod.core.objects.opengl.LodBufferBuilder;
+import com.seibel.lod.core.util.ColorUtil;
import com.seibel.lod.core.util.DataPointUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
/**
* Builds LODs as rectangular prisms.
+ *
* @author James Seibel
* @version 12-8-2021
*/
-public class CubicLodTemplate extends AbstractLodTemplate
+public class CubicLodTemplate
{
-
- public CubicLodTemplate()
- {
-
- }
-
- @Override
- public void addLodToBuffer(LodBufferBuilder buffer, AbstractBlockPosWrapper bufferCenterBlockPos, long data, Map adjData,
+ public static void addLodToBuffer(LodBufferBuilder buffer, AbstractBlockPosWrapper bufferCenterBlockPos, long data, Map adjData,
byte detailLevel, int posX, int posZ, VertexOptimizer vertexOptimizer, DebugMode debugging, boolean[] adjShadeDisabled)
{
if (vertexOptimizer == null)
@@ -75,7 +70,21 @@ public class CubicLodTemplate extends AbstractLodTemplate
addBoundingBoxToBuffer(buffer, vertexOptimizer);
}
- private void generateBoundingBox(VertexOptimizer vertexOptimizer,
+ /** add the given position and color to the buffer */
+ public static void addPosAndColor(LodBufferBuilder buffer,
+ float x, float y, float z,
+ int color, byte skyLightValue, byte blockLightValue)
+ {
+ // TODO re-add transparency by replacing the color 255 with "ColorUtil.getAlpha(color)"
+ buffer.position(x, y, z)
+ .color(ColorUtil.getRed(color), ColorUtil.getGreen(color), ColorUtil.getBlue(color), 255)
+ .minecraftLightValue(skyLightValue).minecraftLightValue(blockLightValue)
+ .endVertex();
+ }
+
+
+
+ private static void generateBoundingBox(VertexOptimizer vertexOptimizer,
int height, int depth, int width,
double xOffset, double yOffset, double zOffset,
AbstractBlockPosWrapper bufferCenterBlockPos,
@@ -106,7 +115,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
vertexOptimizer.setAdjData(adjData);
}
- private void addBoundingBoxToBuffer(LodBufferBuilder buffer, VertexOptimizer vertexOptimizer)
+ private static void addBoundingBoxToBuffer(LodBufferBuilder buffer, VertexOptimizer vertexOptimizer)
{
int color;
byte skyLight;
diff --git a/src/main/java/com/seibel/lod/core/builders/bufferBuilding/LodBufferBuilderFactory.java b/src/main/java/com/seibel/lod/core/builders/bufferBuilding/LodBufferBuilderFactory.java
index 17a9a03b0..a86ab62bd 100644
--- a/src/main/java/com/seibel/lod/core/builders/bufferBuilding/LodBufferBuilderFactory.java
+++ b/src/main/java/com/seibel/lod/core/builders/bufferBuilding/LodBufferBuilderFactory.java
@@ -68,7 +68,7 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper;
* rendered by the LodRenderer.
*
* @author James Seibel
- * @version 12-8-2021
+ * @version 12-9-2021
*/
public class LodBufferBuilderFactory
{
@@ -418,7 +418,7 @@ public class LodBufferBuilderFactory
break;
//We send the call to create the vertices
- CONFIG.client().graphics().advancedGraphics().getLodTemplate().template.addLodToBuffer(currentBuffers[bufferIndex], playerBlockPosRounded, data, adjData,
+ CubicLodTemplate.addLodToBuffer(currentBuffers[bufferIndex], playerBlockPosRounded, data, adjData,
detailLevel, posX, posZ, vertexOptimizer, renderer.previousDebugMode, adjShadeDisabled);
}
@@ -879,7 +879,7 @@ public class LodBufferBuilderFactory
if (vbo.id != -1 && GLProxy.getInstance().getGlContext() == GLProxyContext.LOD_BUILDER)
{
// this is how many points will be rendered
- vbo.vertexCount = (uploadBuffer.capacity() / ((Float.BYTES * 3) + (Byte.BYTES * 4) + Byte.BYTES + Byte.BYTES)); // TODO make this change with the LodTemplate
+ vbo.vertexCount = (uploadBuffer.capacity() / LodUtil.LOD_VERTEX_FORMAT.getByteSize());
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo.id);
try
diff --git a/src/main/java/com/seibel/lod/core/builders/bufferBuilding/lodTemplates/AbstractLodTemplate.java b/src/main/java/com/seibel/lod/core/builders/bufferBuilding/lodTemplates/AbstractLodTemplate.java
deleted file mode 100644
index fdac5507f..000000000
--- a/src/main/java/com/seibel/lod/core/builders/bufferBuilding/lodTemplates/AbstractLodTemplate.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * This file is part of the Distant Horizon mod (formerly the LOD Mod),
- * licensed under the GNU GPL v3 License.
- *
- * Copyright (C) 2020 James Seibel
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.seibel.lod.core.builders.bufferBuilding.lodTemplates;
-
-import java.util.Map;
-
-import com.seibel.lod.core.enums.LodDirection;
-import com.seibel.lod.core.enums.rendering.DebugMode;
-import com.seibel.lod.core.objects.VertexOptimizer;
-import com.seibel.lod.core.objects.opengl.LodBufferBuilder;
-import com.seibel.lod.core.util.ColorUtil;
-import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
-
-/**
- * This is the abstract class used to create different
- * BufferBuilders.
- * @author James Seibel
- * @version 12-8-2021
- */
-public abstract class AbstractLodTemplate
-{
- /** Uploads the given LOD to the buffer. */
- public abstract void addLodToBuffer(LodBufferBuilder buffer, AbstractBlockPosWrapper bufferCenterBlockPos, long data, Map adjData,
- byte detailLevel, int posX, int posZ, VertexOptimizer vertexOptimizer, DebugMode debugging, boolean[] adjShadeDisabled);
-
- /** add the given position and color to the buffer */
- protected void addPosAndColor(LodBufferBuilder buffer,
- float x, float y, float z,
- int color, byte skyLightValue, byte blockLightValue)
- {
- // TODO re-add transparency by replacing the color 255 with "ColorUtil.getAlpha(color)"
- buffer.position(x, y, z)
- .color(ColorUtil.getRed(color), ColorUtil.getGreen(color), ColorUtil.getBlue(color), 255)
- .minecraftLightValue(skyLightValue).minecraftLightValue(blockLightValue)
- .endVertex();
- }
-
-}
diff --git a/src/main/java/com/seibel/lod/core/builders/bufferBuilding/lodTemplates/DynamicLodTemplate.java b/src/main/java/com/seibel/lod/core/builders/bufferBuilding/lodTemplates/DynamicLodTemplate.java
deleted file mode 100644
index a1c302b00..000000000
--- a/src/main/java/com/seibel/lod/core/builders/bufferBuilding/lodTemplates/DynamicLodTemplate.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * This file is part of the Distant Horizon mod (formerly the LOD Mod),
- * licensed under the GNU GPL v3 License.
- *
- * Copyright (C) 2020 James Seibel
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.seibel.lod.core.builders.bufferBuilding.lodTemplates;
-
-import java.util.Map;
-
-import com.seibel.lod.core.api.ClientApi;
-import com.seibel.lod.core.enums.LodDirection;
-import com.seibel.lod.core.enums.rendering.DebugMode;
-import com.seibel.lod.core.objects.VertexOptimizer;
-import com.seibel.lod.core.objects.opengl.LodBufferBuilder;
-import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
-
-/**
- * TODO DynamicLodTemplate
- * Chunks smoothly transition between
- * each other, unless a neighboring chunk
- * is at a significantly different height.
- * @author James Seibel
- * @version 06-16-2021
- */
-public class DynamicLodTemplate extends AbstractLodTemplate
-{
- @Override
- public void addLodToBuffer(LodBufferBuilder buffer, AbstractBlockPosWrapper bufferCenterBlockPos, long data, Map adjData,
- byte detailLevel, int posX, int posZ, VertexOptimizer vertexOptimizer, DebugMode debugging, boolean[] adjShadeDisabled)
- {
- ClientApi.LOGGER.error(DynamicLodTemplate.class.getSimpleName() + " is not implemented!");
- }
-
-}
diff --git a/src/main/java/com/seibel/lod/core/builders/bufferBuilding/lodTemplates/TriangularLodTemplate.java b/src/main/java/com/seibel/lod/core/builders/bufferBuilding/lodTemplates/TriangularLodTemplate.java
deleted file mode 100644
index 489869645..000000000
--- a/src/main/java/com/seibel/lod/core/builders/bufferBuilding/lodTemplates/TriangularLodTemplate.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * This file is part of the Distant Horizon mod (formerly the LOD Mod),
- * licensed under the GNU GPL v3 License.
- *
- * Copyright (C) 2020 James Seibel
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.seibel.lod.core.builders.bufferBuilding.lodTemplates;
-
-import java.util.Map;
-
-import com.seibel.lod.core.api.ClientApi;
-import com.seibel.lod.core.enums.LodDirection;
-import com.seibel.lod.core.enums.rendering.DebugMode;
-import com.seibel.lod.core.objects.VertexOptimizer;
-import com.seibel.lod.core.objects.opengl.LodBufferBuilder;
-import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
-
-/**
- * TODO #21 TriangularLodTemplate
- * Builds each LOD chunk as a singular rectangular prism.
- * @author James Seibel
- * @version 06-16-2021
- */
-public class TriangularLodTemplate extends AbstractLodTemplate
-{
- @Override
- public void addLodToBuffer(LodBufferBuilder buffer, AbstractBlockPosWrapper bufferCenterBlockPos, long data, Map adjData,
- byte detailLevel, int posX, int posZ, VertexOptimizer vertexOptimizer, DebugMode debugging, boolean[] adjShadeDisabled)
- {
- ClientApi.LOGGER.error(DynamicLodTemplate.class.getSimpleName() + " is not implemented!");
- }
-
-}
diff --git a/src/main/java/com/seibel/lod/core/enums/config/LodTemplate.java b/src/main/java/com/seibel/lod/core/enums/config/LodTemplate.java
deleted file mode 100644
index 397699c7d..000000000
--- a/src/main/java/com/seibel/lod/core/enums/config/LodTemplate.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * This file is part of the Distant Horizon mod (formerly the LOD Mod),
- * licensed under the GNU GPL v3 License.
- *
- * Copyright (C) 2020 James Seibel
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.seibel.lod.core.enums.config;
-
-import com.seibel.lod.core.builders.bufferBuilding.lodTemplates.AbstractLodTemplate;
-import com.seibel.lod.core.builders.bufferBuilding.lodTemplates.CubicLodTemplate;
-import com.seibel.lod.core.builders.bufferBuilding.lodTemplates.DynamicLodTemplate;
-import com.seibel.lod.core.builders.bufferBuilding.lodTemplates.TriangularLodTemplate;
-
-/**
- * Cubic, Triangular, Dynamic
- *
- * @author James Seibel
- * @version 10-10-2021
- */
-public enum LodTemplate
-{
- /**
- * LODs are rendered as
- * rectangular prisms.
- */
- CUBIC(new CubicLodTemplate()),
-
- /**
- * LODs smoothly transition between
- * each other.
- */
- TRIANGULAR(new TriangularLodTemplate()),
-
- /**
- * LODs smoothly transition between
- * each other, unless a neighboring LOD
- * is at a significantly different height.
- */
- DYNAMIC(new DynamicLodTemplate());
-
-
- public final AbstractLodTemplate template;
-
- LodTemplate(AbstractLodTemplate newTemplate)
- {
- template = newTemplate;
- }
-
-}
diff --git a/src/main/java/com/seibel/lod/core/objects/opengl/LodBufferBuilder.java b/src/main/java/com/seibel/lod/core/objects/opengl/LodBufferBuilder.java
index 1baa8a165..22466dd58 100644
--- a/src/main/java/com/seibel/lod/core/objects/opengl/LodBufferBuilder.java
+++ b/src/main/java/com/seibel/lod/core/objects/opengl/LodBufferBuilder.java
@@ -37,7 +37,7 @@ import com.google.common.collect.Lists;
* OpenGL buffers.
*
* @author James Seibel
- * @version 12-8-2021
+ * @version 12-9-2021
*/
public class LodBufferBuilder
{
@@ -83,7 +83,7 @@ public class LodBufferBuilder
/** make sure the buffer doesn't overflow when inserting new elements */
private void ensureVertexCapacity()
{
- this.ensureCapacity(this.format.getVertexSize());
+ this.ensureCapacity(this.format.getByteSize());
}
private void ensureCapacity(int vertexSizeInBytes)
{
@@ -282,7 +282,7 @@ public class LodBufferBuilder
{
this.building = false;
this.vertexCounts.add(new LodBufferBuilder.DrawState(this.format, this.vertices, this.mode));
- this.totalRenderedBytes += this.vertices * this.format.getVertexSize();
+ this.totalRenderedBytes += this.vertices * this.format.getByteSize();
this.vertices = 0;
this.currentElement = null;
this.elementIndex = 0;
@@ -450,7 +450,7 @@ public class LodBufferBuilder
{
LodBufferBuilder.DrawState bufferbuilder$drawstate = this.vertexCounts.get(this.lastRenderedCountIndex++);
this.buffer.position(this.totalUploadedBytes);
- this.totalUploadedBytes += bufferbuilder$drawstate.vertexCount() * bufferbuilder$drawstate.format().getVertexSize();
+ this.totalUploadedBytes += bufferbuilder$drawstate.vertexCount() * bufferbuilder$drawstate.format().getByteSize();
this.buffer.limit(this.totalUploadedBytes);
if (this.lastRenderedCountIndex == this.vertexCounts.size() && this.vertices == 0)
{
@@ -543,10 +543,10 @@ public class LodBufferBuilder
// Forge added methods
public void putBulkData(ByteBuffer buffer)
{
- ensureCapacity(buffer.limit() + this.format.getVertexSize());
- this.buffer.position(this.vertices * this.format.getVertexSize());
+ ensureCapacity(buffer.limit() + this.format.getByteSize());
+ this.buffer.position(this.vertices * this.format.getByteSize());
this.buffer.put(buffer);
- this.vertices += buffer.limit() / this.format.getVertexSize();
+ this.vertices += buffer.limit() / this.format.getByteSize();
this.nextElementByte += buffer.limit();
}
diff --git a/src/main/java/com/seibel/lod/core/objects/opengl/LodVertexFormat.java b/src/main/java/com/seibel/lod/core/objects/opengl/LodVertexFormat.java
index a35cee4e9..c3ef47c07 100644
--- a/src/main/java/com/seibel/lod/core/objects/opengl/LodVertexFormat.java
+++ b/src/main/java/com/seibel/lod/core/objects/opengl/LodVertexFormat.java
@@ -35,13 +35,13 @@ import it.unimi.dsi.fastutil.ints.IntList;
* were commented out since we didn't need them.
*
* @author James Seibel
- * @version 11-13-2021
+ * @version 12-9-2021
*/
public class LodVertexFormat
{
private final ImmutableList elements;
private final IntList offsets = new IntArrayList();
- private final int vertexSize;
+ private final int byteSize;
public LodVertexFormat(ImmutableList elementList)
{
@@ -54,17 +54,12 @@ public class LodVertexFormat
i += LodVertexFormatElement.getByteSize();
}
- this.vertexSize = i;
+ this.byteSize = i;
}
- public int getIntegerSize()
+ public int getByteSize()
{
- return this.getVertexSize() / 4;
- }
-
- public int getVertexSize()
- {
- return this.vertexSize;
+ return this.byteSize;
}
public ImmutableList getElements()
@@ -98,7 +93,7 @@ public class LodVertexFormat
else if (obj != null && this.getClass() == obj.getClass())
{
LodVertexFormat vertexformat = (LodVertexFormat) obj;
- return this.vertexSize == vertexformat.vertexSize && this.elements.equals(vertexformat.elements);
+ return this.byteSize == vertexformat.byteSize && this.elements.equals(vertexformat.elements);
}
else
{
diff --git a/src/main/java/com/seibel/lod/core/render/LodRenderer.java b/src/main/java/com/seibel/lod/core/render/LodRenderer.java
index 988e3292d..099dfe969 100644
--- a/src/main/java/com/seibel/lod/core/render/LodRenderer.java
+++ b/src/main/java/com/seibel/lod/core/render/LodRenderer.java
@@ -61,7 +61,7 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IProfilerWrapper;
* This is where LODs are draw to the world.
*
* @author James Seibel
- * @version 12-8-2021
+ * @version 12-9-2021
*/
public class LodRenderer
{
@@ -101,8 +101,6 @@ public class LodRenderer
private int[] previousPos = new int[] { 0, 0, 0 };
// these variables are used to determine if the buffers should be rebuilt
- private float prevSkyBrightness = 0;
- private double prevBrightness = 0;
private int prevRenderDistance = 0;
private long prevPlayerPosTime = 0;
private long prevVanillaChunkTime = 0;
@@ -476,7 +474,7 @@ public class LodRenderer
GL30.glBindVertexArray(GLProxy.getInstance().vertexArrayObjectId);
// let OpenGL know how our buffer is set up
- int vertexByteCount = (Float.BYTES * 3) + (Byte.BYTES * 4) + Byte.BYTES + Byte.BYTES; // TODO move this into the template
+ int vertexByteCount = LodUtil.LOD_VERTEX_FORMAT.getByteSize();
GL20.glEnableVertexAttribArray(posAttrib);
GL20.glVertexAttribPointer(posAttrib, 3, GL15.GL_FLOAT, false, vertexByteCount, 0);
GL20.glEnableVertexAttribArray(colAttrib);
diff --git a/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/ILodConfigWrapperSingleton.java b/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/ILodConfigWrapperSingleton.java
index 2d0fc46e6..3f7b7e669 100644
--- a/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/ILodConfigWrapperSingleton.java
+++ b/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/ILodConfigWrapperSingleton.java
@@ -26,8 +26,6 @@ import com.seibel.lod.core.enums.config.GenerationPriority;
import com.seibel.lod.core.enums.config.GpuUploadMethod;
import com.seibel.lod.core.enums.config.HorizontalQuality;
import com.seibel.lod.core.enums.config.HorizontalResolution;
-import com.seibel.lod.core.enums.config.HorizontalScale;
-import com.seibel.lod.core.enums.config.LodTemplate;
import com.seibel.lod.core.enums.config.VanillaOverdraw;
import com.seibel.lod.core.enums.config.VerticalQuality;
import com.seibel.lod.core.enums.rendering.DebugMode;
@@ -43,7 +41,7 @@ import com.seibel.lod.core.util.LodUtil;
* the options that should be implemented in a configWrapperSingleton.
*
* @author James Seibel
- * @version 12-1-2021
+ * @version 12-9-2021
*/
public interface ILodConfigWrapperSingleton
{
@@ -184,18 +182,6 @@ public interface ILodConfigWrapperSingleton
{
String DESC = "Graphics options that are a bit more technical.";
- LodTemplate LOD_TEMPLATE_DEFAULT = LodTemplate.CUBIC;
- String LOD_TEMPLATE_DESC = ""
- + " How should the LODs be drawn? \n"
- + " NOTE: Currently only " + LodTemplate.CUBIC + " is implemented! \n"
- + " \n"
- + " " + LodTemplate.CUBIC + ": LOD Chunks are drawn as rectangular prisms (boxes). \n"
- + " " + LodTemplate.TRIANGULAR + ": LOD Chunks smoothly transition between other. \n"
- + " " + LodTemplate.DYNAMIC + ": LOD Chunks smoothly transition between each other, \n"
- + " " + " unless a neighboring chunk is at a significantly different height. \n";
- LodTemplate getLodTemplate();
- void setLodTemplate(LodTemplate newLodTemplate);
-
boolean DISABLE_DIRECTIONAL_CULLING_DEFAULT = false;
String DISABLE_DIRECTIONAL_CULLING_DESC = ""
+ " If false fake chunks behind the player's camera \n"