Merge branch 'main' of https://gitlab.com/jeseibel/distant-horizons-core
This commit is contained in:
@@ -1 +0,0 @@
|
||||
<mxfile host="app.diagrams.net" modified="2021-12-22T02:14:44.485Z" agent="5.0 (Windows)" etag="8Lz4CpREcKLpQpROSPVl" version="16.0.3" type="gitlab"><diagram id="xLs7mM1S-vncSruOQYJG" name="Page-1">xZVNj5swEIZ/DcetAJdkc2yTbXvZVaQcuunNtSfgrsGRcRbor6+Jx4BDom3VSr1Enmc+7HnHOBFZl+1nTY/Fo+IgozTmbUQ2UZou71P724POAZIlDuRacIcmYCd+AsIY6UlwqINAo5Q04hhCpqoKmAkY1Vo1YdhByXDXI81hBnaMyjn9KrgpHL3P4pF/AZEXfuckRk9JfTCCuqBcNRNEHiKy1koZtyrbNcheO6+Ly/t0wzscTENlfichf/r2ohqemP2Pp+3dtn3s9tkdVnml8oQNCwOlJeioTeeV0OpUceiLxRH52BQ2cHekrPc2dvSWFaaU1krsEsuCNtDePG8yqGBvD6gSjO5sCCasUDe8OMl7tJtxDInXtpiMYIGM4uTzofIojl2gPn+gVXpLq/TvtDoIKddKKn3OJYcDLBizvDZavcDEw5er73H8b9QlSSjv4n+rS2bqzlSFin/oP2lrMUnrWrBQyFB1aIV5Rk+/3vf8XYbWpp2EbTpvVLaV56nhspaZt8e8s+UT3VmBzx6Ti3nYftRJM3j7kzRU52Deuo7z+U4GmF2Zn2caJDXiNTzutaHiDlslbCM3r89Q15dwbWLW9FW6LLS4+MxXF4WcDrNC5zs2tH3t2llzfFxd+PgPRR5+AQ==</diagram></mxfile>
|
||||
@@ -0,0 +1 @@
|
||||
<mxfile host="app.diagrams.net" modified="2022-01-01T15:42:59.419Z" agent="5.0 (Windows)" etag="hsDveQWDaeM6f7rOSc9c" version="16.0.3" type="device"><diagram id="xLs7mM1S-vncSruOQYJG" name="Page-1">7Vxpc9o4GP41zOx+SMc38DFcTWZztWyapl92hC1AjbFc2QTor1/5Cth6Abfgg9BkJrFl2bKfR3pvu6F2Z8uPDLnTW2phu6FI1rKh9hqKIrc0jf8LWlZRi9pWooYJI1bcad0wJD9x3CjFrXNiYS/V0afU9ombbjSp42DTT7Uhxugi3W1M7fSoLppgoWFoIltsfSKWP41aW7q0br/CZDJNRpal+MgImS8TRudOPJ5DHRwdmaHkMnFXb4osuthoUvsNtcso9aOt2bKL7QDWBLHovEF0lI6+Bw+uSDYacfDDDp314OEIKajT13QRw44PXJdvxJeGb+Lb5MfPm5c798fVf083s6/ucvZ4daFG470iex4DGD+iv0oQDW8LBxeRGmpnMSU+HrrIDI4u+BzibVN/FjyHzDfDZ1o/TZfalPFDIZhqZ0xsO2lqKOpgMND6Ld7u+Yy+4I0jVrM9koLh4tvDzMfLDMFrGDZR+ojpDPtsxbvEJ+jtmLZVeqYu1tNDacVt042poSczA8VTcvJ26RToMdAw6PYjwc+Opvqs++Xu05B+eu63LmSjStT7nYHS70CoS0bbUHpvqAsQA0RsRf1CMdKwtwDYJQB2TSsM9kon+1gPfiHYjfAnOIM6/kZ79HMcOrT9ZCgAGa1mYWS0BDK+YOYR6vDGoYtNMibm+18VkDCCVkVxPLQFHnrE85ETaKgryshP6nh88/LhuqEYNr+dzojxrUmw9deasmvOi4v5H8f/+1xXFUQmtKqOQebk7tsLXViy//z97uHiYXm7etYvZIHLW8KtLIbGPkQeQbzzLVkSxzuQswwrlo5blgax0lJGasjKURaTmsVfJEDWQNVe1GrSRAaotXX5DCjj1qwicXQUaYBGjJjHJaKn91u98omA9AtIhHEEIkC7VtQuZeoSKfg9QCgdZO8aenpRaAAXTYALWS5qVWh6lWxUJYz0nGtALszPUCrFfTzGhmnm8O4Owt2Q9f2wt3UR9nZhqEsC6p8Dw4jdUMs7JSl0EC+ylOGlKfLSLlU1i4shooW3dadz58UTFXT/NQDg/YmqunGjiIargDrn6jKID/I900aeR8w00GlW8JL4X+MjwfZz0P5Bj/d6y41uvVWy4/Bn+bq5s3FWsLs+LdxLzovISqKNyi6SPDpnJs4xS33ELUM/h5TBVioeKpK+wam+g1OGbeST13QUFSI6HuGBktBFTOZUxhVSssZE9OTxWevpIlxIzmjRrIUYASNcJ5x2b099wEwUQ3OhELh0ydmI7owBqSbSYp8BWVjgTmlWacfUiwwtJxl6Sy+KDTFiNMSMP9G/xHwpW2NWS04ms6ACelSGAkCFKVJVjD+Ets0NRdZZU6OplVMj2p9PlNnWEL3i86amXTk1UD4u8gUs8po4AyFbGwsp6sAH3OhzrhzqOqCWyuUQshFgDh8d+w+LEIuGUvlKFOO2HZuaL90pcibnLSYNKKZeLjmi4Xfv/INX1447P1tamlB4vVRakhvYoOXBRivMbumZWxYtKB9YLjdKHq30heBFlHTnFGzRSMJJkUj8o8YA2o0SaQezjznCmaVkdQ/KIwoZLRUSdWBGqzBgxeUEFqt0KcN1rFapT8FjUWUpIGui3dC1yekFVY+alYdUU1FBVVhGQarpTMhQpfQKUSDHB6oJbh6jRgKmQyxOPc2s8VGJgTKTIDHFqXIxoiqw4U2RG2yObbyMc5Sd+qYro9vP5A1/L1uZLJvNbOWO2V1VclKI02eFat7kpJrNcmaLSI6XnYTNnxyTMVjk7talGL92g0ZJ97f3YnIvUUX+kNZlChRbT+Jx5ZTciLrs+q3y9YkLRDco8yhNhv5W5dNuwvf7QvvAL86QyBV5NW2M2IChWX4P9z58m6mLzOnWc+pH6R71t4NlkdJVmrl9DBfndeWoIyxf7IDuKIRLqzBcxMgbt9bCHEOJU7Noi23HlKiRFAJKyLgm5nT0yAw7kdt/npT8ohQpjqEcbz2WL0XAwoCijBcYFyCohX1E7CQk/OgT+92oOqNuckP0u+euhTia2PeJMynT964E+boYGaoowE+x8vKw8IcgnvS84qmwBaJCcULBVn/9k8I6NvNQ6Ktc5kXR6J5uYvnI9BhAVqVkemoRDMoUqUCp11KtKaDMsiInoFBtrm4JGVQ3G0Xr3pz7n/GEg35HLexdeiunzA86VAJ/bYypXDE5vHSRY92zoKg1t9KOKE3ofCdhuV+Tck3oHdNy+RXrJLmUixKG9Qx1H5Y8z77kC2XPoZd8iyNArGmwGFrc3PdO0WHcg76qZIwfGVLzSVsp+ANFj5UbPy2oiqBU40cTfejTFgs7uK+R7QNUeZ6wMPglzOti8GhNAemgwmEY71LmT+mEOsjur1szNRjrPjeUujED37Hvr+KvXKK5T9P81L9sY+d83Vu2EWk5kfUD6zGMbPlVMlX2lFFcMoZWG93coIO3fRw9K6Djd2K3lXdk+8vp/nwjuoOj1nRoZ2RJtLPlXZAdUWp5l57DjnhvqEMFwTDqSmGwixpTgP0cqup2+hZ7xbO2RTyXU1XX1tJOQdaqzf/FD13aeaGCi+r0HJ+FLdqVaGc0D1iQXKoroYvR5esdH5OMfIwal9r9jtGr769aLdfR0KFCLCFCFyVprpCXO6bXsYljOdjz+hxPs/pcXCWsFu/K8N31R+Ij8bX+CL/a/x8=</diagram></mxfile>
|
||||
@@ -28,9 +28,13 @@ 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.util.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
|
||||
import static com.seibel.lod.core.builders.lodBuilding.LodBuilder.MIN_WORLD_HEIGHT;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Builds LODs as rectangular prisms.
|
||||
* @author James Seibel
|
||||
@@ -38,8 +42,9 @@ import static com.seibel.lod.core.builders.lodBuilding.LodBuilder.MIN_WORLD_HEIG
|
||||
*/
|
||||
public class CubicLodTemplate
|
||||
{
|
||||
public static void addLodToBuffer(LodBufferBuilder buffer, int playerX, int playerY, int playerZ, long data, Map<LodDirection, long[]> adjData,
|
||||
byte detailLevel, int posX, int posZ, VertexOptimizer vertexOptimizer, DebugMode debugging, boolean[] adjShadeDisabled)
|
||||
|
||||
public static void addLodToBuffer(LodBufferBuilder buffer, int playerX, int playerZ, long data, Map<LodDirection, long[]> adjData,
|
||||
byte detailLevel, int posX, int posZ, VertexOptimizer vertexOptimizer, DebugMode debugging, boolean[] adjShadeDisabled, int cullingRangeX, int cullingRangeZ)
|
||||
{
|
||||
if (vertexOptimizer == null)
|
||||
return;
|
||||
@@ -61,7 +66,6 @@ public class CubicLodTemplate
|
||||
blockWidth,
|
||||
posX * blockWidth, 0, posZ * blockWidth, // x, y, z offset
|
||||
playerX,
|
||||
playerY,
|
||||
playerZ,
|
||||
adjData,
|
||||
color,
|
||||
@@ -69,7 +73,7 @@ public class CubicLodTemplate
|
||||
DataPointUtil.getLightBlock(data),
|
||||
adjShadeDisabled);
|
||||
|
||||
addBoundingBoxToBuffer(buffer, vertexOptimizer);
|
||||
addBoundingBoxToBuffer(buffer, vertexOptimizer, cullingRangeX, cullingRangeZ);
|
||||
}
|
||||
|
||||
/** add the given position and color to the buffer */
|
||||
@@ -77,7 +81,7 @@ public class CubicLodTemplate
|
||||
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)"
|
||||
// TODO transparency re-add 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)
|
||||
@@ -89,7 +93,7 @@ public class CubicLodTemplate
|
||||
private static void generateBoundingBox(VertexOptimizer vertexOptimizer,
|
||||
int height, int depth, int width,
|
||||
double xOffset, double yOffset, double zOffset,
|
||||
int playerX, int playerY, int playerZ,
|
||||
int playerX, int playerZ,
|
||||
Map<LodDirection, long[]> adjData,
|
||||
int color, byte skyLight, byte blockLight,
|
||||
boolean[] adjShadeDisabled)
|
||||
@@ -116,15 +120,25 @@ public class CubicLodTemplate
|
||||
vertexOptimizer.setAdjData(adjData);
|
||||
}
|
||||
|
||||
private static void addBoundingBoxToBuffer(LodBufferBuilder buffer, VertexOptimizer vertexOptimizer)
|
||||
private static void addBoundingBoxToBuffer(LodBufferBuilder buffer, VertexOptimizer vertexOptimizer, int cullingRangeX, int cullingRangeZ)
|
||||
{
|
||||
int color;
|
||||
byte skyLight;
|
||||
byte blockLight;
|
||||
|
||||
for (LodDirection lodDirection : VertexOptimizer.DIRECTIONS)
|
||||
{
|
||||
//if(vertexOptimizer.isCulled(lodDirection))
|
||||
// continue;
|
||||
// culling
|
||||
// FIXME: Reimpl backface culling
|
||||
/*
|
||||
if (lodDirection == LodDirection.NORTH && vertexOptimizer.getZ(lodDirection, 0) < -cullingRangeZ
|
||||
|| lodDirection == LodDirection.EAST && vertexOptimizer.getX(lodDirection, 0) > cullingRangeX
|
||||
|| lodDirection == LodDirection.SOUTH && vertexOptimizer.getZ(lodDirection, 0) > cullingRangeZ
|
||||
|| lodDirection == LodDirection.WEST && vertexOptimizer.getX(lodDirection, 0) < -cullingRangeX)
|
||||
continue;
|
||||
*/
|
||||
|
||||
int verticalFaceIndex = 0;
|
||||
while (vertexOptimizer.shouldRenderFace(lodDirection, verticalFaceIndex))
|
||||
|
||||
+566
-628
File diff suppressed because it is too large
Load Diff
@@ -80,7 +80,6 @@ public class LodBuilder
|
||||
|
||||
//public static final boolean useExperimentalLighting = true;
|
||||
|
||||
private static int timesToEdgeDetect = 1;
|
||||
|
||||
|
||||
|
||||
@@ -249,32 +248,23 @@ public class LodBuilder
|
||||
yAbs = chunk.getMaxY(xRel,zRel) - MIN_WORLD_HEIGHT;
|
||||
int count = 0;
|
||||
boolean topBlock = true;
|
||||
if (yAbs <= 0)
|
||||
dataToMerge[index * verticalData] = DataPointUtil.createVoidDataPoint(generation);
|
||||
while (yAbs > 0)
|
||||
{
|
||||
height = determineHeightPointFrom(chunk, config, xAbs, yAbs, zAbs);
|
||||
|
||||
// If the lod is at the default height, it must be void data
|
||||
if (height == 0)
|
||||
{
|
||||
if (topBlock)
|
||||
dataToMerge[index * verticalData] = DataPointUtil.createVoidDataPoint(generation);
|
||||
break;
|
||||
}
|
||||
|
||||
yAbs = height - 1;
|
||||
// We search light on above air block
|
||||
depth = determineBottomPointFrom(chunk, config, xAbs, yAbs, zAbs, count < timesToEdgeDetect);
|
||||
depth = determineBottomPointFrom(chunk, config, xAbs, yAbs, zAbs, count < this.config.client().graphics().quality().getVerticalQuality().maxConnectedLods && !hasCeiling);
|
||||
if (hasCeiling && topBlock)
|
||||
{
|
||||
yAbs = depth;
|
||||
light = getLightValue(chunk, xAbs,yAbs,zAbs, true, hasSkyLight, true);
|
||||
color = generateLodColor(chunk, config, xAbs, yAbs, zAbs);
|
||||
}
|
||||
else
|
||||
{
|
||||
light = getLightValue(chunk, xAbs, yAbs, zAbs, hasCeiling, hasSkyLight, topBlock);
|
||||
color = generateLodColor(chunk, config, xAbs, yAbs, zAbs);
|
||||
}
|
||||
light = getLightValue(chunk, xAbs,yAbs + MIN_WORLD_HEIGHT, zAbs, hasCeiling, hasSkyLight, topBlock);
|
||||
color = generateLodColor(chunk, config, xAbs, yAbs, zAbs);
|
||||
lightBlock = light & 0b1111;
|
||||
lightSky = (light >> 4) & 0b1111;
|
||||
isDefault = ((light >> 8)) == 1;
|
||||
@@ -296,15 +286,21 @@ public class LodBuilder
|
||||
{
|
||||
short depth = 0;
|
||||
|
||||
IBlockColorWrapper blockColorWrapper;
|
||||
int colorOfBlock = 0;
|
||||
if (strictEdge)
|
||||
{
|
||||
blockColorWrapper = chunk.getBlockColorWrapper(xAbs, yAbs, zAbs);
|
||||
colorOfBlock = blockColorWrapper.getColor();
|
||||
colorOfBlock = chunk.getBlockColorWrapper(xAbs, yAbs, zAbs).getColor();
|
||||
IBlockShapeWrapper block = chunk.getBlockShapeWrapper(xAbs, yAbs + 1, zAbs);
|
||||
if (block != null && ((this.config.client().worldGenerator().getBlocksToAvoid().nonFull && block.isNonFull())
|
||||
|| (this.config.client().worldGenerator().getBlocksToAvoid().noCollision && block.hasNoCollision())))
|
||||
{
|
||||
int aboveColorInt = chunk.getBlockColorWrapper(xAbs, yAbs + 1, zAbs).getColor();
|
||||
if (aboveColorInt != 0)
|
||||
colorOfBlock = aboveColorInt;
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = yAbs; y >= 0; y--)
|
||||
for (int y = yAbs - 1; y >= 0; y--)
|
||||
{
|
||||
|
||||
if (!isLayerValidLodPoint(chunk, xAbs, y, zAbs))
|
||||
@@ -314,8 +310,7 @@ public class LodBuilder
|
||||
}
|
||||
if (strictEdge)
|
||||
{
|
||||
blockColorWrapper = chunk.getBlockColorWrapper(xAbs, y, zAbs);
|
||||
if (colorOfBlock != blockColorWrapper.getColor())
|
||||
if (colorOfBlock != chunk.getBlockColorWrapper(xAbs, y, zAbs).getColor())
|
||||
{
|
||||
depth = (short) (y + 1);
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.seibel.lod.core.config;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Where the annotations for the config are defined
|
||||
*
|
||||
* @author coolGi2007
|
||||
* @version 12-28-2021
|
||||
*/
|
||||
public class ConfigAnnotations {
|
||||
/** a textField, button, etc. that can be interacted with */
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Entry
|
||||
{
|
||||
String name() default "";
|
||||
|
||||
int width() default 150;
|
||||
|
||||
double minValue() default Double.MIN_NORMAL;
|
||||
|
||||
double maxValue() default Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface ScreenEntry
|
||||
{
|
||||
String name() default "";
|
||||
|
||||
int width() default 100;
|
||||
}
|
||||
|
||||
|
||||
/** Makes text (looks like @Entry but dosnt save and has no button */
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Comment
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -92,4 +92,44 @@ public enum DistanceGenerationMode
|
||||
{
|
||||
this.complexity = complexity;
|
||||
}
|
||||
|
||||
// Note: return null if out of range
|
||||
public static DistanceGenerationMode previous(DistanceGenerationMode mode) {
|
||||
switch (mode) {
|
||||
case FULL:
|
||||
return DistanceGenerationMode.FEATURES;
|
||||
case FEATURES:
|
||||
return DistanceGenerationMode.SURFACE;
|
||||
case SURFACE:
|
||||
return DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT;
|
||||
case BIOME_ONLY_SIMULATE_HEIGHT:
|
||||
return DistanceGenerationMode.BIOME_ONLY;
|
||||
case BIOME_ONLY:
|
||||
return DistanceGenerationMode.NONE;
|
||||
case NONE:
|
||||
return null;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Note: return null if out of range
|
||||
public static DistanceGenerationMode next(DistanceGenerationMode mode) {
|
||||
switch (mode) {
|
||||
case FULL:
|
||||
return null;
|
||||
case FEATURES:
|
||||
return DistanceGenerationMode.FULL;
|
||||
case SURFACE:
|
||||
return DistanceGenerationMode.FEATURES;
|
||||
case BIOME_ONLY_SIMULATE_HEIGHT:
|
||||
return DistanceGenerationMode.SURFACE;
|
||||
case BIOME_ONLY:
|
||||
return DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT;
|
||||
case NONE:
|
||||
return DistanceGenerationMode.BIOME_ONLY;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,52 +29,54 @@ package com.seibel.lod.core.enums.config;
|
||||
public enum VerticalQuality
|
||||
{
|
||||
LOW(
|
||||
new int[] { 2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1 }
|
||||
new int[] { 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1 },
|
||||
0
|
||||
),
|
||||
|
||||
MEDIUM(
|
||||
new int[] { 4,
|
||||
4,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1 }
|
||||
new int[] { 4, 4, 2, 2, 2, 1, 1, 1, 1, 1, 1 },
|
||||
1
|
||||
),
|
||||
|
||||
HIGH(
|
||||
new int[] {
|
||||
8,
|
||||
8,
|
||||
4,
|
||||
4,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1 }
|
||||
new int[] { 8, 8, 4, 4, 2, 2, 2, 1, 1, 1, 1 },
|
||||
2
|
||||
);
|
||||
|
||||
public final int[] maxVerticalData;
|
||||
public final int maxConnectedLods;
|
||||
|
||||
VerticalQuality(int[] maxVerticalData)
|
||||
VerticalQuality(int[] maxVerticalData, int maxConnectedLods)
|
||||
{
|
||||
this.maxVerticalData = maxVerticalData;
|
||||
this.maxConnectedLods = maxConnectedLods;
|
||||
}
|
||||
|
||||
// Note: return null if out of range
|
||||
public static VerticalQuality previous(VerticalQuality mode) {
|
||||
switch (mode) {
|
||||
case HIGH:
|
||||
return VerticalQuality.MEDIUM;
|
||||
case MEDIUM:
|
||||
return VerticalQuality.LOW;
|
||||
case LOW:
|
||||
return null;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Note: return null if out of range
|
||||
public static VerticalQuality next(VerticalQuality mode) {
|
||||
switch (mode) {
|
||||
case HIGH:
|
||||
return null;
|
||||
case MEDIUM:
|
||||
return VerticalQuality.HIGH;
|
||||
case LOW:
|
||||
return VerticalQuality.MEDIUM;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,6 +100,8 @@ public class LodDimensionFileHandler
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// read from file //
|
||||
//================//
|
||||
@@ -116,136 +118,78 @@ public class LodDimensionFileHandler
|
||||
|
||||
for (byte tempDetailLevel = LodUtil.REGION_DETAIL_LEVEL; tempDetailLevel >= detailLevel; tempDetailLevel--)
|
||||
{
|
||||
String fileName = getFileNameAndPathForRegion(regionX, regionZ, generationMode, tempDetailLevel, verticalQuality);
|
||||
File file = getBestMatchingRegionFile(tempDetailLevel, regionX, regionZ, generationMode, verticalQuality);
|
||||
if (file == null) {
|
||||
region.addLevelContainer(new VerticalLevelContainer(tempDetailLevel));
|
||||
continue; // Failed to find the file for this detail level. continue and try next one
|
||||
}
|
||||
|
||||
try
|
||||
long fileSize = file.length();
|
||||
if (fileSize == 0) {
|
||||
region.addLevelContainer(new VerticalLevelContainer(tempDetailLevel));
|
||||
continue; // file is empty. Let's not try parsing empty files
|
||||
}
|
||||
try (FileInputStream fileInStream = new FileInputStream(file))
|
||||
{
|
||||
// if the fileName was null that means the folder is inaccessible
|
||||
// for some reason
|
||||
if (fileName == null)
|
||||
throw new IllegalArgumentException("Unable to read region [" + regionX + ", " + regionZ + "] file, no fileName.");
|
||||
XZCompressorInputStream inputStream = new XZCompressorInputStream(fileInStream);
|
||||
int fileVersion;
|
||||
fileVersion = inputStream.read();
|
||||
|
||||
File file = new File(fileName);
|
||||
if (!file.exists())
|
||||
// check if this file can be read by this file handler
|
||||
if (fileVersion < 6)
|
||||
{
|
||||
//there is no file for current gen mode
|
||||
//search others above current from the most to the least detailed
|
||||
VerticalQuality tempVerticalQuality = VerticalQuality.HIGH;
|
||||
do {
|
||||
DistanceGenerationMode tempGenMode = DistanceGenerationMode.FULL;
|
||||
do {
|
||||
fileName = getFileNameAndPathForRegion(regionX, regionZ, tempGenMode, tempDetailLevel, verticalQuality);
|
||||
if (fileName != null)
|
||||
{
|
||||
file = new File(fileName);
|
||||
if (file.exists())
|
||||
break;
|
||||
}
|
||||
//decrease gen mode
|
||||
if (tempGenMode == DistanceGenerationMode.FULL)
|
||||
tempGenMode = DistanceGenerationMode.FEATURES;
|
||||
else if (tempGenMode == DistanceGenerationMode.FEATURES)
|
||||
tempGenMode = DistanceGenerationMode.SURFACE;
|
||||
else if (tempGenMode == DistanceGenerationMode.SURFACE)
|
||||
tempGenMode = DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT;
|
||||
else if (tempGenMode == DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT)
|
||||
tempGenMode = DistanceGenerationMode.BIOME_ONLY;
|
||||
else if (tempGenMode == DistanceGenerationMode.BIOME_ONLY)
|
||||
tempGenMode = DistanceGenerationMode.NONE;
|
||||
} while (tempGenMode != generationMode);
|
||||
if (fileName != null)
|
||||
{
|
||||
file = new File(fileName);
|
||||
if (file.exists())
|
||||
break;
|
||||
}
|
||||
if (tempVerticalQuality == VerticalQuality.HIGH)
|
||||
tempVerticalQuality = VerticalQuality.MEDIUM;
|
||||
else if (tempVerticalQuality == VerticalQuality.MEDIUM)
|
||||
tempVerticalQuality = VerticalQuality.LOW;
|
||||
} while (tempVerticalQuality != verticalQuality);
|
||||
if (!file.exists())
|
||||
//there wasn't a file, don't return anything
|
||||
continue;
|
||||
// the file we are reading is an older version,
|
||||
// close the reader and delete the file.
|
||||
inputStream.close();
|
||||
file.delete();
|
||||
ClientApi.LOGGER.info("Outdated LOD region file for region: (" + regionX + "," + regionZ + ")"
|
||||
+ " version found: " + fileVersion
|
||||
+ ", version requested: " + LOD_SAVE_FILE_VERSION
|
||||
+ ". File has been deleted.");
|
||||
// This should not break, but be continue to see whether other detail levels can be loaded or updated
|
||||
region.addLevelContainer(new VerticalLevelContainer(tempDetailLevel));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// don't try parsing empty files
|
||||
long dataSize = file.length();
|
||||
dataSize -= 1;
|
||||
if (dataSize > 0)
|
||||
else if (fileVersion > LOD_SAVE_FILE_VERSION)
|
||||
{
|
||||
try (XZCompressorInputStream inputStream = new XZCompressorInputStream(new FileInputStream(file)))
|
||||
{
|
||||
int fileVersion;
|
||||
fileVersion = inputStream.read();
|
||||
|
||||
// check if this file can be read by this file handler
|
||||
if (fileVersion < 6)
|
||||
{
|
||||
// the file we are reading is an older version,
|
||||
// close the reader and delete the file.
|
||||
inputStream.close();
|
||||
file.delete();
|
||||
ClientApi.LOGGER.info("Outdated LOD region file for region: (" + regionX + "," + regionZ + ")"
|
||||
+ " version found: " + fileVersion
|
||||
+ ", version requested: " + LOD_SAVE_FILE_VERSION
|
||||
+ ". File was been deleted.");
|
||||
|
||||
break;
|
||||
}
|
||||
else if (fileVersion > LOD_SAVE_FILE_VERSION)
|
||||
{
|
||||
// the file we are reading is a newer version,
|
||||
// close the reader and ignore the file, we don't
|
||||
// want to accidentally delete anything the user may want.
|
||||
inputStream.close();
|
||||
ClientApi.LOGGER.info("Newer LOD region file for region: (" + regionX + "," + regionZ + ")"
|
||||
+ " version found: " + fileVersion
|
||||
+ ", version requested: " + LOD_SAVE_FILE_VERSION
|
||||
+ " this region will not be written to in order to protect the newer file.");
|
||||
|
||||
break;
|
||||
}
|
||||
else if (fileVersion < LOD_SAVE_FILE_VERSION)
|
||||
{
|
||||
//this is old, but readable version
|
||||
byte[] data = ThreadMapUtil.getSaveContainer(tempDetailLevel);
|
||||
inputStream.read(data);
|
||||
inputStream.close();
|
||||
// add the data to our region
|
||||
region.addLevelContainer(new VerticalLevelContainer(data, fileVersion));
|
||||
} else
|
||||
{
|
||||
// this file is a readable version,
|
||||
// read the file
|
||||
byte[] data = ThreadMapUtil.getSaveContainer(tempDetailLevel);
|
||||
inputStream.read(data);
|
||||
inputStream.close();
|
||||
// add the data to our region
|
||||
region.addLevelContainer(new VerticalLevelContainer(data, LOD_SAVE_FILE_VERSION));
|
||||
}
|
||||
}
|
||||
catch (IOException ioEx)
|
||||
{
|
||||
ClientApi.LOGGER.error("LOD file read error. Unable to read to [" + fileName + "] error [" + ioEx.getMessage() + "]: ");
|
||||
ioEx.printStackTrace();
|
||||
}
|
||||
// the file we are reading is a newer version,
|
||||
// close the reader and ignore the file, we don't
|
||||
// want to accidentally delete anything the user may want.
|
||||
inputStream.close();
|
||||
ClientApi.LOGGER.info("Newer LOD region file for region: (" + regionX + "," + regionZ + ")"
|
||||
+ " version found: " + fileVersion
|
||||
+ ", version requested: " + LOD_SAVE_FILE_VERSION
|
||||
+ " this region will not be written to in order to protect the newer file.");
|
||||
// This should not break, but be continue to see whether other detail levels can be loaded or updated
|
||||
region.addLevelContainer(new VerticalLevelContainer(tempDetailLevel));
|
||||
continue;
|
||||
}
|
||||
else if (fileVersion < LOD_SAVE_FILE_VERSION)
|
||||
{
|
||||
ClientApi.LOGGER.debug("Old LOD region file for region: (" + regionX + "," + regionZ + ")"
|
||||
+ " version found: " + fileVersion
|
||||
+ ", version requested: " + LOD_SAVE_FILE_VERSION
|
||||
+ ". File will be loaded and updated to new format in next save.");
|
||||
// this is old, but readable version
|
||||
// read and add the data to our region
|
||||
region.addLevelContainer(new VerticalLevelContainer(new DataInputStream(inputStream), fileVersion, tempDetailLevel));
|
||||
inputStream.close();
|
||||
} else
|
||||
{
|
||||
// this file is a readable version,
|
||||
// read and add the data to our region
|
||||
region.addLevelContainer(new VerticalLevelContainer(new DataInputStream(inputStream), LOD_SAVE_FILE_VERSION, tempDetailLevel));
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (IOException ioEx)
|
||||
{
|
||||
// the buffered reader encountered a
|
||||
// problem reading the file
|
||||
ClientApi.LOGGER.error("LOD file read error. Unable to read to [" + fileName + "] error [" + e.getMessage() + "]: ");
|
||||
e.printStackTrace();
|
||||
ClientApi.LOGGER.error("LOD file read error. Unable to read xz compressed file [" + file + "] error [" + ioEx.getMessage() + "]: ");
|
||||
ioEx.printStackTrace();
|
||||
region.addLevelContainer(new VerticalLevelContainer(tempDetailLevel));
|
||||
}
|
||||
}// for each detail level
|
||||
|
||||
if (region.getMinDetailLevel() >= detailLevel)
|
||||
region.growTree(detailLevel);
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
@@ -294,163 +238,105 @@ public class LodDimensionFileHandler
|
||||
{
|
||||
for (byte detailLevel = region.getMinDetailLevel(); detailLevel <= LodUtil.REGION_DETAIL_LEVEL; detailLevel++)
|
||||
{
|
||||
String fileName = getFileNameAndPathForRegion(region.regionPosX, region.regionPosZ, region.getGenerationMode(), detailLevel, region.getVerticalQuality());
|
||||
// Get the old file
|
||||
File oldFile = getRegionFile(region.regionPosX, region.regionPosZ, region.getGenerationMode(), detailLevel, region.getVerticalQuality());
|
||||
ClientApi.LOGGER.debug("saving region [" + region.regionPosX + ", " + region.regionPosZ + "] to file.");
|
||||
|
||||
// if the fileName was null that means the folder is inaccessible
|
||||
// for some reason
|
||||
if (fileName == null)
|
||||
boolean isFileFullyGened = false;
|
||||
// make sure the file and folder exists
|
||||
if (!oldFile.exists())
|
||||
{
|
||||
ClientApi.LOGGER.warn("Unable to save region [" + region.regionPosX + ", " + region.regionPosZ + "] to file, file is inaccessible.");
|
||||
return;
|
||||
}
|
||||
File oldFile = new File(fileName);
|
||||
//ClientProxy.LOGGER.info("saving region [" + region.regionPosX + ", " + region.regionPosZ + "] to file.");
|
||||
byte[] temp = region.getLevel(detailLevel).toDataString();
|
||||
|
||||
try
|
||||
{
|
||||
// make sure the file and folder exists
|
||||
if (!oldFile.exists())
|
||||
{
|
||||
// the file doesn't exist,
|
||||
// create it and the folder if need be
|
||||
if (!oldFile.getParentFile().exists())
|
||||
oldFile.getParentFile().mkdirs();
|
||||
// the file doesn't exist,
|
||||
// create it and the folder if need be
|
||||
if (!oldFile.getParentFile().exists())
|
||||
oldFile.getParentFile().mkdirs();
|
||||
try {
|
||||
oldFile.createNewFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
// the file exists, make sure it
|
||||
// is the correct version.
|
||||
// (to make sure we don't overwrite a newer
|
||||
// version file if it exists)
|
||||
int fileVersion = LOD_SAVE_FILE_VERSION;
|
||||
int isFull = 0;
|
||||
try (XZCompressorInputStream inputStream = new XZCompressorInputStream(new FileInputStream(oldFile)))
|
||||
{
|
||||
fileVersion = inputStream.read();
|
||||
inputStream.skip(1);
|
||||
isFull = inputStream.read() & 0b10000000;
|
||||
inputStream.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
// check if this file can be written to by the file handler
|
||||
if (fileVersion > LOD_SAVE_FILE_VERSION)
|
||||
{
|
||||
// the file we are reading is a newer version,
|
||||
// don't write anything, we don't want to accidentally
|
||||
// delete anything the user may want.
|
||||
return;
|
||||
}
|
||||
if ((temp[1] & 0b10000000) != 0b10000000 && isFull == 0b10000000)
|
||||
{
|
||||
// existing file is complete while new one is only partially generate
|
||||
// this can happen is for some reason loading failed
|
||||
// this doesn't fix the bug, but at least protects old data
|
||||
ClientApi.LOGGER.error("LOD file write error. Attempted to overwrite complete region with incomplete one [" + fileName + "]");
|
||||
return;
|
||||
}
|
||||
// if we got this far then we are good
|
||||
// to overwrite the old file
|
||||
}
|
||||
// the old file is good, now create a new temporary save file
|
||||
File newFile = new File(fileName + TMP_FILE_EXTENSION);
|
||||
try (XZCompressorOutputStream outputStream = new XZCompressorOutputStream(new FileOutputStream(newFile), 3))
|
||||
{
|
||||
// add the version of this file
|
||||
outputStream.write(LOD_SAVE_FILE_VERSION);
|
||||
|
||||
// add each LodChunk to the file
|
||||
outputStream.write(temp);
|
||||
outputStream.close();
|
||||
|
||||
// overwrite the old file with the new one
|
||||
Files.move(newFile.toPath(), oldFile.toPath(), StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
ClientApi.LOGGER.error("LOD file write error. Unable to create parent directory for [" + oldFile + "] error [" + e.getMessage() + "]: ");
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
else
|
||||
{
|
||||
ClientApi.LOGGER.error("LOD file write error. Unable to write to [" + fileName + "] error [" + e.getMessage() + "]: ");
|
||||
// the file exists, make sure it
|
||||
// is the correct version.
|
||||
// (to make sure we don't overwrite a newer
|
||||
// version file if it exists)
|
||||
int fileVersion = LOD_SAVE_FILE_VERSION;
|
||||
try (FileInputStream fileInStream = new FileInputStream(oldFile))
|
||||
{
|
||||
XZCompressorInputStream inputStream = new XZCompressorInputStream(fileInStream);
|
||||
fileVersion = inputStream.read();
|
||||
inputStream.skip(1);
|
||||
isFileFullyGened = (inputStream.read() & 0b10000000) != 0;
|
||||
inputStream.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
ClientApi.LOGGER.warn("LOD file write warning. Unable to read existing file [" + oldFile + "] version. Treating it as latest version. [" + e.getMessage() + "]: ");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// check if this file can be written to by the file handler
|
||||
if (fileVersion > LOD_SAVE_FILE_VERSION)
|
||||
{
|
||||
// the file we are reading is a newer version,
|
||||
// don't write anything, we don't want to accidentally
|
||||
// delete anything the user may want.
|
||||
continue;
|
||||
}
|
||||
// if we got this far then we are good
|
||||
// to overwrite the old file
|
||||
}
|
||||
|
||||
// Now create a new temporary save file
|
||||
File tempFile = new File(oldFile.getPath() + TMP_FILE_EXTENSION);
|
||||
try (FileOutputStream fileOutStream = new FileOutputStream(tempFile))
|
||||
{
|
||||
XZCompressorOutputStream outputStream = new XZCompressorOutputStream(fileOutStream, 3);
|
||||
// add the version of this file
|
||||
outputStream.write(LOD_SAVE_FILE_VERSION);
|
||||
// add each LodChunk to the file
|
||||
boolean isNewDataFullyGened = region.getLevel(detailLevel).writeData(new DataOutputStream(outputStream));
|
||||
outputStream.close();
|
||||
|
||||
if (!isNewDataFullyGened && isFileFullyGened)
|
||||
{
|
||||
// existing file is complete while new one is only partially generate
|
||||
// this can happen is for some reason loading failed
|
||||
// this doesn't fix the bug, but at least protects old data
|
||||
ClientApi.LOGGER.error("LOD file write error. Attempted to overwrite complete region with incomplete one [" + oldFile + "]");
|
||||
try {
|
||||
tempFile.delete();
|
||||
} catch (SecurityException e) {
|
||||
// Failed to delete temp file... just continue.
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
ClientApi.LOGGER.error("LOD file write error. Unable to write to temp file [" + tempFile + "] error [" + e.getMessage() + "]: ");
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
|
||||
// overwrite the old file with the new one
|
||||
try {
|
||||
Files.move(tempFile.toPath(), oldFile.toPath(), StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (IOException e) {
|
||||
ClientApi.LOGGER.error("LOD file write error. Unable to update file [" + oldFile + "] error [" + e.getMessage() + "]: ");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void saveRegionFile (byte[] regionFile, RegionPos regionPos, DistanceGenerationMode generationMode, byte detailLevel, VerticalQuality verticalQuality)
|
||||
{
|
||||
int regionX = regionPos.x;
|
||||
int regionZ = regionPos.z;
|
||||
String fileName = getFileNameAndPathForRegion(regionX, regionZ, generationMode, detailLevel, verticalQuality);
|
||||
|
||||
if (fileName != null)
|
||||
{
|
||||
File oldFile = new File(fileName);
|
||||
File newFile = new File(fileName + TMP_FILE_EXTENSION);
|
||||
try (OutputStream os = new FileOutputStream(newFile))
|
||||
{
|
||||
os.write(regionFile);
|
||||
Files.move(newFile.toPath(), oldFile.toPath(), StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
|
||||
os.close();
|
||||
}
|
||||
catch (IOException ioEx)
|
||||
{
|
||||
ClientApi.LOGGER.error("LOD file write error. Unable to write to [" + fileName + "] error [" + ioEx.getMessage() + "]: ");
|
||||
ioEx.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getRegionFile (RegionPos regionPos, DistanceGenerationMode generationMode, byte detailLevel, VerticalQuality verticalQuality)
|
||||
{
|
||||
int regionX = regionPos.x;
|
||||
int regionZ = regionPos.z;
|
||||
String fileName = getFileNameAndPathForRegion(regionX, regionZ, generationMode, detailLevel, verticalQuality);
|
||||
if (fileName != null)
|
||||
{
|
||||
File file = new File(fileName);
|
||||
try (InputStream is = new FileInputStream(file))
|
||||
{
|
||||
byte[] data = ThreadMapUtil.getSaveContainer(detailLevel);
|
||||
is.read(data);
|
||||
is.close();
|
||||
return Arrays.copyOf(data, (int) file.length());
|
||||
}
|
||||
catch (IOException ioEx)
|
||||
{
|
||||
ClientApi.LOGGER.error("LOD file read error. Unable to read to [" + fileName + "] error [" + ioEx.getMessage() + "]: ");
|
||||
ioEx.printStackTrace();
|
||||
}
|
||||
}
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
|
||||
//================//
|
||||
// helper methods //
|
||||
//================//
|
||||
|
||||
public int getHashFromFile(RegionPos regionPos, DistanceGenerationMode generationMode, byte detailLevel, VerticalQuality verticalQuality)
|
||||
{
|
||||
int regionX = regionPos.x;
|
||||
int regionZ = regionPos.z;
|
||||
String fileName = getFileNameAndPathForRegion(regionX, regionZ, generationMode, detailLevel, verticalQuality);
|
||||
if (fileName == null)
|
||||
return 0;
|
||||
|
||||
File file = new File(fileName);
|
||||
return file.hashCode();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the file that should contain the
|
||||
* region at the given x and z. <br>
|
||||
@@ -460,26 +346,39 @@ public class LodDimensionFileHandler
|
||||
* <p>
|
||||
* Returns null if there is an IO or security Exception.
|
||||
*/
|
||||
private String getFileNameAndPathForRegion(int regionX, int regionZ, DistanceGenerationMode generationMode, byte detailLevel, VerticalQuality verticalQuality)
|
||||
{
|
||||
try
|
||||
{
|
||||
// saveFolder is something like
|
||||
// ".\Super Flat\DIM-1\data\"
|
||||
// or
|
||||
// ".\Super Flat\data\"
|
||||
return dimensionDataSaveFolder.getCanonicalPath() + File.separatorChar +
|
||||
verticalQuality + File.separatorChar +
|
||||
generationMode.toString() + File.separatorChar +
|
||||
DETAIL_FOLDER_NAME_PREFIX + detailLevel + File.separatorChar +
|
||||
FILE_NAME_PREFIX + "." + regionX + "." + regionZ + FILE_EXTENSION;
|
||||
}
|
||||
catch (IOException | SecurityException e)
|
||||
{
|
||||
ClientApi.LOGGER.warn("Unable to get the filename for the region [" + regionX + ", " + regionZ + "], error: [" + e.getMessage() + "], stacktrace: ");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
||||
private String getFileBasePath() {
|
||||
try {
|
||||
return dimensionDataSaveFolder.getCanonicalPath() + File.separatorChar;
|
||||
} catch (IOException e) {
|
||||
ClientApi.LOGGER.warn("Unable to get the base save file path. One possible cause is that"
|
||||
+ " the process failed to read the current path location due to security configs.");
|
||||
throw new RuntimeException("DistantHorizons Get Save File Path Failure");
|
||||
}
|
||||
}
|
||||
|
||||
private File getRegionFile(int regionX, int regionZ, DistanceGenerationMode genMode, byte detail, VerticalQuality vertQuality) {
|
||||
return new File(getFileBasePath() + vertQuality + File.separatorChar +
|
||||
genMode + File.separatorChar +
|
||||
DETAIL_FOLDER_NAME_PREFIX + detail + File.separatorChar +
|
||||
FILE_NAME_PREFIX + "." + regionX + "." + regionZ + FILE_EXTENSION);
|
||||
}
|
||||
|
||||
// Return null if no file found
|
||||
private File getBestMatchingRegionFile(byte detailLevel, int regionX, int regionZ, DistanceGenerationMode targetGenMode, VerticalQuality targetVertQuality) {
|
||||
DistanceGenerationMode genMode = targetGenMode;
|
||||
// Search from least GenMode to max GenMode, than least vertQuality to max vertQuality
|
||||
do {
|
||||
File file = getRegionFile(regionX, regionZ, genMode, detailLevel, targetVertQuality);
|
||||
if (file.exists()) return file; // Found target file.
|
||||
targetGenMode = DistanceGenerationMode.next(targetGenMode);
|
||||
if (targetGenMode == null) { // Failed to find any files for this vertQuality. Try next one up.
|
||||
targetGenMode = genMode;
|
||||
targetVertQuality = VerticalQuality.next(targetVertQuality);
|
||||
}
|
||||
} while (targetVertQuality != null);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -200,6 +200,9 @@ public class VertexOptimizer
|
||||
public final Map<LodDirection, byte[]> skyLights;
|
||||
public byte blockLight;
|
||||
|
||||
boolean skipTop;
|
||||
boolean skipBot;
|
||||
|
||||
|
||||
|
||||
/** creates an empty box */
|
||||
@@ -317,15 +320,13 @@ public class VertexOptimizer
|
||||
int maxY = getMaxY();
|
||||
long singleAdjDataPoint;
|
||||
|
||||
/* TODO implement attached vertical face culling
|
||||
// TODO transparency uncomment final condition to see ocean floor
|
||||
//Up direction case
|
||||
if(DataPointUtil.doesItExist(adjData.get(Direction.UP)))
|
||||
{
|
||||
height = DataPointUtil.getHeight(singleAdjDataPoint);
|
||||
depth = DataPointUtil.getDepth(singleAdjDataPoint);
|
||||
}*/
|
||||
singleAdjDataPoint = adjData.get(LodDirection.UP)[0];
|
||||
skipTop = DataPointUtil.doesItExist(singleAdjDataPoint) && DataPointUtil.getDepth(singleAdjDataPoint) == maxY;// && DataPointUtil.getAlpha(singleAdjDataPoint) == 255;
|
||||
//Down direction case
|
||||
singleAdjDataPoint = adjData.get(LodDirection.DOWN)[0];
|
||||
skipBot = DataPointUtil.doesItExist(singleAdjDataPoint) && DataPointUtil.getHeight(singleAdjDataPoint) == minY;// && DataPointUtil.getAlpha(singleAdjDataPoint) == 255;
|
||||
if(DataPointUtil.doesItExist(singleAdjDataPoint))
|
||||
skyLights.get(LodDirection.DOWN)[0] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
|
||||
else
|
||||
@@ -351,17 +352,22 @@ public class VertexOptimizer
|
||||
boolean toFinish = false;
|
||||
int toFinishIndex = 0;
|
||||
boolean allAbove = true;
|
||||
// TODO transparency ocean floor fix
|
||||
//boolean isOpaque = ((colorMap[0] >> 24) & 0xFF) == 255;
|
||||
for (i = 0; i < dataPoint.length; i++)
|
||||
{
|
||||
singleAdjDataPoint = dataPoint[i];
|
||||
|
||||
if (DataPointUtil.isVoid(singleAdjDataPoint) || !DataPointUtil.doesItExist(singleAdjDataPoint))
|
||||
break;
|
||||
|
||||
// TODO transparency ocean floor fix
|
||||
//if (isOpaque && DataPointUtil.getAlpha(singleAdjDataPoint) != 255)
|
||||
// continue;
|
||||
|
||||
height = DataPointUtil.getHeight(singleAdjDataPoint);
|
||||
depth = DataPointUtil.getDepth(singleAdjDataPoint);
|
||||
|
||||
if (depth <= maxY)
|
||||
if (depth < maxY)
|
||||
{
|
||||
allAbove = false;
|
||||
if (height < minY)
|
||||
@@ -415,7 +421,7 @@ public class VertexOptimizer
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (height >= maxY)//depth > minY &&
|
||||
else if (height >= maxY)// && depth > minY
|
||||
{
|
||||
// the adj data intersects the higher part of the current data
|
||||
// we start the creation of a new face
|
||||
@@ -488,13 +494,14 @@ public class VertexOptimizer
|
||||
boxOffset[Z] = zOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if the given direction should be rendered.
|
||||
*/
|
||||
/** returns true if the given direction should be rendered. */
|
||||
public boolean shouldRenderFace(LodDirection lodDirection, int adjIndex)
|
||||
{
|
||||
if (lodDirection == LodDirection.UP || lodDirection == LodDirection.DOWN)
|
||||
return adjIndex == 0;
|
||||
if (lodDirection == LodDirection.UP)
|
||||
return adjIndex == 0 && !skipTop;
|
||||
if (lodDirection == LodDirection.DOWN)
|
||||
return adjIndex == 0 && !skipBot;
|
||||
|
||||
return !(adjHeight.get(lodDirection)[adjIndex] == VOID_FACE && adjDepth.get(lodDirection)[adjIndex] == VOID_FACE);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
|
||||
package com.seibel.lod.core.objects.lod;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* A level container is a quad tree level
|
||||
*/
|
||||
@@ -99,13 +103,13 @@ public interface LevelContainer
|
||||
* @param posZ z position in the detail level to update
|
||||
*/
|
||||
void updateData(LevelContainer lowerLevelContainer, int posX, int posZ);
|
||||
|
||||
|
||||
/**
|
||||
* This will give the data to save in the file
|
||||
* @return data as a String
|
||||
* This will write the raw data with metadata to the output stream
|
||||
* @return isAllGenerated whether the data is all generated
|
||||
* @throws IOException
|
||||
*/
|
||||
byte[] toDataString();
|
||||
|
||||
boolean writeData(DataOutputStream output) throws IOException;
|
||||
|
||||
/**
|
||||
* This will give the data to save in the file
|
||||
|
||||
@@ -78,9 +78,9 @@ public class LodDimension
|
||||
/** stores if the region at the given x and z index needs to be saved to disk */
|
||||
private volatile boolean[][] isRegionDirty;
|
||||
/** stores if the region at the given x and z index needs to be regenerated */
|
||||
private volatile boolean[][] regenRegionBuffer;
|
||||
/** stores if the buffer size at the given x and z index needs to be changed */
|
||||
private volatile boolean[][] recreateRegionBuffer;
|
||||
// Use int because I need Tri state:
|
||||
// 0: both buffer good. 1: the displaying buffer good. 2: both buffer bad.
|
||||
private volatile int[][] regenRegionBuffer;
|
||||
|
||||
/**
|
||||
* if true that means there are regions in this dimension
|
||||
@@ -143,13 +143,14 @@ public class LodDimension
|
||||
|
||||
regions = new LodRegion[width][width];
|
||||
isRegionDirty = new boolean[width][width];
|
||||
regenRegionBuffer = new boolean[width][width];
|
||||
recreateRegionBuffer = new boolean[width][width];
|
||||
regenRegionBuffer = new int[width][width];
|
||||
|
||||
center = new RegionPos(0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//FIXME: Race condition on this move and other reading regions!
|
||||
/**
|
||||
* Move the center of this LodDimension and move all owned
|
||||
* regions over by the given x and z offset. <br><br>
|
||||
@@ -167,9 +168,10 @@ public class LodDimension
|
||||
if (Math.abs(xOffset) >= width || Math.abs(zOffset) >= width)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
for (int z = 0; z < width; z++)
|
||||
for (int z = 0; z < width; z++) {
|
||||
regions[x][z] = null;
|
||||
|
||||
regenRegionBuffer[x][z] = 0;
|
||||
}
|
||||
// update the new center
|
||||
center.x += xOffset;
|
||||
center.z += zOffset;
|
||||
@@ -186,10 +188,14 @@ public class LodDimension
|
||||
{
|
||||
for (int z = 0; z < width; z++)
|
||||
{
|
||||
if (x + xOffset < width)
|
||||
if (x + xOffset < width) {
|
||||
regions[x][z] = regions[x + xOffset][z];
|
||||
else
|
||||
regenRegionBuffer[x][z] = regenRegionBuffer[x + xOffset][z];
|
||||
}
|
||||
else {
|
||||
regions[x][z] = null;
|
||||
regenRegionBuffer[x][z] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,11 +206,14 @@ public class LodDimension
|
||||
{
|
||||
for (int z = 0; z < width; z++)
|
||||
{
|
||||
if (x + xOffset >= 0)
|
||||
if (x + xOffset >= 0) {
|
||||
regions[x][z] = regions[x + xOffset][z];
|
||||
else
|
||||
regenRegionBuffer[x][z] = regenRegionBuffer[x + xOffset][z];
|
||||
}
|
||||
else {
|
||||
regions[x][z] = null;
|
||||
}
|
||||
regenRegionBuffer[x][z] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,10 +226,14 @@ public class LodDimension
|
||||
{
|
||||
for (int z = 0; z < width; z++)
|
||||
{
|
||||
if (z + zOffset < width)
|
||||
if (z + zOffset < width) {
|
||||
regions[x][z] = regions[x][z + zOffset];
|
||||
else
|
||||
regenRegionBuffer[x][z] = regenRegionBuffer[x][z + zOffset];
|
||||
}
|
||||
else {
|
||||
regions[x][z] = null;
|
||||
regenRegionBuffer[x][z] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,10 +244,15 @@ public class LodDimension
|
||||
{
|
||||
for (int z = width - 1; z >= 0; z--)
|
||||
{
|
||||
if (z + zOffset >= 0)
|
||||
if (z + zOffset >= 0) {
|
||||
regions[x][z] = regions[x][z + zOffset];
|
||||
else
|
||||
regenRegionBuffer[x][z] = regenRegionBuffer[x][z + zOffset];
|
||||
}
|
||||
else {
|
||||
regions[x][z] = null;
|
||||
regenRegionBuffer[x][z] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,6 +328,32 @@ public class LodDimension
|
||||
|
||||
regions[xIndex][zIndex] = newRegion;
|
||||
}
|
||||
public interface PosComsumer {
|
||||
void run(int x, int z);
|
||||
}
|
||||
|
||||
public void iterateWithSpiral(PosComsumer r) {
|
||||
int ox,oy,dx,dy;
|
||||
ox = oy = dx = 0;
|
||||
dy = -1;
|
||||
int len = regions.length;
|
||||
int maxI = len*len;
|
||||
int halfLen = len/2;
|
||||
for(int i =0; i < maxI; i++){
|
||||
if ((-halfLen <= ox) && (ox <= halfLen) && (-halfLen <= oy) && (oy <= halfLen)){
|
||||
int x = ox+halfLen;
|
||||
int z = oy+halfLen;
|
||||
r.run(x, z);
|
||||
}
|
||||
if( (ox == oy) || ((ox < 0) && (ox == -oy)) || ((ox > 0) && (ox == 1-oy))){
|
||||
int temp = dx;
|
||||
dx = -dy;
|
||||
dy = temp;
|
||||
}
|
||||
ox += dx;
|
||||
oy += dy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -325,116 +369,100 @@ public class LodDimension
|
||||
|
||||
// don't run the tree cutter multiple times
|
||||
// for the same location
|
||||
if (newPlayerChunk.getX() != lastCutChunk.getX() || newPlayerChunk.getZ() != lastCutChunk.getZ())
|
||||
{
|
||||
if (newPlayerChunk.getX() != lastCutChunk.getX() || newPlayerChunk.getZ() != lastCutChunk.getZ()) {
|
||||
lastCutChunk = newPlayerChunk;
|
||||
|
||||
Thread thread = new Thread(() ->
|
||||
{
|
||||
int regionX;
|
||||
int regionZ;
|
||||
int minDistance;
|
||||
byte detail;
|
||||
byte minAllowedDetailLevel;
|
||||
|
||||
|
||||
Runnable thread = () -> {
|
||||
|
||||
// go over every region in the dimension
|
||||
for (int x = 0; x < regions.length; x++)
|
||||
{
|
||||
for (int z = 0; z < regions.length; z++)
|
||||
{
|
||||
regionX = (x + center.x) - halfWidth;
|
||||
regionZ = (z + center.z) - halfWidth;
|
||||
|
||||
if (regions[x][z] != null)
|
||||
{
|
||||
// check what detail level this region should be
|
||||
// and cut it if it is higher then that
|
||||
minDistance = LevelPosUtil.minDistance(LodUtil.REGION_DETAIL_LEVEL, regionX, regionZ, playerPosX, playerPosZ);
|
||||
detail = DetailDistanceUtil.getTreeCutDetailFromDistance(minDistance);
|
||||
minAllowedDetailLevel = DetailDistanceUtil.getCutLodDetail(detail);
|
||||
|
||||
if (regions[x][z].getMinDetailLevel() > minAllowedDetailLevel)
|
||||
{
|
||||
regions[x][z].cutTree(minAllowedDetailLevel);
|
||||
recreateRegionBuffer[x][z] = true;
|
||||
}
|
||||
iterateWithSpiral((int x, int z) -> {
|
||||
int regionX;
|
||||
int regionZ;
|
||||
int minDistance;
|
||||
byte detail;
|
||||
byte minAllowedDetailLevel;
|
||||
regionX = (x + center.x) - halfWidth;
|
||||
regionZ = (z + center.z) - halfWidth;
|
||||
|
||||
if (regions[x][z] != null) {
|
||||
// check what detail level this region should be
|
||||
// and cut it if it is higher then that
|
||||
minDistance = LevelPosUtil.minDistance(LodUtil.REGION_DETAIL_LEVEL, regionX, regionZ,
|
||||
playerPosX, playerPosZ);
|
||||
detail = DetailDistanceUtil.getTreeCutDetailFromDistance(minDistance);
|
||||
minAllowedDetailLevel = DetailDistanceUtil.getCutLodDetail(detail);
|
||||
|
||||
if (regions[x][z].getMinDetailLevel() > minAllowedDetailLevel) {
|
||||
regions[x][z].cutTree(minAllowedDetailLevel);
|
||||
regenRegionBuffer[x][z] = 2;
|
||||
regenDimensionBuffers = true;
|
||||
}
|
||||
}// region z
|
||||
}// region z
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
cutAndExpandThread.execute(thread);
|
||||
}
|
||||
}
|
||||
|
||||
/** Either expands or loads all regions in the rendered LOD area */
|
||||
public void expandOrLoadRegionsAsync(int playerPosX, int playerPosZ)
|
||||
{
|
||||
public void expandOrLoadRegionsAsync(int playerPosX, int playerPosZ) {
|
||||
DistanceGenerationMode generationMode = CONFIG.client().worldGenerator().getDistanceGenerationMode();
|
||||
AbstractChunkPosWrapper newPlayerChunk = FACTORY.createChunkPos(LevelPosUtil.getChunkPos((byte) 0, playerPosX), LevelPosUtil.getChunkPos((byte) 0, playerPosZ));
|
||||
AbstractChunkPosWrapper newPlayerChunk = FACTORY.createChunkPos(LevelPosUtil.getChunkPos((byte) 0, playerPosX),
|
||||
LevelPosUtil.getChunkPos((byte) 0, playerPosZ));
|
||||
VerticalQuality verticalQuality = CONFIG.client().graphics().quality().getVerticalQuality();
|
||||
|
||||
|
||||
|
||||
if (lastExpandedChunk == null)
|
||||
lastExpandedChunk = FACTORY.createChunkPos(newPlayerChunk.getX() + 1, newPlayerChunk.getZ() - 1);
|
||||
|
||||
|
||||
// don't run the expander multiple times
|
||||
// for the same location
|
||||
if (newPlayerChunk.getX() != lastExpandedChunk.getX() || newPlayerChunk.getZ() != lastExpandedChunk.getZ())
|
||||
{
|
||||
if (newPlayerChunk.getX() != lastExpandedChunk.getX() || newPlayerChunk.getZ() != lastExpandedChunk.getZ()) {
|
||||
lastExpandedChunk = newPlayerChunk;
|
||||
|
||||
Thread thread = new Thread(() ->
|
||||
{
|
||||
int regionX;
|
||||
int regionZ;
|
||||
LodRegion region;
|
||||
int minDistance;
|
||||
byte detail;
|
||||
byte levelToGen;
|
||||
|
||||
for (int x = 0; x < regions.length; x++)
|
||||
{
|
||||
for (int z = 0; z < regions.length; z++)
|
||||
{
|
||||
regionX = (x + center.x) - halfWidth;
|
||||
regionZ = (z + center.z) - halfWidth;
|
||||
final RegionPos regionPos = new RegionPos(regionX, regionZ);
|
||||
region = regions[x][z];
|
||||
|
||||
minDistance = LevelPosUtil.minDistance(LodUtil.REGION_DETAIL_LEVEL, regionX, regionZ, playerPosX, playerPosZ);
|
||||
detail = DetailDistanceUtil.getTreeGenDetailFromDistance(minDistance);
|
||||
levelToGen = DetailDistanceUtil.getLodGenDetail(detail).detailLevel;
|
||||
|
||||
// check that the region isn't null and at least this detail level
|
||||
if (region == null || region.getGenerationMode() != generationMode)
|
||||
{
|
||||
// First case, region has to be created
|
||||
|
||||
// try to get the region from file
|
||||
regions[x][z] = getRegionFromFile(regionPos, levelToGen, generationMode, verticalQuality);
|
||||
|
||||
// if there is no region file create an empty region
|
||||
if (regions[x][z] == null)
|
||||
regions[x][z] = new LodRegion(levelToGen, regionPos, generationMode, verticalQuality);
|
||||
|
||||
regenRegionBuffer[x][z] = true;
|
||||
regenDimensionBuffers = true;
|
||||
recreateRegionBuffer[x][z] = true;
|
||||
}
|
||||
else if (region.getMinDetailLevel() > levelToGen)
|
||||
{
|
||||
// Second case, the region exists at a higher detail level.
|
||||
|
||||
// Expand the region by introducing the missing layer
|
||||
region.growTree(levelToGen);
|
||||
regions[x][z] = getRegionFromFile(regionPos, levelToGen, generationMode, verticalQuality);
|
||||
recreateRegionBuffer[x][z] = true;
|
||||
}
|
||||
|
||||
Runnable thread = () -> {
|
||||
|
||||
iterateWithSpiral((int x, int z) -> {
|
||||
int regionX;
|
||||
int regionZ;
|
||||
LodRegion region;
|
||||
int minDistance;
|
||||
byte detail;
|
||||
byte levelToGen;
|
||||
regionX = (x + center.x) - halfWidth;
|
||||
regionZ = (z + center.z) - halfWidth;
|
||||
final RegionPos regionPos = new RegionPos(regionX, regionZ);
|
||||
region = regions[x][z];
|
||||
|
||||
minDistance = LevelPosUtil.minDistance(LodUtil.REGION_DETAIL_LEVEL, regionX, regionZ, playerPosX,
|
||||
playerPosZ);
|
||||
detail = DetailDistanceUtil.getTreeGenDetailFromDistance(minDistance);
|
||||
levelToGen = DetailDistanceUtil.getLodGenDetail(detail).detailLevel;
|
||||
|
||||
// check that the region isn't null and at least this detail level
|
||||
if (region == null || region.getGenerationMode() != generationMode) {
|
||||
// First case, region has to be created
|
||||
|
||||
// try to get the region from file
|
||||
regions[x][z] = getRegionFromFile(regionPos, levelToGen, generationMode, verticalQuality);
|
||||
|
||||
// if there is no region file create an empty region
|
||||
if (regions[x][z] == null)
|
||||
regions[x][z] = new LodRegion(levelToGen, regionPos, generationMode, verticalQuality);
|
||||
|
||||
regenRegionBuffer[x][z] = 2;
|
||||
regenDimensionBuffers = true;
|
||||
} else if (region.getMinDetailLevel() > levelToGen) {
|
||||
// Second case, the region exists at a higher detail level.
|
||||
|
||||
// Expand the region by introducing the missing layer
|
||||
region.growTree(levelToGen);
|
||||
regions[x][z] = getRegionFromFile(regionPos, levelToGen, generationMode, verticalQuality);
|
||||
regenRegionBuffer[x][z] = 2;
|
||||
regenDimensionBuffers = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
cutAndExpandThread.execute(thread);
|
||||
}
|
||||
}
|
||||
@@ -467,7 +495,7 @@ public class LodDimension
|
||||
int zIndex = (regionPosZ - center.z) + halfWidth;
|
||||
|
||||
isRegionDirty[xIndex][zIndex] = true;
|
||||
regenRegionBuffer[xIndex][zIndex] = true;
|
||||
regenRegionBuffer[xIndex][zIndex] = 2;
|
||||
regenDimensionBuffers = true;
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
@@ -509,7 +537,7 @@ public class LodDimension
|
||||
int zIndex = (regionPosZ - center.z) + halfWidth;
|
||||
|
||||
isRegionDirty[xIndex][zIndex] = true;
|
||||
regenRegionBuffer[xIndex][zIndex] = true;
|
||||
regenRegionBuffer[xIndex][zIndex] = 2;
|
||||
regenDimensionBuffers = true;
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
@@ -529,7 +557,7 @@ public class LodDimension
|
||||
{
|
||||
int xIndex = (xRegion - center.x) + halfWidth;
|
||||
int zIndex = (zRegion - center.z) + halfWidth;
|
||||
regenRegionBuffer[xIndex][zIndex] = true;
|
||||
regenRegionBuffer[xIndex][zIndex] = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -751,31 +779,35 @@ public class LodDimension
|
||||
{
|
||||
if (detailLevel > LodUtil.REGION_DETAIL_LEVEL)
|
||||
throw new IllegalArgumentException("getLodFromCoordinates given a level of \"" + detailLevel + "\" when \"" + LodUtil.REGION_DETAIL_LEVEL + "\" is the max.");
|
||||
|
||||
LodRegion region = getRegion(detailLevel, posX, posZ);
|
||||
|
||||
int xRegion = LevelPosUtil.getRegion(detailLevel, posX);
|
||||
int zRegion = LevelPosUtil.getRegion(detailLevel, posZ);
|
||||
LodRegion region = getRegion(xRegion, zRegion);
|
||||
if (region == null)
|
||||
return;
|
||||
|
||||
markRegionBufferToRegen(xRegion, zRegion);
|
||||
region.clear(detailLevel, posX, posZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the buffer at the given array index needs
|
||||
* to have its buffer regenerated.
|
||||
* to have its buffer regenerated. Also decrease the state by 1
|
||||
*/
|
||||
public boolean doesRegionNeedBufferRegen(int xIndex, int zIndex)
|
||||
public boolean getAndClearRegionNeedBufferRegen(int regionX, int regionZ)
|
||||
{
|
||||
return regenRegionBuffer[xIndex][zIndex] || recreateRegionBuffer[xIndex][zIndex];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets if the buffer at the given array index needs
|
||||
* to have its buffer regenerated.
|
||||
*/
|
||||
public void setRegenRegionBufferByArrayIndex(int xIndex, int zIndex, boolean newRegen)
|
||||
{
|
||||
regenRegionBuffer[xIndex][zIndex] = newRegen;
|
||||
//FIXME: Use actual atomics on regenRegionBuffer
|
||||
//FIXME: Race condition on lodDim move/resize!
|
||||
int xIndex = (regionX - center.x) + halfWidth;
|
||||
int zIndex = (regionZ - center.z) + halfWidth;
|
||||
|
||||
if (xIndex < 0 || xIndex >= width || zIndex < 0 || zIndex >= width)
|
||||
return false;
|
||||
int i = regenRegionBuffer[xIndex][zIndex];
|
||||
if (i > 0) {
|
||||
regenRegionBuffer[xIndex][zIndex]--;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -789,10 +821,13 @@ public class LodDimension
|
||||
{
|
||||
if (detailLevel > LodUtil.REGION_DETAIL_LEVEL)
|
||||
throw new IllegalArgumentException("getLodFromCoordinates given a level of \"" + detailLevel + "\" when \"" + LodUtil.REGION_DETAIL_LEVEL + "\" is the max.");
|
||||
|
||||
LodRegion region = getRegion(detailLevel, posX, posZ);
|
||||
|
||||
int xRegion = LevelPosUtil.getRegion(detailLevel, posX);
|
||||
int zRegion = LevelPosUtil.getRegion(detailLevel, posZ);
|
||||
LodRegion region = getRegion(xRegion, zRegion);
|
||||
if (region == null)
|
||||
return;
|
||||
markRegionBufferToRegen(xRegion, zRegion);
|
||||
|
||||
region.updateArea(detailLevel, posX, posZ);
|
||||
}
|
||||
@@ -873,8 +908,7 @@ public class LodDimension
|
||||
|
||||
regions = new LodRegion[width][width];
|
||||
isRegionDirty = new boolean[width][width];
|
||||
regenRegionBuffer = new boolean[width][width];
|
||||
recreateRegionBuffer = new boolean[width][width];
|
||||
regenRegionBuffer = new int[width][width];
|
||||
|
||||
// populate isRegionDirty
|
||||
for (int i = 0; i < width; i++)
|
||||
|
||||
@@ -19,6 +19,15 @@
|
||||
|
||||
package com.seibel.lod.core.objects.lod;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.LongBuffer;
|
||||
|
||||
import com.seibel.lod.core.dataFormat.*;
|
||||
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
|
||||
import com.seibel.lod.core.util.*;
|
||||
@@ -165,6 +174,100 @@ public class VerticalLevelContainer implements LevelContainer
|
||||
return DataPointUtil.doesItExist(getSingleData(posX, posZ));
|
||||
}
|
||||
|
||||
private long[] readDataVersion6(DataInputStream inputData, int tempMaxVerticalData) throws IOException {
|
||||
int x = size * size * tempMaxVerticalData;
|
||||
byte[] data = new byte[x * Long.BYTES];
|
||||
ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
|
||||
inputData.readFully(data);
|
||||
long[] result = new long[x];
|
||||
bb.asLongBuffer().get(result);
|
||||
patchHeightAndDepth(result,-minHeight);
|
||||
return result;
|
||||
}
|
||||
private long[] readDataVersion7(DataInputStream inputData, int tempMaxVerticalData) throws IOException {
|
||||
int x = size * size * tempMaxVerticalData;
|
||||
byte[] data = new byte[x * Long.BYTES];
|
||||
ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
|
||||
inputData.readFully(data);
|
||||
long[] result = new long[x];
|
||||
bb.asLongBuffer().get(result);
|
||||
patchHeightAndDepth(result, 64 - minHeight);
|
||||
return result;
|
||||
}
|
||||
|
||||
private long[] readDataVersion8(DataInputStream inputData, int tempMaxVerticalData) throws IOException {
|
||||
int x = size * size * tempMaxVerticalData;
|
||||
byte[] data = new byte[x * Long.BYTES];
|
||||
short tempMinHeight = Short.reverseBytes(inputData.readShort());
|
||||
ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
|
||||
inputData.readFully(data);
|
||||
long[] result = new long[x];
|
||||
bb.asLongBuffer().get(result);
|
||||
if (tempMinHeight != minHeight) {
|
||||
patchHeightAndDepth(result,tempMinHeight - minHeight);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static long[] downgradeVerticalSize(int oldVertSize, int newVertSize, long[] data) {
|
||||
long[] dataToMerge = new long[oldVertSize];
|
||||
int size = data.length/oldVertSize;
|
||||
long[] newData = new long[size * newVertSize];
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
System.arraycopy(oldVertSize, i * oldVertSize, dataToMerge, 0, oldVertSize);
|
||||
dataToMerge = DataPointUtil.mergeMultiData(dataToMerge, oldVertSize, newVertSize);
|
||||
System.arraycopy(dataToMerge, 0, newData, i * newVertSize, newVertSize);
|
||||
}
|
||||
return newData;
|
||||
}
|
||||
|
||||
private static void patchHeightAndDepth(long[] data, int offset) {
|
||||
for (int i=0; i<data.length; i++) {
|
||||
data[i] = DataPointUtil.shiftHeightAndDepth(data[i], (short)offset);
|
||||
}
|
||||
}
|
||||
|
||||
public VerticalLevelContainer(DataInputStream inputData, int version, byte expectedDetailLevel) throws IOException {
|
||||
minHeight = SingletonHandler.get(IMinecraftWrapper.class).getWrappedClientWorld().getMinHeight();
|
||||
detailLevel = inputData.readByte();
|
||||
if (detailLevel != expectedDetailLevel)
|
||||
throw new IOException("Invalid Data: The expected detail level should be "+expectedDetailLevel+
|
||||
" but the data header say it's "+detailLevel);
|
||||
|
||||
size = 1 << (LodUtil.REGION_DETAIL_LEVEL - detailLevel);
|
||||
int fileMaxVerticalData = inputData.readByte() & 0b01111111;
|
||||
long[] tempDataContainer = null;
|
||||
|
||||
switch (version) {
|
||||
case 6:
|
||||
tempDataContainer = readDataVersion6(inputData, fileMaxVerticalData);
|
||||
break;
|
||||
case 7:
|
||||
tempDataContainer = readDataVersion7(inputData, fileMaxVerticalData);
|
||||
break;
|
||||
case 8:
|
||||
tempDataContainer = readDataVersion8(inputData, fileMaxVerticalData);
|
||||
break;
|
||||
default:
|
||||
assert false;
|
||||
}
|
||||
|
||||
int targetMaxVerticalData = DetailDistanceUtil.getMaxVerticalData(detailLevel);
|
||||
if (fileMaxVerticalData > targetMaxVerticalData)
|
||||
{
|
||||
verticalSize = targetMaxVerticalData;
|
||||
this.dataContainer = downgradeVerticalSize(fileMaxVerticalData, targetMaxVerticalData, tempDataContainer);
|
||||
}
|
||||
else
|
||||
{
|
||||
verticalSize = fileMaxVerticalData;
|
||||
this.dataContainer = tempDataContainer;
|
||||
}
|
||||
}
|
||||
|
||||
// Deprecated. Please use the DataInputStream version.
|
||||
@Deprecated
|
||||
public VerticalLevelContainer(byte[] inputData, int version)
|
||||
{
|
||||
minHeight = SingletonHandler.get(IMinecraftWrapper.class).getWrappedClientWorld().getMinHeight();
|
||||
@@ -1062,40 +1165,24 @@ public class VerticalLevelContainer implements LevelContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] toDataString()
|
||||
{
|
||||
int index = 0;
|
||||
int x = size * size;
|
||||
int tempIndex;
|
||||
long current;
|
||||
public boolean writeData(DataOutputStream output) throws IOException {
|
||||
output.writeByte(detailLevel);
|
||||
output.writeByte((byte) verticalSize);
|
||||
output.writeByte((byte) (minHeight & 0xFF));
|
||||
output.writeByte((byte) ((minHeight >> 8) & 0xFF));
|
||||
boolean allGenerated = true;
|
||||
byte[] tempData = ThreadMapUtil.getSaveContainer(detailLevel);
|
||||
|
||||
tempData[index] = detailLevel;
|
||||
index++;
|
||||
tempData[index] = (byte) verticalSize;
|
||||
index++;
|
||||
tempData[index] = (byte) (minHeight & 0xFF);
|
||||
index++;
|
||||
tempData[index] = (byte) ((minHeight >> 8) & 0xFF);
|
||||
index++;
|
||||
|
||||
int j;
|
||||
int x = size * size;
|
||||
for (int i = 0; i < x; i++)
|
||||
{
|
||||
for (j = 0; j < verticalSize; j++)
|
||||
for (int j = 0; j < verticalSize; j++)
|
||||
{
|
||||
current = dataContainer[i * verticalSize + j];
|
||||
for (tempIndex = 0; tempIndex < 8; tempIndex++)
|
||||
tempData[index + tempIndex] = (byte) (current >>> (8 * tempIndex));
|
||||
index += 8;
|
||||
long current = dataContainer[i * verticalSize + j];
|
||||
output.writeLong(Long.reverseBytes(current));
|
||||
}
|
||||
if (!DataPointUtil.doesItExist(dataContainer[i]))
|
||||
allGenerated = false;
|
||||
}
|
||||
if (allGenerated)
|
||||
tempData[1] |= 0b10000000;
|
||||
return tempData;
|
||||
return allGenerated;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,14 +30,14 @@ import com.google.common.collect.ImmutableList;
|
||||
*/
|
||||
public class DefaultLodVertexFormats
|
||||
{
|
||||
public static final LodVertexFormatElement ELEMENT_POSITION = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.FLOAT, 3);
|
||||
public static final LodVertexFormatElement ELEMENT_COLOR = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.UBYTE, 4);
|
||||
public static final LodVertexFormatElement ELEMENT_UV = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.FLOAT, 2);
|
||||
public static final LodVertexFormatElement ELEMENT_LIGHT_MAP_UV = new LodVertexFormatElement(1, LodVertexFormatElement.DataType.SHORT, 2);
|
||||
public static final LodVertexFormatElement ELEMENT_NORMAL = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.BYTE, 3);
|
||||
public static final LodVertexFormatElement ELEMENT_PADDING = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.BYTE, 1);
|
||||
public static final LodVertexFormatElement ELEMENT_POSITION = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.FLOAT, 3, false);
|
||||
public static final LodVertexFormatElement ELEMENT_COLOR = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.UBYTE, 4, false);
|
||||
public static final LodVertexFormatElement ELEMENT_UV = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.FLOAT, 2, false);
|
||||
public static final LodVertexFormatElement ELEMENT_LIGHT_MAP_UV = new LodVertexFormatElement(1, LodVertexFormatElement.DataType.SHORT, 2, false);
|
||||
public static final LodVertexFormatElement ELEMENT_NORMAL = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.BYTE, 3, false);
|
||||
public static final LodVertexFormatElement ELEMENT_PADDING = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.BYTE, 1, true);
|
||||
|
||||
public static final LodVertexFormatElement ELEMENT_BLOCK_LIGHT = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.UBYTE, 1);
|
||||
public static final LodVertexFormatElement ELEMENT_BLOCK_LIGHT = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.UBYTE, 1, false);
|
||||
|
||||
|
||||
public static final LodVertexFormat POSITION = new LodVertexFormat(ImmutableList.<LodVertexFormatElement>builder().add(ELEMENT_POSITION).build());
|
||||
@@ -47,5 +47,5 @@ public class DefaultLodVertexFormats
|
||||
public static final LodVertexFormat POSITION_COLOR_TEX = new LodVertexFormat(ImmutableList.<LodVertexFormatElement>builder().add(ELEMENT_POSITION).add(ELEMENT_COLOR).add(ELEMENT_UV).build());
|
||||
public static final LodVertexFormat POSITION_COLOR_TEX_LIGHTMAP = new LodVertexFormat(ImmutableList.<LodVertexFormatElement>builder().add(ELEMENT_POSITION).add(ELEMENT_COLOR).add(ELEMENT_UV).add(ELEMENT_LIGHT_MAP_UV).build());
|
||||
|
||||
public static final LodVertexFormat POSITION_COLOR_BLOCK_LIGHT_SKY_LIGHT = new LodVertexFormat(ImmutableList.<LodVertexFormatElement>builder().add(ELEMENT_POSITION).add(ELEMENT_COLOR).add(ELEMENT_BLOCK_LIGHT).add(ELEMENT_BLOCK_LIGHT).build());
|
||||
public static final LodVertexFormat POSITION_COLOR_BLOCK_LIGHT_SKY_LIGHT = new LodVertexFormat(ImmutableList.<LodVertexFormatElement>builder().add(ELEMENT_POSITION).add(ELEMENT_COLOR).add(ELEMENT_BLOCK_LIGHT).add(ELEMENT_BLOCK_LIGHT).add(ELEMENT_PADDING).add(ELEMENT_PADDING).build());
|
||||
}
|
||||
|
||||
@@ -323,10 +323,10 @@ public class LodBufferBuilder
|
||||
this.elementIndex = (this.elementIndex + 1) % immutablelist.size();
|
||||
this.nextElementByte += this.currentElement.getByteSize();
|
||||
this.currentElement = immutablelist.get(this.elementIndex);
|
||||
// if (LodVertexFormatelement.getUsage() == LodVertexFormatElement.Usage.PADDING)
|
||||
// {
|
||||
// this.nextElement();
|
||||
// }
|
||||
if (currentElement.getIsPadding())
|
||||
{
|
||||
this.nextElement();
|
||||
}
|
||||
|
||||
// if (this.defaultColorSet && this.currentElement.getUsage() == LodVertexFormatElement.Usage.COLOR)
|
||||
// {
|
||||
@@ -458,7 +458,7 @@ public class LodBufferBuilder
|
||||
}
|
||||
|
||||
ByteBuffer bytebuffer = this.buffer.slice();
|
||||
bytebuffer.order(this.buffer.order()); // FORGE: Fix incorrect byte order
|
||||
//bytebuffer.order(this.buffer.order()); // FORGE: Fix incorrect byte order
|
||||
this.buffer.clear();
|
||||
return bytebuffer; // the original method also returned bufferbuilder$drawstate
|
||||
}
|
||||
|
||||
@@ -35,13 +35,15 @@ public class LodVertexBuffer implements AutoCloseable
|
||||
{
|
||||
public int id;
|
||||
public int vertexCount;
|
||||
public final boolean isBufferStorage;
|
||||
public long size = 0;
|
||||
|
||||
public LodVertexBuffer()
|
||||
public LodVertexBuffer(boolean isBufferStorage)
|
||||
{
|
||||
if (GLProxy.getInstance().getGlContext() == GLProxyContext.NONE)
|
||||
throw new IllegalStateException("Thread [" +Thread.currentThread().getName() + "] tried to create a [" + LodVertexBuffer.class.getSimpleName() + "] outside a OpenGL contex.");
|
||||
|
||||
this.id = GL32.glGenBuffers();
|
||||
this.isBufferStorage = isBufferStorage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,13 +39,19 @@ public class LodVertexFormatElement
|
||||
private final int index;
|
||||
private final int count;
|
||||
private final int byteSize;
|
||||
private final boolean isPadding;
|
||||
|
||||
public LodVertexFormatElement(int newIndex, LodVertexFormatElement.DataType newType, int newCount)
|
||||
public LodVertexFormatElement(int newIndex, LodVertexFormatElement.DataType newType, int newCount, boolean isPadding)
|
||||
{
|
||||
this.dataType = newType;
|
||||
this.index = newIndex;
|
||||
this.count = newCount;
|
||||
this.byteSize = newType.getSize() * this.count;
|
||||
this.isPadding = isPadding;
|
||||
}
|
||||
|
||||
public final boolean getIsPadding() {
|
||||
return isPadding;
|
||||
}
|
||||
|
||||
public final LodVertexFormatElement.DataType getType()
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
|
||||
package com.seibel.lod.core.render;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@@ -34,6 +37,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.enums.config.GpuUploadMethod;
|
||||
import com.seibel.lod.core.enums.rendering.DebugMode;
|
||||
import com.seibel.lod.core.enums.rendering.GLProxyContext;
|
||||
import com.seibel.lod.core.util.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
@@ -157,6 +161,9 @@ public class GLProxy
|
||||
*/
|
||||
private GLProxy()
|
||||
{
|
||||
|
||||
boolean enableDebugLogging = CONFIG.client().advanced().debugging().getDebugMode() == DebugMode.SHOW_DETAIL;
|
||||
|
||||
// this must be created on minecraft's render context to work correctly
|
||||
|
||||
ClientApi.LOGGER.info("Creating " + GLProxy.class.getSimpleName() + "... If this is the last message you see in the log there must have been a OpenGL error.");
|
||||
@@ -225,7 +232,21 @@ public class GLProxy
|
||||
|
||||
setGlContext(GLProxyContext.LOD_BUILDER);
|
||||
// TODO: Enable this but disable INFO logging
|
||||
//GLUtil.setupDebugMessageCallback();
|
||||
|
||||
File proxyLog = new File("OpenGL-Lod-ProxyContext.log");
|
||||
try {
|
||||
proxyLog.createNewFile();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (enableDebugLogging)
|
||||
try {
|
||||
GLUtil.setupDebugMessageCallback(new PrintStream(proxyLog));
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// get specific capabilities
|
||||
// Check if we can use the Buffer Storage, which is available in GL4.4 or after
|
||||
@@ -252,8 +273,20 @@ public class GLProxy
|
||||
ClientApi.LOGGER.info("GPU Vendor [" + vendor + "], Preferred upload method is [" + preferredUploadMethod + "].");
|
||||
|
||||
setGlContext(GLProxyContext.PROXY_WORKER);
|
||||
// TODO: Enable this but disable INFO logging
|
||||
//GLUtil.setupDebugMessageCallback();
|
||||
File workerLog = new File("OpenGL-Lod-WorkerContext.log");
|
||||
try {
|
||||
workerLog.createNewFile();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (enableDebugLogging)
|
||||
try {
|
||||
GLUtil.setupDebugMessageCallback(new PrintStream(workerLog));
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//==========//
|
||||
// clean up //
|
||||
|
||||
@@ -40,8 +40,7 @@ public class LodRenderProgram extends ShaderProgram {
|
||||
// Attributes
|
||||
public final int posAttrib;
|
||||
public final int colAttrib;
|
||||
public final int blockSkyLightAttrib;
|
||||
public final int blockLightAttrib;
|
||||
public final int lightAttrib; //Sky light then block light
|
||||
// Uniforms
|
||||
public final int mvmUniform;
|
||||
public final int projUniform;
|
||||
@@ -64,8 +63,7 @@ public class LodRenderProgram extends ShaderProgram {
|
||||
|
||||
posAttrib = getAttributeLocation("vPosition");
|
||||
colAttrib = getAttributeLocation("color");
|
||||
blockSkyLightAttrib = getAttributeLocation("blockSkyLight");
|
||||
blockLightAttrib = getAttributeLocation("blockLight");
|
||||
lightAttrib = getAttributeLocation("light");
|
||||
|
||||
mvmUniform = getUniformLocation("modelViewMatrix");
|
||||
projUniform = getUniformLocation("projectionMatrix");
|
||||
@@ -92,11 +90,15 @@ public class LodRenderProgram extends ShaderProgram {
|
||||
else
|
||||
vao = new VertexAttributePreGL43(); // also binds VertexAttribute
|
||||
//vao.bind();
|
||||
vao.setVertexAttribute(0, posAttrib, VertexAttribute.VertexPointer.addVec3Pointer(false));
|
||||
vao.setVertexAttribute(0, colAttrib, VertexAttribute.VertexPointer.addUnsignedBytesPointer(4, true));
|
||||
vao.setVertexAttribute(0, blockSkyLightAttrib, VertexAttribute.VertexPointer.addUnsignedBytePointer(false));
|
||||
vao.setVertexAttribute(0, blockLightAttrib, VertexAttribute.VertexPointer.addUnsignedBytePointer(false));
|
||||
vao.setVertexAttribute(0, posAttrib, VertexAttribute.VertexPointer.addVec3Pointer(false)); // 4+4+4
|
||||
vao.setVertexAttribute(0, colAttrib, VertexAttribute.VertexPointer.addUnsignedBytesPointer(4, true)); // +4
|
||||
vao.setVertexAttribute(0, lightAttrib, VertexAttribute.VertexPointer.addUnsignedBytesPointer(2, false)); // +4 due to how it aligns
|
||||
try {
|
||||
vao.completeAndCheck(vertexByteCount);
|
||||
} catch (RuntimeException e) {
|
||||
System.out.println(LodUtil.LOD_VERTEX_FORMAT);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// Override ShaderProgram.bind()
|
||||
@@ -135,9 +137,15 @@ public class LodRenderProgram extends ShaderProgram {
|
||||
setUniform(lightMapUniform, lightmapBindPoint);
|
||||
}
|
||||
|
||||
public void fillUniformDataForFog(LodFogConfig fogSettings) {
|
||||
public void fillUniformDataForFog(LodFogConfig fogSettings, boolean isUnderWater) {
|
||||
super.bind();
|
||||
if (fogSettings.fogDrawMode != FogDrawMode.FOG_DISABLED) {
|
||||
if (isUnderWater) {
|
||||
setUniform(fogEnabledUniform, true);
|
||||
setUniform(nearFogEnabledUniform, false);
|
||||
setUniform(farFogEnabledUniform, true);
|
||||
setUniform(farFogStartUniform, 0.0f);
|
||||
setUniform(farFogEndUniform, 0.0f);
|
||||
} else if (fogSettings.fogDrawMode != FogDrawMode.FOG_DISABLED) {
|
||||
setUniform(fogEnabledUniform, true);
|
||||
setUniform(nearFogEnabledUniform, fogSettings.fogDistance != FogDistance.FAR);
|
||||
setUniform(farFogEnabledUniform, fogSettings.fogDistance != FogDistance.NEAR);
|
||||
|
||||
@@ -20,15 +20,14 @@
|
||||
package com.seibel.lod.core.render;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.HashSet;
|
||||
import java.time.Duration;
|
||||
import java.util.Set;
|
||||
|
||||
import org.lwjgl.opengl.GL32;
|
||||
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.builders.bufferBuilding.LodBufferBuilderFactory;
|
||||
import com.seibel.lod.core.builders.bufferBuilding.LodBufferBuilderFactory.VertexBuffersAndOffset;
|
||||
import com.seibel.lod.core.enums.config.GpuUploadMethod;
|
||||
import com.seibel.lod.core.enums.rendering.DebugMode;
|
||||
import com.seibel.lod.core.enums.rendering.FogColorMode;
|
||||
import com.seibel.lod.core.enums.rendering.FogDistance;
|
||||
@@ -40,9 +39,11 @@ import com.seibel.lod.core.objects.math.Vec3f;
|
||||
import com.seibel.lod.core.objects.opengl.LodVertexBuffer;
|
||||
import com.seibel.lod.core.render.objects.LightmapTexture;
|
||||
import com.seibel.lod.core.util.DetailDistanceUtil;
|
||||
import com.seibel.lod.core.util.LevelPosUtil;
|
||||
import com.seibel.lod.core.util.GridList;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.util.MovableGridList;
|
||||
import com.seibel.lod.core.util.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
@@ -58,11 +59,40 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IProfilerWrapper;
|
||||
*/
|
||||
public class LodRenderer
|
||||
{
|
||||
public static class VanillaRenderedChunksList extends GridList<Boolean> {
|
||||
private static final long serialVersionUID = -5448501880911391315L;
|
||||
|
||||
public final int centerX;
|
||||
public final int centerZ;
|
||||
|
||||
public VanillaRenderedChunksList(int range, int centerX, int centerZ) {
|
||||
super(range);
|
||||
this.centerX = centerX;
|
||||
this.centerZ = centerZ;
|
||||
for (int i=0; i<gridSize*gridSize; i++) {
|
||||
add(i, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class LagSpikeCatcher {
|
||||
|
||||
long timer = System.nanoTime();
|
||||
public LagSpikeCatcher() {}
|
||||
public void end(String source) {
|
||||
timer = System.nanoTime() - timer;
|
||||
if (timer> 16000000) { //16 ms
|
||||
ClientApi.LOGGER.info("NOTE: "+source+" took "+Duration.ofNanos(timer)+"!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static final IMinecraftWrapper MC = SingletonHandler.get(IMinecraftWrapper.class);
|
||||
private static final IMinecraftRenderWrapper MC_RENDER = SingletonHandler.get(IMinecraftRenderWrapper.class);
|
||||
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
private static final IReflectionHandler REFLECTION_HANDLER = SingletonHandler.get(IReflectionHandler.class);
|
||||
|
||||
|
||||
public static final int VANILLA_REFRESH_TIMEOUT = 60;
|
||||
/**
|
||||
* If true the LODs colors will be replaced with
|
||||
* a checkerboard, this can be used for debugging.
|
||||
@@ -75,23 +105,11 @@ public class LodRenderer
|
||||
/** This is used to generate the buildable buffers */
|
||||
private final LodBufferBuilderFactory lodBufferBuilderFactory;
|
||||
|
||||
/** Each VertexBuffer represents 1 region */
|
||||
private LodVertexBuffer[][][] vbos;
|
||||
/**
|
||||
* the OpenGL IDs for the vbos of the same indices.
|
||||
* These have to be separate because we can't override the
|
||||
* buffers in the VBOs (and we don't want to)
|
||||
*/
|
||||
private int[][][] storageBufferIds = null;
|
||||
|
||||
// The shader program
|
||||
LodRenderProgram shaderProgram = null;
|
||||
|
||||
private int vbosCenterX = 0;
|
||||
private int vbosCenterZ = 0;
|
||||
|
||||
/** This is used to determine if the LODs should be regenerated */
|
||||
private int[] previousPos = new int[] { 0, 0, 0 };
|
||||
private AbstractBlockPosWrapper previousPos = null;
|
||||
|
||||
// these variables are used to determine if the buffers should be rebuilt
|
||||
private int prevRenderDistance = 0;
|
||||
@@ -115,9 +133,10 @@ public class LodRenderer
|
||||
* This HashSet contains every chunk that Vanilla Minecraft
|
||||
* is going to render
|
||||
*/
|
||||
public boolean[][] vanillaRenderedChunks;
|
||||
public boolean vanillaRenderedChunksChanged;
|
||||
public boolean vanillaRenderedChunksEmptySkip = false;
|
||||
public VanillaRenderedChunksList vanillaRenderedChunks;
|
||||
public int vanillaRenderedChunksCenterX;
|
||||
public int vanillaRenderedChunksCenterZ;
|
||||
public int vanillaRenderedChunksRefreshTimer;
|
||||
|
||||
private boolean canVanillaFogBeDisabled = true;
|
||||
|
||||
@@ -149,8 +168,6 @@ public class LodRenderer
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (MC_RENDER.playerHasBlindnessEffect())
|
||||
{
|
||||
// if the player is blind, don't render LODs,
|
||||
@@ -160,7 +177,12 @@ public class LodRenderer
|
||||
}
|
||||
|
||||
// get MC's shader program
|
||||
// Save all MC render state
|
||||
int currentProgram = GL32.glGetInteger(GL32.GL_CURRENT_PROGRAM);
|
||||
int currentVBO = GL32.glGetInteger(GL32.GL_ARRAY_BUFFER_BINDING);
|
||||
int currentVAO = GL32.glGetInteger(GL32.GL_VERTEX_ARRAY_BINDING);
|
||||
int currentActiveText = GL32.glGetInteger(GL32.GL_ACTIVE_TEXTURE);
|
||||
boolean currentBlend = GL32.glGetBoolean(GL32.GL_BLEND);
|
||||
|
||||
GLProxy glProxy = GLProxy.getInstance();
|
||||
if (canVanillaFogBeDisabled && CONFIG.client().graphics().fogQuality().getDisableVanillaFog())
|
||||
@@ -170,8 +192,17 @@ public class LodRenderer
|
||||
|
||||
// TODO move the buffer regeneration logic into its own class (probably called in the client api instead)
|
||||
// starting here...
|
||||
determineIfLodsShouldRegenerate(lodDim, partialTicks);
|
||||
LagSpikeCatcher updateStatue = new LagSpikeCatcher();
|
||||
updateRegenStatus(lodDim, partialTicks);
|
||||
updateStatue.end("LodDrawSetup:UpdateStatus");
|
||||
|
||||
|
||||
// FIXME: Currently, we check for last Lod Dimension so that we can trigger a cleanup() if dimension has changed
|
||||
// The better thing to do is to call cleanup() on leaving dimensions in the EventApi, but only for client-side.
|
||||
if (markToCleanup) {
|
||||
markToCleanup = false;
|
||||
cleanup(); // This will unset the isSetupComplete, causing a setup() call.
|
||||
}
|
||||
|
||||
//=================//
|
||||
// create the LODs //
|
||||
@@ -182,46 +213,37 @@ public class LodRenderer
|
||||
// 2. we aren't already regenerating the LODs
|
||||
// 3. we aren't waiting for the build and draw buffers to swap
|
||||
// (this is to prevent thread conflicts)
|
||||
if ((partialRegen || fullRegen) && !lodBufferBuilderFactory.generatingBuffers && !lodBufferBuilderFactory.newBuffersAvailable())
|
||||
{
|
||||
// generate the LODs on a separate thread to prevent stuttering or freezing
|
||||
lodBufferBuilderFactory.generateLodBuffersAsync(this, lodDim, MC.getPlayerBlockPos().getX(), MC.getPlayerBlockPos().getY(), MC.getPlayerBlockPos().getZ(), fullRegen);
|
||||
|
||||
if (lodBufferBuilderFactory.updateAndSwapLodBuffersAsync(this, lodDim, MC.getPlayerBlockPos().getX(),
|
||||
MC.getPlayerBlockPos().getY(), MC.getPlayerBlockPos().getZ(), partialRegen, fullRegen)) {
|
||||
// the regen process has been started,
|
||||
// it will be done when lodBufferBuilder.newBuffersAvailable()
|
||||
// is true
|
||||
// it will be done when lodBufferBuilder.newBuffersAvailable() is true
|
||||
fullRegen = false;
|
||||
partialRegen = false;
|
||||
}
|
||||
|
||||
// TODO move the buffer regeneration logic into its own class (probably called in the client api instead)
|
||||
// ...ending here
|
||||
|
||||
if (lodBufferBuilderFactory.newBuffersAvailable())
|
||||
{
|
||||
swapBuffers();
|
||||
}
|
||||
// Get the front buffers to draw
|
||||
MovableGridList<LodVertexBuffer[]> vbos = lodBufferBuilderFactory.getFrontBuffers();
|
||||
int vbosCenterX = lodBufferBuilderFactory.getFrontBuffersCenterX();
|
||||
int vbosCenterZ = lodBufferBuilderFactory.getFrontBuffersCenterZ();
|
||||
|
||||
// @Unused
|
||||
if (vbos == null) {
|
||||
// There is still no vbos, which means nothing needs to be drawn. So no rendering needed
|
||||
// (Vbos should be setup by now)
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: Currently, we check for last Lod Dimension so that we can trigger a cleanup() if dimension has changed
|
||||
// The better thing to do is to call cleanup() on leaving dimensions in the EventApi, but only for client-side.
|
||||
if (markToCleanup) {
|
||||
markToCleanup = false;
|
||||
cleanup(); // This will unset the isSetupComplete, causing a setup() call.
|
||||
}
|
||||
|
||||
//===================//
|
||||
// draw params setup //
|
||||
//===================//
|
||||
|
||||
profiler.push("LOD draw setup");
|
||||
LagSpikeCatcher drawSetup = new LagSpikeCatcher();
|
||||
|
||||
/*---------Set GL State--------*/
|
||||
// Make sure to unbind current VBO so we don't mess up vanilla settings
|
||||
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, 0);
|
||||
|
||||
// set the required open GL settings
|
||||
if (CONFIG.client().advanced().debugging().getDebugMode() == DebugMode.SHOW_DETAIL_WIREFRAME)
|
||||
GL32.glPolygonMode(GL32.GL_FRONT_AND_BACK, GL32.GL_LINE);
|
||||
@@ -232,8 +254,8 @@ public class LodRenderer
|
||||
GL32.glEnable(GL32.GL_DEPTH_TEST);
|
||||
|
||||
// enable transparent rendering
|
||||
GL32.glBlendFunc(GL32.GL_SRC_ALPHA, GL32.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL32.glEnable(GL32.GL_BLEND);
|
||||
// GL32.glBlendFunc(GL32.GL_SRC_ALPHA, GL32.GL_ONE_MINUS_SRC_ALPHA);
|
||||
// GL32.glEnable(GL32.GL_BLEND);
|
||||
|
||||
/*---------Bind required objects--------*/
|
||||
// Setup LodRenderProgram and the LightmapTexture if it has not yet been done
|
||||
@@ -248,7 +270,7 @@ public class LodRenderer
|
||||
|
||||
/*---------Get required data--------*/
|
||||
// Get the matrixs for rendering
|
||||
Mat4f modelViewMatrix = translateModelViewMatrix(mcModelViewMatrix, partialTicks);
|
||||
Mat4f modelViewMatrix = translateModelViewMatrix(mcModelViewMatrix, partialTicks, vbosCenterX, vbosCenterZ);
|
||||
int vanillaBlockRenderedDistance = MC_RENDER.getRenderDistance() * LodUtil.CHUNK_WIDTH;
|
||||
int farPlaneBlockDistance;
|
||||
// required for setupFog and setupProjectionMatrix
|
||||
@@ -261,71 +283,77 @@ public class LodRenderer
|
||||
|
||||
/*---------Fill uniform data--------*/
|
||||
// Fill the uniform data. Note: GL33.GL_TEXTURE0 == texture bindpoint 0
|
||||
shaderProgram.fillUniformData(modelViewMatrix, projectionMatrix, getTranslatedCameraPos(),
|
||||
getFogColor(), (int) (MC.getSkyDarken(partialTicks) * 15), 0);
|
||||
shaderProgram.fillUniformData(modelViewMatrix, projectionMatrix, getTranslatedCameraPos(vbosCenterX, vbosCenterZ),
|
||||
MC_RENDER.isFogStateInUnderWater() ? getUnderWaterFogColor(partialTicks) : getFogColor(partialTicks), (int) (MC.getSkyDarken(partialTicks) * 15), 0);
|
||||
// Previous guy said fog setting may be different from region to region, but the fogSettings never changed... soooooo...
|
||||
shaderProgram.fillUniformDataForFog(fogSettings);
|
||||
shaderProgram.fillUniformDataForFog(fogSettings, MC_RENDER.isFogStateInUnderWater());
|
||||
// Note: Since lightmapTexture is changing every frame, it's faster to recreate it than to reuse the old one.
|
||||
lightmapTexture.fillData(MC_RENDER.getLightmapTextureWidth(), MC_RENDER.getLightmapTextureHeight(), MC_RENDER.getLightmapPixels());
|
||||
|
||||
//===========//
|
||||
// rendering //
|
||||
//===========//
|
||||
|
||||
drawSetup.end("LodDrawSetup");
|
||||
profiler.popPush("LOD draw");
|
||||
LagSpikeCatcher draw = new LagSpikeCatcher();
|
||||
|
||||
boolean cullingDisabled = CONFIG.client().graphics().advancedGraphics().getDisableDirectionalCulling();
|
||||
boolean usingBufferStorage = glProxy.getGpuUploadMethod() == GpuUploadMethod.BUFFER_STORAGE;
|
||||
|
||||
// where the center of the buffers is (needed when culling regions)
|
||||
// render each of the buffers
|
||||
for (int x = 0; x < vbos.length; x++)
|
||||
{
|
||||
for (int z = 0; z < vbos.length; z++)
|
||||
{
|
||||
//int tempX = LodUtil.convertLevelPos(x + vbosCenterX - (lodDim.getWidth() / 2), LodUtil.REGION_DETAIL_LEVEL , LodUtil.BLOCK_DETAIL_LEVEL);
|
||||
//int tempY = LodUtil.convertLevelPos(z + vbosCenterZ - (lodDim.getWidth() / 2), LodUtil.REGION_DETAIL_LEVEL, LodUtil.BLOCK_DETAIL_LEVEL);
|
||||
int lowRegionX = vbos.getCenterX() - vbos.gridCentreToEdge;
|
||||
int lowRegionZ = vbos.getCenterY() - vbos.gridCentreToEdge;
|
||||
int drawCall = 0;
|
||||
for (int regionX=lowRegionX; regionX<vbos.gridSize; regionX++) {
|
||||
for (int regionZ=lowRegionZ; regionZ<vbos.gridSize; regionZ++) {
|
||||
if (vbos.get(regionX, regionZ) == null) continue;
|
||||
if (cullingDisabled || RenderUtil.isRegionInViewFrustum(MC_RENDER.getCameraBlockPosition(),
|
||||
MC_RENDER.getLookAtVector(),
|
||||
vbosCenterX + LodUtil.convertLevelPos(x - (lodDim.getWidth() / 2), LodUtil.REGION_DETAIL_LEVEL , LodUtil.BLOCK_DETAIL_LEVEL),
|
||||
vbosCenterZ + LodUtil.convertLevelPos(z - (lodDim.getWidth() / 2), LodUtil.REGION_DETAIL_LEVEL , LodUtil.BLOCK_DETAIL_LEVEL)))
|
||||
{
|
||||
|
||||
// actual rendering
|
||||
int bufferId = 0;
|
||||
for (int i = 0; i < vbos[x][z].length; i++)
|
||||
{
|
||||
bufferId = (storageBufferIds != null && usingBufferStorage) ? storageBufferIds[x][z][i] : vbos[x][z][i].id;
|
||||
if (bufferId==0) continue;
|
||||
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, bufferId);
|
||||
shaderProgram.bindVertexBuffer(bufferId);
|
||||
GL32.glDrawArrays(GL32.GL_TRIANGLES, 0, vbos[x][z][i].vertexCount);
|
||||
MC_RENDER.getLookAtVector(), regionX, regionZ)) {
|
||||
for (LodVertexBuffer vbo : vbos.get(regionX, regionZ)) {
|
||||
if (vbo == null) continue;
|
||||
if (vbo.vertexCount == 0) continue;
|
||||
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, vbo.id);
|
||||
shaderProgram.bindVertexBuffer(vbo.id);
|
||||
drawCall++;
|
||||
GL32.glDrawArrays(GL32.GL_TRIANGLES, 0, vbo.vertexCount);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//if (drawCall!=0)
|
||||
// ClientApi.LOGGER.info("DrawCall Count: "+drawCall);
|
||||
|
||||
//================//
|
||||
// render cleanup //
|
||||
//================//
|
||||
|
||||
draw.end("LodDraw");
|
||||
profiler.popPush("LOD cleanup");
|
||||
LagSpikeCatcher drawCleanup = new LagSpikeCatcher();
|
||||
|
||||
// if this cleanup isn't done MC will crash
|
||||
// when trying to render its own terrain
|
||||
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, 0);
|
||||
|
||||
shaderProgram.unbind();
|
||||
lightmapTexture.free();
|
||||
|
||||
GL32.glPolygonMode(GL32.GL_FRONT_AND_BACK, GL32.GL_FILL);
|
||||
GL32.glDisable(GL32.GL_BLEND); // TODO: what should this be reset to?
|
||||
|
||||
if (currentBlend)
|
||||
GL32.glEnable(GL32.GL_BLEND);
|
||||
else
|
||||
GL32.glDisable(GL32.GL_BLEND);
|
||||
|
||||
// if this cleanup isn't done MC will crash
|
||||
// when trying to render its own terrain
|
||||
// And may causes mod compat issue
|
||||
GL32.glUseProgram(currentProgram);
|
||||
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, currentVBO);
|
||||
GL32.glBindVertexArray(currentVAO);
|
||||
GL32.glActiveTexture(currentActiveText);
|
||||
|
||||
// clear the depth buffer so everything is drawn over the LODs
|
||||
GL32.glClear(GL32.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
drawCleanup.end("LodDrawCleanup");
|
||||
// end of internal LOD profiling
|
||||
profiler.pop();
|
||||
}
|
||||
@@ -352,20 +380,24 @@ public class LodRenderer
|
||||
/** Create all buffers that will be used. */
|
||||
public void setupBuffers(LodDimension lodDim)
|
||||
{
|
||||
lodBufferBuilderFactory.setupBuffers(lodDim);
|
||||
lodBufferBuilderFactory.allBuffersRequireReset = true;
|
||||
}
|
||||
|
||||
private Color getFogColor()
|
||||
private Color getFogColor(float partialTicks)
|
||||
{
|
||||
Color fogColor;
|
||||
|
||||
if (CONFIG.client().graphics().fogQuality().getFogColorMode() == FogColorMode.USE_SKY_COLOR)
|
||||
fogColor = MC_RENDER.getSkyColor();
|
||||
else
|
||||
fogColor = MC_RENDER.getFogColor();
|
||||
fogColor = MC_RENDER.getFogColor(partialTicks);
|
||||
|
||||
return fogColor;
|
||||
}
|
||||
private Color getUnderWaterFogColor(float partialTicks)
|
||||
{
|
||||
return MC_RENDER.getUnderWaterFogColor(partialTicks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the camera relative to the LodDimension's center,
|
||||
@@ -374,7 +406,7 @@ public class LodRenderer
|
||||
* (since AxisAlignedBoundingBoxes (LODs) use doubles and thus have a higher
|
||||
* accuracy vs the model view matrix, which only uses floats)
|
||||
*/
|
||||
private Mat4f translateModelViewMatrix(Mat4f mcModelViewMatrix, float partialTicks)
|
||||
private Mat4f translateModelViewMatrix(Mat4f mcModelViewMatrix, float partialTicks, int vbosCenterX, int vbosCenterZ)
|
||||
{
|
||||
// get all relevant camera info
|
||||
Vec3d projectedView = MC_RENDER.getCameraExactPosition();
|
||||
@@ -397,7 +429,7 @@ public class LodRenderer
|
||||
* Similar to translateModelViewMatrix (above),
|
||||
* but for the camera position
|
||||
*/
|
||||
private Vec3f getTranslatedCameraPos()
|
||||
private Vec3f getTranslatedCameraPos(int vbosCenterX, int vbosCenterZ)
|
||||
{
|
||||
//int worldCenterX = LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, vbosCenterX, LodUtil.BLOCK_DETAIL_LEVEL);
|
||||
//int worldCenterZ = LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, vbosCenterZ, LodUtil.BLOCK_DETAIL_LEVEL);
|
||||
@@ -465,138 +497,127 @@ public class LodRenderer
|
||||
fullRegen = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the current Vertex Buffers with the newly
|
||||
* created buffers from the lodBufferBuilder. <br><br>
|
||||
* <p>
|
||||
* For some reason this has to be called after the frame has been rendered,
|
||||
* otherwise visual stuttering/rubber banding may happen. I'm not sure why...
|
||||
*/
|
||||
private void swapBuffers()
|
||||
{
|
||||
// replace the drawable buffers with
|
||||
// the newly created buffers from the lodBufferBuilder
|
||||
VertexBuffersAndOffset result = lodBufferBuilderFactory.getVertexBuffers();
|
||||
vbos = result.vbos;
|
||||
storageBufferIds = result.storageBufferIds;
|
||||
vbosCenterX = result.drawableCenterBlockPosX;
|
||||
vbosCenterZ = result.drawableCenterBlockPosZ;
|
||||
// returns whether anything changed
|
||||
private boolean updateVanillaRenderedChunks(LodDimension lodDim, boolean recreateChunks) {
|
||||
short chunkRenderDistance = (short) MC_RENDER.getRenderDistance();
|
||||
int chunkX = Math.floorDiv(previousPos.getX(), 16);
|
||||
int chunkZ = Math.floorDiv(previousPos.getZ(), 16);
|
||||
// if the player is high enough, draw all LODs
|
||||
if (previousPos.getY() > 256) {
|
||||
vanillaRenderedChunks = new VanillaRenderedChunksList(
|
||||
chunkRenderDistance, chunkX, chunkZ);
|
||||
return true;
|
||||
}
|
||||
VanillaRenderedChunksList chunkList;
|
||||
|
||||
if (recreateChunks) {
|
||||
vanillaRenderedChunks = new VanillaRenderedChunksList(chunkRenderDistance, chunkX, chunkZ);
|
||||
return true;
|
||||
} else {
|
||||
chunkList = vanillaRenderedChunks;
|
||||
chunkX = chunkList.centerX;
|
||||
chunkZ = chunkList.centerZ;
|
||||
chunkRenderDistance = (short) vanillaRenderedChunks.gridCentreToEdge;
|
||||
}
|
||||
|
||||
boolean anyChanged = false;
|
||||
LagSpikeCatcher getChunks = new LagSpikeCatcher();
|
||||
Set<AbstractChunkPosWrapper> chunkPosToSkip = LodUtil.getNearbyLodChunkPosToSkip(lodDim, previousPos);
|
||||
getChunks.end("LodDrawSetup:UpdateStatus:UpdateVanillaChunks:getChunks");
|
||||
for (AbstractChunkPosWrapper pos : chunkPosToSkip)
|
||||
{
|
||||
int xIndex = (pos.getX() - chunkX) + (chunkRenderDistance + 1);
|
||||
int zIndex = (pos.getZ() - chunkZ) + (chunkRenderDistance + 1);
|
||||
|
||||
// sometimes we are given chunks that are outside the render distance,
|
||||
// This prevents index out of bounds exceptions
|
||||
if (xIndex >= 0 && zIndex >= 0
|
||||
&& xIndex < vanillaRenderedChunks.gridSize
|
||||
&& zIndex < vanillaRenderedChunks.gridSize)
|
||||
{
|
||||
if (!chunkList.get(chunkList.calculateOffset(xIndex, zIndex)))
|
||||
{
|
||||
chunkList.set(chunkList.calculateOffset(xIndex, zIndex), true);
|
||||
anyChanged = true;
|
||||
lodDim.markRegionBufferToRegen(pos.getRegionX(), pos.getRegionZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
vanillaRenderedChunks = chunkList;
|
||||
return anyChanged;
|
||||
}
|
||||
|
||||
/** Determines if the LODs should have a fullRegen or partialRegen */
|
||||
private void determineIfLodsShouldRegenerate(LodDimension lodDim, float partialTicks)
|
||||
{
|
||||
private void updateRegenStatus(LodDimension lodDim, float partialTicks) {
|
||||
short chunkRenderDistance = (short) MC_RENDER.getRenderDistance();
|
||||
int vanillaRenderedChunksWidth = chunkRenderDistance * 2 + 2;
|
||||
|
||||
//=============//
|
||||
// full regens //
|
||||
//=============//
|
||||
|
||||
// check if the view distance changed
|
||||
long newTime = System.currentTimeMillis();
|
||||
AbstractBlockPosWrapper newPos = MC.getPlayerBlockPos();
|
||||
boolean shouldUpdateChunks = false;
|
||||
boolean posUpdated = false;
|
||||
boolean tryPartialGen = false;
|
||||
boolean tryFullGen = false;
|
||||
|
||||
// check if the view distance or config changed
|
||||
if (ApiShared.previousLodRenderDistance != CONFIG.client().graphics().quality().getLodChunkRenderDistance()
|
||||
|| chunkRenderDistance != prevRenderDistance
|
||||
|| prevFogDistance != CONFIG.client().graphics().fogQuality().getFogDistance())
|
||||
{
|
||||
|
||||
vanillaRenderedChunks = new boolean[vanillaRenderedChunksWidth][vanillaRenderedChunksWidth];
|
||||
DetailDistanceUtil.updateSettings();
|
||||
fullRegen = true;
|
||||
previousPos = LevelPosUtil.createLevelPos((byte) 4, MC.getPlayerChunkPos().getZ(), MC.getPlayerChunkPos().getZ());
|
||||
DetailDistanceUtil.updateSettings(); // FIXME: This should NOT be here!
|
||||
prevFogDistance = CONFIG.client().graphics().fogQuality().getFogDistance();
|
||||
prevRenderDistance = chunkRenderDistance;
|
||||
}
|
||||
|
||||
// did the user change the debug setting?
|
||||
if (CONFIG.client().advanced().debugging().getDebugMode() != previousDebugMode)
|
||||
{
|
||||
tryFullGen = true;
|
||||
} else if (CONFIG.client().advanced().debugging().getDebugMode() != previousDebugMode)
|
||||
{ // did the user change the debug setting?
|
||||
previousDebugMode = CONFIG.client().advanced().debugging().getDebugMode();
|
||||
fullRegen = true;
|
||||
tryFullGen = true;
|
||||
}
|
||||
|
||||
|
||||
long newTime = System.currentTimeMillis();
|
||||
|
||||
// check if the player has moved
|
||||
if (newTime - prevPlayerPosTime > CONFIG.client().advanced().buffers().getRebuildTimes().playerMoveTimeout)
|
||||
{
|
||||
if (LevelPosUtil.getDetailLevel(previousPos) == 0
|
||||
|| Math.abs(MC.getPlayerChunkPos().getX() - LevelPosUtil.getPosX(previousPos)) > CONFIG.client().advanced().buffers().getRebuildTimes().playerMoveDistance
|
||||
|| Math.abs(MC.getPlayerChunkPos().getZ() - LevelPosUtil.getPosZ(previousPos)) > CONFIG.client().advanced().buffers().getRebuildTimes().playerMoveDistance)
|
||||
if (newTime - prevPlayerPosTime > CONFIG.client().advanced().buffers().getRebuildTimes().playerMoveTimeout) {
|
||||
if (previousPos == null
|
||||
|| Math.abs(newPos.getX() - previousPos.getX()) > CONFIG.client().advanced().buffers().getRebuildTimes().playerMoveDistance*16
|
||||
|| Math.abs(newPos.getZ() - previousPos.getZ()) > CONFIG.client().advanced().buffers().getRebuildTimes().playerMoveDistance*16)
|
||||
{
|
||||
vanillaRenderedChunks = new boolean[vanillaRenderedChunksWidth][vanillaRenderedChunksWidth];
|
||||
fullRegen = true;
|
||||
previousPos = LevelPosUtil.createLevelPos((byte) 4, MC.getPlayerChunkPos().getX(), MC.getPlayerChunkPos().getZ());
|
||||
tryPartialGen = true;
|
||||
previousPos = newPos;
|
||||
posUpdated = true;
|
||||
}
|
||||
prevPlayerPosTime = newTime;
|
||||
}
|
||||
|
||||
//================//
|
||||
// partial regens //
|
||||
//================//
|
||||
|
||||
|
||||
// check if the vanilla rendered chunks changed
|
||||
if (newTime - prevVanillaChunkTime > CONFIG.client().advanced().buffers().getRebuildTimes().renderedChunkTimeout)
|
||||
{
|
||||
if (vanillaRenderedChunksChanged)
|
||||
{
|
||||
partialRegen = true;
|
||||
vanillaRenderedChunksChanged = false;
|
||||
}
|
||||
shouldUpdateChunks = true;
|
||||
prevVanillaChunkTime = newTime;
|
||||
}
|
||||
|
||||
|
||||
// check if there is any newly generated terrain to show
|
||||
if (newTime - prevChunkTime > CONFIG.client().advanced().buffers().getRebuildTimes().chunkChangeTimeout)
|
||||
{
|
||||
tryPartialGen = true;
|
||||
prevChunkTime = newTime;
|
||||
}
|
||||
|
||||
|
||||
if (tryFullGen && !posUpdated) {
|
||||
previousPos = newPos;
|
||||
posUpdated = true;
|
||||
}
|
||||
shouldUpdateChunks |= posUpdated;
|
||||
if (shouldUpdateChunks) {
|
||||
tryPartialGen |= updateVanillaRenderedChunks(lodDim, posUpdated);
|
||||
}
|
||||
|
||||
if (tryFullGen) {
|
||||
fullRegen = true;
|
||||
lodDim.regenDimensionBuffers = false;
|
||||
} else if (tryPartialGen) {
|
||||
if (lodDim.regenDimensionBuffers)
|
||||
{
|
||||
partialRegen = true;
|
||||
lodDim.regenDimensionBuffers = false;
|
||||
}
|
||||
prevChunkTime = newTime;
|
||||
}
|
||||
|
||||
//==============//
|
||||
// LOD skipping //
|
||||
//==============//
|
||||
|
||||
// determine which LODs should not be rendered close to the player
|
||||
HashSet<AbstractChunkPosWrapper> chunkPosToSkip = LodUtil.getNearbyLodChunkPosToSkip(lodDim, MC.getPlayerBlockPos());
|
||||
int xIndex;
|
||||
int zIndex;
|
||||
for (AbstractChunkPosWrapper pos : chunkPosToSkip)
|
||||
{
|
||||
vanillaRenderedChunksEmptySkip = false;
|
||||
|
||||
xIndex = (pos.getX() - MC.getPlayerChunkPos().getX()) + (chunkRenderDistance + 1);
|
||||
zIndex = (pos.getZ() - MC.getPlayerChunkPos().getZ()) + (chunkRenderDistance + 1);
|
||||
|
||||
// sometimes we are given chunks that are outside the render distance,
|
||||
// This prevents index out of bounds exceptions
|
||||
if (xIndex >= 0 && zIndex >= 0
|
||||
&& xIndex < vanillaRenderedChunks.length
|
||||
&& zIndex < vanillaRenderedChunks.length)
|
||||
{
|
||||
if (!vanillaRenderedChunks[xIndex][zIndex])
|
||||
{
|
||||
vanillaRenderedChunks[xIndex][zIndex] = true;
|
||||
vanillaRenderedChunksChanged = true;
|
||||
lodDim.markRegionBufferToRegen(pos.getRegionX(), pos.getRegionZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if the player is high enough, draw all LODs
|
||||
if (chunkPosToSkip.isEmpty() && MC.getPlayerBlockPos().getY() > 256 && !vanillaRenderedChunksEmptySkip)
|
||||
{
|
||||
vanillaRenderedChunks = new boolean[vanillaRenderedChunksWidth][vanillaRenderedChunksWidth];
|
||||
vanillaRenderedChunksChanged = true;
|
||||
vanillaRenderedChunksEmptySkip = true;
|
||||
}
|
||||
|
||||
vanillaRenderedChunks = new boolean[vanillaRenderedChunksWidth][vanillaRenderedChunksWidth];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -85,23 +85,20 @@ public class RenderUtil
|
||||
* Returns true if one of the region's 4 corners is in front
|
||||
* of the camera.
|
||||
*/
|
||||
public static boolean isRegionInViewFrustum(AbstractBlockPosWrapper playerBlockPos, Vec3f cameraDir, int vboCenterPosX, int vboCenterPosZ)
|
||||
public static boolean isRegionInViewFrustum(AbstractBlockPosWrapper playerBlockPos, Vec3f cameraDir, int vboRegionX, int vboRegionZ)
|
||||
{
|
||||
// convert the vbo position into a direction vector
|
||||
// starting from the player's position
|
||||
Vec3f vboVec = new Vec3f(vboCenterPosX, 0, vboCenterPosZ);
|
||||
Vec3f vboVec = new Vec3f(vboRegionX * LodUtil.REGION_WIDTH, 0, vboRegionZ * LodUtil.REGION_WIDTH);
|
||||
Vec3f playerVec = new Vec3f(playerBlockPos.getX(), playerBlockPos.getY(), playerBlockPos.getZ());
|
||||
|
||||
vboVec.subtract(playerVec);
|
||||
|
||||
|
||||
int halfRegionWidth = LodUtil.REGION_WIDTH / 2;
|
||||
|
||||
// calculate the 4 corners
|
||||
Vec3f vboSeVec = new Vec3f(vboVec.x + halfRegionWidth, vboVec.y, vboVec.z + halfRegionWidth);
|
||||
Vec3f vboSwVec = new Vec3f(vboVec.x - halfRegionWidth, vboVec.y, vboVec.z + halfRegionWidth);
|
||||
Vec3f vboNwVec = new Vec3f(vboVec.x - halfRegionWidth, vboVec.y, vboVec.z - halfRegionWidth);
|
||||
Vec3f vboNeVec = new Vec3f(vboVec.x + halfRegionWidth, vboVec.y, vboVec.z - halfRegionWidth);
|
||||
Vec3f vboSeVec = new Vec3f(vboVec.x + LodUtil.REGION_WIDTH, vboVec.y, vboVec.z + LodUtil.REGION_WIDTH);
|
||||
Vec3f vboSwVec = new Vec3f(vboVec.x , vboVec.y, vboVec.z + LodUtil.REGION_WIDTH);
|
||||
Vec3f vboNwVec = new Vec3f(vboVec.x , vboVec.y, vboVec.z);
|
||||
Vec3f vboNeVec = new Vec3f(vboVec.x + LodUtil.REGION_WIDTH, vboVec.y, vboVec.z);
|
||||
|
||||
// if any corner is visible, this region should be rendered
|
||||
return isNormalizedVectorInViewFrustum(vboSeVec, cameraDir) ||
|
||||
|
||||
@@ -47,10 +47,10 @@ public abstract class VertexAttribute {
|
||||
return new VertexPointer(1, GL32.GL_FLOAT, normalized, 16);
|
||||
}
|
||||
public static VertexPointer addUnsignedBytePointer(boolean normalized) {
|
||||
return new VertexPointer(1, GL32.GL_UNSIGNED_BYTE, normalized, 1);
|
||||
return new VertexPointer(1, GL32.GL_UNSIGNED_BYTE, normalized, 4); // Always aligned to 4 bytes
|
||||
}
|
||||
public static VertexPointer addUnsignedBytesPointer(int elementCount, boolean normalized) {
|
||||
return new VertexPointer(elementCount, GL32.GL_UNSIGNED_BYTE, normalized, elementCount);
|
||||
return new VertexPointer(elementCount, GL32.GL_UNSIGNED_BYTE, normalized, (-Math.floorDiv(-elementCount, 4))*4); // aligned to 4 bytes
|
||||
}
|
||||
public static VertexPointer addIntPointer(boolean normalized) {
|
||||
return new VertexPointer(1, GL32.GL_INT, normalized, 4);
|
||||
|
||||
@@ -65,6 +65,7 @@ public final class VertexAttributePostGL43 extends VertexAttribute {
|
||||
if (strideSize != expectedStrideSize) {
|
||||
ClientApi.LOGGER.error("Vertex Attribute calculated stride size " + strideSize +
|
||||
" does not match the provided expected stride size " + expectedStrideSize + "!");
|
||||
throw new IllegalArgumentException("Vertex Attribute Incorrect Format");
|
||||
}
|
||||
ClientApi.LOGGER.info("Vertex Attribute (GL43+) completed. It contains "+numberOfBindingPoints
|
||||
+" binding points and a stride size of "+strideSize);
|
||||
|
||||
@@ -19,7 +19,6 @@ public final class VertexAttributePreGL43 extends VertexAttribute {
|
||||
VertexPointer[] pointers;
|
||||
int[] pointersOffset;
|
||||
|
||||
|
||||
TreeMap<Integer, TreeSet<Integer>> bindingPointsToIndexBuilder;
|
||||
ArrayList<VertexPointer> pointersBuilder;
|
||||
|
||||
@@ -124,9 +123,11 @@ public final class VertexAttributePreGL43 extends VertexAttribute {
|
||||
pointersOffset[i] = currentOffset;
|
||||
currentOffset += pointer.byteSize;
|
||||
}
|
||||
if (currentOffset != expectedStrideSize)
|
||||
if (currentOffset != expectedStrideSize) {
|
||||
ClientApi.LOGGER.error("Vertex Attribute calculated stride size " + currentOffset +
|
||||
" does not match the provided expected stride size " + expectedStrideSize + "!");
|
||||
throw new IllegalArgumentException("Vertex Attribute Incorrect Format");
|
||||
}
|
||||
strideSize = currentOffset;
|
||||
ClientApi.LOGGER.info("Vertex Attribute (pre GL43) completed.");
|
||||
|
||||
|
||||
@@ -103,6 +103,9 @@ public class DataPointUtil
|
||||
public final static long VOID_MASK = 1;
|
||||
public final static long EXISTENCE_MASK = 1;
|
||||
|
||||
public final static long HEIGHT_SHIFTED_MASK = HEIGHT_MASK << HEIGHT_SHIFT;
|
||||
public final static long DEPTH_SHIFTED_MASK = DEPTH_MASK << DEPTH_SHIFT;
|
||||
|
||||
|
||||
public static long createVoidDataPoint(int generationMode)
|
||||
{
|
||||
@@ -141,6 +144,12 @@ public class DataPointUtil
|
||||
return dataPoint;
|
||||
}
|
||||
|
||||
public static long shiftHeightAndDepth(long dataPoint, short offset) {
|
||||
long height = (dataPoint + (offset << HEIGHT_SHIFT)) & HEIGHT_SHIFTED_MASK;
|
||||
long depth = (dataPoint + (offset << DEPTH_SHIFT)) & DEPTH_SHIFTED_MASK;
|
||||
return dataPoint & ~(HEIGHT_SHIFTED_MASK | DEPTH_SHIFTED_MASK) | height | depth;
|
||||
}
|
||||
|
||||
public static short getHeight(long dataPoint)
|
||||
{
|
||||
return (short) ((dataPoint >>> HEIGHT_SHIFT) & HEIGHT_MASK);
|
||||
@@ -213,7 +222,7 @@ public class DataPointUtil
|
||||
public static int getColor(long dataPoint)
|
||||
{
|
||||
// TODO re-add transparency by replacing the color 255 with what is in comment
|
||||
return (int) (((dataPoint >>> COLOR_SHIFT) & COLOR_MASK) | /*((((dataPoint >>> ALPHA_SHIFT) & ALPHA_MASK) << ALPHA_DOWNSIZE_SHIFT) | 0b1111)*/ 255 << 24);
|
||||
return (int) (((dataPoint >>> COLOR_SHIFT) & COLOR_MASK) | ((((dataPoint >>> ALPHA_SHIFT) & ALPHA_MASK) << ALPHA_DOWNSIZE_SHIFT) | 0b1111) << 24);
|
||||
}
|
||||
|
||||
/** This is used to convert a dataPoint to string (useful for the print function) */
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.seibel.lod.core.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GridList<T> extends ArrayList<T> implements List<T> {
|
||||
|
||||
public static class Pos {
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
public Pos(int xx, int yy) {
|
||||
x = xx;
|
||||
y = yy;
|
||||
}
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1585978374811888116L;
|
||||
public final int gridCentreToEdge;
|
||||
public final int gridSize;
|
||||
|
||||
public GridList(int gridCentreToEdge) {
|
||||
super((gridCentreToEdge * 2 + 1) * (gridCentreToEdge * 2 + 1));
|
||||
gridSize = gridCentreToEdge * 2 + 1;
|
||||
this.gridCentreToEdge = gridCentreToEdge;
|
||||
}
|
||||
|
||||
public final T getOffsetOf(int index, int x, int y) {
|
||||
return get(index + x + y * gridSize);
|
||||
}
|
||||
|
||||
public final int offsetOf(int index, int x, int y) {
|
||||
return index + x + y * gridSize;
|
||||
}
|
||||
|
||||
public final Pos posOf(int index) {
|
||||
return new Pos(index % gridSize, index / gridSize);
|
||||
}
|
||||
|
||||
public final int calculateOffset(int x, int y) {
|
||||
return x + y * gridSize;
|
||||
}
|
||||
|
||||
public final GridList<T> subGrid(int gridCentreToEdge) {
|
||||
int centreIndex = size() / 2;
|
||||
GridList<T> subGrid = new GridList<T>(gridCentreToEdge);
|
||||
for (int oy = -gridCentreToEdge; oy <= gridCentreToEdge; oy++) {
|
||||
int begin = offsetOf(centreIndex, -gridCentreToEdge, oy);
|
||||
int end = offsetOf(centreIndex, gridCentreToEdge, oy);
|
||||
subGrid.addAll(this.subList(begin, end + 1));
|
||||
}
|
||||
// System.out.println("========================================\n"+
|
||||
// this.toDetailString() + "\nTOOOOOOOOOOOOO\n"+subGrid.toDetailString()+
|
||||
// "==========================================\n");
|
||||
return subGrid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GridList " + gridSize + "*" + gridSize + "[" + size() + "]";
|
||||
}
|
||||
|
||||
public String toDetailString() {
|
||||
StringBuilder str = new StringBuilder("\n");
|
||||
int i = 0;
|
||||
for (T t : this) {
|
||||
str.append(t.toString());
|
||||
str.append(", ");
|
||||
i++;
|
||||
if (i % gridSize == 0) {
|
||||
str.append("\n");
|
||||
}
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
}
|
||||
@@ -182,12 +182,6 @@ public class LodUtil
|
||||
return new RegionPos(relativePosX, relativePosZ);
|
||||
}
|
||||
|
||||
/** Convert a 2D absolute position into a quad tree relative position. */
|
||||
public static int convertLevelPos(int pos, int currentDetailLevel, int targetDetailLevel)
|
||||
{
|
||||
return pos / (1 << (targetDetailLevel - currentDetailLevel));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If on single player this will return the name of the user's
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.seibel.lod.core.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/*Layout:
|
||||
* 0,1,2,
|
||||
* 3,4,5,
|
||||
* 6,7,8
|
||||
*/
|
||||
|
||||
public class MovableGridList<T> extends ArrayList<T> implements List<T> {
|
||||
|
||||
private static final long serialVersionUID = 5366261085254591277L;
|
||||
|
||||
public static class Pos {
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
public Pos(int xx, int yy) {
|
||||
x = xx;
|
||||
y = yy;
|
||||
}
|
||||
}
|
||||
|
||||
private int centerX;
|
||||
private int centerY;
|
||||
|
||||
public final int gridCentreToEdge;
|
||||
public final int gridSize;
|
||||
|
||||
public MovableGridList(int gridCentreToEdge, int centerX, int centerY) {
|
||||
super((gridCentreToEdge * 2 + 1) * (gridCentreToEdge * 2 + 1));
|
||||
gridSize = gridCentreToEdge * 2 + 1;
|
||||
this.gridCentreToEdge = gridCentreToEdge;
|
||||
this.centerX = centerX;
|
||||
this.centerY = centerY;
|
||||
clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
super.ensureCapacity(gridSize*gridSize);
|
||||
for (int i=0; i<gridSize*gridSize; i++) {
|
||||
super.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
public int getCenterX() {return centerX;}
|
||||
public int getCenterY() {return centerY;}
|
||||
|
||||
// return null if x,y is outside of the grid
|
||||
public T get(int x, int y) {
|
||||
x = x-centerX+gridCentreToEdge;
|
||||
y = y-centerY+gridCentreToEdge;
|
||||
return _getDirect(x,y);
|
||||
}
|
||||
|
||||
// return null if x,y is outside of the grid
|
||||
public T setAndGet(int x, int y, T t) {
|
||||
x = x-centerX+gridCentreToEdge;
|
||||
y = y-centerY+gridCentreToEdge;
|
||||
return _setDirect(x,y, t) ? t : null;
|
||||
}
|
||||
|
||||
private final T _getDirect(int x, int y) {
|
||||
if (x<0 || x>=gridSize || y<0 || y>=gridSize) return null;
|
||||
return super.get(x + y * gridSize);
|
||||
}
|
||||
private final boolean _setDirect(int x, int y, T t) {
|
||||
if (x<0 || x>=gridSize || y<0 || y>=gridSize) return false;
|
||||
super.set(x + y * gridSize, t);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void move(int newCenterX, int newCenterY) {
|
||||
if (centerX == newCenterX && centerY == newCenterY) return;
|
||||
int deltaX = newCenterX - centerX;
|
||||
int deltaY = newCenterY - centerY;
|
||||
|
||||
// if the x or z offset is equal to or greater than
|
||||
// the total width, just delete the current data
|
||||
// and update the centerX and/or centerZ
|
||||
if (Math.abs(deltaX) >= gridSize || Math.abs(deltaY) >= gridSize)
|
||||
{
|
||||
clear();
|
||||
// update the new center
|
||||
centerX = newCenterX;
|
||||
centerY = newCenterY;
|
||||
return;
|
||||
}
|
||||
|
||||
// X
|
||||
if (deltaX >= 0 && deltaY >= 0)
|
||||
{
|
||||
// move everything over to the left-up (as the center moves to the right-down)
|
||||
for (int x = 0; x < gridSize; x++)
|
||||
{
|
||||
for (int y = 0; y < gridSize; y++)
|
||||
{
|
||||
_setDirect(x, y, _getDirect(x+deltaX, y+deltaY));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (deltaX < 0 && deltaY >= 0)
|
||||
{
|
||||
// move everything over to the right-up (as the center moves to the left-down)
|
||||
for (int x = gridSize - 1; x >= 0; x--)
|
||||
{
|
||||
for (int y = 0; y < gridSize; y++)
|
||||
{
|
||||
_setDirect(x, y, _getDirect(x+deltaX, y+deltaY));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (deltaX >= 0 && deltaY < 0)
|
||||
{
|
||||
// move everything over to the left-down (as the center moves to the right-up)
|
||||
for (int x = 0; x < gridSize; x++)
|
||||
{
|
||||
for (int y = gridSize - 1; y >= 0; y--)
|
||||
{
|
||||
_setDirect(x, y, _getDirect(x+deltaX, y+deltaY));
|
||||
}
|
||||
}
|
||||
}
|
||||
else //if (deltaX < 0 && deltaY < 0)
|
||||
{
|
||||
// move everything over to the right-down (as the center moves to the left-up)
|
||||
for (int x = gridSize - 1; x >= 0; x--)
|
||||
{
|
||||
for (int y = gridSize - 1; y >= 0; y--)
|
||||
{
|
||||
_setDirect(x, y, _getDirect(x+deltaX, y+deltaY));
|
||||
}
|
||||
}
|
||||
}
|
||||
centerX = newCenterX;
|
||||
centerY = newCenterY;
|
||||
}
|
||||
|
||||
|
||||
// TODO: This is unused but may be useful later on.
|
||||
/*
|
||||
public final MovableGridList<T> subGrid(int gridCentreToEdge, int newCenterX, int newCenterY) {
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MovableGridList[" + centerX + "," + centerY + "] " + gridSize + "*" + gridSize + "[" + size() + "]";
|
||||
}
|
||||
|
||||
public String toDetailString() {
|
||||
StringBuilder str = new StringBuilder("\n");
|
||||
int i = 0;
|
||||
for (T t : this) {
|
||||
|
||||
str.append(t!=null ? t.toString() : "NULL");
|
||||
str.append(", ");
|
||||
i++;
|
||||
if (i % gridSize == 0) {
|
||||
str.append("\n");
|
||||
}
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,8 @@ import java.util.concurrent.ConcurrentMap;
|
||||
import com.seibel.lod.core.enums.LodDirection;
|
||||
import com.seibel.lod.core.objects.VertexOptimizer;
|
||||
|
||||
// FIXME: Nuke this whole thing and use ThreadLocal instead. And no more redundant get() please!
|
||||
|
||||
/**
|
||||
* Holds data used by specific threads so
|
||||
* the data doesn't have to be recreated every
|
||||
@@ -42,7 +44,6 @@ public class ThreadMapUtil
|
||||
public static final ConcurrentMap<String, long[][]> threadBuilderArrayMap = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentMap<String, long[][]> threadBuilderVerticalArrayMap = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentMap<String, long[]> threadVerticalAddDataMap = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentMap<String, byte[][]> saveContainer = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentMap<String, short[]> projectionArrayMap = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentMap<String, short[]> heightAndDepthMap = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentMap<String, long[]> singleDataToMergeMap = new ConcurrentHashMap<>();
|
||||
@@ -117,7 +118,8 @@ public class ThreadMapUtil
|
||||
//________________________//
|
||||
|
||||
|
||||
|
||||
|
||||
//TODO: Maybe use actual valid total world height instead of always assuming the worse and alloc 1024 blocks.
|
||||
/** returns the array filled with 0's */
|
||||
public static long[] getBuilderVerticalArray(int detailLevel)
|
||||
{
|
||||
@@ -136,41 +138,22 @@ public class ThreadMapUtil
|
||||
return threadBuilderVerticalArrayMap.get(Thread.currentThread().getName())[detailLevel];
|
||||
}
|
||||
|
||||
/** returns the array NOT cleared every time */
|
||||
public static byte[] getSaveContainer(int detailLevel)
|
||||
{
|
||||
if (!saveContainer.containsKey(Thread.currentThread().getName()) || (saveContainer.get(Thread.currentThread().getName()) == null))
|
||||
{
|
||||
byte[][] array = new byte[LodUtil.DETAIL_OPTIONS][];
|
||||
int size = 1;
|
||||
for (int i = LodUtil.DETAIL_OPTIONS - 1; i >= 0; i--)
|
||||
{
|
||||
array[i] = new byte[4 + 8 * size * size * DetailDistanceUtil.getMaxVerticalData(i)];
|
||||
size = size << 1;
|
||||
}
|
||||
saveContainer.put(Thread.currentThread().getName(), array);
|
||||
}
|
||||
//Arrays.fill(threadBuilderVerticalArrayMap.get(Thread.currentThread().getName())[detailLevel], 0);
|
||||
return saveContainer.get(Thread.currentThread().getName())[detailLevel];
|
||||
}
|
||||
|
||||
|
||||
/** returns the array filled with 0's */
|
||||
public static long[] getVerticalDataArray(int arrayLength)
|
||||
{
|
||||
if (!threadVerticalAddDataMap.containsKey(Thread.currentThread().getName()) || (threadVerticalAddDataMap.get(Thread.currentThread().getName()) == null))
|
||||
long[] array = threadVerticalAddDataMap.get(Thread.currentThread().getName());
|
||||
if (array == null || array.length != arrayLength)
|
||||
{
|
||||
threadVerticalAddDataMap.put(Thread.currentThread().getName(), new long[arrayLength]);
|
||||
array = new long[arrayLength];
|
||||
threadVerticalAddDataMap.put(Thread.currentThread().getName(), array);
|
||||
}
|
||||
else
|
||||
{
|
||||
Arrays.fill(threadVerticalAddDataMap.get(Thread.currentThread().getName()), 0);
|
||||
}
|
||||
return threadVerticalAddDataMap.get(Thread.currentThread().getName());
|
||||
Arrays.fill(array, 0);
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//FIXME: If the arrayLength change, this may return incorrect sized array
|
||||
/** returns the array NOT cleared every time */
|
||||
public static short[] getHeightAndDepth(int arrayLength)
|
||||
{
|
||||
@@ -185,18 +168,20 @@ public class ThreadMapUtil
|
||||
/** returns the array filled with 0's */
|
||||
public static long[] getVerticalUpdateArray(int detailLevel)
|
||||
{
|
||||
if (!verticalUpdate.containsKey(Thread.currentThread().getName()) || (verticalUpdate.get(Thread.currentThread().getName()) == null))
|
||||
detailLevel--; //we are asking for a place to fit lower level detail, so this will never get called with value of 0
|
||||
long[][] arrays = verticalUpdate.get(Thread.currentThread().getName());
|
||||
if (arrays == null)
|
||||
{
|
||||
long[][] array = new long[LodUtil.DETAIL_OPTIONS][];
|
||||
for (int i = 1; i < LodUtil.DETAIL_OPTIONS; i++)
|
||||
array[i] = new long[DetailDistanceUtil.getMaxVerticalData(i - 1) * 4];
|
||||
verticalUpdate.put(Thread.currentThread().getName(), array);
|
||||
arrays = new long[LodUtil.DETAIL_OPTIONS - 1][];
|
||||
verticalUpdate.put(Thread.currentThread().getName(), arrays);
|
||||
}
|
||||
long[] array = arrays[detailLevel];
|
||||
int arrayLength = DetailDistanceUtil.getMaxVerticalData(detailLevel) * 4;
|
||||
if (array == null || array.length != arrayLength)
|
||||
array = new long[arrayLength];
|
||||
else
|
||||
{
|
||||
Arrays.fill(verticalUpdate.get(Thread.currentThread().getName())[detailLevel], 0);
|
||||
}
|
||||
return verticalUpdate.get(Thread.currentThread().getName())[detailLevel];
|
||||
Arrays.fill(array, 0);
|
||||
return array;
|
||||
}
|
||||
|
||||
/** clears all arrays so they will have to be rebuilt */
|
||||
@@ -209,7 +194,6 @@ public class ThreadMapUtil
|
||||
threadBuilderArrayMap.clear();
|
||||
threadBuilderVerticalArrayMap.clear();
|
||||
threadVerticalAddDataMap.clear();
|
||||
saveContainer.clear();
|
||||
projectionArrayMap.clear();
|
||||
heightAndDepthMap.clear();
|
||||
singleDataToMergeMap.clear();
|
||||
|
||||
+72
-21
@@ -65,6 +65,7 @@ public interface ILodConfigWrapperSingleton
|
||||
|
||||
IQuality quality();
|
||||
IFogQuality fogQuality();
|
||||
ICloudQuality cloudQuality();
|
||||
IAdvancedGraphics advancedGraphics();
|
||||
|
||||
|
||||
@@ -150,7 +151,8 @@ public interface ILodConfigWrapperSingleton
|
||||
String FOG_DRAW_MODE_DESC = ""
|
||||
+ " When should fog be drawn? \n"
|
||||
+ "\n"
|
||||
+ " " + FogDrawMode.USE_OPTIFINE_SETTING + ": Use whatever Fog setting Optifine is using. If Optifine isn't installed this defaults to " + FogDrawMode.FOG_ENABLED + ". \n"
|
||||
+ " " + FogDrawMode.USE_OPTIFINE_SETTING + ": Use whatever Fog setting Optifine is using.\n"
|
||||
+ " If Optifine isn't installed this defaults to " + FogDrawMode.FOG_ENABLED + ". \n"
|
||||
+ " " + FogDrawMode.FOG_ENABLED + ": Never draw fog on the LODs \n"
|
||||
+ " " + FogDrawMode.FOG_DISABLED + ": Always draw fast fog on the LODs \n"
|
||||
+ "\n"
|
||||
@@ -174,11 +176,48 @@ public interface ILodConfigWrapperSingleton
|
||||
+ " If true disable Minecraft's fog. \n"
|
||||
+ "\n"
|
||||
+ " Experimental! Will cause issues with Sodium and \n"
|
||||
+ " may not play nice with other mods that edit fog. \n";
|
||||
+ " may not play nice with other mods that edit fog. \n"
|
||||
+ " Intended for those who do not use Sodium or Optifine.";
|
||||
boolean getDisableVanillaFog();
|
||||
void setDisableVanillaFog(boolean newDisableVanillaFog);
|
||||
}
|
||||
|
||||
|
||||
interface ICloudQuality
|
||||
{
|
||||
String DESC = "These settings control the clouds.";
|
||||
|
||||
boolean CUSTOM_CLOUDS_DEFAULT = false;
|
||||
String CUSTOM_CLOUDS_DESC = ""
|
||||
+ " Should we use our own method for rendering clouds \n"
|
||||
+ "\n"
|
||||
+ " If you disable this then the rest of the cloud configs wont work. \n";
|
||||
boolean getCustomClouds();
|
||||
void setCustomClouds(boolean newCustomClouds);
|
||||
|
||||
boolean FABULOUS_CLOUDS_DEFAULT = false;
|
||||
String FABULOUS_CLOUDS_DESC = ""
|
||||
+ " A complete rework on how clouds work \n"
|
||||
+ " Rather than getting from a texure and rendering that \n"
|
||||
+ " It gets the terrain height and decides how much cloud to put \n"
|
||||
+ " This idea came from this 11 year old(as of when this is being written) \n"
|
||||
+ "reddit post https://www.reddit.com/r/Minecraft/comments/e7xol/this_is_how_clouds_should_work_gif_simulation/ \n";
|
||||
boolean getFabulousClouds();
|
||||
void setFabulousClouds(boolean newFabulousClouds);
|
||||
|
||||
boolean EXTEND_CLOUDS_DEFAULT = true;
|
||||
String EXTEND_CLOUDS_DESC = ""
|
||||
+ " Extends how far the clouds render \n"
|
||||
+ " to the lod render distance \n";
|
||||
boolean getExtendClouds();
|
||||
void setExtendClouds(boolean newExtendClouds);
|
||||
|
||||
MinDefaultMax<Double> CLOUD_HEIGHT_MIN_DEFAULT_MAX = new MinDefaultMax<Double>(Double.MIN_VALUE, 0., Double.MAX_VALUE); // make it get minecraft cloud height
|
||||
String CLOUD_HEIGHT_DESC = ""
|
||||
+ " What y level to render the clouds at \n";
|
||||
double getCloudHeight();
|
||||
void setCloudHeight(double newCloudHeight);
|
||||
}
|
||||
|
||||
interface IAdvancedGraphics
|
||||
{
|
||||
String DESC = "Graphics options that are a bit more technical.";
|
||||
@@ -210,20 +249,33 @@ public interface ILodConfigWrapperSingleton
|
||||
VanillaOverdraw VANILLA_OVERDRAW_DEFAULT = VanillaOverdraw.DYNAMIC;
|
||||
String VANILLA_OVERDRAW_DESC = ""
|
||||
+ " How often should LODs be drawn on top of regular chunks? \n"
|
||||
+ " HALF and ALWAYS will prevent holes in the world, but may look odd for transparent blocks or in caves. \n"
|
||||
+ " HALF and ALWAYS will prevent holes in the world, \n"
|
||||
+ " but may look odd for transparent blocks or in caves. \n"
|
||||
+ "\n"
|
||||
+ " " + VanillaOverdraw.NEVER + ": LODs won't render on top of vanilla chunks. \n"
|
||||
+ " " + VanillaOverdraw.BORDER + ": LODs will render only on the border of vanilla chunks, preventing some holes in the world. \n"
|
||||
+ " " + VanillaOverdraw.DYNAMIC + ": LODs will render on top of distant vanilla chunks to hide delayed loading. \n"
|
||||
+ " " + " More effective on higher render distances. \n"
|
||||
+ " " + " For vanilla render distances less than or equal to " + LodUtil.MINIMUM_RENDER_DISTANCE_FOR_PARTIAL_OVERDRAW + " \n"
|
||||
+ " " + " " + VanillaOverdraw.NEVER + " or " + VanillaOverdraw.ALWAYS + " will be used depending on the dimension. \n"
|
||||
+ " " + VanillaOverdraw.ALWAYS + ": LODs will render on all vanilla chunks preventing all holes in the world. \n"
|
||||
+ " " + VanillaOverdraw.NEVER + ": \n"
|
||||
+ " LODs won't render on top of vanilla chunks. \n"
|
||||
+ " " + VanillaOverdraw.BORDER + ": \n"
|
||||
+ " LODs will render only on the border of vanilla chunks, preventing some holes in the world. \n"
|
||||
+ " " + VanillaOverdraw.DYNAMIC + ": \n"
|
||||
+ " LODs will render on top of distant vanilla chunks to hide delayed loading. \n"
|
||||
+ " More effective on higher render distances. \n"
|
||||
+ " For vanilla render distances less than or equal to " + LodUtil.MINIMUM_RENDER_DISTANCE_FOR_PARTIAL_OVERDRAW + " \n"
|
||||
+ " " + VanillaOverdraw.NEVER + " or " + VanillaOverdraw.ALWAYS + " will be used depending on the dimension. \n"
|
||||
+ " " + VanillaOverdraw.ALWAYS + ": \n"
|
||||
+ " LODs will render on all vanilla chunks preventing all holes in the world. \n"
|
||||
+ "\n"
|
||||
+ " This setting shouldn't affect performance. \n";
|
||||
VanillaOverdraw getVanillaOverdraw();
|
||||
void setVanillaOverdraw(VanillaOverdraw newVanillaOverdraw);
|
||||
|
||||
MinDefaultMax<Integer> VANILLA_CULLING_RANGE_MIN_DEFAULT_MAX = new MinDefaultMax<Integer>(0, 32, 512);
|
||||
String VANILLA_CULLING_RANGE_DESC = ""
|
||||
+ " This indicates the minimum range where back sides of blocks start get get culled. \n"
|
||||
+ " Higher settings will make terrain look good when looking backwards \n"
|
||||
+ " when changing speeds quickly, but will increase upload times and GPU usage.";
|
||||
int getBacksideCullingRange();
|
||||
void setBacksideCullingRange(int backsideCullingRange);
|
||||
|
||||
boolean USE_EXTENDED_NEAR_CLIP_PLANE_DEFAULT = false;
|
||||
String USE_EXTENDED_NEAR_CLIP_PLANE_DESC = ""
|
||||
+ " Will prevent some overdraw issues, but may cause nearby fake chunks to render incorrectly \n"
|
||||
@@ -475,7 +527,7 @@ public interface ILodConfigWrapperSingleton
|
||||
+ " " + GpuUploadMethod.BUFFER_MAPPING + ": Slow rendering but won't stutter when uploading. Possibly the best option for integrated GPUs. \n"
|
||||
+ " Default option for AMD/Intel. \n"
|
||||
+ " May end up storing buffers in System memory. \n"
|
||||
+ " Fast rending if in GPU memory, slow if in system memory, \n"
|
||||
+ " Fast rendering if in GPU memory, slow if in system memory, \n"
|
||||
+ " but won't stutter when uploading. \n"
|
||||
+ " " + GpuUploadMethod.DATA + ": Fast rendering but will stutter when uploading. \n"
|
||||
+ " Backup option for AMD/Intel. \n"
|
||||
@@ -486,20 +538,19 @@ public interface ILodConfigWrapperSingleton
|
||||
GpuUploadMethod getGpuUploadMethod();
|
||||
void setGpuUploadMethod(GpuUploadMethod newGpuUploadMethod);
|
||||
|
||||
MinDefaultMax<Integer> GPU_UPLOAD_TIMEOUT_IN_MILLISECONDS_DEFAULT = new MinDefaultMax<Integer>(0, 0, 5000);
|
||||
String GPU_UPLOAD_TIMEOUT_IN_MILLISECONDS_DESC = ""
|
||||
+ " How long should we wait before uploading a buffer to the GPU? \n"
|
||||
MinDefaultMax<Integer> GPU_UPLOAD_PER_MEGABYTE_IN_MILLISECONDS_DEFAULT = new MinDefaultMax<Integer>(0, 10, 5000);
|
||||
String GPU_UPLOAD_PER_MEGABYTE_IN_MILLISECONDS_DESC = ""
|
||||
+ " How long should a buffer wait per Megabyte of data uploaded?\n"
|
||||
+ " Helpful resource for frame times: https://fpstoms.com \n"
|
||||
+ "\n"
|
||||
+ " Longer times may reduce stuttering but will make fake chunks \n"
|
||||
+ " transition and load slower. \n"
|
||||
+ " transition and load slower. Change this to [0] for no timeout.\n"
|
||||
+ "\n"
|
||||
+ " NOTE:\n"
|
||||
+ " This should be a last resort option."
|
||||
+ " Only change this from [0], after you have tried all of the \n"
|
||||
+ " \"GPU Upload methods\" and determined even the best stutters with yoru hardware.";
|
||||
int getGpuUploadTimeoutInMilliseconds();
|
||||
void setGpuUploadTimeoutInMilliseconds(int newTimeoutInMilliseconds);
|
||||
+ " Before changing this config, try changing \"GPU Upload methods\"\n"
|
||||
+ " and determined the best method for your hardware first. \n";
|
||||
int getGpuUploadPerMegabyteInMilliseconds();
|
||||
void setGpuUploadPerMegabyteInMilliseconds(int newMilliseconds);
|
||||
|
||||
String REBUILD_TIMES_DESC = ""
|
||||
+ " How frequently should vertex buffers (geometry) be rebuilt and sent to the GPU? \n"
|
||||
|
||||
+8
-1
@@ -51,8 +51,14 @@ public interface IMinecraftRenderWrapper
|
||||
|
||||
double getGamma();
|
||||
|
||||
Color getFogColor();
|
||||
Color getFogColor(float partialTicks);
|
||||
|
||||
public default Color getUnderWaterFogColor(float partialTicks) {return getFogColor(partialTicks);}
|
||||
|
||||
public default boolean isFogStateInUnderWater() {
|
||||
return false;
|
||||
}
|
||||
|
||||
Color getSkyColor();
|
||||
|
||||
double getFov(float partialTicks);
|
||||
@@ -131,4 +137,5 @@ public interface IMinecraftRenderWrapper
|
||||
public default boolean tryDisableVanillaFog() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,621 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -0,0 +1,131 @@
|
||||
{
|
||||
"lod.title": "Distant Horizons",
|
||||
"DistantHorizons.config.title": "Distant Horizons config",
|
||||
"DistantHorizons.config.ShowButton": "Show menu button",
|
||||
"DistantHorizons.config.ShowButton.@tooltip": "Show the custom button to the left of the fov button",
|
||||
"DistantHorizons.config.client": "Client",
|
||||
"DistantHorizons.config.client.graphics": "Graphics",
|
||||
"DistantHorizons.config.client.graphics.quality": "Quality options",
|
||||
"DistantHorizons.config.client.graphics.quality.drawResolution": "Draw resolution",
|
||||
"DistantHorizons.config.client.graphics.quality.drawResolution.@tooltip": "What is the maximum detail fake chunks should be drawn at?",
|
||||
"DistantHorizons.config.client.graphics.quality.lodChunkRenderDistance": "Chunk render distance",
|
||||
"DistantHorizons.config.client.graphics.quality.lodChunkRenderDistance.@tooltip": "The mod's render distance, measured in chunks",
|
||||
"DistantHorizons.config.client.graphics.quality.verticalQuality": "Vertical quality",
|
||||
"DistantHorizons.config.client.graphics.quality.verticalQuality.@tooltip": "This indicates how detailed fake chunks will represent overhangs, caves, floating islands, ect. \nHigher options will use more memory and increase GPU usage",
|
||||
"DistantHorizons.config.client.graphics.quality.horizontalScale": "Horizontal scale",
|
||||
"DistantHorizons.config.client.graphics.quality.horizontalScale.@tooltip": "This indicates how quickly fake chunks drop off in quality",
|
||||
"DistantHorizons.config.client.graphics.quality.horizontalQuality": "Horizontal quality",
|
||||
"DistantHorizons.config.client.graphics.quality.horizontalQuality.@tooltip": "This indicates the exponential base of the quadratic drop-off",
|
||||
"DistantHorizons.config.client.graphics.fogQuality": "Fog options",
|
||||
"DistantHorizons.config.client.graphics.fogQuality.fogDistance": "Fog distance",
|
||||
"DistantHorizons.config.client.graphics.fogQuality.fogDistance.@tooltip": "At what distance should Fog be drawn on the fake chunks?",
|
||||
"DistantHorizons.config.client.graphics.fogQuality.fogDrawMode": "Fog draw mode",
|
||||
"DistantHorizons.config.client.graphics.fogQuality.fogDrawMode.@tooltip": "When should fog be drawn?",
|
||||
"DistantHorizons.config.client.graphics.fogQuality.fogColorMode": "Fog color mode",
|
||||
"DistantHorizons.config.client.graphics.fogQuality.fogColorMode.@tooltip": "What color should fog use?",
|
||||
"DistantHorizons.config.client.graphics.fogQuality.disableVanillaFog": "Disable vanilla fog",
|
||||
"DistantHorizons.config.client.graphics.fogQuality.disableVanillaFog.@tooltip": "If true disable Minecraft's fog. \nMay cause issues with other mods that edit fog. \nMay cause errors with other fog editing mods",
|
||||
"DistantHorizons.config.client.graphics.cloudQuality": "Cloud options",
|
||||
"DistantHorizons.config.client.graphics.cloudQuality.customClouds": "Custom cloud",
|
||||
"DistantHorizons.config.client.graphics.cloudQuality.customClouds.@tooltip": "Do you want to use a custom way or rendering the clouds. \nIf you turn this off then the other settings here wont do anything \nThis will also make the clouds more dynamic",
|
||||
"DistantHorizons.config.client.graphics.cloudQuality.fabulousClouds": "Fabulous clouds",
|
||||
"DistantHorizons.config.client.graphics.cloudQuality.fabulousClouds.@tooltip": "Makes clouds look way better. \nTHIS IS CURRENTLY AN EXPERIMENTAL SETTING",
|
||||
"DistantHorizons.config.client.graphics.cloudQuality.extendClouds": "Extend the clouds",
|
||||
"DistantHorizons.config.client.graphics.cloudQuality.cloudHeight": "Cloud height",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics": "Advanced quality option",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics.lodTemplate": "LOD template",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics.lodTemplate.@tooltip": "How should the LODs be drawn? \nNOTE: Currently only CUBIC is implemented!",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics.disableDirectionalCulling": "Disable directional culling",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics.disableDirectionalCulling.@tooltip": "If false fake chunks behind the player's camera aren't drawn, increasing performance. \nIf true all LODs are drawn, even those behind the player's camera, decreasing performance",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics.alwaysDrawAtMaxQuality": "Always draw at max quality",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics.alwaysDrawAtMaxQuality.@tooltip": "Disable quality falloff, all fake chunks will be drawn at the highest available detail level",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics.vanillaOverdraw": "Vanilla overdraw",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics.vanillaOverdraw.@tooltip": "How often should LODs be drawn on top of regular chunks? \nHALF and ALWAYS will prevent holes in the world, but may look odd for transparent blocks or in caves.",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics.useExtendedNearClipPlane": "Use extended near clip plane",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics.useExtendedNearClipPlane.@tooltip": "Will prevent some overdraw issues, but may cause nearby fake chunks to render incorrectly especially when in/near an ocean",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics.backsideCullingRange": "Backside Culling Range",
|
||||
"DistantHorizons.config.client.graphics.advancedGraphics.backsideCullingRange.@tooltip": "This indicates the minimum range where back sides of blocks start get get culled.",
|
||||
"DistantHorizons.config.client.worldGenerator": "World generator",
|
||||
"DistantHorizons.config.client.worldGenerator.generationPriority": "Generation priority",
|
||||
"DistantHorizons.config.client.worldGenerator.generationPriority.@tooltip": "What is the priority of the chunks being generated around the player",
|
||||
"DistantHorizons.config.client.worldGenerator.distanceGenerationMode": "Distance generation mode",
|
||||
"DistantHorizons.config.client.worldGenerator.distanceGenerationMode.@tooltip": "How much of the generation should be used when generating fake chunks",
|
||||
"DistantHorizons.config.client.worldGenerator.allowUnstableFeatureGeneration": "Allow unstable feature generation",
|
||||
"DistantHorizons.config.client.worldGenerator.allowUnstableFeatureGeneration.@tooltip": "Some features may not be thread safe. \nCould cause instability and crashes",
|
||||
"DistantHorizons.config.client.worldGenerator.blocksToAvoid": "Block to avoid",
|
||||
"DistantHorizons.config.client.worldGenerator.blocksToAvoid.@tooltip": "What block to avoid when generating fake chunks",
|
||||
"DistantHorizons.config.client.advanced": "Advance options",
|
||||
"DistantHorizons.config.client.advanced.threading": "Threading",
|
||||
"DistantHorizons.config.client.advanced.threading.numberOfWorldGenerationThreads": "NO. of world generation threads",
|
||||
"DistantHorizons.config.client.advanced.threading.numberOfWorldGenerationThreads.@tooltip": "This is how many threads are used when generating LODs outside the normal render distance. \nIf you experience stuttering when generating distant LODs, decrease this number. If you want to increase LOD generation speed, increase this number \nCan only be between 1 and your current number of threads",
|
||||
"DistantHorizons.config.client.advanced.threading.numberOfBufferBuilderThreads": "NO. of buffer builder threads",
|
||||
"DistantHorizons.config.client.advanced.threading.numberOfBufferBuilderThreads.@tooltip": "This is how many threads are used when building vertex buffers (The things sent to your GPU to draw the fake chunks) \nCan only be between 1 and your current number of threads",
|
||||
"DistantHorizons.config.client.advanced.buffers": "Buffers",
|
||||
"DistantHorizons.config.client.advanced.buffers.gpuUploadMethod": "GPU upload method",
|
||||
"DistantHorizons.config.client.advanced.buffers.gpuUploadMethod.@tooltip": "What method should be used to upload geometry to the GPU?",
|
||||
"DistantHorizons.config.client.advanced.buffers.gpuUploadPerMegabyteInMilliseconds": "GPU upload speed (milliseconds)",
|
||||
"DistantHorizons.config.client.advanced.buffers.gpuUploadPerMegabyteInMilliseconds.@tooltip": "How long should a buffer wait per Megabyte of data uploaded? \nHelpful resource for frame times: https://fpstoms.com",
|
||||
"DistantHorizons.config.client.advanced.buffers.rebuildTimes": "Rebuild times",
|
||||
"DistantHorizons.config.client.advanced.buffers.rebuildTimes.@tooltip": "Rebuild times",
|
||||
"DistantHorizons.config.client.advanced.debugging": "Debug",
|
||||
"DistantHorizons.config.client.advanced.debugging.drawLods": "Draw LOD's",
|
||||
"DistantHorizons.config.client.advanced.debugging.drawLods.@tooltip": "If true, the mod is enabled and fake chunks will be drawn.",
|
||||
"DistantHorizons.config.client.advanced.debugging.debugMode": "Debug mode",
|
||||
"DistantHorizons.config.client.advanced.debugging.debugMode.@tooltip": "What type of debug mode do you want",
|
||||
"DistantHorizons.config.client.advanced.debugging.enableDebugKeybindings": "Enable debug keybindings",
|
||||
"DistantHorizons.config.client.advanced.debugging.enableDebugKeybindings.@tooltip": "Enable debug keybindings to change the Debug mode on the fly in game",
|
||||
"DistantHorizons.config.enum.HorizontalResolution.BLOCK": "Block",
|
||||
"DistantHorizons.config.enum.HorizontalResolution.TWO_BLOCKS": "2 blocks",
|
||||
"DistantHorizons.config.enum.HorizontalResolution.FOUR_BLOCKS": "4 blocks",
|
||||
"DistantHorizons.config.enum.HorizontalResolution.HALF_CHUNK": "Half a chunk",
|
||||
"DistantHorizons.config.enum.HorizontalResolution.CHUNK": "Chunk",
|
||||
"DistantHorizons.config.enum.VerticalQuality.LOW": "Low",
|
||||
"DistantHorizons.config.enum.VerticalQuality.MEDIUM": "Medium",
|
||||
"DistantHorizons.config.enum.VerticalQuality.HIGH": "High",
|
||||
"DistantHorizons.config.enum.HorizontalScale.LOW": "Low",
|
||||
"DistantHorizons.config.enum.HorizontalScale.MEDIUM": "Medium",
|
||||
"DistantHorizons.config.enum.HorizontalScale.HIGH": "High",
|
||||
"DistantHorizons.config.enum.HorizontalQuality.LOWEST": "Lowest",
|
||||
"DistantHorizons.config.enum.HorizontalQuality.LOW": "Low",
|
||||
"DistantHorizons.config.enum.HorizontalQuality.MEDIUM": "Medium",
|
||||
"DistantHorizons.config.enum.HorizontalQuality.HIGH": "High",
|
||||
"DistantHorizons.config.enum.FogDistance.NEAR": "Near",
|
||||
"DistantHorizons.config.enum.FogDistance.FAR": "Far",
|
||||
"DistantHorizons.config.enum.FogDistance.NEAR_AND_FAR": "Near and far",
|
||||
"DistantHorizons.config.enum.FogDrawMode.USE_OPTIFINE_SETTING": "Use modded settings",
|
||||
"DistantHorizons.config.enum.FogDrawMode.FOG_ENABLED": "Fog enabled",
|
||||
"DistantHorizons.config.enum.FogDrawMode.FOG_DISABLED": "Fog disabled",
|
||||
"DistantHorizons.config.enum.FogColorMode.USE_WORLD_FOG_COLOR": "Use world fog",
|
||||
"DistantHorizons.config.enum.FogColorMode.USE_SKY_COLOR": "Use sky color",
|
||||
"DistantHorizons.config.enum.LodTemplate.CUBIC": "Cubic",
|
||||
"DistantHorizons.config.enum.LodTemplate.TRIANGULAR": "Triangular",
|
||||
"DistantHorizons.config.enum.LodTemplate.DYNAMIC": "Dynamic",
|
||||
"DistantHorizons.config.enum.VanillaOverdraw.NEVER": "Never",
|
||||
"DistantHorizons.config.enum.VanillaOverdraw.DYNAMIC": "Dynamic",
|
||||
"DistantHorizons.config.enum.VanillaOverdraw.ALWAYS": "Always",
|
||||
"DistantHorizons.config.enum.VanillaOverdraw.BORDER": "Border",
|
||||
"DistantHorizons.config.enum.GenerationPriority.AUTO": "Auto",
|
||||
"DistantHorizons.config.enum.GenerationPriority.NEAR_FIRST": "Near first",
|
||||
"DistantHorizons.config.enum.GenerationPriority.FAR_FIRST": "Far first",
|
||||
"DistantHorizons.config.enum.DistanceGenerationMode.NONE": "None",
|
||||
"DistantHorizons.config.enum.DistanceGenerationMode.BIOME_ONLY": "Biome only",
|
||||
"DistantHorizons.config.enum.DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT": "Biome only simulate height",
|
||||
"DistantHorizons.config.enum.DistanceGenerationMode.SURFACE": "Surface",
|
||||
"DistantHorizons.config.enum.DistanceGenerationMode.FEATURES": "Features",
|
||||
"DistantHorizons.config.enum.DistanceGenerationMode.FULL": "Full",
|
||||
"DistantHorizons.config.enum.BlocksToAvoid.NONE": "None",
|
||||
"DistantHorizons.config.enum.BlocksToAvoid.NON_FULL": "Non full",
|
||||
"DistantHorizons.config.enum.BlocksToAvoid.NO_COLLISION": "No collision",
|
||||
"DistantHorizons.config.enum.BlocksToAvoid.BOTH": "Both",
|
||||
"DistantHorizons.config.enum.DebugMode.OFF": "Off",
|
||||
"DistantHorizons.config.enum.DebugMode.SHOW_DETAIL": "Show detail",
|
||||
"DistantHorizons.config.enum.DebugMode.SHOW_DETAIL_WIREFRAME": "Show detail with wireframe",
|
||||
"DistantHorizons.config.enum.GpuUploadMethod.AUTO": "Auto",
|
||||
"DistantHorizons.config.enum.GpuUploadMethod.BUFFER_STORAGE": "Buffer storage",
|
||||
"DistantHorizons.config.enum.GpuUploadMethod.SUB_DATA": "Sub data",
|
||||
"DistantHorizons.config.enum.GpuUploadMethod.BUFFER_MAPPING": "Buffer mapping",
|
||||
"DistantHorizons.config.enum.GpuUploadMethod.DATA": "Data",
|
||||
"DistantHorizons.config.enum.BufferRebuildTimes.FREQUENT": "Frequent",
|
||||
"DistantHorizons.config.enum.BufferRebuildTimes.NORMAL": "Normal",
|
||||
"DistantHorizons.config.enum.BufferRebuildTimes.RARE": "Rare"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 924 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 172 KiB |
@@ -2,8 +2,7 @@
|
||||
|
||||
in vec3 vPosition;
|
||||
in vec4 color;
|
||||
in float blockSkyLight;
|
||||
in float blockLight;
|
||||
in vec2 light;
|
||||
|
||||
out vec4 vertexColor;
|
||||
out vec4 vertexWorldPos;
|
||||
@@ -25,6 +24,8 @@ uniform sampler2D lightMap;
|
||||
*/
|
||||
void main()
|
||||
{
|
||||
float blockSkyLight = light[0];
|
||||
float blockLight = light[1];
|
||||
|
||||
// just skylight
|
||||
// good for sanity checks; but will cause OpenGL errors since we are binding unused data
|
||||
|
||||
Reference in New Issue
Block a user