Remove Manifold from core. Remove use of awt.Colors.
Removing awt.Colors due to it being just slow. And unneeded to import entire awt lib just because of Color. Removed Manifold from core due to Manifold java compiler has quite some bugs, and it is causing crashes on inferring a generic class args on inline Iterator class def. Core arn't needing those preprocessor features anyways.
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
package com.seibel.lod.core.api;
|
||||
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.builders.bufferBuilding.LodBufferBuilderFactory;
|
||||
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
|
||||
import com.seibel.lod.core.enums.config.VerticalQuality;
|
||||
import com.seibel.lod.core.objects.lod.LodWorld;
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.seibel.lod.core.enums.rendering.DebugMode;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.objects.opengl.LodBox;
|
||||
import com.seibel.lod.core.objects.opengl.LodQuadBuilder;
|
||||
import com.seibel.lod.core.util.ColorUtil;
|
||||
import com.seibel.lod.core.util.DataPointUtil;
|
||||
import com.seibel.lod.core.util.LevelPosUtil;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
@@ -38,8 +39,7 @@ import java.awt.*;
|
||||
public class CubicLodTemplate
|
||||
{
|
||||
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
|
||||
|
||||
|
||||
public static void addLodToBuffer(long data, long topData, long botData, long[][][] adjData, byte detailLevel,
|
||||
int offsetPosX, int offsetOosZ, LodQuadBuilder quadBuilder, DebugMode debugging)
|
||||
{
|
||||
@@ -55,20 +55,20 @@ public class CubicLodTemplate
|
||||
if (debugging != DebugMode.OFF && debugging != DebugMode.SHOW_WIREFRAME)
|
||||
{
|
||||
if (debugging == DebugMode.SHOW_DETAIL || debugging == DebugMode.SHOW_DETAIL_WIREFRAME)
|
||||
color = LodUtil.DEBUG_DETAIL_LEVEL_COLORS[detailLevel].getRGB();
|
||||
color = LodUtil.DEBUG_DETAIL_LEVEL_COLORS[detailLevel];
|
||||
else /// if (debugging == DebugMode.SHOW_GENMODE || debugging ==
|
||||
/// DebugMode.SHOW_GENMODE_WIREFRAME)
|
||||
color = LodUtil.DEBUG_DETAIL_LEVEL_COLORS[DataPointUtil.getGenerationMode(data)].getRGB();
|
||||
color = LodUtil.DEBUG_DETAIL_LEVEL_COLORS[DataPointUtil.getGenerationMode(data)];
|
||||
}
|
||||
else
|
||||
{
|
||||
double saturationMultiplier = CONFIG.client().graphics().advancedGraphics().getSaturationMultiplier();
|
||||
double brightnessMultiplier = CONFIG.client().graphics().advancedGraphics().getBrightnessMultiplier();
|
||||
|
||||
Color colorObject = LodUtil.intToColor(DataPointUtil.getColor(data));
|
||||
|
||||
float[] hsb = Color.RGBtoHSB(colorObject.getRed(), colorObject.getGreen(), colorObject.getBlue(), null);
|
||||
color = LodUtil.colorToInt(Color.getHSBColor(hsb[0], (float) LodUtil.clamp(0.0f, hsb[1] * saturationMultiplier, 1.0f), (float) LodUtil.clamp(0.0f, hsb[2] * brightnessMultiplier, 1.0f)));
|
||||
|
||||
float[] ahsv = ColorUtil.argbToAhsv(DataPointUtil.getColor(data));
|
||||
ahsv[2] *= saturationMultiplier;
|
||||
ahsv[3] *= brightnessMultiplier;
|
||||
color = ColorUtil.ahsvToArgb(ahsv[0], ahsv[1], ahsv[2], ahsv[3]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ package com.seibel.lod.core.objects;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.util.LevelPosUtil;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
|
||||
|
||||
@@ -227,10 +227,9 @@ public class LodQuadBuilder {
|
||||
|
||||
}
|
||||
|
||||
final ArrayList<Quad>[] quads;
|
||||
final ArrayList<Quad>[] quads = new ArrayList[6];
|
||||
|
||||
public LodQuadBuilder(int initialSize, boolean enableSkylightCulling) {
|
||||
quads = new ArrayList[6];
|
||||
for (int i=0; i<6; i++) quads[i] = new ArrayList<Quad>();
|
||||
this.skipSkylight0Quads = enableSkylightCulling;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.seibel.lod.core.builders.bufferBuilding.CubicLodTemplate;
|
||||
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
|
||||
import com.seibel.lod.core.enums.LodDirection;
|
||||
import com.seibel.lod.core.enums.config.GpuUploadMethod;
|
||||
import com.seibel.lod.core.enums.config.VanillaOverdraw;
|
||||
import com.seibel.lod.core.enums.rendering.DebugMode;
|
||||
import com.seibel.lod.core.enums.rendering.GLProxyContext;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
@@ -28,10 +27,8 @@ import com.seibel.lod.core.render.GLProxy;
|
||||
import com.seibel.lod.core.render.LodRenderProgram;
|
||||
import com.seibel.lod.core.render.RenderUtil;
|
||||
import com.seibel.lod.core.util.DataPointUtil;
|
||||
import com.seibel.lod.core.util.DetailDistanceUtil;
|
||||
import com.seibel.lod.core.util.LevelPosUtil;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.util.gridList.MovableCenteredGridList;
|
||||
import com.seibel.lod.core.util.StatsMap;
|
||||
import com.seibel.lod.core.util.gridList.PosArrayGridList;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
@@ -46,7 +43,7 @@ public class RenderRegion implements AutoCloseable
|
||||
|
||||
/** stores if the region at the given x and z index needs to be regenerated */
|
||||
// Use int because I need Tri state:
|
||||
private AtomicInteger needRegen = new AtomicInteger(2);
|
||||
private final AtomicInteger needRegen = new AtomicInteger(2);
|
||||
|
||||
private enum BackState {
|
||||
Unused,
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
package com.seibel.lod.core.util;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
|
||||
@@ -89,27 +87,6 @@ public class ColorUtil
|
||||
return (getAlpha(color) << 24) | ((int) Math.min(getRed(color) * shade, 255) << 16) | ((int) Math.min(getGreen(color) * shade, 255) << 8) | (int) Math.min(getBlue(color) * shade, 255);
|
||||
}
|
||||
|
||||
/** This method apply the lightmap to the color to use */
|
||||
public static int applyLightValue(int color, int skyLight, int blockLight)
|
||||
{
|
||||
int lightColor = MC.getColorIntFromLightMap(blockLight, skyLight);
|
||||
int red = ColorUtil.getRed(lightColor);
|
||||
int green = ColorUtil.getGreen(lightColor);
|
||||
int blue = ColorUtil.getBlue(lightColor);
|
||||
|
||||
return ColorUtil.multiplyARGBwithRGB(color, ColorUtil.rgbToInt(red, green, blue));
|
||||
}
|
||||
|
||||
/** Edit the given color as an HSV (Hue Saturation Value) color */
|
||||
public static int applySaturationAndBrightnessMultipliers(int color, float saturationMultiplier, float brightnessMultiplier)
|
||||
{
|
||||
float[] hsv = Color.RGBtoHSB(getRed(color), getGreen(color), getBlue(color), null);
|
||||
return Color.getHSBColor(
|
||||
hsv[0], // hue
|
||||
LodUtil.clamp(0.0f, hsv[1] * saturationMultiplier, 1.0f),
|
||||
LodUtil.clamp(0.0f, hsv[2] * brightnessMultiplier, 1.0f)).getRGB();
|
||||
}
|
||||
|
||||
/** Multiply ARGB with RGB colors */
|
||||
public static int multiplyARGBwithRGB(int argb, int rgb)
|
||||
{
|
||||
@@ -123,6 +100,59 @@ public class ColorUtil
|
||||
return ((getAlpha(color1) * getAlpha(color2) / 255) << 24) | ((getRed(color1) * getRed(color2) / 255) << 16) | ((getGreen(color1) * getGreen(color2) / 255) << 8) | (getBlue(color1) * getBlue(color2) / 255);
|
||||
}
|
||||
|
||||
// Below 2 functions are from: https://stackoverflow.com/questions/13806483/increase-or-decrease-color-saturation
|
||||
// hue is in 0 to 360 degrees
|
||||
public static float[] argbToAhsv(int color) {
|
||||
float a = getAlpha(color);
|
||||
float r = getRed(color);
|
||||
float g = getGreen(color);
|
||||
float b = getGreen(color);
|
||||
float h, s, v;
|
||||
float min = Math.min(Math.min( r, g), b );
|
||||
float max = Math.max(Math.max( r, g), b );
|
||||
float delta = max - min;
|
||||
|
||||
v = max;
|
||||
if( max != 0f )
|
||||
s = delta / max; // s
|
||||
else {
|
||||
// r = g = b = 0 // s = 0, v is undefined
|
||||
return new float[]{a, 0f, 0f, 0f};
|
||||
}
|
||||
if (delta == 0f) {
|
||||
h = 0f;
|
||||
} else {
|
||||
if (r == max) h = (g - b) / delta; // between yellow & magenta
|
||||
else if (g == max) h = 2f + (b - r) / delta; // between cyan & yellow
|
||||
else h = 4f + (r - g) / delta; // between magenta & cyan
|
||||
h *= 60f; // degrees
|
||||
if (h < 0f)
|
||||
h += 360f;
|
||||
}
|
||||
return new float[]{a,h,s,v};
|
||||
}
|
||||
public static int ahsvToArgb(float a, float h, float s, float v) {
|
||||
if(s == 0f) {
|
||||
// achromatic (grey)
|
||||
return ColorUtil.rgbToInt((int) a, (int)v, (int)v, (int)v);
|
||||
}
|
||||
if (s > 255f) s = 255f;
|
||||
if (v > 255f) v = 255f;
|
||||
int i = (int)(h/60f) % 6;
|
||||
float f = h - i; // factorial part of h
|
||||
float p = v * ( 1f - s );
|
||||
float q = v * ( 1f - s * f );
|
||||
float t = v * ( 1f - s * ( 1f - f ) );
|
||||
return switch (i) {
|
||||
case 0 -> ColorUtil.rgbToInt((int) a, (int) v, (int) t, (int) p);
|
||||
case 1 -> ColorUtil.rgbToInt((int) a, (int) q, (int) v, (int) p);
|
||||
case 2 -> ColorUtil.rgbToInt((int) a, (int) p, (int) v, (int) t);
|
||||
case 3 -> ColorUtil.rgbToInt((int) a, (int) p, (int) q, (int) v);
|
||||
case 4 -> ColorUtil.rgbToInt((int) a, (int) t, (int) p, (int) v);
|
||||
default -> ColorUtil.rgbToInt((int) a, (int) v, (int) p, (int) q); // case 5
|
||||
};
|
||||
}
|
||||
|
||||
public static String toString(int color)
|
||||
{
|
||||
return "A:"+Integer.toHexString(getAlpha(color)) + ",R:" +
|
||||
|
||||
@@ -19,13 +19,10 @@
|
||||
|
||||
package com.seibel.lod.core.util;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.seibel.lod.core.enums.LodDirection;
|
||||
import com.seibel.lod.core.enums.config.HorizontalResolution;
|
||||
import com.seibel.lod.core.enums.config.ServerFolderNameMode;
|
||||
import com.seibel.lod.core.enums.config.VanillaOverdraw;
|
||||
import com.seibel.lod.core.handlers.IReflectionHandler;
|
||||
@@ -37,10 +34,8 @@ import com.seibel.lod.core.objects.lod.RegionPos;
|
||||
import com.seibel.lod.core.objects.opengl.DefaultLodVertexFormats;
|
||||
import com.seibel.lod.core.objects.opengl.LodVertexFormat;
|
||||
import com.seibel.lod.core.util.gridList.EdgeDistanceBooleanGrid;
|
||||
import com.seibel.lod.core.util.gridList.MovableCenteredGridList;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IVersionConstants;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
@@ -84,10 +79,11 @@ public class LodUtil
|
||||
/**
|
||||
* alpha used when drawing chunks in debug mode
|
||||
*/
|
||||
public static final int DEBUG_ALPHA = 255; // 0 - 255
|
||||
public static final Color COLOR_DEBUG_BLACK = new Color(0, 0, 0, DEBUG_ALPHA);
|
||||
public static final Color COLOR_DEBUG_WHITE = new Color(255, 255, 255, DEBUG_ALPHA);
|
||||
public static final Color COLOR_INVISIBLE = new Color(0, 0, 0, 0);
|
||||
public static final int DEBUG_ALPHA = 255; // 0 - 25;
|
||||
|
||||
public static final int COLOR_DEBUG_BLACK = ColorUtil.rgbToInt(DEBUG_ALPHA, 0, 0, 0);
|
||||
public static final int COLOR_DEBUG_WHITE = ColorUtil.rgbToInt(DEBUG_ALPHA, 255, 255, 255);
|
||||
public static final int COLOR_INVISIBLE = ColorUtil.rgbToInt(0, 0, 0, 0);
|
||||
|
||||
public static final int CEILED_DIMENSION_MAX_RENDER_DISTANCE = 64; // 0 - 255
|
||||
|
||||
@@ -96,9 +92,14 @@ public class LodUtil
|
||||
* In order of nearest to farthest: <br>
|
||||
* Red, Orange, Yellow, Green, Cyan, Blue, Magenta, white, gray, black
|
||||
*/
|
||||
public static final Color[] DEBUG_DETAIL_LEVEL_COLORS = new Color[] {
|
||||
Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA, Color.BLACK,
|
||||
Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK};
|
||||
public static final int[] DEBUG_DETAIL_LEVEL_COLORS = new int[] {
|
||||
ColorUtil.rgbToInt(255,0,0), ColorUtil.rgbToInt(255,127,0),
|
||||
ColorUtil.rgbToInt(255, 255, 0), ColorUtil.rgbToInt(127, 255, 0),
|
||||
ColorUtil.rgbToInt(0, 255, 0), ColorUtil.rgbToInt(0, 255, 127),
|
||||
ColorUtil.rgbToInt(0, 255, 255), ColorUtil.rgbToInt(0, 127, 255),
|
||||
ColorUtil.rgbToInt(0, 0, 255), ColorUtil.rgbToInt(127, 0, 255),
|
||||
ColorUtil.rgbToInt(255, 0, 255), ColorUtil.rgbToInt(255, 127, 255),
|
||||
ColorUtil.rgbToInt(255, 255, 255)};
|
||||
|
||||
|
||||
public static final byte DETAIL_OPTIONS = 10;
|
||||
@@ -301,26 +302,6 @@ public class LodUtil
|
||||
return folderName;
|
||||
}
|
||||
|
||||
|
||||
/** Convert a BlockColors int into a Color object */
|
||||
public static Color intToColor(int num)
|
||||
{
|
||||
int filter = 0b11111111;
|
||||
|
||||
int red = (num >> 16) & filter;
|
||||
int green = (num >> 8) & filter;
|
||||
int blue = num & filter;
|
||||
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
/** Convert a Color into a BlockColors object. */
|
||||
public static int colorToInt(Color color)
|
||||
{
|
||||
return color.getRGB();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clamps the given value between the min and max values.
|
||||
* May behave strangely if min > max.
|
||||
@@ -381,22 +362,23 @@ public class LodUtil
|
||||
if (offset == Integer.MAX_VALUE) return null;
|
||||
int renderDist = MC_RENDER.getRenderDistance() + 1;
|
||||
|
||||
HashSet<AbstractChunkPosWrapper> posSet = MC_RENDER.getVanillaRenderedChunks();
|
||||
Iterator<AbstractChunkPosWrapper> posIter = MC_RENDER.getVanillaRenderedChunks().iterator();
|
||||
|
||||
return new EdgeDistanceBooleanGrid(new Iterator<>() {
|
||||
final Iterator<AbstractChunkPosWrapper> iter = posSet.iterator();
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return iter.hasNext();
|
||||
return posIter.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pos2D next() {
|
||||
AbstractChunkPosWrapper pos = iter.next();
|
||||
AbstractChunkPosWrapper pos = posIter.next();
|
||||
return new Pos2D(pos.getX(), pos.getZ());
|
||||
}
|
||||
},
|
||||
MC.getPlayerChunkPos().getX() - renderDist,
|
||||
MC.getPlayerChunkPos().getZ() - renderDist, renderDist * 2 + 1);
|
||||
MC.getPlayerChunkPos().getZ() - renderDist,
|
||||
renderDist * 2 + 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@ package com.seibel.lod.core.util.gridList;
|
||||
import com.seibel.lod.core.objects.Pos2D;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ArrayGridList<T> extends ArrayList<T> implements List<T> {
|
||||
public class ArrayGridList<T> extends ArrayList<T> {
|
||||
public final int gridSize;
|
||||
|
||||
public ArrayGridList(int gridSize, BiFunction<Integer, Integer, T> filler) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.seibel.lod.core.util.gridList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/*Layout:
|
||||
@@ -11,7 +10,7 @@ import java.util.function.Consumer;
|
||||
*/
|
||||
|
||||
@Deprecated // Replace with PosArrayGridList<T>
|
||||
public class MovableCenteredGridList<T> extends ArrayList<T> implements List<T> {
|
||||
public class MovableCenteredGridList<T> extends ArrayList<T> {
|
||||
|
||||
private int centerX;
|
||||
private int centerY;
|
||||
|
||||
-10
@@ -19,7 +19,6 @@
|
||||
|
||||
package com.seibel.lod.core.wrapperInterfaces.minecraft;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -83,15 +82,6 @@ public interface IMinecraftClientWrapper extends IBindable
|
||||
*/
|
||||
int getColorIntFromLightMap(int blockLight, int skyLight);
|
||||
|
||||
/**
|
||||
* Returns the Color at the given pixel coordinates
|
||||
* from the current lightmap.
|
||||
* @param blockLight x location in texture space
|
||||
* @param skyLight z location in texture space
|
||||
*/
|
||||
Color getColorFromLightMap(int blockLight, int skyLight);
|
||||
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
|
||||
Reference in New Issue
Block a user