add LodDirection
This commit is contained in:
@@ -38,6 +38,7 @@ import org.lwjgl.opengl.GL45;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.lod.config.LodConfig;
|
||||
import com.seibel.lod.enums.LodDirection;
|
||||
import com.seibel.lod.enums.config.GpuUploadMethod;
|
||||
import com.seibel.lod.enums.config.VanillaOverdraw;
|
||||
import com.seibel.lod.enums.rendering.GlProxyContext;
|
||||
@@ -61,8 +62,6 @@ import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
import com.seibel.lod.wrappers.Chunk.ChunkPosWrapper;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
/**
|
||||
* This object creates the buffers that are
|
||||
* rendered by the LodRenderer.
|
||||
@@ -280,7 +279,7 @@ public class LodBufferBuilderFactory
|
||||
int maxVerticalData = DetailDistanceUtil.getMaxVerticalData((byte) 0);
|
||||
|
||||
//we get or create the map that will contain the adj data
|
||||
Map<Direction, long[]> adjData = ThreadMapUtil.getAdjDataArray(maxVerticalData);
|
||||
Map<LodDirection, long[]> adjData = ThreadMapUtil.getAdjDataArray(maxVerticalData);
|
||||
|
||||
//previous setToRender cache
|
||||
if (setsToRender[xR][zR] == null)
|
||||
@@ -335,11 +334,11 @@ public class LodBufferBuilderFactory
|
||||
Arrays.fill(adjShadeDisabled, false);
|
||||
|
||||
//We check every adj block in each direction
|
||||
for (Direction direction : Box.ADJ_DIRECTIONS)
|
||||
for (LodDirection lodDirection : Box.ADJ_DIRECTIONS)
|
||||
{
|
||||
|
||||
xAdj = posX + Box.DIRECTION_NORMAL_MAP.get(direction).getX();
|
||||
zAdj = posZ + Box.DIRECTION_NORMAL_MAP.get(direction).getZ();
|
||||
xAdj = posX + Box.DIRECTION_NORMAL_MAP.get(lodDirection).x;
|
||||
zAdj = posZ + Box.DIRECTION_NORMAL_MAP.get(lodDirection).z;
|
||||
long data;
|
||||
chunkXdist = LevelPosUtil.getChunkPos(detailLevel, xAdj) - playerChunkPos.getX();
|
||||
chunkZdist = LevelPosUtil.getChunkPos(detailLevel, zAdj) - playerChunkPos.getZ();
|
||||
@@ -357,8 +356,8 @@ public class LodBufferBuilderFactory
|
||||
for (int verticalIndex = 0; verticalIndex < lodDim.getMaxVerticalData(detailLevel, xAdj, zAdj); verticalIndex++)
|
||||
{
|
||||
data = lodDim.getData(detailLevel, xAdj, zAdj, verticalIndex);
|
||||
adjShadeDisabled[Box.DIRECTION_INDEX.get(direction)] = false;
|
||||
adjData.get(direction)[verticalIndex] = data;
|
||||
adjShadeDisabled[Box.DIRECTION_INDEX.get(lodDirection)] = false;
|
||||
adjData.get(lodDirection)[verticalIndex] = data;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -366,12 +365,12 @@ public class LodBufferBuilderFactory
|
||||
//Otherwise, we check if this position is
|
||||
data = lodDim.getSingleData(detailLevel, xAdj, zAdj);
|
||||
|
||||
adjData.get(direction)[0] = DataPointUtil.EMPTY_DATA;
|
||||
adjData.get(lodDirection)[0] = DataPointUtil.EMPTY_DATA;
|
||||
|
||||
if ((isThisPositionGoingToBeRendered(detailLevel, xAdj, zAdj, playerChunkPos, vanillaRenderedChunks, gameChunkRenderDistance) || (posNotInPlayerChunk && adjPosInPlayerChunk))
|
||||
&& !DataPointUtil.isVoid(data))
|
||||
{
|
||||
adjShadeDisabled[Box.DIRECTION_INDEX.get(direction)] = DataPointUtil.getAlpha(data) < 255;
|
||||
adjShadeDisabled[Box.DIRECTION_INDEX.get(lodDirection)] = DataPointUtil.getAlpha(data) < 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -385,16 +384,16 @@ public class LodBufferBuilderFactory
|
||||
|
||||
//we get the above block as adj UP
|
||||
if (verticalIndex > 0)
|
||||
adjData.get(Direction.UP)[0] = lodDim.getData(detailLevel, posX, posZ, verticalIndex - 1);
|
||||
adjData.get(LodDirection.UP)[0] = lodDim.getData(detailLevel, posX, posZ, verticalIndex - 1);
|
||||
else
|
||||
adjData.get(Direction.UP)[0] = DataPointUtil.EMPTY_DATA;
|
||||
adjData.get(LodDirection.UP)[0] = DataPointUtil.EMPTY_DATA;
|
||||
|
||||
|
||||
//we get the below block as adj DOWN
|
||||
if (verticalIndex < lodDim.getMaxVerticalData(detailLevel, posX, posZ) - 1)
|
||||
adjData.get(Direction.DOWN)[0] = lodDim.getData(detailLevel, posX, posZ, verticalIndex + 1);
|
||||
adjData.get(LodDirection.DOWN)[0] = lodDim.getData(detailLevel, posX, posZ, verticalIndex + 1);
|
||||
else
|
||||
adjData.get(Direction.DOWN)[0] = DataPointUtil.EMPTY_DATA;
|
||||
adjData.get(LodDirection.DOWN)[0] = DataPointUtil.EMPTY_DATA;
|
||||
|
||||
//We extract the data to render
|
||||
data = lodDim.getData(detailLevel, posX, posZ, verticalIndex);
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ import com.seibel.lod.objects.opengl.LodBufferBuilder;
|
||||
import com.seibel.lod.util.ColorUtil;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import com.seibel.lod.enums.LodDirection;
|
||||
|
||||
/**
|
||||
* This is the abstract class used to create different
|
||||
@@ -39,7 +39,7 @@ public abstract class AbstractLodTemplate
|
||||
{
|
||||
|
||||
/** Uploads the given LOD to the buffer. */
|
||||
public abstract void addLodToBuffer(LodBufferBuilder buffer, BlockPosWrapper bufferCenterBlockPos, long data, Map<Direction, long[]> adjData,
|
||||
public abstract void addLodToBuffer(LodBufferBuilder buffer, BlockPosWrapper bufferCenterBlockPos, long data, Map<LodDirection, long[]> adjData,
|
||||
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, boolean[] adjShadeDisabled);
|
||||
|
||||
/** add the given position and color to the buffer */
|
||||
|
||||
+11
-11
@@ -29,7 +29,7 @@ import com.seibel.lod.util.DataPointUtil;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import com.seibel.lod.enums.LodDirection;
|
||||
|
||||
/**
|
||||
* Builds LODs as rectangular prisms.
|
||||
@@ -45,7 +45,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLodToBuffer(LodBufferBuilder buffer, BlockPosWrapper bufferCenterBlockPos, long data, Map<Direction, long[]> adjData,
|
||||
public void addLodToBuffer(LodBufferBuilder buffer, BlockPosWrapper bufferCenterBlockPos, long data, Map<LodDirection, long[]> adjData,
|
||||
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, boolean[] adjShadeDisabled)
|
||||
{
|
||||
if (box == null)
|
||||
@@ -81,7 +81,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
|
||||
int height, int depth, int width,
|
||||
double xOffset, double yOffset, double zOffset,
|
||||
BlockPosWrapper bufferCenterBlockPos,
|
||||
Map<Direction, long[]> adjData,
|
||||
Map<LodDirection, long[]> adjData,
|
||||
int color,
|
||||
int skyLight,
|
||||
int blockLight,
|
||||
@@ -115,24 +115,24 @@ public class CubicLodTemplate extends AbstractLodTemplate
|
||||
int color;
|
||||
int skyLight;
|
||||
int blockLight;
|
||||
for (Direction direction : Box.DIRECTIONS)
|
||||
for (LodDirection lodDirection : Box.DIRECTIONS)
|
||||
{
|
||||
if(box.isCulled(direction))
|
||||
if(box.isCulled(lodDirection))
|
||||
continue;
|
||||
|
||||
int verticalFaceIndex = 0;
|
||||
while (box.shouldRenderFace(direction, verticalFaceIndex))
|
||||
while (box.shouldRenderFace(lodDirection, verticalFaceIndex))
|
||||
{
|
||||
for (int vertexIndex = 0; vertexIndex < 6; vertexIndex++)
|
||||
{
|
||||
color = box.getColor(direction);
|
||||
skyLight = box.getSkyLight(direction, verticalFaceIndex);
|
||||
color = box.getColor(lodDirection);
|
||||
skyLight = box.getSkyLight(lodDirection, verticalFaceIndex);
|
||||
blockLight = box.getBlockLight();
|
||||
color = ColorUtil.applyLightValue(color, skyLight, blockLight);
|
||||
addPosAndColor(buffer,
|
||||
box.getX(direction, vertexIndex),
|
||||
box.getY(direction, vertexIndex, verticalFaceIndex),
|
||||
box.getZ(direction, vertexIndex),
|
||||
box.getX(lodDirection, vertexIndex),
|
||||
box.getY(lodDirection, vertexIndex, verticalFaceIndex),
|
||||
box.getZ(lodDirection, vertexIndex),
|
||||
color);
|
||||
}
|
||||
verticalFaceIndex++;
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ import com.seibel.lod.objects.Box;
|
||||
import com.seibel.lod.objects.opengl.LodBufferBuilder;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import com.seibel.lod.enums.LodDirection;
|
||||
|
||||
/**
|
||||
* TODO DynamicLodTemplate
|
||||
@@ -40,7 +40,7 @@ import net.minecraft.util.Direction;
|
||||
public class DynamicLodTemplate extends AbstractLodTemplate
|
||||
{
|
||||
@Override
|
||||
public void addLodToBuffer(LodBufferBuilder buffer, BlockPosWrapper bufferCenterBlockPos, long data, Map<Direction, long[]> adjData,
|
||||
public void addLodToBuffer(LodBufferBuilder buffer, BlockPosWrapper bufferCenterBlockPos, long data, Map<LodDirection, long[]> adjData,
|
||||
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, boolean[] adjShadeDisabled)
|
||||
{
|
||||
ClientApi.LOGGER.error(DynamicLodTemplate.class.getSimpleName() + " is not implemented!");
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ import com.seibel.lod.objects.Box;
|
||||
import com.seibel.lod.objects.opengl.LodBufferBuilder;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import com.seibel.lod.enums.LodDirection;
|
||||
|
||||
/**
|
||||
* TODO #21 TriangularLodTemplate
|
||||
@@ -38,7 +38,7 @@ import net.minecraft.util.Direction;
|
||||
public class TriangularLodTemplate extends AbstractLodTemplate
|
||||
{
|
||||
@Override
|
||||
public void addLodToBuffer(LodBufferBuilder buffer, BlockPosWrapper bufferCenterBlockPos, long data, Map<Direction, long[]> adjData,
|
||||
public void addLodToBuffer(LodBufferBuilder buffer, BlockPosWrapper bufferCenterBlockPos, long data, Map<LodDirection, long[]> adjData,
|
||||
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, boolean[] adjShadeDisabled)
|
||||
{
|
||||
ClientApi.LOGGER.error(DynamicLodTemplate.class.getSimpleName() + " is not implemented!");
|
||||
|
||||
@@ -0,0 +1,533 @@
|
||||
package com.seibel.lod.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.seibel.lod.objects.math.Vec3i;
|
||||
|
||||
/**
|
||||
* A (almost) exact copy of Minecraft's
|
||||
* Direction enum.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 11-13-2021
|
||||
*/
|
||||
public enum LodDirection
|
||||
{
|
||||
DOWN(0, 1, -1, "down", LodDirection.AxisDirection.NEGATIVE, LodDirection.Axis.Y, new Vec3i(0, -1, 0)),
|
||||
UP(1, 0, -1, "up", LodDirection.AxisDirection.POSITIVE, LodDirection.Axis.Y, new Vec3i(0, 1, 0)),
|
||||
NORTH(2, 3, 2, "north", LodDirection.AxisDirection.NEGATIVE, LodDirection.Axis.Z, new Vec3i(0, 0, -1)),
|
||||
SOUTH(3, 2, 0, "south", LodDirection.AxisDirection.POSITIVE, LodDirection.Axis.Z, new Vec3i(0, 0, 1)),
|
||||
WEST(4, 5, 1, "west", LodDirection.AxisDirection.NEGATIVE, LodDirection.Axis.X, new Vec3i(-1, 0, 0)),
|
||||
EAST(5, 4, 3, "east", LodDirection.AxisDirection.POSITIVE, LodDirection.Axis.X, new Vec3i(1, 0, 0));
|
||||
|
||||
// private final int data3d;
|
||||
// private final int oppositeIndex;
|
||||
// private final int data2d;
|
||||
|
||||
private final String name;
|
||||
private final LodDirection.Axis axis;
|
||||
private final LodDirection.AxisDirection axisDirection;
|
||||
private final Vec3i normal;
|
||||
private static final LodDirection[] VALUES = values();
|
||||
|
||||
private static final Map<String, LodDirection> BY_NAME = Arrays.stream(VALUES).collect(Collectors.toMap(LodDirection::getName, (p_199787_0_) ->
|
||||
{
|
||||
return p_199787_0_;
|
||||
}));
|
||||
|
||||
// private static final LodDirection[] BY_3D_DATA = Arrays.stream(VALUES).sorted(Comparator.comparingInt((p_199790_0_) ->
|
||||
// {
|
||||
// return p_199790_0_.data3d;
|
||||
// })).toArray((p_199788_0_) ->
|
||||
// {
|
||||
// return new LodDirection[p_199788_0_];
|
||||
// });
|
||||
//
|
||||
// private static final LodDirection[] BY_2D_DATA = Arrays.stream(VALUES).filter((p_199786_0_) ->
|
||||
// {
|
||||
// return p_199786_0_.getAxis().isHorizontal();
|
||||
// }).sorted(Comparator.comparingInt((p_199789_0_) ->
|
||||
// {
|
||||
// return p_199789_0_.data2d;
|
||||
// })).toArray((p_199791_0_) ->
|
||||
// {
|
||||
// return new LodDirection[p_199791_0_];
|
||||
// });
|
||||
|
||||
// private static final Long2ObjectMap<LodDirection> BY_NORMAL = Arrays.stream(VALUES).collect(Collectors.toMap((p_218385_0_) ->
|
||||
// {
|
||||
// return (new BlockPos(p_218385_0_.getNormal())).asLong();
|
||||
// }, (p_218384_0_) ->
|
||||
// {
|
||||
// return p_218384_0_;
|
||||
// }, (p_218386_0_, p_218386_1_) ->
|
||||
// {
|
||||
// throw new IllegalArgumentException("Duplicate keys");
|
||||
// }, Long2ObjectOpenHashMap::new));
|
||||
|
||||
|
||||
|
||||
private LodDirection(int p_i46016_3_, int p_i46016_4_, int p_i46016_5_, String p_i46016_6_, LodDirection.AxisDirection p_i46016_7_, LodDirection.Axis p_i46016_8_, Vec3i p_i46016_9_)
|
||||
{
|
||||
// this.data3d = p_i46016_3_;
|
||||
// this.data2d = p_i46016_5_;
|
||||
// this.oppositeIndex = p_i46016_4_;
|
||||
this.name = p_i46016_6_;
|
||||
this.axis = p_i46016_8_;
|
||||
this.axisDirection = p_i46016_7_;
|
||||
this.normal = p_i46016_9_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// public static LodDirection[] orderedByNearest(Entity p_196054_0_)
|
||||
// {
|
||||
// float f = p_196054_0_.getViewXRot(1.0F) * ((float) Math.PI / 180F);
|
||||
// float f1 = -p_196054_0_.getViewYRot(1.0F) * ((float) Math.PI / 180F);
|
||||
// float f2 = MathHelper.sin(f);
|
||||
// float f3 = MathHelper.cos(f);
|
||||
// float f4 = MathHelper.sin(f1);
|
||||
// float f5 = MathHelper.cos(f1);
|
||||
// boolean flag = f4 > 0.0F;
|
||||
// boolean flag1 = f2 < 0.0F;
|
||||
// boolean flag2 = f5 > 0.0F;
|
||||
// float f6 = flag ? f4 : -f4;
|
||||
// float f7 = flag1 ? -f2 : f2;
|
||||
// float f8 = flag2 ? f5 : -f5;
|
||||
// float f9 = f6 * f3;
|
||||
// float f10 = f8 * f3;
|
||||
// LodDirection lodDirection = flag ? EAST : WEST;
|
||||
// LodDirection direction1 = flag1 ? UP : DOWN;
|
||||
// LodDirection direction2 = flag2 ? SOUTH : NORTH;
|
||||
// if (f6 > f8)
|
||||
// {
|
||||
// if (f7 > f9)
|
||||
// {
|
||||
// return makeDirectionArray(direction1, lodDirection, direction2);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return f10 > f7 ? makeDirectionArray(lodDirection, direction2, direction1) : makeDirectionArray(lodDirection, direction1, direction2);
|
||||
// }
|
||||
// }
|
||||
// else if (f7 > f10)
|
||||
// {
|
||||
// return makeDirectionArray(direction1, direction2, lodDirection);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return f9 > f7 ? makeDirectionArray(direction2, lodDirection, direction1) : makeDirectionArray(direction2, direction1, lodDirection);
|
||||
// }
|
||||
// }
|
||||
|
||||
// private static LodDirection[] makeDirectionArray(LodDirection p_196053_0_, LodDirection p_196053_1_, LodDirection p_196053_2_)
|
||||
// {
|
||||
// return new LodDirection[] { p_196053_0_, p_196053_1_, p_196053_2_, p_196053_2_.getOpposite(), p_196053_1_.getOpposite(), p_196053_0_.getOpposite() };
|
||||
// }
|
||||
|
||||
// public static LodDirection rotate(Mat4f p_229385_0_, LodDirection p_229385_1_)
|
||||
// {
|
||||
// Vec3i Vec3i = p_229385_1_.getNormal();
|
||||
// Vector4f vector4f = new Vector4f(Vec3i.getX(), Vec3i.getY(), Vec3i.getZ(), 0.0F);
|
||||
// vector4f.transform(p_229385_0_);
|
||||
// return getNearest(vector4f.x(), vector4f.y(), vector4f.z());
|
||||
// }
|
||||
|
||||
// public Quaternion getRotation()
|
||||
// {
|
||||
// Quaternion quaternion = Vector3f.XP.rotationDegrees(90.0F);
|
||||
// switch (this)
|
||||
// {
|
||||
// case DOWN:
|
||||
// return Vector3f.XP.rotationDegrees(180.0F);
|
||||
// case UP:
|
||||
// return Quaternion.ONE.copy();
|
||||
// case NORTH:
|
||||
// quaternion.mul(Vector3f.ZP.rotationDegrees(180.0F));
|
||||
// return quaternion;
|
||||
// case SOUTH:
|
||||
// return quaternion;
|
||||
// case WEST:
|
||||
// quaternion.mul(Vector3f.ZP.rotationDegrees(90.0F));
|
||||
// return quaternion;
|
||||
// case EAST:
|
||||
// default:
|
||||
// quaternion.mul(Vector3f.ZP.rotationDegrees(-90.0F));
|
||||
// return quaternion;
|
||||
// }
|
||||
// }
|
||||
|
||||
// public int get3DDataValue()
|
||||
// {
|
||||
// return this.data3d;
|
||||
// }
|
||||
//
|
||||
// public int get2DDataValue()
|
||||
// {
|
||||
// return this.data2d;
|
||||
// }
|
||||
|
||||
public LodDirection.AxisDirection getAxisDirection()
|
||||
{
|
||||
return this.axisDirection;
|
||||
}
|
||||
|
||||
// public LodDirection getOpposite()
|
||||
// {
|
||||
// return from3DDataValue(this.oppositeIndex);
|
||||
// }
|
||||
|
||||
public LodDirection getClockWise()
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case NORTH:
|
||||
return EAST;
|
||||
case SOUTH:
|
||||
return WEST;
|
||||
case WEST:
|
||||
return NORTH;
|
||||
case EAST:
|
||||
return SOUTH;
|
||||
default:
|
||||
throw new IllegalStateException("Unable to get Y-rotated facing of " + this);
|
||||
}
|
||||
}
|
||||
|
||||
public LodDirection getCounterClockWise()
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case NORTH:
|
||||
return WEST;
|
||||
case SOUTH:
|
||||
return EAST;
|
||||
case WEST:
|
||||
return SOUTH;
|
||||
case EAST:
|
||||
return NORTH;
|
||||
default:
|
||||
throw new IllegalStateException("Unable to get CCW facing of " + this);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public LodDirection.Axis getAxis()
|
||||
{
|
||||
return this.axis;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static LodDirection byName(@Nullable String name)
|
||||
{
|
||||
return name == null ? null : BY_NAME.get(name.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
// public static LodDirection from3DDataValue(int p_82600_0_)
|
||||
// {
|
||||
// return BY_3D_DATA[MathHelper.abs(p_82600_0_ % BY_3D_DATA.length)];
|
||||
// }
|
||||
//
|
||||
// public static LodDirection from2DDataValue(int p_176731_0_)
|
||||
// {
|
||||
// return BY_2D_DATA[MathHelper.abs(p_176731_0_ % BY_2D_DATA.length)];
|
||||
// }
|
||||
|
||||
// @Nullable
|
||||
// public static LodDirection fromNormal(int p_218383_0_, int p_218383_1_, int p_218383_2_)
|
||||
// {
|
||||
// return BY_NORMAL.get(BlockPos.asLong(p_218383_0_, p_218383_1_, p_218383_2_));
|
||||
// }
|
||||
|
||||
// public static LodDirection fromYRot(double p_176733_0_)
|
||||
// {
|
||||
// return from2DDataValue(MathHelper.floor(p_176733_0_ / 90.0D + 0.5D) & 3);
|
||||
// }
|
||||
|
||||
public static LodDirection fromAxisAndDirection(LodDirection.Axis p_211699_0_, LodDirection.AxisDirection p_211699_1_)
|
||||
{
|
||||
switch (p_211699_0_)
|
||||
{
|
||||
case X:
|
||||
return p_211699_1_ == LodDirection.AxisDirection.POSITIVE ? EAST : WEST;
|
||||
case Y:
|
||||
return p_211699_1_ == LodDirection.AxisDirection.POSITIVE ? UP : DOWN;
|
||||
case Z:
|
||||
default:
|
||||
return p_211699_1_ == LodDirection.AxisDirection.POSITIVE ? SOUTH : NORTH;
|
||||
}
|
||||
}
|
||||
|
||||
// public float toYRot()
|
||||
// {
|
||||
// return (this.data2d & 3) * 90;
|
||||
// }
|
||||
|
||||
// public static LodDirection getRandom(Random p_239631_0_)
|
||||
// {
|
||||
// return Util.getRandom(VALUES, p_239631_0_);
|
||||
// }
|
||||
|
||||
// public static LodDirection getNearest(double p_210769_0_, double p_210769_2_, double p_210769_4_)
|
||||
// {
|
||||
// return getNearest((float) p_210769_0_, (float) p_210769_2_, (float) p_210769_4_);
|
||||
// }
|
||||
|
||||
// public static LodDirection getNearest(float p_176737_0_, float p_176737_1_, float p_176737_2_)
|
||||
// {
|
||||
// LodDirection lodDirection = NORTH;
|
||||
// float f = Float.MIN_VALUE;
|
||||
//
|
||||
// for (LodDirection direction1 : VALUES)
|
||||
// {
|
||||
// float f1 = p_176737_0_ * direction1.normal.x + p_176737_1_ * direction1.normal.y + p_176737_2_ * direction1.normal.z;
|
||||
// if (f1 > f)
|
||||
// {
|
||||
// f = f1;
|
||||
// lodDirection = direction1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return lodDirection;
|
||||
// }
|
||||
|
||||
public static LodDirection get(LodDirection.AxisDirection p_181076_0_, LodDirection.Axis p_181076_1_)
|
||||
{
|
||||
for (LodDirection lodDirection : VALUES)
|
||||
{
|
||||
if (lodDirection.getAxisDirection() == p_181076_0_ && lodDirection.getAxis() == p_181076_1_)
|
||||
{
|
||||
return lodDirection;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("No such direction: " + p_181076_0_ + " " + p_181076_1_);
|
||||
}
|
||||
|
||||
public Vec3i getNormal()
|
||||
{
|
||||
return this.normal;
|
||||
}
|
||||
|
||||
// public boolean isFacingAngle(float p_243532_1_)
|
||||
// {
|
||||
// float f = p_243532_1_ * ((float) Math.PI / 180F);
|
||||
// float f1 = -MathHelper.sin(f);
|
||||
// float f2 = MathHelper.cos(f);
|
||||
// return this.normal.getX() * f1 + this.normal.getZ() * f2 > 0.0F;
|
||||
// }
|
||||
|
||||
public static enum Axis implements Predicate<LodDirection>
|
||||
{
|
||||
X("x")
|
||||
{
|
||||
@Override
|
||||
public int choose(int x, int y, int z)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double choose(double x, double y, double z)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
},
|
||||
Y("y")
|
||||
{
|
||||
@Override
|
||||
public int choose(int x, int y, int z)
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double choose(double x, double y, double z)
|
||||
{
|
||||
return y;
|
||||
}
|
||||
},
|
||||
Z("z")
|
||||
{
|
||||
@Override
|
||||
public int choose(int x, int y, int z)
|
||||
{
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double choose(double x, double y, double z)
|
||||
{
|
||||
return z;
|
||||
}
|
||||
};
|
||||
|
||||
private static final LodDirection.Axis[] VALUES = values();
|
||||
|
||||
private static final Map<String, LodDirection.Axis> BY_NAME = Arrays.stream(VALUES).collect(Collectors.toMap(LodDirection.Axis::getName, (p_199785_0_) ->
|
||||
{
|
||||
return p_199785_0_;
|
||||
}));
|
||||
private final String name;
|
||||
|
||||
private Axis(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static LodDirection.Axis byName(String name)
|
||||
{
|
||||
return BY_NAME.get(name.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isVertical()
|
||||
{
|
||||
return this == Y;
|
||||
}
|
||||
|
||||
public boolean isHorizontal()
|
||||
{
|
||||
return this == X || this == Z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
// public static LodDirection.Axis getRandom(Random p_239634_0_)
|
||||
// {
|
||||
// return Util.getRandom(VALUES, p_239634_0_);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean test(@Nullable LodDirection p_test_1_)
|
||||
{
|
||||
return p_test_1_ != null && p_test_1_.getAxis() == this;
|
||||
}
|
||||
|
||||
// public LodDirection.Plane getPlane()
|
||||
// {
|
||||
// switch (this)
|
||||
// {
|
||||
// case X:
|
||||
// case Z:
|
||||
// return LodDirection.Plane.HORIZONTAL;
|
||||
// case Y:
|
||||
// return LodDirection.Plane.VERTICAL;
|
||||
// default:
|
||||
// throw new Error("Someone's been tampering with the universe!");
|
||||
// }
|
||||
// }
|
||||
|
||||
public abstract int choose(int p_196052_1_, int p_196052_2_, int p_196052_3_);
|
||||
|
||||
public abstract double choose(double p_196051_1_, double p_196051_3_, double p_196051_5_);
|
||||
}
|
||||
|
||||
public static enum AxisDirection
|
||||
{
|
||||
POSITIVE(1, "Towards positive"),
|
||||
NEGATIVE(-1, "Towards negative");
|
||||
|
||||
private final int step;
|
||||
private final String name;
|
||||
|
||||
private AxisDirection(int newStep, String newName)
|
||||
{
|
||||
this.step = newStep;
|
||||
this.name = newName;
|
||||
}
|
||||
|
||||
public int getStep()
|
||||
{
|
||||
return this.step;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public LodDirection.AxisDirection opposite()
|
||||
{
|
||||
return this == POSITIVE ? NEGATIVE : POSITIVE;
|
||||
}
|
||||
}
|
||||
|
||||
// public static enum Plane implements Iterable<LodDirection>, Predicate<LodDirection>
|
||||
// {
|
||||
// HORIZONTAL(new LodDirection[] { LodDirection.NORTH, LodDirection.EAST, LodDirection.SOUTH, LodDirection.WEST }, new LodDirection.Axis[] { LodDirection.Axis.X, LodDirection.Axis.Z }),
|
||||
// VERTICAL(new LodDirection[] { LodDirection.UP, LodDirection.DOWN }, new LodDirection.Axis[] { LodDirection.Axis.Y });
|
||||
//
|
||||
// private final LodDirection[] faces;
|
||||
// private final LodDirection.Axis[] axis;
|
||||
//
|
||||
// private Plane(LodDirection[] p_i49393_3_, LodDirection.Axis[] p_i49393_4_)
|
||||
// {
|
||||
// this.faces = p_i49393_3_;
|
||||
// this.axis = p_i49393_4_;
|
||||
// }
|
||||
//
|
||||
// public LodDirection getRandomDirection(Random p_179518_1_)
|
||||
// {
|
||||
// return Util.getRandom(this.faces, p_179518_1_);
|
||||
// }
|
||||
//
|
||||
// public LodDirection.Axis getRandomAxis(Random p_244803_1_)
|
||||
// {
|
||||
// return Util.getRandom(this.axis, p_244803_1_);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean test(@Nullable LodDirection p_test_1_)
|
||||
// {
|
||||
// return p_test_1_ != null && p_test_1_.getAxis().getPlane() == this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Iterator<LodDirection> iterator()
|
||||
// {
|
||||
// return Iterators.forArray(this.faces);
|
||||
// }
|
||||
//
|
||||
// public Stream<LodDirection> stream()
|
||||
// {
|
||||
// return Arrays.stream(this.faces);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
public String getSerializedName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,15 +24,14 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.seibel.lod.config.LodConfig;
|
||||
import com.seibel.lod.enums.LodDirection;
|
||||
import com.seibel.lod.enums.rendering.DebugMode;
|
||||
import com.seibel.lod.objects.math.Vec3i;
|
||||
import com.seibel.lod.util.ColorUtil;
|
||||
import com.seibel.lod.util.DataPointUtil;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
|
||||
/**
|
||||
* Similar to Minecraft's AxisAlignedBoundingBox.
|
||||
@@ -55,25 +54,25 @@ public class Box
|
||||
public static final int VOID_FACE = 0;
|
||||
|
||||
/** The six cardinal directions */
|
||||
public static final Direction[] DIRECTIONS = new Direction[] {
|
||||
Direction.UP,
|
||||
Direction.DOWN,
|
||||
Direction.WEST,
|
||||
Direction.EAST,
|
||||
Direction.NORTH,
|
||||
Direction.SOUTH };
|
||||
public static final LodDirection[] DIRECTIONS = new LodDirection[] {
|
||||
LodDirection.UP,
|
||||
LodDirection.DOWN,
|
||||
LodDirection.WEST,
|
||||
LodDirection.EAST,
|
||||
LodDirection.NORTH,
|
||||
LodDirection.SOUTH };
|
||||
|
||||
/** North, South, East, West */
|
||||
public static final Direction[] ADJ_DIRECTIONS = new Direction[] {
|
||||
Direction.EAST,
|
||||
Direction.WEST,
|
||||
Direction.SOUTH,
|
||||
Direction.NORTH };
|
||||
public static final LodDirection[] ADJ_DIRECTIONS = new LodDirection[] {
|
||||
LodDirection.EAST,
|
||||
LodDirection.WEST,
|
||||
LodDirection.SOUTH,
|
||||
LodDirection.NORTH };
|
||||
|
||||
/** All the faces and vertices of a cube. This is used to extract the vertex from the column */
|
||||
public static final Map<Direction, int[][]> DIRECTION_VERTEX_MAP = new HashMap<Direction, int[][]>()
|
||||
public static final Map<LodDirection, int[][]> DIRECTION_VERTEX_MAP = new HashMap<LodDirection, int[][]>()
|
||||
{{
|
||||
put(Direction.UP, new int[][] {
|
||||
put(LodDirection.UP, new int[][] {
|
||||
{ 0, 1, 0 }, // 0
|
||||
{ 0, 1, 1 }, // 1
|
||||
{ 1, 1, 1 }, // 2
|
||||
@@ -82,7 +81,7 @@ public class Box
|
||||
{ 1, 1, 1 }, // 2
|
||||
{ 1, 1, 0 } // 3
|
||||
});
|
||||
put(Direction.DOWN, new int[][] {
|
||||
put(LodDirection.DOWN, new int[][] {
|
||||
{ 1, 0, 0 }, // 0
|
||||
{ 1, 0, 1 }, // 1
|
||||
{ 0, 0, 1 }, // 2
|
||||
@@ -91,7 +90,7 @@ public class Box
|
||||
{ 0, 0, 1 }, // 2
|
||||
{ 0, 0, 0 } // 3
|
||||
});
|
||||
put(Direction.EAST, new int[][] {
|
||||
put(LodDirection.EAST, new int[][] {
|
||||
{ 1, 1, 0 }, // 0
|
||||
{ 1, 1, 1 }, // 1
|
||||
{ 1, 0, 1 }, // 2
|
||||
@@ -99,7 +98,7 @@ public class Box
|
||||
{ 1, 1, 0 }, // 0
|
||||
{ 1, 0, 1 }, // 2
|
||||
{ 1, 0, 0 } }); // 3
|
||||
put(Direction.WEST, new int[][] {
|
||||
put(LodDirection.WEST, new int[][] {
|
||||
{ 0, 0, 0 }, // 0
|
||||
{ 0, 0, 1 }, // 1
|
||||
{ 0, 1, 1 }, // 2
|
||||
@@ -108,7 +107,7 @@ public class Box
|
||||
{ 0, 1, 1 }, // 2
|
||||
{ 0, 1, 0 } // 3
|
||||
});
|
||||
put(Direction.SOUTH, new int[][] {
|
||||
put(LodDirection.SOUTH, new int[][] {
|
||||
{ 1, 0, 1 }, // 0
|
||||
{ 1, 1, 1 }, // 1
|
||||
{ 0, 1, 1 }, // 2
|
||||
@@ -117,7 +116,7 @@ public class Box
|
||||
{ 0, 1, 1 }, // 2
|
||||
{ 0, 0, 1 } // 3
|
||||
});
|
||||
put(Direction.NORTH, new int[][] {
|
||||
put(LodDirection.NORTH, new int[][] {
|
||||
{ 0, 0, 0 }, // 0
|
||||
{ 0, 1, 0 }, // 1
|
||||
{ 1, 1, 0 }, // 2
|
||||
@@ -133,14 +132,14 @@ public class Box
|
||||
* This indicates which position is invariable in the DIRECTION_VERTEX_MAP.
|
||||
* Is used to extract the vertex
|
||||
*/
|
||||
public static final Map<Direction, int[]> FACE_DIRECTION = new HashMap<Direction, int[]>()
|
||||
public static final Map<LodDirection, int[]> FACE_DIRECTION = new HashMap<LodDirection, int[]>()
|
||||
{{
|
||||
put(Direction.UP, new int[] { Y, MAX });
|
||||
put(Direction.DOWN, new int[] { Y, MIN });
|
||||
put(Direction.EAST, new int[] { X, MAX });
|
||||
put(Direction.WEST, new int[] { X, MIN });
|
||||
put(Direction.SOUTH, new int[] { Z, MAX });
|
||||
put(Direction.NORTH, new int[] { Z, MIN });
|
||||
put(LodDirection.UP, new int[] { Y, MAX });
|
||||
put(LodDirection.DOWN, new int[] { Y, MIN });
|
||||
put(LodDirection.EAST, new int[] { X, MAX });
|
||||
put(LodDirection.WEST, new int[] { X, MIN });
|
||||
put(LodDirection.SOUTH, new int[] { Z, MAX });
|
||||
put(LodDirection.NORTH, new int[] { Z, MIN });
|
||||
}};
|
||||
|
||||
|
||||
@@ -148,33 +147,33 @@ public class Box
|
||||
* This is a map from Direction to the relative normal vector
|
||||
* we are using this since I'm not sure if the getNormal create new object at every call
|
||||
*/
|
||||
public static final Map<Direction, Vector3i> DIRECTION_NORMAL_MAP = new HashMap<Direction, Vector3i>()
|
||||
public static final Map<LodDirection, Vec3i> DIRECTION_NORMAL_MAP = new HashMap<LodDirection, Vec3i>()
|
||||
{{
|
||||
put(Direction.UP, Direction.UP.getNormal());
|
||||
put(Direction.DOWN, Direction.DOWN.getNormal());
|
||||
put(Direction.EAST, Direction.EAST.getNormal());
|
||||
put(Direction.WEST, Direction.WEST.getNormal());
|
||||
put(Direction.SOUTH, Direction.SOUTH.getNormal());
|
||||
put(Direction.NORTH, Direction.NORTH.getNormal());
|
||||
put(LodDirection.UP, LodDirection.UP.getNormal());
|
||||
put(LodDirection.DOWN, LodDirection.DOWN.getNormal());
|
||||
put(LodDirection.EAST, LodDirection.EAST.getNormal());
|
||||
put(LodDirection.WEST, LodDirection.WEST.getNormal());
|
||||
put(LodDirection.SOUTH, LodDirection.SOUTH.getNormal());
|
||||
put(LodDirection.NORTH, LodDirection.NORTH.getNormal());
|
||||
}};
|
||||
|
||||
/** We use this index for all array that are going to */
|
||||
public static final Map<Direction, Integer> DIRECTION_INDEX = new HashMap<Direction, Integer>()
|
||||
public static final Map<LodDirection, Integer> DIRECTION_INDEX = new HashMap<LodDirection, Integer>()
|
||||
{{
|
||||
put(Direction.UP, 0);
|
||||
put(Direction.DOWN, 1);
|
||||
put(Direction.EAST, 2);
|
||||
put(Direction.WEST, 3);
|
||||
put(Direction.SOUTH, 4);
|
||||
put(Direction.NORTH, 5);
|
||||
put(LodDirection.UP, 0);
|
||||
put(LodDirection.DOWN, 1);
|
||||
put(LodDirection.EAST, 2);
|
||||
put(LodDirection.WEST, 3);
|
||||
put(LodDirection.SOUTH, 4);
|
||||
put(LodDirection.NORTH, 5);
|
||||
}};
|
||||
|
||||
public static final Map<Direction, Integer> ADJ_DIRECTION_INDEX = new HashMap<Direction, Integer>()
|
||||
public static final Map<LodDirection, Integer> ADJ_DIRECTION_INDEX = new HashMap<LodDirection, Integer>()
|
||||
{{
|
||||
put(Direction.EAST, 0);
|
||||
put(Direction.WEST, 1);
|
||||
put(Direction.SOUTH, 2);
|
||||
put(Direction.NORTH, 3);
|
||||
put(LodDirection.EAST, 0);
|
||||
put(LodDirection.WEST, 1);
|
||||
put(LodDirection.SOUTH, 2);
|
||||
put(LodDirection.NORTH, 3);
|
||||
}};
|
||||
/** holds the box's x, y, z offset */
|
||||
public final int[] boxOffset;
|
||||
@@ -188,9 +187,9 @@ public class Box
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final Map<Direction, int[]> adjHeight;
|
||||
public final Map<Direction, int[]> adjDepth;
|
||||
public final Map<Direction, byte[]> skyLights;
|
||||
public final Map<LodDirection, int[]> adjHeight;
|
||||
public final Map<LodDirection, int[]> adjDepth;
|
||||
public final Map<LodDirection, byte[]> skyLights;
|
||||
public byte blockLight;
|
||||
|
||||
/** Holds if the given direction should be culled or not */
|
||||
@@ -204,28 +203,28 @@ public class Box
|
||||
boxWidth = new int[3];
|
||||
|
||||
colorMap = new int[6];
|
||||
skyLights = new HashMap<Direction, byte[]>()
|
||||
skyLights = new HashMap<LodDirection, byte[]>()
|
||||
{{
|
||||
put(Direction.UP, new byte[1]);
|
||||
put(Direction.DOWN, new byte[1]);
|
||||
put(Direction.EAST, new byte[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(Direction.WEST, new byte[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(Direction.SOUTH, new byte[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(Direction.NORTH, new byte[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(LodDirection.UP, new byte[1]);
|
||||
put(LodDirection.DOWN, new byte[1]);
|
||||
put(LodDirection.EAST, new byte[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(LodDirection.WEST, new byte[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(LodDirection.SOUTH, new byte[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(LodDirection.NORTH, new byte[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
}};
|
||||
adjHeight = new HashMap<Direction, int[]>()
|
||||
adjHeight = new HashMap<LodDirection, int[]>()
|
||||
{{
|
||||
put(Direction.EAST, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(Direction.WEST, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(Direction.SOUTH, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(Direction.NORTH, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(LodDirection.EAST, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(LodDirection.WEST, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(LodDirection.SOUTH, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(LodDirection.NORTH, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
}};
|
||||
adjDepth = new HashMap<Direction, int[]>()
|
||||
adjDepth = new HashMap<LodDirection, int[]>()
|
||||
{{
|
||||
put(Direction.EAST, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(Direction.WEST, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(Direction.SOUTH, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(Direction.NORTH, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(LodDirection.EAST, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(LodDirection.WEST, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(LodDirection.SOUTH, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
put(LodDirection.NORTH, new int[LodUtil.MAX_NUMBER_OF_VERTICAL_LODS]);
|
||||
}};
|
||||
|
||||
culling = new boolean[6];
|
||||
@@ -235,7 +234,7 @@ public class Box
|
||||
public void setLights(int skyLight, int blockLight)
|
||||
{
|
||||
this.blockLight = (byte) blockLight;
|
||||
skyLights.get(Direction.UP)[0] = (byte) skyLight;
|
||||
skyLights.get(LodDirection.UP)[0] = (byte) skyLight;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,35 +245,35 @@ public class Box
|
||||
public void setColor(int color, boolean[] adjShadeDisabled)
|
||||
{
|
||||
this.color = color;
|
||||
for (Direction direction : DIRECTIONS)
|
||||
for (LodDirection lodDirection : DIRECTIONS)
|
||||
{
|
||||
if (!adjShadeDisabled[DIRECTION_INDEX.get(direction)])
|
||||
colorMap[DIRECTION_INDEX.get(direction)] = ColorUtil.applyShade(color, MinecraftWrapper.INSTANCE.getClientWorld().getShade(direction, true));
|
||||
if (!adjShadeDisabled[DIRECTION_INDEX.get(lodDirection)])
|
||||
colorMap[DIRECTION_INDEX.get(lodDirection)] = ColorUtil.applyShade(color, MinecraftWrapper.INSTANCE.getShade(lodDirection));
|
||||
else
|
||||
colorMap[DIRECTION_INDEX.get(direction)] = color;
|
||||
colorMap[DIRECTION_INDEX.get(lodDirection)] = color;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param direction of the face of which we want to get the color
|
||||
* @param lodDirection of the face of which we want to get the color
|
||||
* @return color of the face
|
||||
*/
|
||||
public int getColor(Direction direction)
|
||||
public int getColor(LodDirection lodDirection)
|
||||
{
|
||||
if (LodConfig.CLIENT.advancedModOptions.debugging.debugMode.get() != DebugMode.SHOW_DETAIL)
|
||||
return colorMap[DIRECTION_INDEX.get(direction)];
|
||||
return colorMap[DIRECTION_INDEX.get(lodDirection)];
|
||||
else
|
||||
return ColorUtil.applyShade(color, MinecraftWrapper.INSTANCE.getClientWorld().getShade(direction, true));
|
||||
return ColorUtil.applyShade(color, MinecraftWrapper.INSTANCE.getShade(lodDirection));
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public byte getSkyLight(Direction direction, int verticalIndex)
|
||||
public byte getSkyLight(LodDirection lodDirection, int verticalIndex)
|
||||
{
|
||||
if(direction == Direction.UP || direction == Direction.DOWN)
|
||||
return skyLights.get(direction)[0];
|
||||
if(lodDirection == LodDirection.UP || lodDirection == LodDirection.DOWN)
|
||||
return skyLights.get(lodDirection)[0];
|
||||
else
|
||||
return skyLights.get(direction)[verticalIndex];
|
||||
return skyLights.get(lodDirection)[verticalIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,13 +289,13 @@ public class Box
|
||||
Arrays.fill(boxOffset, 0);
|
||||
Arrays.fill(colorMap, 0);
|
||||
blockLight = 0;
|
||||
for (Direction direction : ADJ_DIRECTIONS)
|
||||
for (LodDirection lodDirection : ADJ_DIRECTIONS)
|
||||
{
|
||||
for (int i = 0; i < adjHeight.get(direction).length; i++)
|
||||
for (int i = 0; i < adjHeight.get(lodDirection).length; i++)
|
||||
{
|
||||
adjHeight.get(direction)[i] = VOID_FACE;
|
||||
adjDepth.get(direction)[i] = VOID_FACE;
|
||||
skyLights.get(direction)[i] = 0;
|
||||
adjHeight.get(lodDirection)[i] = VOID_FACE;
|
||||
adjDepth.get(lodDirection)[i] = VOID_FACE;
|
||||
skyLights.get(lodDirection)[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,25 +303,25 @@ public class Box
|
||||
/** determine which faces should be culled */
|
||||
public void setUpCulling(int cullingDistance, BlockPosWrapper playerPos)
|
||||
{
|
||||
for (Direction direction : DIRECTIONS)
|
||||
for (LodDirection lodDirection : DIRECTIONS)
|
||||
{
|
||||
if (direction == Direction.DOWN || direction == Direction.WEST || direction == Direction.NORTH)
|
||||
culling[DIRECTION_INDEX.get(direction)] = playerPos.get(direction.getAxis()) > getFacePos(direction) + cullingDistance;
|
||||
if (lodDirection == LodDirection.DOWN || lodDirection == LodDirection.WEST || lodDirection == LodDirection.NORTH)
|
||||
culling[DIRECTION_INDEX.get(lodDirection)] = playerPos.get(lodDirection.getAxis()) > getFacePos(lodDirection) + cullingDistance;
|
||||
|
||||
else if (direction == Direction.UP || direction == Direction.EAST || direction == Direction.SOUTH)
|
||||
culling[DIRECTION_INDEX.get(direction)] = playerPos.get(direction.getAxis()) < getFacePos(direction) - cullingDistance;
|
||||
else if (lodDirection == LodDirection.UP || lodDirection == LodDirection.EAST || lodDirection == LodDirection.SOUTH)
|
||||
culling[DIRECTION_INDEX.get(lodDirection)] = playerPos.get(lodDirection.getAxis()) < getFacePos(lodDirection) - cullingDistance;
|
||||
|
||||
culling[DIRECTION_INDEX.get(direction)] = false;
|
||||
culling[DIRECTION_INDEX.get(lodDirection)] = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param direction direction that we want to check if it's culled
|
||||
* @param lodDirection direction that we want to check if it's culled
|
||||
* @return true if and only if the face of the direction is culled
|
||||
*/
|
||||
public boolean isCulled(Direction direction)
|
||||
public boolean isCulled(LodDirection lodDirection)
|
||||
{
|
||||
return culling[DIRECTION_INDEX.get(direction)];
|
||||
return culling[DIRECTION_INDEX.get(lodDirection)];
|
||||
}
|
||||
|
||||
|
||||
@@ -330,7 +329,7 @@ public class Box
|
||||
* This method create all the shared face culling based on the adjacent data
|
||||
* @param adjData data adjacent to the column we are going to render
|
||||
*/
|
||||
public void setAdjData(Map<Direction, long[]> adjData)
|
||||
public void setAdjData(Map<LodDirection, long[]> adjData)
|
||||
{
|
||||
int height;
|
||||
int depth;
|
||||
@@ -346,26 +345,26 @@ public class Box
|
||||
depth = DataPointUtil.getDepth(singleAdjDataPoint);
|
||||
}*/
|
||||
//Down direction case
|
||||
singleAdjDataPoint = adjData.get(Direction.DOWN)[0];
|
||||
singleAdjDataPoint = adjData.get(LodDirection.DOWN)[0];
|
||||
if(DataPointUtil.doesItExist(singleAdjDataPoint))
|
||||
skyLights.get(Direction.DOWN)[0] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
|
||||
skyLights.get(LodDirection.DOWN)[0] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
|
||||
else
|
||||
skyLights.get(Direction.DOWN)[0] = skyLights.get(Direction.UP)[0];
|
||||
skyLights.get(LodDirection.DOWN)[0] = skyLights.get(LodDirection.UP)[0];
|
||||
//other sided
|
||||
//TODO clean some similar cases
|
||||
for (Direction direction : ADJ_DIRECTIONS)
|
||||
for (LodDirection lodDirection : ADJ_DIRECTIONS)
|
||||
{
|
||||
if (isCulled(direction))
|
||||
if (isCulled(lodDirection))
|
||||
continue;
|
||||
|
||||
long[] dataPoint = adjData.get(direction);
|
||||
long[] dataPoint = adjData.get(lodDirection);
|
||||
if (dataPoint == null || DataPointUtil.isVoid(dataPoint[0]))
|
||||
{
|
||||
adjHeight.get(direction)[0] = maxY;
|
||||
adjDepth.get(direction)[0] = minY;
|
||||
adjHeight.get(direction)[1] = VOID_FACE;
|
||||
adjDepth.get(direction)[1] = VOID_FACE;
|
||||
skyLights.get(direction)[0] = 15; //in void set full sky light
|
||||
adjHeight.get(lodDirection)[0] = maxY;
|
||||
adjDepth.get(lodDirection)[0] = minY;
|
||||
adjHeight.get(lodDirection)[1] = VOID_FACE;
|
||||
adjDepth.get(lodDirection)[1] = VOID_FACE;
|
||||
skyLights.get(lodDirection)[0] = 15; //in void set full sky light
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -394,14 +393,14 @@ public class Box
|
||||
|
||||
if (firstFace)
|
||||
{
|
||||
adjHeight.get(direction)[0] = getMaxY();
|
||||
adjDepth.get(direction)[0] = getMinY();
|
||||
skyLights.get(direction)[0] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint); //skyLights.get(Direction.UP)[0];
|
||||
adjHeight.get(lodDirection)[0] = getMaxY();
|
||||
adjDepth.get(lodDirection)[0] = getMinY();
|
||||
skyLights.get(lodDirection)[0] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint); //skyLights.get(Direction.UP)[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
adjDepth.get(direction)[faceToDraw] = getMinY();
|
||||
skyLights.get(direction)[faceToDraw] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
|
||||
adjDepth.get(lodDirection)[faceToDraw] = getMinY();
|
||||
skyLights.get(lodDirection)[faceToDraw] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
|
||||
}
|
||||
faceToDraw++;
|
||||
toFinish = false;
|
||||
@@ -415,8 +414,8 @@ public class Box
|
||||
{
|
||||
// the adj data is inside the current data
|
||||
// don't draw the face
|
||||
adjHeight.get(direction)[0] = VOID_FACE;
|
||||
adjDepth.get(direction)[0] = VOID_FACE;
|
||||
adjHeight.get(lodDirection)[0] = VOID_FACE;
|
||||
adjDepth.get(lodDirection)[0] = VOID_FACE;
|
||||
}
|
||||
else // height < maxY
|
||||
{
|
||||
@@ -425,14 +424,14 @@ public class Box
|
||||
// if there was another face we finish the last one and break
|
||||
if (firstFace)
|
||||
{
|
||||
adjHeight.get(direction)[0] = getMaxY();
|
||||
adjDepth.get(direction)[0] = height;
|
||||
skyLights.get(direction)[0] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint); //skyLights.get(Direction.UP)[0];
|
||||
adjHeight.get(lodDirection)[0] = getMaxY();
|
||||
adjDepth.get(lodDirection)[0] = height;
|
||||
skyLights.get(lodDirection)[0] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint); //skyLights.get(Direction.UP)[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
adjDepth.get(direction)[faceToDraw] = height;
|
||||
skyLights.get(direction)[faceToDraw] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
|
||||
adjDepth.get(lodDirection)[faceToDraw] = height;
|
||||
skyLights.get(lodDirection)[faceToDraw] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
|
||||
}
|
||||
toFinish = false;
|
||||
faceToDraw++;
|
||||
@@ -443,7 +442,7 @@ public class Box
|
||||
{
|
||||
// the adj data intersects the higher part of the current data
|
||||
// we start the creation of a new face
|
||||
adjHeight.get(direction)[faceToDraw] = depth;
|
||||
adjHeight.get(lodDirection)[faceToDraw] = depth;
|
||||
//skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
|
||||
firstFace = false;
|
||||
toFinish = true;
|
||||
@@ -456,13 +455,13 @@ public class Box
|
||||
// the adj data is contained in the current data
|
||||
if (firstFace)
|
||||
{
|
||||
adjHeight.get(direction)[0] = getMaxY();
|
||||
adjHeight.get(lodDirection)[0] = getMaxY();
|
||||
}
|
||||
|
||||
adjDepth.get(direction)[faceToDraw] = height;
|
||||
skyLights.get(direction)[faceToDraw] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
|
||||
adjDepth.get(lodDirection)[faceToDraw] = height;
|
||||
skyLights.get(lodDirection)[faceToDraw] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
|
||||
faceToDraw++;
|
||||
adjHeight.get(direction)[faceToDraw] = depth;
|
||||
adjHeight.get(lodDirection)[faceToDraw] = depth;
|
||||
firstFace = false;
|
||||
toFinish = true;
|
||||
toFinishIndex = i + 1;
|
||||
@@ -472,27 +471,27 @@ public class Box
|
||||
|
||||
if (allAbove)
|
||||
{
|
||||
adjHeight.get(direction)[0] = getMaxY();
|
||||
adjDepth.get(direction)[0] = getMinY();
|
||||
skyLights.get(direction)[0] = skyLights.get(Direction.UP)[0];
|
||||
adjHeight.get(lodDirection)[0] = getMaxY();
|
||||
adjDepth.get(lodDirection)[0] = getMinY();
|
||||
skyLights.get(lodDirection)[0] = skyLights.get(LodDirection.UP)[0];
|
||||
faceToDraw++;
|
||||
}
|
||||
else if (toFinish)
|
||||
{
|
||||
adjDepth.get(direction)[faceToDraw] = minY;
|
||||
adjDepth.get(lodDirection)[faceToDraw] = minY;
|
||||
if(toFinishIndex < dataPoint.length)
|
||||
{
|
||||
singleAdjDataPoint = dataPoint[toFinishIndex];
|
||||
if (DataPointUtil.doesItExist(singleAdjDataPoint))
|
||||
skyLights.get(direction)[faceToDraw] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
|
||||
skyLights.get(lodDirection)[faceToDraw] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
|
||||
else
|
||||
skyLights.get(direction)[faceToDraw] = skyLights.get(Direction.UP)[0];
|
||||
skyLights.get(lodDirection)[faceToDraw] = skyLights.get(LodDirection.UP)[0];
|
||||
}
|
||||
faceToDraw++;
|
||||
}
|
||||
|
||||
adjHeight.get(direction)[faceToDraw] = VOID_FACE;
|
||||
adjDepth.get(direction)[faceToDraw] = VOID_FACE;
|
||||
adjHeight.get(lodDirection)[faceToDraw] = VOID_FACE;
|
||||
adjDepth.get(lodDirection)[faceToDraw] = VOID_FACE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,74 +514,74 @@ public class Box
|
||||
/**
|
||||
* This method return the position of a face in the axis of the face
|
||||
* This is useful for the face culling
|
||||
* @param direction that we want to check
|
||||
* @param lodDirection that we want to check
|
||||
* @return position in the axis of the face
|
||||
*/
|
||||
public int getFacePos(Direction direction)
|
||||
public int getFacePos(LodDirection lodDirection)
|
||||
{
|
||||
return boxOffset[FACE_DIRECTION.get(direction)[0]] + boxWidth[FACE_DIRECTION.get(direction)[0]] * FACE_DIRECTION.get(direction)[1];
|
||||
return boxOffset[FACE_DIRECTION.get(lodDirection)[0]] + boxWidth[FACE_DIRECTION.get(lodDirection)[0]] * FACE_DIRECTION.get(lodDirection)[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if the given direction should be rendered.
|
||||
*/
|
||||
public boolean shouldRenderFace(Direction direction, int adjIndex)
|
||||
public boolean shouldRenderFace(LodDirection lodDirection, int adjIndex)
|
||||
{
|
||||
if (direction == Direction.UP || direction == Direction.DOWN)
|
||||
if (lodDirection == LodDirection.UP || lodDirection == LodDirection.DOWN)
|
||||
return adjIndex == 0;
|
||||
return !(adjHeight.get(direction)[adjIndex] == VOID_FACE && adjDepth.get(direction)[adjIndex] == VOID_FACE);
|
||||
return !(adjHeight.get(lodDirection)[adjIndex] == VOID_FACE && adjDepth.get(lodDirection)[adjIndex] == VOID_FACE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param direction direction of the face we want to render
|
||||
* @param lodDirection direction of the face we want to render
|
||||
* @param vertexIndex index of the vertex of the face (0-1-2-3)
|
||||
* @return position x of the relative vertex
|
||||
*/
|
||||
public int getX(Direction direction, int vertexIndex)
|
||||
public int getX(LodDirection lodDirection, int vertexIndex)
|
||||
{
|
||||
return boxOffset[X] + boxWidth[X] * DIRECTION_VERTEX_MAP.get(direction)[vertexIndex][X];
|
||||
return boxOffset[X] + boxWidth[X] * DIRECTION_VERTEX_MAP.get(lodDirection)[vertexIndex][X];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param direction direction of the face we want to render
|
||||
* @param lodDirection direction of the face we want to render
|
||||
* @param vertexIndex index of the vertex of the face (0-1-2-3)
|
||||
* @return position y of the relative vertex
|
||||
*/
|
||||
public int getY(Direction direction, int vertexIndex)
|
||||
public int getY(LodDirection lodDirection, int vertexIndex)
|
||||
{
|
||||
return boxOffset[Y] + boxWidth[Y] * DIRECTION_VERTEX_MAP.get(direction)[vertexIndex][Y];
|
||||
return boxOffset[Y] + boxWidth[Y] * DIRECTION_VERTEX_MAP.get(lodDirection)[vertexIndex][Y];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param direction direction of the face we want to render
|
||||
* @param lodDirection direction of the face we want to render
|
||||
* @param vertexIndex index of the vertex of the face (0-1-2-3)
|
||||
* @param adjIndex, index of the n-th culled face of this direction
|
||||
* @return position x of the relative vertex
|
||||
*/
|
||||
public int getY(Direction direction, int vertexIndex, int adjIndex)
|
||||
public int getY(LodDirection lodDirection, int vertexIndex, int adjIndex)
|
||||
{
|
||||
if (direction == Direction.DOWN || direction == Direction.UP)
|
||||
return boxOffset[Y] + boxWidth[Y] * DIRECTION_VERTEX_MAP.get(direction)[vertexIndex][Y];
|
||||
if (lodDirection == LodDirection.DOWN || lodDirection == LodDirection.UP)
|
||||
return boxOffset[Y] + boxWidth[Y] * DIRECTION_VERTEX_MAP.get(lodDirection)[vertexIndex][Y];
|
||||
else
|
||||
{
|
||||
// this could probably be cleaned up more,
|
||||
// but it still works
|
||||
if (1 - DIRECTION_VERTEX_MAP.get(direction)[vertexIndex][Y] == ADJACENT_HEIGHT_INDEX)
|
||||
return adjHeight.get(direction)[adjIndex];
|
||||
if (1 - DIRECTION_VERTEX_MAP.get(lodDirection)[vertexIndex][Y] == ADJACENT_HEIGHT_INDEX)
|
||||
return adjHeight.get(lodDirection)[adjIndex];
|
||||
else
|
||||
return adjDepth.get(direction)[adjIndex];
|
||||
return adjDepth.get(lodDirection)[adjIndex];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param direction direction of the face we want to render
|
||||
* @param lodDirection direction of the face we want to render
|
||||
* @param vertexIndex index of the vertex of the face (0-1-2-3)
|
||||
* @return position z of the relative vertex
|
||||
*/
|
||||
public int getZ(Direction direction, int vertexIndex)
|
||||
public int getZ(LodDirection lodDirection, int vertexIndex)
|
||||
{
|
||||
return boxOffset[Z] + boxWidth[Z] * DIRECTION_VERTEX_MAP.get(direction)[vertexIndex][Z];
|
||||
return boxOffset[Z] + boxWidth[Z] * DIRECTION_VERTEX_MAP.get(lodDirection)[vertexIndex][Z];
|
||||
}
|
||||
|
||||
public int getMinX()
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.io.File;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.seibel.lod.config.LodConfig;
|
||||
import com.seibel.lod.enums.LodDirection;
|
||||
import com.seibel.lod.enums.config.HorizontalResolution;
|
||||
import com.seibel.lod.enums.config.VanillaOverdraw;
|
||||
import com.seibel.lod.objects.Box;
|
||||
@@ -41,7 +42,6 @@ import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher.CompiledChunk;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.chunk.ChunkSection;
|
||||
@@ -483,10 +483,10 @@ public class LodUtil
|
||||
return false;
|
||||
int tempX;
|
||||
int tempZ;
|
||||
for (Direction direction : Box.ADJ_DIRECTIONS)
|
||||
for (LodDirection lodDirection : Box.ADJ_DIRECTIONS)
|
||||
{
|
||||
tempX = x + Box.DIRECTION_NORMAL_MAP.get(direction).getX();
|
||||
tempZ = z + Box.DIRECTION_NORMAL_MAP.get(direction).getZ();
|
||||
tempX = x + Box.DIRECTION_NORMAL_MAP.get(lodDirection).x;
|
||||
tempZ = z + Box.DIRECTION_NORMAL_MAP.get(lodDirection).z;
|
||||
if (vanillaRenderedChunks[x][z] || (!(tempX < 0 || tempZ < 0 || tempX >= vanillaRenderedChunks.length || tempZ >= vanillaRenderedChunks[0].length)
|
||||
&& !vanillaRenderedChunks[tempX][tempZ]))
|
||||
return true;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import com.seibel.lod.objects.Box;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import com.seibel.lod.enums.LodDirection;
|
||||
|
||||
/**
|
||||
* Holds data used by specific threads so
|
||||
@@ -55,7 +55,7 @@ public class ThreadMapUtil
|
||||
//________________________//
|
||||
|
||||
public static final ConcurrentMap<String, boolean[]> adjShadeDisabled = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentMap<String, Map<Direction, long[]>> adjDataMap = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentMap<String, Map<LodDirection, long[]>> adjDataMap = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentMap<String, Box> boxMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
@@ -73,24 +73,24 @@ public class ThreadMapUtil
|
||||
}
|
||||
|
||||
/** returns the array NOT cleared every time */
|
||||
public static Map<Direction, long[]> getAdjDataArray(int verticalData)
|
||||
public static Map<LodDirection, long[]> getAdjDataArray(int verticalData)
|
||||
{
|
||||
if (!adjDataMap.containsKey(Thread.currentThread().getName())
|
||||
|| (adjDataMap.get(Thread.currentThread().getName()) == null)
|
||||
|| (adjDataMap.get(Thread.currentThread().getName()).get(Direction.NORTH) == null)
|
||||
|| (adjDataMap.get(Thread.currentThread().getName()).get(Direction.NORTH).length != verticalData))
|
||||
|| (adjDataMap.get(Thread.currentThread().getName()).get(LodDirection.NORTH) == null)
|
||||
|| (adjDataMap.get(Thread.currentThread().getName()).get(LodDirection.NORTH).length != verticalData))
|
||||
{
|
||||
adjDataMap.put(Thread.currentThread().getName(), new HashMap<>());
|
||||
adjDataMap.get(Thread.currentThread().getName()).put(Direction.UP, new long[1]);
|
||||
adjDataMap.get(Thread.currentThread().getName()).put(Direction.DOWN, new long[1]);
|
||||
for (Direction direction : Box.ADJ_DIRECTIONS)
|
||||
adjDataMap.get(Thread.currentThread().getName()).put(direction, new long[verticalData]);
|
||||
adjDataMap.get(Thread.currentThread().getName()).put(LodDirection.UP, new long[1]);
|
||||
adjDataMap.get(Thread.currentThread().getName()).put(LodDirection.DOWN, new long[1]);
|
||||
for (LodDirection lodDirection : Box.ADJ_DIRECTIONS)
|
||||
adjDataMap.get(Thread.currentThread().getName()).put(lodDirection, new long[verticalData]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
for (Direction direction : Box.ADJ_DIRECTIONS)
|
||||
Arrays.fill(adjDataMap.get(Thread.currentThread().getName()).get(direction), DataPointUtil.EMPTY_DATA);
|
||||
for (LodDirection lodDirection : Box.ADJ_DIRECTIONS)
|
||||
Arrays.fill(adjDataMap.get(Thread.currentThread().getName()).get(lodDirection), DataPointUtil.EMPTY_DATA);
|
||||
}
|
||||
return adjDataMap.get(Thread.currentThread().getName());
|
||||
}
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
package com.seibel.lod.wrappers.Block;
|
||||
|
||||
import com.seibel.lod.util.ColorUtil;
|
||||
import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import com.seibel.lod.util.ColorUtil;
|
||||
import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
|
||||
import net.minecraft.block.AbstractPlantBlock;
|
||||
import net.minecraft.block.AbstractTopPlantBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.BushBlock;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.GrassBlock;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.TallGrassBlock;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
|
||||
|
||||
//This class wraps the minecraft Block class
|
||||
public class BlockColorWrapper
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.seibel.lod.wrappers.Block;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import com.seibel.lod.enums.LodDirection;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class BlockPosWrapper {
|
||||
return blockPos.getZ();
|
||||
}
|
||||
|
||||
public int get(Direction.Axis axis)
|
||||
public int get(LodDirection.Axis axis)
|
||||
{
|
||||
return axis.choose(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
@@ -21,12 +21,14 @@ package com.seibel.lod.wrappers;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
import com.seibel.lod.enums.LodDirection;
|
||||
import com.seibel.lod.objects.math.Mat4f;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
|
||||
/**
|
||||
* This class converts between Minecraft objects (Ex: Matrix4f)
|
||||
* This class converts to and from Minecraft objects (Ex: Matrix4f)
|
||||
* and objects we created (Ex: Mat4f).
|
||||
* Since we don't want to deal with a bunch of tiny changes
|
||||
* every time Minecraft renames a variable in Matrix4f or something.
|
||||
@@ -52,4 +54,12 @@ public class McObjectConverter
|
||||
matrix.transpose();
|
||||
return matrix;
|
||||
}
|
||||
|
||||
|
||||
public static Direction Convert(LodDirection lodDirection)
|
||||
{
|
||||
return Direction.byName(lodDirection.name());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.seibel.lod.ModInfo;
|
||||
import com.seibel.lod.enums.LodDirection;
|
||||
import com.seibel.lod.lodApi.ClientApi;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
|
||||
@@ -101,9 +102,10 @@ public class MinecraftWrapper
|
||||
// method wrappers //
|
||||
//=================//
|
||||
|
||||
public float getShading(Direction direction)
|
||||
public float getShade(LodDirection lodDirection)
|
||||
{
|
||||
return mc.level.getShade(Direction.UP, true);
|
||||
Direction mcDir = McObjectConverter.Convert(lodDirection);
|
||||
return mc.level.getShade(mcDir, true);
|
||||
}
|
||||
|
||||
public boolean hasSinglePlayerServer()
|
||||
@@ -321,6 +323,10 @@ public class MinecraftWrapper
|
||||
CrashReport report = new CrashReport(errorMessage, exception);
|
||||
Minecraft.crash(report);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user