Merge branch '1.16.5' of gitlab.com:jeseibel/minecraft-lod-mod into
1.16.5 # Conflicts: # src/main/java/com/seibel/lod/builders/LodNodeBufferBuilder.java
This commit is contained in:
@@ -27,6 +27,7 @@ import com.seibel.lod.builders.worldGeneration.LodNodeGenWorker;
|
||||
import com.seibel.lod.enums.DistanceGenerationMode;
|
||||
import com.seibel.lod.enums.LodDetail;
|
||||
import com.seibel.lod.handlers.LodConfig;
|
||||
import com.seibel.lod.objects.LodQuadTree;
|
||||
import com.seibel.lod.objects.LodQuadTreeDimension;
|
||||
import com.seibel.lod.objects.LodQuadTreeNode;
|
||||
import com.seibel.lod.objects.NearFarVbos;
|
||||
@@ -302,10 +303,37 @@ public class LodNodeBufferBuilder
|
||||
int distance = (int) Math.sqrt(Math.pow((playerBlockPosRounded.getX() - lod.getCenter().getX()), 2) + Math.pow((playerBlockPosRounded.getZ() - lod.getCenter().getZ()), 2));
|
||||
LodDetail detail = LodDetail.getDetailForDistance(LodConfig.CLIENT.maxDrawDetail.get(), distance, maxBlockDistance);
|
||||
|
||||
// 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, detail);
|
||||
|
||||
for (int k = 0; k < detail.dataPointLengthCount * detail.dataPointLengthCount; k++)
|
||||
{
|
||||
// how much to offset this LOD by
|
||||
int startX = detail.startX[k];
|
||||
int startZ = detail.startZ[k];
|
||||
|
||||
// get the QuadTree location of this
|
||||
LodQuadTree lodTree = lodDim.getLevelFromPos(
|
||||
LodUtil.convertLevelPos((int) xOffset + startX, 0, LodUtil.CHUNK_DETAIL_LEVEL),
|
||||
LodUtil.convertLevelPos((int) zOffset + startZ, 0, LodUtil.CHUNK_DETAIL_LEVEL),
|
||||
LodUtil.CHUNK_DETAIL_LEVEL);
|
||||
|
||||
if (lodTree == null)
|
||||
continue;
|
||||
|
||||
LodQuadTreeNode newLod = lodTree.getNodeAtPos(
|
||||
LodUtil.convertLevelPos((int) xOffset + startX, 0, detail.detailLevel),
|
||||
LodUtil.convertLevelPos((int) zOffset + startZ, 0, detail.detailLevel),
|
||||
detail.detailLevel);
|
||||
|
||||
if (newLod != null)
|
||||
{
|
||||
// get the desired LodTemplate and
|
||||
// add this LOD to the buffer
|
||||
LodConfig.CLIENT.lodTemplate.get().
|
||||
template.addLodToBuffer(currentBuffer, lodDim, newLod,
|
||||
xOffset + startX, yOffset, zOffset + startZ, renderer.debugging, detail);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +361,7 @@ public class LodNodeBufferBuilder
|
||||
break;
|
||||
|
||||
// TODO add a list of locations we are waiting to generate so we don't add the
|
||||
// same position to the queue multiple times
|
||||
// same position to the queue multiple times
|
||||
|
||||
numberOfChunksWaitingToGenerate.addAndGet(1);
|
||||
|
||||
@@ -370,6 +398,14 @@ public class LodNodeBufferBuilder
|
||||
// regardless of if we successfully created the buffers or not
|
||||
// we are done generating.
|
||||
generatingBuffers = false;
|
||||
|
||||
|
||||
// clean up any potentially open resources
|
||||
if (buildableNearBuffer != null && buildableNearBuffer.building())
|
||||
buildableNearBuffer.end();
|
||||
|
||||
if (buildableFarBuffer != null && buildableFarBuffer.building())
|
||||
buildableFarBuffer.end();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.seibel.lod.builders.lodNodeTemplates;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import com.seibel.lod.enums.LodDetail;
|
||||
@@ -28,7 +29,6 @@ import com.seibel.lod.util.LodUtil;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
|
||||
/**
|
||||
* Builds LODs as rectangular prisms.
|
||||
*
|
||||
@@ -37,86 +37,79 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||
*/
|
||||
public class CubicLodNodeTemplate extends AbstractLodNodeTemplate
|
||||
{
|
||||
public CubicLodNodeTemplate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLodToBuffer(BufferBuilder buffer,
|
||||
LodQuadTreeDimension lodDim, LodQuadTreeNode lod,
|
||||
double xOffset, double yOffset, double zOffset,
|
||||
boolean debugging, LodDetail detail)
|
||||
{
|
||||
AxisAlignedBB bbox;
|
||||
|
||||
// add each LOD for the detail level
|
||||
for(int i = 0; i < detail.dataPointLengthCount * detail.dataPointLengthCount; i++)
|
||||
public CubicLodNodeTemplate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLodToBuffer(BufferBuilder buffer,
|
||||
LodQuadTreeDimension lodDim, LodQuadTreeNode lod,
|
||||
double xOffset, double yOffset, double zOffset,
|
||||
boolean debugging, LodDetail detail)
|
||||
{
|
||||
AxisAlignedBB bbox;
|
||||
|
||||
// add each LOD for the detail level
|
||||
bbox = generateBoundingBox(
|
||||
lod.getLodDataPoint().height,
|
||||
lod.getLodDataPoint().depth,
|
||||
lod.width,
|
||||
xOffset,
|
||||
yOffset,
|
||||
zOffset);
|
||||
|
||||
Color color = lod.getLodDataPoint().color;
|
||||
if (LodConfig.CLIENT.debugMode.get())
|
||||
{
|
||||
// how much to offset this LOD by
|
||||
int startX = detail.startX[i];
|
||||
int startZ = detail.startZ[i];
|
||||
|
||||
// get the QuadTree location of this LOD
|
||||
int posX = LodUtil.convertLevelPos((int) xOffset + startX, 0, detail.detailLevel);
|
||||
int posZ = LodUtil.convertLevelPos((int) zOffset + startZ, 0, detail.detailLevel);
|
||||
|
||||
LodQuadTreeNode newLod = lodDim.getLodFromCoordinates(posX, posZ, detail.detailLevel);
|
||||
if(newLod != null)
|
||||
{
|
||||
bbox = generateBoundingBox(
|
||||
newLod.getLodDataPoint().height,
|
||||
newLod.getLodDataPoint().depth,
|
||||
newLod.width,
|
||||
xOffset + startX,
|
||||
yOffset,
|
||||
zOffset + startZ);
|
||||
|
||||
|
||||
Color color = newLod.getLodDataPoint().color;
|
||||
if (LodConfig.CLIENT.debugMode.get())
|
||||
{
|
||||
color = LodUtil.DEBUG_DETAIL_LEVEL_COLORS[detail.detailLevel];
|
||||
}
|
||||
|
||||
if (bbox != null)
|
||||
{
|
||||
addBoundingBoxToBuffer(buffer, bbox, color);
|
||||
}
|
||||
}
|
||||
color = LodUtil.DEBUG_DETAIL_LEVEL_COLORS[detail.detailLevel];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private AxisAlignedBB generateBoundingBox(int height, int depth, int width, double xOffset, double yOffset, double zOffset)
|
||||
{
|
||||
// don't add an LOD if it is empty
|
||||
if (height == -1 && depth == -1)
|
||||
return null;
|
||||
|
||||
if (depth == height)
|
||||
|
||||
if (bbox != null)
|
||||
{
|
||||
// if the top and bottom points are at the same height
|
||||
// render this LOD as 1 block thick
|
||||
height++;
|
||||
}
|
||||
|
||||
return new AxisAlignedBB(0, depth, 0, width, height, width).move(xOffset, yOffset, zOffset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
addBoundingBoxToBuffer(buffer, bbox, color);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public void addLodToBuffer(BufferBuilder buffer,
|
||||
* LodQuadTreeDimension lodDim, LodQuadTreeNode lod, double xOffset, double
|
||||
* yOffset, double zOffset, boolean debugging) { AxisAlignedBB bbox;
|
||||
*
|
||||
* bbox = generateBoundingBox( lod.getLodDataPoint().height,
|
||||
* lod.getLodDataPoint().depth, lod.width, xOffset, yOffset, zOffset);
|
||||
*
|
||||
* Color color = lod.getLodDataPoint().color;
|
||||
*
|
||||
* if (bbox != null) { addBoundingBoxToBuffer(buffer, bbox, color); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
private AxisAlignedBB generateBoundingBox(int height, int depth, int width, double xOffset, double yOffset, double zOffset)
|
||||
{
|
||||
// don't add an LOD if it is empty
|
||||
if (height == -1 && depth == -1)
|
||||
return null;
|
||||
|
||||
if (depth == height)
|
||||
{
|
||||
// if the top and bottom points are at the same height
|
||||
// render this LOD as 1 block thick
|
||||
height++;
|
||||
}
|
||||
|
||||
return new AxisAlignedBB(0, depth, 0, width, height, width).move(xOffset, yOffset, zOffset);
|
||||
}
|
||||
|
||||
private void addBoundingBoxToBuffer(BufferBuilder buffer, AxisAlignedBB bb, Color c)
|
||||
{
|
||||
Color topColor = c;
|
||||
Color northSouthColor = c;
|
||||
Color eastWestColor = c;
|
||||
Color bottomColor = c;
|
||||
|
||||
|
||||
// darken the bottom and side colors if requested
|
||||
if (LodConfig.CLIENT.shadingMode.get() == ShadingMode.DARKEN_SIDES)
|
||||
{
|
||||
@@ -131,8 +124,7 @@ public class CubicLodNodeTemplate extends AbstractLodNodeTemplate
|
||||
eastWestColor = new Color(Math.max(0, c.getRed() - eastWestDarkenAmount), Math.max(0, c.getGreen() - eastWestDarkenAmount), Math.max(0, c.getBlue() - eastWestDarkenAmount), c.getAlpha());
|
||||
bottomColor = new Color(Math.max(0, c.getRed() - bottomDarkenAmount), Math.max(0, c.getGreen() - bottomDarkenAmount), Math.max(0, c.getBlue() - bottomDarkenAmount), c.getAlpha());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// apply the user specified saturation and brightness
|
||||
float saturationMultiplier = LodConfig.CLIENT.saturationMultiplier.get().floatValue();
|
||||
float brightnessMultiplier = LodConfig.CLIENT.brightnessMultiplier.get().floatValue();
|
||||
@@ -141,49 +133,46 @@ public class CubicLodNodeTemplate extends AbstractLodNodeTemplate
|
||||
northSouthColor = applySaturationAndBrightnessMultipliers(northSouthColor, saturationMultiplier, brightnessMultiplier);
|
||||
bottomColor = applySaturationAndBrightnessMultipliers(bottomColor, saturationMultiplier, brightnessMultiplier);
|
||||
|
||||
|
||||
|
||||
// top (facing up)
|
||||
// top (facing up)
|
||||
addPosAndColor(buffer, bb.minX, bb.maxY, bb.minZ, topColor.getRed(), topColor.getGreen(), topColor.getBlue(), topColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.minX, bb.maxY, bb.maxZ, topColor.getRed(), topColor.getGreen(), topColor.getBlue(), topColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.maxX, bb.maxY, bb.maxZ, topColor.getRed(), topColor.getGreen(), topColor.getBlue(), topColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.maxX, bb.maxY, bb.minZ, topColor.getRed(), topColor.getGreen(), topColor.getBlue(), topColor.getAlpha());
|
||||
// bottom (facing down)
|
||||
// bottom (facing down)
|
||||
addPosAndColor(buffer, bb.maxX, bb.minY, bb.minZ, bottomColor.getRed(), bottomColor.getGreen(), bottomColor.getBlue(), bottomColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.maxX, bb.minY, bb.maxZ, bottomColor.getRed(), bottomColor.getGreen(), bottomColor.getBlue(), bottomColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.minX, bb.minY, bb.maxZ, bottomColor.getRed(), bottomColor.getGreen(), bottomColor.getBlue(), bottomColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.minX, bb.minY, bb.minZ, bottomColor.getRed(), bottomColor.getGreen(), bottomColor.getBlue(), bottomColor.getAlpha());
|
||||
|
||||
// south (facing -Z)
|
||||
|
||||
// south (facing -Z)
|
||||
addPosAndColor(buffer, bb.maxX, bb.minY, bb.maxZ, northSouthColor.getRed(), northSouthColor.getGreen(), northSouthColor.getBlue(), northSouthColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.maxX, bb.maxY, bb.maxZ, northSouthColor.getRed(), northSouthColor.getGreen(), northSouthColor.getBlue(), northSouthColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.minX, bb.maxY, bb.maxZ, northSouthColor.getRed(), northSouthColor.getGreen(), northSouthColor.getBlue(), northSouthColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.minX, bb.minY, bb.maxZ, northSouthColor.getRed(), northSouthColor.getGreen(), northSouthColor.getBlue(), northSouthColor.getAlpha());
|
||||
// north (facing +Z)
|
||||
// north (facing +Z)
|
||||
addPosAndColor(buffer, bb.minX, bb.minY, bb.minZ, northSouthColor.getRed(), northSouthColor.getGreen(), northSouthColor.getBlue(), northSouthColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.minX, bb.maxY, bb.minZ, northSouthColor.getRed(), northSouthColor.getGreen(), northSouthColor.getBlue(), northSouthColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.maxX, bb.maxY, bb.minZ, northSouthColor.getRed(), northSouthColor.getGreen(), northSouthColor.getBlue(), northSouthColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.maxX, bb.minY, bb.minZ, northSouthColor.getRed(), northSouthColor.getGreen(), northSouthColor.getBlue(), northSouthColor.getAlpha());
|
||||
|
||||
// west (facing -X)
|
||||
|
||||
// west (facing -X)
|
||||
addPosAndColor(buffer, bb.minX, bb.minY, bb.minZ, eastWestColor.getRed(), eastWestColor.getGreen(), eastWestColor.getBlue(), eastWestColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.minX, bb.minY, bb.maxZ, eastWestColor.getRed(), eastWestColor.getGreen(), eastWestColor.getBlue(), eastWestColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.minX, bb.maxY, bb.maxZ, eastWestColor.getRed(), eastWestColor.getGreen(), eastWestColor.getBlue(), eastWestColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.minX, bb.maxY, bb.minZ, eastWestColor.getRed(), eastWestColor.getGreen(), eastWestColor.getBlue(), eastWestColor.getAlpha());
|
||||
// east (facing +X)
|
||||
// east (facing +X)
|
||||
addPosAndColor(buffer, bb.maxX, bb.maxY, bb.minZ, eastWestColor.getRed(), eastWestColor.getGreen(), eastWestColor.getBlue(), eastWestColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.maxX, bb.maxY, bb.maxZ, eastWestColor.getRed(), eastWestColor.getGreen(), eastWestColor.getBlue(), eastWestColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.maxX, bb.minY, bb.maxZ, eastWestColor.getRed(), eastWestColor.getGreen(), eastWestColor.getBlue(), eastWestColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.maxX, bb.minY, bb.minZ, eastWestColor.getRed(), eastWestColor.getGreen(), eastWestColor.getBlue(), eastWestColor.getAlpha());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferMemoryForSingleNode(int detailLevel)
|
||||
{
|
||||
// (sidesOnACube * pointsInASquare * (positionPoints + colorPoints))) *
|
||||
// howManyPointsPerLodChunk
|
||||
return (6 * 4 * (3 + 4));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getBufferMemoryForSingleNode(int detailLevel)
|
||||
{
|
||||
// (sidesOnACube * pointsInASquare * (positionPoints + colorPoints))) * howManyPointsPerLodChunk
|
||||
return (6 * 4 * (3 + 4));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user