Compare commits
11 Commits
1.19.1_tmp
...
1.6.4a_dev
| Author | SHA1 | Date | |
|---|---|---|---|
| c8b8817909 | |||
| 8a70545439 | |||
| d8e5cbda0a | |||
| 6f4b0a54e9 | |||
| 61ea29a6fd | |||
| 7d6c4fa1f9 | |||
| 108b4c7470 | |||
| 63fff244eb | |||
| 5e86aa1275 | |||
| db72d1cdc2 | |||
| 5e99efe093 |
@@ -44,7 +44,7 @@ public enum VerticalQuality
|
||||
),
|
||||
|
||||
ULTRA(
|
||||
new int[] { 16, 8, 4, 2, 2, 2, 2, 1, 1, 1, 1 },
|
||||
new int[] { 16, 16, 8, 8, 4, 4, 4, 1, 1, 1, 1 },
|
||||
12
|
||||
);
|
||||
|
||||
|
||||
@@ -38,13 +38,20 @@ public class LodBox
|
||||
short maxY = (short) (y + ySize);
|
||||
short maxZ = (short) (z + zSize);
|
||||
byte skyLightTop = skyLight;
|
||||
boolean isTransparent = ColorUtil.getAlpha(color)<255;
|
||||
boolean isTopTransparent = DataPointUtil.isTransparent(topData);
|
||||
boolean isBotTransparent = DataPointUtil.isTransparent(botData);
|
||||
byte skyLightBot = DataPointUtil.doesItExist(botData) ? DataPointUtil.getLightSky(botData) : 0;
|
||||
|
||||
// Up direction case
|
||||
boolean skipTop = DataPointUtil.doesItExist(topData) && DataPointUtil.getDepth(topData) == maxY;// &&
|
||||
boolean skipTop = DataPointUtil.doesItExist(topData) && (
|
||||
(isTransparent && (DataPointUtil.getDepth(topData) == maxY)) ||
|
||||
(!isTransparent && (DataPointUtil.getDepth(topData) == maxY) && !isTopTransparent));
|
||||
boolean skipBot = DataPointUtil.doesItExist(botData) && (
|
||||
(isTransparent && (DataPointUtil.getDepth(botData) == maxY)) ||
|
||||
(!isTransparent && (DataPointUtil.getDepth(botData) == maxY) && !isBotTransparent));
|
||||
// DataPointUtil.getAlpha(singleAdjDataPoint)
|
||||
// == 255;
|
||||
boolean skipBot = DataPointUtil.doesItExist(botData) && DataPointUtil.getHeight(botData) == y;// &&
|
||||
//boolean skipBot = DataPointUtil.doesItExist(botData) && DataPointUtil.getHeight(botData) == y;// &&
|
||||
// DataPointUtil.getAlpha(singleAdjDataPoint)
|
||||
// == 255;
|
||||
|
||||
@@ -148,6 +155,8 @@ public class LodBox
|
||||
private static void makeAdjQuads(LodQuadBuilder builder, long[] adjData, LodDirection direction, short x, short y,
|
||||
short z, short w0, short wy, int color, int overlapColor, byte upSkyLight, byte blockLight)
|
||||
{
|
||||
|
||||
boolean isTransparent = ColorUtil.getAlpha(color)<255;
|
||||
color = ColorUtil.applyShade(color, MC.getShade(direction));
|
||||
long[] dataPoint = adjData;
|
||||
if (dataPoint == null || DataPointUtil.isVoid(dataPoint[0]))
|
||||
@@ -164,14 +173,13 @@ public class LodBox
|
||||
|
||||
// TODO transparency ocean floor fix
|
||||
// boolean isOpaque = ((colorMap[0] >> 24) & 0xFF) == 255;
|
||||
for (i = 0; i < dataPoint.length && DataPointUtil.doesItExist(adjData[i])
|
||||
&& !DataPointUtil.isVoid(adjData[i]); i++)
|
||||
for (i = 0; i < dataPoint.length && DataPointUtil.doesItExist(adjData[i]) && !DataPointUtil.isVoid(adjData[i]); i++)
|
||||
{
|
||||
long adjPoint = adjData[i];
|
||||
|
||||
boolean isAdjTransparent = DataPointUtil.isTransparent(adjPoint);
|
||||
// TODO transparency ocean floor fix
|
||||
// if (isOpaque && DataPointUtil.getAlpha(singleAdjDataPoint) != 255)
|
||||
// continue;
|
||||
if (!isTransparent && isAdjTransparent)
|
||||
continue;
|
||||
|
||||
short height = DataPointUtil.getHeight(adjPoint);
|
||||
short depth = DataPointUtil.getDepth(adjPoint);
|
||||
|
||||
@@ -277,7 +277,7 @@ public class RenderRegion implements AutoCloseable
|
||||
private static void makeLodRenderData(LodQuadBuilder quadBuilder, LodRegion region, LodRegion[] adjRegions, int playerX,
|
||||
int playerZ) {
|
||||
byte minDetail = region.getMinDetailLevel();
|
||||
|
||||
|
||||
// Variable initialization
|
||||
DebugMode debugMode = CONFIG.client().advanced().debugging().getDebugMode();
|
||||
|
||||
@@ -292,7 +292,7 @@ public class RenderRegion implements AutoCloseable
|
||||
byte detailLevel = posToRender.getNthDetailLevel(index);
|
||||
int posX = posToRender.getNthPosX(index);
|
||||
int posZ = posToRender.getNthPosZ(index);
|
||||
|
||||
|
||||
// TODO: In the future, We don't need to ignore rendered chunks! Just build it
|
||||
// and leave it for the renderer to decide!
|
||||
// We don't want to render this fake block if
|
||||
@@ -311,7 +311,7 @@ public class RenderRegion implements AutoCloseable
|
||||
if (posData == null || posData.length == 0 || !DataPointUtil.doesItExist(posData[0])
|
||||
|| DataPointUtil.isVoid(posData[0]))
|
||||
continue;
|
||||
|
||||
|
||||
long[][][] adjData = new long[4][][];
|
||||
boolean[] adjUseBlack = new boolean[4];
|
||||
|
||||
@@ -321,79 +321,85 @@ public class RenderRegion implements AutoCloseable
|
||||
// border when we have transparent block like water or glass
|
||||
// to avoid having a "darker border" underground
|
||||
// Arrays.fill(adjShadeDisabled, false);
|
||||
|
||||
|
||||
// We check every adj block in each direction
|
||||
|
||||
|
||||
// If the adj block is rendered in the same region and with same detail
|
||||
// and is positioned in a place that is not going to be rendered by vanilla game
|
||||
// then we can set this position as adj
|
||||
// We avoid cases where the adjPosition is in player chunk while the position is
|
||||
// not
|
||||
// to always have a wall underwater
|
||||
for (LodDirection lodDirection : LodDirection.ADJ_DIRECTIONS) {
|
||||
try {
|
||||
int xAdj = posX + lodDirection.getNormal().x;
|
||||
int zAdj = posZ + lodDirection.getNormal().z;
|
||||
int chunkXAdj = LevelPosUtil.getChunkPos(detailLevel, xAdj);
|
||||
int chunkZAdj = LevelPosUtil.getChunkPos(detailLevel, zAdj);
|
||||
if (chunkGrid != null && chunkGrid.get(chunkXAdj, chunkZAdj)!=null) {
|
||||
adjUseBlack[lodDirection.ordinal()-2] = true;
|
||||
|
||||
/**TODO REMOVE THIS UGLY TRANSPARENCY THING AND MAKE IT MORE SIMPLE*/
|
||||
for (int transparency = 0; transparency <= 1; transparency++)
|
||||
{
|
||||
for (LodDirection lodDirection : LodDirection.ADJ_DIRECTIONS) {
|
||||
try {
|
||||
int xAdj = posX + lodDirection.getNormal().x;
|
||||
int zAdj = posZ + lodDirection.getNormal().z;
|
||||
int chunkXAdj = LevelPosUtil.getChunkPos(detailLevel, xAdj);
|
||||
int chunkZAdj = LevelPosUtil.getChunkPos(detailLevel, zAdj);
|
||||
if (chunkGrid != null && chunkGrid.get(chunkXAdj, chunkZAdj) != null) {
|
||||
adjUseBlack[lodDirection.ordinal() - 2] = true;
|
||||
}
|
||||
|
||||
boolean isCrossRegionBoundary = LevelPosUtil.getRegion(detailLevel, xAdj) != region.regionPosX ||
|
||||
LevelPosUtil.getRegion(detailLevel, zAdj) != region.regionPosZ;
|
||||
|
||||
LodRegion adjRegion;
|
||||
byte adjDetail;
|
||||
int childXAdj = xAdj * 2 + (lodDirection.getNormal().x < 0 ? 1 : 0);
|
||||
int childZAdj = zAdj * 2 + (lodDirection.getNormal().z < 0 ? 1 : 0);
|
||||
|
||||
//we check if the detail of the adjPos is equal to the correct one (region border fix)
|
||||
//or if the detail is wrong by 1 value (region+circle border fix)
|
||||
if (isCrossRegionBoundary) {
|
||||
//we compute at which detail that position should be rendered
|
||||
adjRegion = adjRegions[lodDirection.ordinal() - 2];
|
||||
if (adjRegion == null) continue;
|
||||
adjDetail = adjRegion.getRenderDetailLevelAt(playerX, playerZ, detailLevel, xAdj, zAdj);
|
||||
} else {
|
||||
adjRegion = region;
|
||||
if (posToRender.contains(detailLevel, xAdj, zAdj)) adjDetail = detailLevel;
|
||||
else if (detailLevel > 0 &&
|
||||
posToRender.contains((byte) (detailLevel - 1), childXAdj, childZAdj))
|
||||
adjDetail = (byte) (detailLevel - 1);
|
||||
else if (detailLevel < LodUtil.REGION_DETAIL_LEVEL &&
|
||||
posToRender.contains((byte) (detailLevel + 1), xAdj / 2, zAdj / 2))
|
||||
adjDetail = (byte) (detailLevel + 1);
|
||||
else continue;
|
||||
}
|
||||
|
||||
if (adjDetail < detailLevel - 1 || adjDetail > detailLevel + 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (adjDetail == detailLevel || adjDetail > detailLevel) {
|
||||
adjData[lodDirection.ordinal() - 2] = new long[1][];
|
||||
adjData[lodDirection.ordinal() - 2][0] = adjRegion.getAllData(adjDetail,
|
||||
LevelPosUtil.convert(detailLevel, xAdj, adjDetail),
|
||||
LevelPosUtil.convert(detailLevel, zAdj, adjDetail));
|
||||
} else {
|
||||
adjData[lodDirection.ordinal() - 2] = new long[2][];
|
||||
adjData[lodDirection.ordinal() - 2][0] = adjRegion.getAllData(adjDetail,
|
||||
childXAdj, childZAdj);
|
||||
adjData[lodDirection.ordinal() - 2][1] = adjRegion.getAllData(adjDetail,
|
||||
childXAdj + (lodDirection.getAxis() == LodDirection.Axis.X ? 0 : 1),
|
||||
childZAdj + (lodDirection.getAxis() == LodDirection.Axis.Z ? 0 : 1));
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
EVENT_LOGGER.warn("Failed to get adj data for [{}:{},{}] at [{}]", detailLevel, posX, posZ, lodDirection);
|
||||
EVENT_LOGGER.warn("Detail exception: ", e);
|
||||
}
|
||||
|
||||
boolean isCrossRegionBoundary = LevelPosUtil.getRegion(detailLevel, xAdj) != region.regionPosX ||
|
||||
LevelPosUtil.getRegion(detailLevel, zAdj) != region.regionPosZ;
|
||||
|
||||
LodRegion adjRegion;
|
||||
byte adjDetail;
|
||||
int childXAdj = xAdj*2 + (lodDirection.getNormal().x<0 ? 1 : 0);
|
||||
int childZAdj = zAdj*2 + (lodDirection.getNormal().z<0 ? 1 : 0);
|
||||
|
||||
//we check if the detail of the adjPos is equal to the correct one (region border fix)
|
||||
//or if the detail is wrong by 1 value (region+circle border fix)
|
||||
if (isCrossRegionBoundary) {
|
||||
//we compute at which detail that position should be rendered
|
||||
adjRegion = adjRegions[lodDirection.ordinal()-2];
|
||||
if(adjRegion == null) continue;
|
||||
adjDetail = adjRegion.getRenderDetailLevelAt(playerX, playerZ, detailLevel, xAdj, zAdj);
|
||||
} else {
|
||||
adjRegion = region;
|
||||
if (posToRender.contains(detailLevel, xAdj, zAdj)) adjDetail = detailLevel;
|
||||
else if (detailLevel>0 &&
|
||||
posToRender.contains((byte) (detailLevel-1), childXAdj, childZAdj))
|
||||
adjDetail = (byte) (detailLevel-1);
|
||||
else if (detailLevel<LodUtil.REGION_DETAIL_LEVEL &&
|
||||
posToRender.contains((byte) (detailLevel+1), xAdj/2, zAdj/2))
|
||||
adjDetail = (byte) (detailLevel+1);
|
||||
else continue;
|
||||
}
|
||||
|
||||
if (adjDetail < detailLevel-1 || adjDetail > detailLevel+1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (adjDetail == detailLevel || adjDetail > detailLevel) {
|
||||
adjData[lodDirection.ordinal() - 2] = new long[1][];
|
||||
adjData[lodDirection.ordinal() - 2][0] = adjRegion.getAllData(adjDetail,
|
||||
LevelPosUtil.convert(detailLevel, xAdj, adjDetail),
|
||||
LevelPosUtil.convert(detailLevel, zAdj, adjDetail));
|
||||
} else {
|
||||
adjData[lodDirection.ordinal() - 2] = new long[2][];
|
||||
adjData[lodDirection.ordinal() - 2][0] = adjRegion.getAllData(adjDetail,
|
||||
childXAdj, childZAdj);
|
||||
adjData[lodDirection.ordinal() - 2][1] = adjRegion.getAllData(adjDetail,
|
||||
childXAdj + (lodDirection.getAxis()==LodDirection.Axis.X ? 0 : 1),
|
||||
childZAdj + (lodDirection.getAxis()==LodDirection.Axis.Z ? 0 : 1));
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
EVENT_LOGGER.warn("Failed to get adj data for [{}:{},{}] at [{}]", detailLevel, posX, posZ, lodDirection);
|
||||
EVENT_LOGGER.warn("Detail exception: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// We render every vertical lod present in this position
|
||||
// We only stop when we find a block that is void or non-existing block
|
||||
for (int i = 0; i < posData.length; i++) {
|
||||
long data = posData[i];
|
||||
if (DataPointUtil.isTransparent(data) == (transparency == 1))
|
||||
continue;
|
||||
// If the data is not renderable (Void or non-existing) we stop since there is
|
||||
// no data left in this position
|
||||
if (DataPointUtil.isVoid(data) || !DataPointUtil.doesItExist(data))
|
||||
@@ -407,8 +413,8 @@ public class RenderRegion implements AutoCloseable
|
||||
LevelPosUtil.getRegionModule(detailLevel, posX),
|
||||
LevelPosUtil.getRegionModule(detailLevel, posZ), quadBuilder, debugMode);
|
||||
}
|
||||
|
||||
} // for pos to in list to render
|
||||
}
|
||||
}// for pos to in list to render
|
||||
// the thread executed successfully
|
||||
// Merge all quads
|
||||
quadBuilder.mergeQuads();
|
||||
|
||||
@@ -267,9 +267,10 @@ public class LodRenderer
|
||||
drawEnableDepth.end("drawEnableDepth");
|
||||
drawGLSetup.end("drawGLSetup");
|
||||
// enable transparent rendering
|
||||
// GL32.glBlendFunc(GL32.GL_SRC_ALPHA, GL32.GL_ONE_MINUS_SRC_ALPHA);
|
||||
// GL32.glEnable(GL32.GL_BLEND);
|
||||
GL32.glDisable(GL32.GL_BLEND);
|
||||
GL32.glBlendFunc(GL32.GL_SRC_ALPHA, GL32.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL32.glEnable(GL32.GL_BLEND);
|
||||
|
||||
//GL32.glDisable(GL32.GL_BLEND);
|
||||
GL32.glClear(GL32.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
/*---------Bind required objects--------*/
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
|
||||
package com.seibel.lod.core.util;
|
||||
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.logging.SpamReducedLogger;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -245,7 +247,11 @@ public class DataPointUtil
|
||||
long alpha = getAlpha(dataPoint);
|
||||
return (int) (((dataPoint >>> COLOR_SHIFT) & COLOR_MASK) | (alpha << (ALPHA_SHIFT-COLOR_SHIFT)));
|
||||
}
|
||||
|
||||
|
||||
public static boolean isTransparent(long dataPoint){
|
||||
return getAlpha(dataPoint) < 255;
|
||||
}
|
||||
|
||||
/** This is used to convert a dataPoint to string (useful for the print function) */
|
||||
@SuppressWarnings("unused")
|
||||
public static String toString(long dataPoint)
|
||||
@@ -388,6 +394,17 @@ public class DataPointUtil
|
||||
{
|
||||
int size = dataToMerge.length / inputVerticalData;
|
||||
|
||||
int[] indeces = new int[size];
|
||||
Arrays.fill(indeces,0);
|
||||
boolean[] increaseIndex = new boolean[size];
|
||||
boolean[] indexHandled = new boolean[size];
|
||||
byte genMode = getGenerationMode(dataToMerge[0]);
|
||||
if (genMode == 0) genMode = 1; // FIXME: Hack to make the version 10 genMode never be 0.
|
||||
boolean limited = false;
|
||||
boolean allDefault;
|
||||
long singleData;
|
||||
|
||||
|
||||
// We initialize the arrays that are going to be used
|
||||
int heightAndDepthLength = (MAX_WORLD_Y_SIZE / 2 + 16) * 2;
|
||||
short[] heightAndDepth = tLocalHeightAndDepth.get();
|
||||
@@ -401,161 +418,20 @@ public class DataPointUtil
|
||||
dataPoint = new long[dataPointLength];
|
||||
tMaxVerticalData.set(dataPoint);
|
||||
} else Arrays.fill(dataPoint, 0);
|
||||
|
||||
byte genMode = getGenerationMode(dataToMerge[0]);
|
||||
if (genMode == 0) genMode = 1; // FIXME: Hack to make the version 10 genMode never be 0.
|
||||
|
||||
|
||||
//First we check if it's all void or all empty
|
||||
boolean allEmpty = true;
|
||||
boolean allVoid = true;
|
||||
boolean limited = false;
|
||||
boolean allDefault;
|
||||
long singleData;
|
||||
|
||||
|
||||
short depth;
|
||||
short height;
|
||||
int count = 0;
|
||||
int i;
|
||||
int ii;
|
||||
int dataIndex;
|
||||
//We collect the indexes of the data, ordered by the depth
|
||||
long tempData;
|
||||
|
||||
for (int index = 0; index < size; index++)
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
for (dataIndex = 0; dataIndex < inputVerticalData; dataIndex++)
|
||||
{
|
||||
singleData = dataToMerge[dataIndex];
|
||||
if (doesItExist(singleData))
|
||||
{
|
||||
//genMode = Math.min(genMode, getGenerationMode(singleData));
|
||||
allEmpty = false;
|
||||
if (!isVoid(singleData))
|
||||
{
|
||||
allVoid = false;
|
||||
count++;
|
||||
heightAndDepth[dataIndex * 2] = getHeight(singleData);
|
||||
heightAndDepth[dataIndex * 2 +1] = getDepth(singleData);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (dataIndex = 0; dataIndex < inputVerticalData; dataIndex++)
|
||||
{
|
||||
singleData = dataToMerge[index * inputVerticalData + dataIndex];
|
||||
if (doesItExist(singleData))
|
||||
{
|
||||
//genMode = Math.min(genMode, getGenerationMode(singleData));
|
||||
allEmpty = false;
|
||||
if (!isVoid(singleData))
|
||||
{
|
||||
allVoid = false;
|
||||
depth = getDepth(singleData);
|
||||
height = getHeight(singleData);
|
||||
|
||||
int botPos = -1;
|
||||
int topPos = -1;
|
||||
//values fall in between and possibly require extension of array
|
||||
boolean botExtend = false;
|
||||
boolean topExtend = false;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (depth < heightAndDepth[i * 2] && depth >= heightAndDepth[i * 2 + 1])
|
||||
{
|
||||
botPos = i;
|
||||
break;
|
||||
}
|
||||
else if (depth < heightAndDepth[i * 2 + 1] && ((i + 1 < count && depth >= heightAndDepth[(i + 1) * 2]) || i + 1 == count))
|
||||
{
|
||||
botPos = i;
|
||||
botExtend = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (height <= heightAndDepth[i * 2] && height > heightAndDepth[i * 2 + 1])
|
||||
{
|
||||
topPos = i;
|
||||
break;
|
||||
}
|
||||
else if (height <= heightAndDepth[i * 2 + 1] && ((i + 1 < count && height > heightAndDepth[(i + 1) * 2]) || i + 1 == count))
|
||||
{
|
||||
topPos = i;
|
||||
topExtend = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (topPos == -1)
|
||||
{
|
||||
if (botPos == -1)
|
||||
{
|
||||
//whole block falls above
|
||||
extendArray(heightAndDepth, 2, 0, 1, count);
|
||||
heightAndDepth[0] = height;
|
||||
heightAndDepth[1] = depth;
|
||||
count++;
|
||||
}
|
||||
else if (!botExtend)
|
||||
{
|
||||
//only top falls above extending it there, while bottom is inside existing
|
||||
shrinkArray(heightAndDepth, 2, 0, botPos, count);
|
||||
heightAndDepth[0] = height;
|
||||
count -= botPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
//top falls between some blocks, extending those as well
|
||||
shrinkArray(heightAndDepth, 2, 0, botPos, count);
|
||||
heightAndDepth[0] = height;
|
||||
heightAndDepth[1] = depth;
|
||||
count -= botPos;
|
||||
}
|
||||
}
|
||||
else if (!topExtend)
|
||||
{
|
||||
if (!botExtend)
|
||||
//both top and bottom are within some exiting blocks, possibly merging them
|
||||
heightAndDepth[topPos * 2 + 1] = heightAndDepth[botPos * 2 + 1];
|
||||
else
|
||||
//top falls between some blocks, extending it there
|
||||
heightAndDepth[topPos * 2 + 1] = depth;
|
||||
shrinkArray(heightAndDepth, 2, topPos + 1, botPos - topPos, count);
|
||||
count -= botPos - topPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!botExtend)
|
||||
{
|
||||
//only top is within some exiting block, extending it
|
||||
topPos++; //to make it easier
|
||||
heightAndDepth[topPos * 2] = height;
|
||||
heightAndDepth[topPos * 2 + 1] = heightAndDepth[botPos * 2 + 1];
|
||||
shrinkArray(heightAndDepth, 2, topPos + 1, botPos - topPos, count);
|
||||
count -= botPos - topPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
//both top and bottom are outside existing blocks
|
||||
shrinkArray(heightAndDepth, 2, topPos + 1, botPos - topPos, count);
|
||||
count -= botPos - topPos;
|
||||
extendArray(heightAndDepth, 2, topPos + 1, 1, count);
|
||||
count++;
|
||||
heightAndDepth[topPos * 2 + 2] = height;
|
||||
heightAndDepth[topPos * 2 + 3] = depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
tempData = dataToMerge[index * inputVerticalData];
|
||||
allVoid = allVoid && DataPointUtil.isVoid(tempData);
|
||||
allEmpty = allEmpty && !DataPointUtil.doesItExist(tempData);
|
||||
}
|
||||
|
||||
|
||||
//We check if there is any data that's not empty or void
|
||||
if (allEmpty)
|
||||
return dataPoint;
|
||||
@@ -564,6 +440,126 @@ public class DataPointUtil
|
||||
dataPoint[0] = createVoidDataPoint(genMode);
|
||||
return dataPoint;
|
||||
}
|
||||
|
||||
|
||||
short depth;
|
||||
short height;
|
||||
int count = 0;
|
||||
int i;
|
||||
int ii;
|
||||
int dataIndex;
|
||||
//We collect the indexes of the data, ordered by the depth
|
||||
|
||||
//this check is used only to see if we have checked all the values in the array
|
||||
boolean stillHasDataToCheck = true;
|
||||
short prevHeight;
|
||||
short prevDepth;
|
||||
|
||||
|
||||
|
||||
while(stillHasDataToCheck)
|
||||
{
|
||||
Arrays.fill(indexHandled, false);
|
||||
boolean connected = true;
|
||||
int newHeight = -10000;
|
||||
int newDepth = -10000;
|
||||
int tempHeight;
|
||||
int tempDepth;
|
||||
while(connected)
|
||||
{
|
||||
Arrays.fill(increaseIndex, false);
|
||||
for (int index = 0; index < size; index++)
|
||||
{
|
||||
if(indeces[index] < inputVerticalData)
|
||||
{
|
||||
tempData = dataToMerge[index * inputVerticalData + indeces[index]];
|
||||
if(!DataPointUtil.isVoid(tempData) && DataPointUtil.doesItExist(tempData)) {
|
||||
tempHeight = DataPointUtil.getHeight(tempData);
|
||||
tempDepth = DataPointUtil.getDepth(tempData);
|
||||
if(tempDepth >= newHeight) {
|
||||
//First case
|
||||
//the column we are checking is higher than the current column
|
||||
newDepth = tempDepth;
|
||||
newHeight = tempHeight;
|
||||
Arrays.fill(increaseIndex, false);
|
||||
Arrays.fill(indexHandled, false);
|
||||
increaseIndex[index] = true;
|
||||
indexHandled[index] = true;
|
||||
}else if((tempDepth >= newDepth) && (tempHeight <= newHeight)){
|
||||
//the column we are checking is contained in the current column
|
||||
//we simply increase this index
|
||||
increaseIndex[index] = true;
|
||||
indexHandled[index] = true;
|
||||
}else if(tempHeight > newHeight && tempDepth <= newDepth){
|
||||
newDepth = tempDepth;
|
||||
newHeight = tempHeight;
|
||||
increaseIndex[index] = true;
|
||||
indexHandled[index] = true;
|
||||
}else if(tempHeight > newDepth && tempHeight <= newHeight){
|
||||
//the column we are checking touches the current column from the bottom
|
||||
//for this reason we extend what's below
|
||||
|
||||
//We want to avoid to expend this column if it has already been expanded by
|
||||
//this index
|
||||
if(!indexHandled[index]) {
|
||||
newDepth = tempDepth;
|
||||
increaseIndex[index] = true;
|
||||
indexHandled[index] = true;
|
||||
}
|
||||
|
||||
}else if(tempDepth < newHeight && tempDepth > newDepth){
|
||||
//the column we are checking touches the current column from the top
|
||||
//for this reason we extend the top
|
||||
newHeight = tempHeight;
|
||||
increaseIndex[index] = true;
|
||||
}
|
||||
}else{
|
||||
indexHandled[index] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//if we added any new data there is a chance that we could add more
|
||||
//for this reason we would continue
|
||||
//if no data is added than the column hasn't changed.
|
||||
//for this reason we can start working on a new column
|
||||
connected = false;
|
||||
for (int index = 0; index < size; index++)
|
||||
{
|
||||
if(increaseIndex[index])
|
||||
{
|
||||
connected = true;
|
||||
indeces[index]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Now we add the height and depth data we extracted to the heightAndDepth array
|
||||
if(newDepth != newHeight)
|
||||
{
|
||||
if(count != 0)
|
||||
{
|
||||
prevDepth = heightAndDepth[(count-1)*2+1];
|
||||
if(newHeight > prevDepth) {
|
||||
newHeight = (short) Math.min(newHeight, prevDepth);
|
||||
}
|
||||
}
|
||||
heightAndDepth[count*2] = (short) newHeight;
|
||||
heightAndDepth[count*2+1] = (short) newDepth;
|
||||
count++;
|
||||
}
|
||||
|
||||
//Here we check the condition that makes the loop continue
|
||||
//We stop the loop only if there is no more data to check
|
||||
stillHasDataToCheck = false;
|
||||
for (int index = 0; index < size; index++)
|
||||
{
|
||||
if(indeces[index] < inputVerticalData)
|
||||
{
|
||||
tempData = dataToMerge[index * inputVerticalData + indeces[index]];
|
||||
stillHasDataToCheck |= !DataPointUtil.isVoid(tempData) && DataPointUtil.doesItExist(tempData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//we limit the vertical portion to maxVerticalData
|
||||
int j = 0;
|
||||
@@ -654,31 +650,23 @@ public class DataPointUtil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (allEmpty)
|
||||
//no child has been initialized
|
||||
dataPoint[j] = EMPTY_DATA;
|
||||
else if (allVoid)
|
||||
//all the children are void
|
||||
dataPoint[j] = createVoidDataPoint(genMode);
|
||||
else
|
||||
|
||||
//we have at least 1 child
|
||||
if (size != 1)
|
||||
{
|
||||
//we have at least 1 child
|
||||
if (size != 1)
|
||||
{
|
||||
tempRed = tempRed / numberOfChildren;
|
||||
tempGreen = tempGreen / numberOfChildren;
|
||||
tempBlue = tempBlue / numberOfChildren;
|
||||
tempLightBlock = tempLightBlock / numberOfChildren;
|
||||
tempLightSky = tempLightSky / numberOfChildren;
|
||||
}
|
||||
//data = createDataPoint(tempAlpha, tempRed, tempGreen, tempBlue, height, depth, tempLightSky, tempLightBlock, tempGenMode, allDefault);
|
||||
//if (j > 0 && getColor(data) == getColor(dataPoint[j]))
|
||||
//{
|
||||
// add simplification at the end due to color
|
||||
//}
|
||||
dataPoint[j] = createDataPoint((int) Math.sqrt(tempAlpha), (int) Math.sqrt(tempRed), (int) Math.sqrt(tempGreen), (int) Math.sqrt(tempBlue), height, depth, tempLightSky, tempLightBlock, genMode);
|
||||
tempRed = tempRed / numberOfChildren;
|
||||
tempGreen = tempGreen / numberOfChildren;
|
||||
tempBlue = tempBlue / numberOfChildren;
|
||||
tempLightBlock = tempLightBlock / numberOfChildren;
|
||||
tempLightSky = tempLightSky / numberOfChildren;
|
||||
}
|
||||
//data = createDataPoint(tempAlpha, tempRed, tempGreen, tempBlue, height, depth, tempLightSky, tempLightBlock, tempGenMode, allDefault);
|
||||
//if (j > 0 && getColor(data) == getColor(dataPoint[j]))
|
||||
//{
|
||||
// add simplification at the end due to color
|
||||
//}
|
||||
dataPoint[j] = createDataPoint(tempAlpha, (int) Math.sqrt(tempRed), (int) Math.sqrt(tempGreen), (int) Math.sqrt(tempBlue), height, depth, tempLightSky, tempLightBlock, genMode);
|
||||
|
||||
}
|
||||
}
|
||||
return dataPoint;
|
||||
|
||||
@@ -70,7 +70,7 @@ void main()
|
||||
|
||||
}
|
||||
//fragColor = vec4(0.7,0.6,0.5,1.0);
|
||||
fragColor = vec4(returnColor.rgb,1.0);
|
||||
fragColor = returnColor;
|
||||
}
|
||||
|
||||
float linearFog(float x, float fogStart, float fogLength, float fogMin, float fogRange) {
|
||||
|
||||
Reference in New Issue
Block a user