Changed the dataPoint, started the introduction of the lightmap use
This commit is contained in:
@@ -11,6 +11,7 @@ public class Main
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
/*
|
||||
try
|
||||
{
|
||||
long[][] dataToMerge = new long[][]{
|
||||
@@ -26,6 +27,6 @@ public class Main
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package com.seibel.lod.builders;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
@@ -26,20 +27,18 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.seibel.lod.util.*;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.seibel.lod.builders.lodTemplates.Box;
|
||||
import com.seibel.lod.config.LodConfig;
|
||||
import com.seibel.lod.util.DataPointUtil;
|
||||
import com.seibel.lod.util.LevelPosUtil;
|
||||
import com.seibel.lod.objects.LodDimension;
|
||||
import com.seibel.lod.objects.LodRegion;
|
||||
import com.seibel.lod.objects.PosToRenderContainer;
|
||||
import com.seibel.lod.objects.RegionPos;
|
||||
import com.seibel.lod.proxy.ClientProxy;
|
||||
import com.seibel.lod.render.LodRenderer;
|
||||
import com.seibel.lod.util.LodThreadFactory;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.vertex.VertexBuffer;
|
||||
@@ -142,6 +141,20 @@ public class LodBufferBuilder
|
||||
public void generateLodBuffersAsync(LodRenderer renderer, LodDimension lodDim,
|
||||
BlockPos playerBlockPos, boolean fullRegen)
|
||||
{
|
||||
|
||||
|
||||
for(int i = 0; i<16; i++)
|
||||
{
|
||||
for(int j = 0; j<16; j++)
|
||||
{
|
||||
int lightTint = LightTexture.pack(i,j);
|
||||
//System.out.print(ColorUtil.getRed(lightTint) + " " + ColorUtil.getGreen(lightTint) + " " + ColorUtil.getBlue(lightTint) + " ");
|
||||
System.out.print(Integer.toHexString(lightTint) + " ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
|
||||
// only allow one generation process to happen at a time
|
||||
if (generatingBuffers)
|
||||
return;
|
||||
|
||||
@@ -36,7 +36,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
@@ -44,8 +43,6 @@ import net.minecraft.world.chunk.ChunkSection;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
|
||||
/**
|
||||
* This object is in charge of creating Lod related objects. (specifically: Lod
|
||||
* World, Dimension, and Region objects)
|
||||
@@ -277,11 +274,11 @@ public class LodBuilder
|
||||
color = generateLodColor(chunk, config, xRel, yAbs, zRel);
|
||||
depth = determineBottomPointFrom(chunk, config, xRel, zRel, yAbs, blockPos);
|
||||
blockPos.set(xAbs, yAbs + 1, zAbs);
|
||||
light = getLightBlockValue(chunk, blockPos);
|
||||
light = getLightValue(chunk, blockPos);
|
||||
|
||||
//System.out.println(dataToMerge.length + " " + index +" " + count + " " + yAbs);
|
||||
//System.out.println(dataToMerge.length + " " + dataToMerge[index].length);
|
||||
dataToMerge[index][count] = DataPointUtil.createDataPoint(height, depth, color, light, generation);
|
||||
dataToMerge[index][count] = DataPointUtil.createDataPoint(height, depth, color, (light >> 4) & 0b1111, light & 0b1111, generation);
|
||||
yAbs = depth - 1;
|
||||
count++;
|
||||
}
|
||||
@@ -409,9 +406,9 @@ public class LodBuilder
|
||||
depth = determineBottomPoint(chunk, config, xRel, zRel, blockPos);
|
||||
|
||||
blockPos.set(xAbs, yAbs + 1, zAbs);
|
||||
light = getLightBlockValue(chunk, blockPos);
|
||||
light = getLightValue(chunk, blockPos);
|
||||
|
||||
dataToMerge[index] = DataPointUtil.createDataPoint(height, depth, color, light, generation);
|
||||
dataToMerge[index] = DataPointUtil.createDataPoint(height, depth, color, (light >> 4) & 0b1111, light & 0b1111, generation);
|
||||
}
|
||||
return dataToMerge;
|
||||
}
|
||||
@@ -522,17 +519,18 @@ public class LodBuilder
|
||||
return colorInt;
|
||||
}
|
||||
|
||||
private int getLightBlockValue(IChunk chunk, BlockPos.Mutable blockPos)
|
||||
private int getLightValue(IChunk chunk, BlockPos.Mutable blockPos)
|
||||
{
|
||||
int lightBlock;
|
||||
int light;
|
||||
|
||||
//*TODO choose the best one between those options*/
|
||||
//lightBlock = MinecraftWrapper.INSTANCE.getPlayer().level.getLightEngine().getLayerListener(LightType.BLOCK).getLightValue(blockPos);
|
||||
//lightBlock = (byte) MinecraftWrapper.INSTANCE.getPlayer().level.getLightEngine().blockEngine.getLightValue(blockPos);
|
||||
lightBlock = (byte) MinecraftWrapper.INSTANCE.getPlayer().level.getBrightness(LightType.BLOCK, blockPos);
|
||||
light = MinecraftWrapper.INSTANCE.getPlayer().level.getBrightness(LightType.BLOCK, blockPos);
|
||||
light += MinecraftWrapper.INSTANCE.getPlayer().level.getBrightness(LightType.SKY, blockPos) << 4;
|
||||
//BlockState blockState = chunk.getBlockState(blockPos);
|
||||
//lightBlock = (byte) blockState.getLightBlock(chunk, blockPos);
|
||||
return lightBlock;
|
||||
return light;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,21 +63,11 @@ public class CubicLodTemplate extends AbstractLodTemplate
|
||||
bufferCenterBlockPos);
|
||||
int color;
|
||||
boolean hasSkyLight = MinecraftWrapper.INSTANCE.getPlayer().level.dimensionType().hasSkyLight();
|
||||
boolean hasRoof = MinecraftWrapper.INSTANCE.getPlayer().level.dimensionType().hasSkyLight();
|
||||
int time = (int) (MinecraftWrapper.INSTANCE.getPlayer().level.getDayTime() - 13000);
|
||||
boolean isDay = time < 0;
|
||||
//USE THIS IN THE boolean hasCeiling = MinecraftWrapper.INSTANCE.getPlayer().level.dimensionType().hasCeiling();
|
||||
if (hasSkyLight)
|
||||
{
|
||||
int time = (int) (MinecraftWrapper.INSTANCE.getPlayer().level.getDayTime() - 13000);
|
||||
if (time < 0)
|
||||
{
|
||||
color = DataPointUtil.getColor(data);
|
||||
} else
|
||||
{
|
||||
/*TODO implement a smoother transition for light from day to night */
|
||||
color = DataPointUtil.getLightColor(data,4);
|
||||
}
|
||||
}else{
|
||||
color = DataPointUtil.getLightColor(data,1);
|
||||
}
|
||||
color = DataPointUtil.getLightColor(data, (hasRoof & hasSkyLight), isDay);
|
||||
|
||||
if (debugging != DebugMode.OFF)
|
||||
|
||||
|
||||
@@ -42,7 +42,9 @@ public class VerticalLevelContainer implements LevelContainer
|
||||
|
||||
public boolean doesItExist(int posX, int posZ){
|
||||
long[] data = getData(posX,posZ);
|
||||
return (data != null && DataPointUtil.doesItExist(data[0]));
|
||||
if(data == null)
|
||||
return false;
|
||||
return DataPointUtil.doesItExist(data[0]);
|
||||
}
|
||||
|
||||
public VerticalLevelContainer(String inputString)
|
||||
|
||||
@@ -1,38 +1,72 @@
|
||||
package com.seibel.lod.util;
|
||||
|
||||
import com.seibel.lod.enums.DistanceGenerationMode;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
|
||||
public class DataPointUtil
|
||||
{
|
||||
/*
|
||||
|a |a |a |a |r |r |r |r |
|
||||
|
||||
|r |r |r |r |g |g |g |g |
|
||||
|
||||
|g |g |g |g |b |b |b |b |
|
||||
|
||||
|b |b |b |b |h |h |h |h |
|
||||
|
||||
|h |h |h |h |h |h |d |d |
|
||||
|
||||
|d |d |d |d |d |d |d |d |
|
||||
|
||||
|bl |bl |bl |bl |sl |sl |sl |sl |
|
||||
|
||||
|l |l |f |g |g |g |v |e |
|
||||
|
||||
|
||||
*/
|
||||
//To be used in the future for negative value
|
||||
//public final static int MIN_DEPTH = -64;
|
||||
//public final static int MIN_HEIGHT = -64;
|
||||
public final static int EMPTY_DATA = 0;
|
||||
public final static int WORLD_HEIGHT = 256;
|
||||
|
||||
public final static int ALPHA_SHIFT = 56;
|
||||
public final static int RED_SHIFT = 48;
|
||||
public final static int GREEN_SHIFT = 40;
|
||||
public final static int BLUE_SHIFT = 32;
|
||||
public final static int COLOR_SHIFT = 32;
|
||||
public final static int HEIGHT_SHIFT = 22;
|
||||
public final static int DEPTH_SHIFT = 12;
|
||||
public final static int LIGHT_SHIFT = 8;
|
||||
public final static int ALPHA_DOWNSIZE_SHIFT = 4;
|
||||
|
||||
public final static int BLUE_COLOR_SHIFT = 0;
|
||||
public final static int GREEN_COLOR_SHIFT = 8;
|
||||
public final static int RED_COLOR_SHIFT = 16;
|
||||
public final static int ALPHA_COLOR_SHIFT = 24;
|
||||
|
||||
public final static int BLUE_SHIFT = 36;
|
||||
public final static int GREEN_SHIFT = BLUE_SHIFT + 8;
|
||||
public final static int RED_SHIFT = BLUE_SHIFT + 16 ;
|
||||
public final static int ALPHA_SHIFT = BLUE_SHIFT + 24;
|
||||
|
||||
public final static int COLOR_SHIFT = 36;
|
||||
|
||||
public final static int HEIGHT_SHIFT = 26;
|
||||
public final static int DEPTH_SHIFT = 16;
|
||||
public final static int BLOCK_LIGHT_SHIFT = 12;
|
||||
public final static int SKY_LIGHT_SHIFT = 8;
|
||||
public final static int LIGHTS_SHIFT = SKY_LIGHT_SHIFT;
|
||||
public final static int VERTICAL_INDEX_SHIFT = 6;
|
||||
public final static int FLAG_SHIFT = 5;
|
||||
public final static int GEN_TYPE_SHIFT = 2;
|
||||
public final static int VOID_SHIFT = 1;
|
||||
public final static int EXISTENCE_SHIFT = 0;
|
||||
|
||||
public final static long ALPHA_MASK = 0b1111_1111;
|
||||
public final static long ALPHA_MASK = 0b1111;
|
||||
public final static long RED_MASK = 0b1111_1111;
|
||||
public final static long GREEN_MASK = 0b1111_1111;
|
||||
public final static long BLUE_MASK = 0b1111_1111;
|
||||
public final static long COLOR_MASK = 0b11111111_11111111_11111111_11111111;
|
||||
public final static long COLOR_MASK = 0b11111111_11111111_11111111;
|
||||
public final static long HEIGHT_MASK = 0b11_1111_1111;
|
||||
public final static long DEPTH_MASK = 0b11_1111_1111;
|
||||
public final static long LIGHT_MASK = 0b1111;
|
||||
public final static long LIGHTS_MASK = 0b1111_1111;
|
||||
public final static long BLOCK_LIGHT_MASK = 0b1111;
|
||||
public final static long SKY_LIGHT_MASK = 0b1111;
|
||||
public final static long VERTICAL_INDEX_MASK = 0b11;
|
||||
public final static long FLAG_MASK = 0b1;
|
||||
public final static long GEN_TYPE_MASK = 0b111;
|
||||
public final static long VOID_MASK = 1;
|
||||
public final static long EXISTENCE_MASK = 1;
|
||||
@@ -47,26 +81,27 @@ public class DataPointUtil
|
||||
return dataPoint;
|
||||
}
|
||||
|
||||
public static long createDataPoint(int height, int depth, int color, int lightValue, int generationMode)
|
||||
public static long createDataPoint(int height, int depth, int color, int lightSky, int lightBlock, int generationMode)
|
||||
{
|
||||
return createDataPoint(
|
||||
ColorUtil.getAlpha(color),
|
||||
ColorUtil.getRed(color),
|
||||
ColorUtil.getGreen(color),
|
||||
ColorUtil.getBlue(color),
|
||||
height, depth, lightValue, generationMode);
|
||||
height, depth, lightSky, lightBlock, generationMode);
|
||||
}
|
||||
|
||||
public static long createDataPoint(int alpha, int red, int green, int blue, int height, int depth, int lightValue, int generationMode)
|
||||
public static long createDataPoint(int alpha, int red, int green, int blue, int height, int depth, int lightSky, int lightBlock, int generationMode)
|
||||
{
|
||||
long dataPoint = 0;
|
||||
dataPoint += (alpha & ALPHA_MASK) << ALPHA_SHIFT;
|
||||
dataPoint += ((alpha & ALPHA_MASK) >>> ALPHA_DOWNSIZE_SHIFT) << ALPHA_SHIFT;
|
||||
dataPoint += (red & RED_MASK) << RED_SHIFT;
|
||||
dataPoint += (green & GREEN_MASK) << GREEN_SHIFT;
|
||||
dataPoint += (blue & BLUE_MASK) << BLUE_SHIFT;
|
||||
dataPoint += (height & HEIGHT_MASK) << HEIGHT_SHIFT;
|
||||
dataPoint += (depth & DEPTH_MASK) << DEPTH_SHIFT;
|
||||
dataPoint += (lightValue & LIGHT_MASK) << LIGHT_SHIFT;
|
||||
dataPoint += (lightBlock & BLOCK_LIGHT_MASK) << BLOCK_LIGHT_SHIFT;
|
||||
dataPoint += (lightSky & SKY_LIGHT_MASK) << SKY_LIGHT_SHIFT;
|
||||
dataPoint += (generationMode & GEN_TYPE_MASK) << GEN_TYPE_SHIFT;
|
||||
dataPoint += EXISTENCE_MASK << EXISTENCE_SHIFT;
|
||||
return dataPoint;
|
||||
@@ -85,7 +120,7 @@ public class DataPointUtil
|
||||
|
||||
public static short getAlpha(long dataPoint)
|
||||
{
|
||||
return (short) ((dataPoint >>> ALPHA_SHIFT) & ALPHA_MASK);
|
||||
return (short) (((dataPoint >>> ALPHA_SHIFT) & ALPHA_MASK) << ALPHA_DOWNSIZE_SHIFT);
|
||||
}
|
||||
|
||||
public static short getRed(long dataPoint)
|
||||
@@ -103,9 +138,14 @@ public class DataPointUtil
|
||||
return (short) ((dataPoint >>> BLUE_SHIFT) & BLUE_MASK);
|
||||
}
|
||||
|
||||
public static int getLightValue(long dataPoint)
|
||||
public static int getLightSky(long dataPoint)
|
||||
{
|
||||
return (int) ((dataPoint >>> LIGHT_SHIFT) & LIGHT_MASK);
|
||||
return (int) ((dataPoint >>> SKY_LIGHT_SHIFT) & SKY_LIGHT_MASK);
|
||||
}
|
||||
|
||||
public static int getLightBlock(long dataPoint)
|
||||
{
|
||||
return (int) ((dataPoint >>> BLOCK_LIGHT_SHIFT) & BLOCK_LIGHT_MASK);
|
||||
}
|
||||
|
||||
public static byte getGenerationMode(long dataPoint)
|
||||
@@ -126,15 +166,25 @@ public class DataPointUtil
|
||||
|
||||
public static int getColor(long dataPoint)
|
||||
{
|
||||
int color = getBlue(dataPoint) << BLUE_COLOR_SHIFT;
|
||||
color += getRed(dataPoint) << BLUE_COLOR_SHIFT;
|
||||
return (int) (dataPoint >>> COLOR_SHIFT);
|
||||
}
|
||||
|
||||
public static int getLightColor(long dataPoint, int amp)
|
||||
public static int getLightColor(long dataPoint, boolean roof, boolean day)
|
||||
{
|
||||
int lightBlock = getLightValue(dataPoint);
|
||||
int red = LodUtil.clamp(0, getRed(dataPoint) + lightBlock * amp, 255);
|
||||
int green = LodUtil.clamp(0, getGreen(dataPoint) + lightBlock * amp, 255);
|
||||
int blue = LodUtil.clamp(0, getBlue(dataPoint) + lightBlock * amp, 255);
|
||||
int lightBlock = getLightBlock(dataPoint);
|
||||
int lightSky = getLightSky(dataPoint);
|
||||
int lightTint = LightTexture.pack(lightSky,lightBlock);
|
||||
|
||||
int red = (ColorUtil.getRed(lightTint) + getRed(dataPoint))/2;
|
||||
int green = (ColorUtil.getGreen(lightTint) + getGreen(dataPoint))/2;
|
||||
int blue = (ColorUtil.getBlue(lightTint) + getBlue(dataPoint))/2;
|
||||
/*
|
||||
red = LodUtil.clamp(0, getRed(dataPoint) + red, 255);
|
||||
green = LodUtil.clamp(0, getGreen(dataPoint) + green, 255);
|
||||
blue = LodUtil.clamp(0, getBlue(dataPoint) + blue, 255);*/
|
||||
|
||||
return ColorUtil.rgbToInt(red, green, blue);
|
||||
}
|
||||
|
||||
@@ -153,7 +203,9 @@ public class DataPointUtil
|
||||
s.append(" ");
|
||||
s.append(getGreen(dataPoint));
|
||||
s.append(" ");
|
||||
s.append(getLightValue(dataPoint));
|
||||
s.append(getLightBlock(dataPoint));
|
||||
s.append(" ");
|
||||
s.append(getLightSky(dataPoint));
|
||||
s.append(" ");
|
||||
s.append(getGenerationMode(dataPoint));
|
||||
s.append(" ");
|
||||
@@ -175,7 +227,8 @@ public class DataPointUtil
|
||||
int tempBlue = 0;
|
||||
int tempHeight = 0;
|
||||
int tempDepth = 0;
|
||||
int tempLight = 0;
|
||||
int tempLightBlock = 0;
|
||||
int tempLightSky = 0;
|
||||
byte tempGenMode = DistanceGenerationMode.SERVER.complexity;
|
||||
boolean allEmpty = true;
|
||||
boolean allVoid = true;
|
||||
@@ -194,7 +247,8 @@ public class DataPointUtil
|
||||
tempBlue += DataPointUtil.getBlue(data);
|
||||
tempHeight += DataPointUtil.getHeight(data);
|
||||
tempDepth += DataPointUtil.getDepth(data);
|
||||
tempLight += DataPointUtil.getLightValue(data);
|
||||
tempLightBlock += DataPointUtil.getLightBlock(data);
|
||||
tempLightSky += DataPointUtil.getLightSky(data);
|
||||
}
|
||||
tempGenMode = (byte) Math.min(tempGenMode, DataPointUtil.getGenerationMode(data));
|
||||
} else
|
||||
@@ -220,8 +274,9 @@ public class DataPointUtil
|
||||
tempBlue = tempBlue / numberOfChildren;
|
||||
tempHeight = tempHeight / numberOfChildren;
|
||||
tempDepth = tempDepth / numberOfChildren;
|
||||
tempLight = tempLight / numberOfChildren;
|
||||
return DataPointUtil.createDataPoint(tempAlpha, tempRed, tempGreen, tempBlue, tempHeight, tempDepth, tempLight, tempGenMode);
|
||||
tempLightBlock = tempLightBlock / numberOfChildren;
|
||||
tempLightSky = tempLightSky / numberOfChildren;
|
||||
return DataPointUtil.createDataPoint(tempAlpha, tempRed, tempGreen, tempBlue, tempHeight, tempDepth, tempLightSky, tempLightBlock, tempGenMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +377,7 @@ public class DataPointUtil
|
||||
}
|
||||
}
|
||||
long data = mergeSingleData(singleDataToMerge);
|
||||
dataPoint[j] = createDataPoint(height, depth, getColor(data), getLightValue(data), getGenerationMode(data));
|
||||
dataPoint[j] = createDataPoint(height, depth, getColor(data), getLightSky(data), getLightBlock(data), getGenerationMode(data));
|
||||
}
|
||||
|
||||
return dataPoint;
|
||||
|
||||
Reference in New Issue
Block a user