mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-17 19:15:06 +00:00
Compare commits
32
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b2d57a32d | ||
|
|
06bf71126f | ||
|
|
4c0f2f2685 | ||
|
|
78334717e7 | ||
|
|
a77765a2c9 | ||
|
|
1a9fe45ee9 | ||
|
|
21ef5905c8 | ||
|
|
5b67eaa474 | ||
|
|
c9d59c3b90 | ||
|
|
fa7ff74fec | ||
|
|
a34a3ebd39 | ||
|
|
2e7476d287 | ||
|
|
3244071012 | ||
|
|
7035dbde02 | ||
|
|
97ae04c2fa | ||
|
|
e7fa7f62d0 | ||
|
|
ea39712749 | ||
|
|
66dd3eaa94 | ||
|
|
270697cd10 | ||
|
|
2b53a851ef | ||
|
|
34b6efde7b | ||
|
|
86edb721da | ||
|
|
39c5f4bf7b | ||
|
|
5dc54bb1da | ||
|
|
7924769ab1 | ||
|
|
8afe2e2ccf | ||
|
|
e8dd60e088 | ||
|
|
9a621405ba | ||
|
|
45a677030d | ||
|
|
4d531022d2 | ||
|
|
48ba2160ad | ||
|
|
334ec81f9b |
No files matched your search
@@ -7,7 +7,7 @@
|
||||
* It's a cute angle -mitchej123
|
||||
* It's the angel that pulls you out of OptiFine's hell -Roadhog360
|
||||
|
||||
## **Beta Quality - Here there be Dragons**
|
||||
## **Beta Quality - Here there be Dragons**
|
||||
* Shaders - Beta
|
||||
* Complementary & BSL mostly function, but have some bugs
|
||||
* Sildurs, Seus, and any other shader probably doesn't work
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
# Required Dependencies
|
||||
* [UniMixins](https://github.com/LegacyModdingMC/UniMixins/releases) >= 0.1.19
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.6.20
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.7.0
|
||||
* NOTE: Some mods are not required, but a specific version is required if present - see: `Permanent Incompatibilities` below.
|
||||
|
||||
# Known (temporary) Incompatibilities
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
# Known Incompatibilities
|
||||
* FalseTweaks - Not currently planned (Looking for volunteers) [Might work if you effectively disable most of the mod]
|
||||
* SmoothFont - Not currently planned (Looking for volunteers)
|
||||
* RPLE - Not currently planned (Looking for volunteers)
|
||||
* LiteLoader - Install [LiteloaderLoader](https://github.com/Midnight145/LiteloaderLoader)
|
||||
|
||||
@@ -42,6 +41,7 @@
|
||||
* [Hodgepodge 2.4.3 and below](https://github.com/GTNewHorizons/Hodgepodge/releases) - Use 0.4.5 or above
|
||||
* CodeChicken[Core](https://github.com/GTNewHorizons/CodeChickenCore/releases)/[Lib](https://github.com/GTNewHorizons/CodeChickenLib/releases) <1.2.0 - Threading issues, use 1.3.0+
|
||||
* Neodymium - Untested, but unlikely to be compatible. (Chunk Meshing is definitely incompatible, other features might work depending on config)
|
||||
* SmoothFont - Equivalent functionality added
|
||||
|
||||
# Credits
|
||||
* ShadersMod
|
||||
|
||||
+10
-11
@@ -49,19 +49,16 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.97")
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.11")
|
||||
|
||||
compileOnly("com.gtnewhorizons.retrofuturabootstrap:RetroFuturaBootstrap:1.0.7") { transitive = false }
|
||||
|
||||
compileOnly("org.projectlombok:lombok:1.18.34") { transitive = false }
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.34")
|
||||
|
||||
// Use modern models+textures to inject QuadProviders
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:TX-Loader:1.8.5:dev')
|
||||
|
||||
// Iris Shaders
|
||||
compileOnly('org.jetbrains:annotations:26.0.2')
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.6.39:dev")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.8.0:dev")
|
||||
shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0
|
||||
shadowImplementation("org.taumc:glsl-transformation-lib:0.2.0-4.g6b42bca") {
|
||||
exclude module: "antlr4" // we only want to shadow the runtime module
|
||||
@@ -70,18 +67,18 @@ dependencies {
|
||||
compileOnly "org.apache.ant:ant:1.8.2"
|
||||
|
||||
// Because who doesn't want NEI
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.72-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.31-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:CodeChickenCore:1.4.7:dev')
|
||||
|
||||
// Notfine Deps
|
||||
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
|
||||
devOnlyNonPublishable("com.github.GTNewHorizons:Baubles-Expanded:2.1.9-GTNH:dev")
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.7.9:dev") { transitive = false }
|
||||
devOnlyNonPublishable("com.github.GTNewHorizons:Baubles-Expanded:2.2.2-GTNH:dev")
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.7.13:dev") { transitive = false }
|
||||
compileOnly(rfg.deobf('curse.maven:witchery-69673:2234410'))
|
||||
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.13.48-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Natura:2.8.8:dev")
|
||||
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.14.6-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Natura:2.8.9:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.7.6:dev")
|
||||
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.8.4:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.3:dev") { transitive = false }
|
||||
|
||||
@@ -101,6 +98,8 @@ dependencies {
|
||||
compileOnly(rfg.deobf("curse.maven:security-craft-64760:2818228"))
|
||||
|
||||
runtimeOnlyNonPublishable(rfg.deobf("CoreTweaks:CoreTweaks:0.3.3.2"))
|
||||
// For testing alternative splash screens, can be sourced from https://github.com/MalTeeez/ModernSplash/releases
|
||||
//runtimeOnly(rfg.deobf(files("dependencies/modernsplash-1.7.10-1.2.2-dev.jar")))
|
||||
|
||||
// Hodgepodge
|
||||
transformedMod("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
|
||||
|
||||
+9
-1
@@ -96,7 +96,9 @@ usesMixinDebug = false
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
# Specify the package that contains all of your Mixins. The package must exist or
|
||||
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
|
||||
# it must match with this or the build will fail.
|
||||
mixinsPackage = mixins
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
@@ -172,6 +174,12 @@ curseForgeRelations = requiredDependency\:gtnhlib
|
||||
# projects. New projects should not use this parameter.
|
||||
# customArchiveBaseName =
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
|
||||
# runClientWorkingDirectory = run/client
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
|
||||
# runServerWorkingDirectory = run/server
|
||||
|
||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
||||
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
||||
# The check is ONLY performed if the version is a git tag.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
+1
-1
@@ -16,5 +16,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.41'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.48'
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gtnewhorizons.angelica;
|
||||
|
||||
import static com.gtnewhorizons.angelica.AngelicaMod.MOD_ID;
|
||||
|
||||
import com.gtnewhorizons.angelica.common.BlockError;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.proxy.CommonProxy;
|
||||
@@ -12,7 +14,7 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
@Mod(
|
||||
modid = "angelica",
|
||||
modid = MOD_ID,
|
||||
name = "Angelica",
|
||||
version = Tags.VERSION,
|
||||
dependencies = """
|
||||
@@ -26,6 +28,8 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
acceptableRemoteVersions = "*",
|
||||
guiFactory = "com.gtnewhorizons.angelica.config.AngelicaGuiConfigFactory")
|
||||
public class AngelicaMod {
|
||||
public static final String MOD_ID = "angelica";
|
||||
|
||||
@SidedProxy(clientSide = "com.gtnewhorizons.angelica.proxy.ClientProxy", serverSide = "com.gtnewhorizons.angelica.proxy.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.FontRendererAccessor;
|
||||
import it.unimi.dsi.fastutil.chars.Char2ShortOpenHashMap;
|
||||
import cpw.mods.fml.client.SplashProgress;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import jss.util.RandomXoshiro256StarStar;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.coderbot.iris.gl.program.Program;
|
||||
import net.coderbot.iris.gl.program.ProgramBuilder;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
/**
|
||||
* A batching replacement for {@code FontRenderer}
|
||||
*
|
||||
@@ -30,8 +34,6 @@ public class BatchingFontRenderer {
|
||||
|
||||
/** The underlying FontRenderer object that's being accelerated */
|
||||
protected FontRenderer underlying;
|
||||
/** Cached locations for each unicode page atlas */
|
||||
private final ResourceLocation[] unicodePageLocations;
|
||||
/** Array of width of all the characters in default.png */
|
||||
protected int[] charWidth = new int[256];
|
||||
/** Array of the start/end column (in upper/lower nibble) for every glyph in the /font directory. */
|
||||
@@ -43,39 +45,38 @@ public class BatchingFontRenderer {
|
||||
private int[] colorCode;
|
||||
/** Location of the primary font atlas to bind. */
|
||||
protected final ResourceLocation locationFontTexture;
|
||||
private final RandomXoshiro256StarStar fontRandom = new RandomXoshiro256StarStar();
|
||||
|
||||
/** The full list of characters present in the default Minecraft font, excluding the Unicode font */
|
||||
@SuppressWarnings("UnnecessaryUnicodeEscape")
|
||||
private static final String MCFONT_CHARS = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000";
|
||||
private final int AAMode;
|
||||
private final int AAStrength;
|
||||
private final int texBoundAttrLocation;
|
||||
private final int fontShaderId;
|
||||
|
||||
private static final short[] MCFONT_ASCII_LUT = new short[512];
|
||||
private static final Char2ShortOpenHashMap MCFONT_UNI_LUT = new Char2ShortOpenHashMap();
|
||||
final boolean isSGA;
|
||||
final boolean isSplash;
|
||||
|
||||
static {
|
||||
Arrays.fill(MCFONT_ASCII_LUT, (short) -1);
|
||||
for (short i = 0; i < MCFONT_CHARS.length(); i++) {
|
||||
char ch = MCFONT_CHARS.charAt(i);
|
||||
if (ch < MCFONT_ASCII_LUT.length) {
|
||||
MCFONT_ASCII_LUT[ch] = i;
|
||||
} else {
|
||||
MCFONT_UNI_LUT.put(ch, i);
|
||||
private static class FontAAShader {
|
||||
|
||||
private static Program fontShader = null;
|
||||
public static Program getProgram() {
|
||||
if (fontShader == null) {
|
||||
String vsh, fsh;
|
||||
try {
|
||||
fsh = new String(IOUtils.toByteArray(Objects.requireNonNull(FontAAShader.class.getResourceAsStream("/assets/angelica/shaders/fontFilter.fsh"))), StandardCharsets.UTF_8);
|
||||
vsh = new String(IOUtils.toByteArray(Objects.requireNonNull(FontAAShader.class.getResourceAsStream("/assets/angelica/shaders/fontFilter.vsh"))), StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
ProgramBuilder builder = ProgramBuilder.begin("fontFilter", vsh, null, fsh, ImmutableSet.of(0));
|
||||
fontShader = builder.build();
|
||||
}
|
||||
return fontShader;
|
||||
}
|
||||
}
|
||||
|
||||
public static int lookupMcFontPosition(char ch) {
|
||||
if (ch < MCFONT_ASCII_LUT.length) {
|
||||
return MCFONT_ASCII_LUT[ch];
|
||||
} else {
|
||||
return MCFONT_UNI_LUT.getOrDefault(ch, (short) -1);
|
||||
}
|
||||
}
|
||||
|
||||
public BatchingFontRenderer(FontRenderer underlying, ResourceLocation[] unicodePageLocations, int[] charWidth,
|
||||
byte[] glyphWidth, int[] colorCode, ResourceLocation locationFontTexture) {
|
||||
public BatchingFontRenderer(FontRenderer underlying, int[] charWidth, byte[] glyphWidth,
|
||||
int[] colorCode, ResourceLocation locationFontTexture) {
|
||||
this.underlying = underlying;
|
||||
this.unicodePageLocations = unicodePageLocations;
|
||||
this.charWidth = charWidth;
|
||||
this.glyphWidth = glyphWidth;
|
||||
this.colorCode = colorCode;
|
||||
@@ -84,6 +85,19 @@ public class BatchingFontRenderer {
|
||||
for (int i = 0; i < 64; i++) {
|
||||
batchCommandPool.add(new FontDrawCmd());
|
||||
}
|
||||
|
||||
this.isSGA = Objects.equals(this.locationFontTexture.getResourcePath(), "textures/font/ascii_sga.png");
|
||||
this.isSplash = FontStrategist.isSplashFontRendererActive(underlying);
|
||||
|
||||
FontProviderMC.get(this.isSGA).charWidth = this.charWidth;
|
||||
FontProviderMC.get(this.isSGA).locationFontTexture = this.locationFontTexture;
|
||||
FontProviderUnicode.get().glyphWidth = this.glyphWidth;
|
||||
|
||||
//noinspection deprecation
|
||||
fontShaderId = FontAAShader.getProgram().getProgramId();
|
||||
AAMode = GL20.glGetUniformLocation(fontShaderId, "aaMode");
|
||||
AAStrength = GL20.glGetUniformLocation(fontShaderId, "strength");
|
||||
texBoundAttrLocation = GL20.glGetAttribLocation(fontShaderId, "texBounds");
|
||||
}
|
||||
|
||||
// === Batched rendering
|
||||
@@ -99,17 +113,22 @@ public class BatchingFontRenderer {
|
||||
private ByteBuffer batchVtxColors = memAlloc(INITIAL_BATCH_SIZE * 4);
|
||||
private FloatBuffer batchVtxTexCoords = memAllocFloat(INITIAL_BATCH_SIZE * 2);
|
||||
private IntBuffer batchIndices = memAllocInt(INITIAL_BATCH_SIZE / 2 * 3);
|
||||
private FloatBuffer batchVtxTexBounds = memAllocFloat(INITIAL_BATCH_SIZE * 4);
|
||||
private final ObjectArrayList<FontDrawCmd> batchCommands = ObjectArrayList.wrap(new FontDrawCmd[64], 0);
|
||||
private final ObjectArrayList<FontDrawCmd> batchCommandPool = ObjectArrayList.wrap(new FontDrawCmd[64], 0);
|
||||
|
||||
private int blendSrcRGB = GL11.GL_SRC_ALPHA;
|
||||
private int blendDstRGB = GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||
|
||||
/** */
|
||||
private void pushVtx(float x, float y, int rgba, float u, float v) {
|
||||
private void pushVtx(float x, float y, int rgba, float u, float v, float uMin, float uMax, float vMin, float vMax) {
|
||||
final int oldCap = batchVtxPositions.capacity() / 2;
|
||||
if (vtxWriterIndex >= oldCap) {
|
||||
final int newCap = oldCap * 2;
|
||||
batchVtxPositions = memRealloc(batchVtxPositions, newCap * 2);
|
||||
batchVtxColors = memRealloc(batchVtxColors, newCap * 4);
|
||||
batchVtxTexCoords = memRealloc(batchVtxTexCoords, newCap * 2);
|
||||
batchVtxTexBounds = memRealloc(batchVtxTexBounds, newCap * 4);
|
||||
final int oldIdxCap = batchIndices.capacity();
|
||||
final int newIdxCap = oldIdxCap * 2;
|
||||
batchIndices = memRealloc(batchIndices, newIdxCap);
|
||||
@@ -126,15 +145,19 @@ public class BatchingFontRenderer {
|
||||
batchVtxColors.put(idx4 + 3, (byte) ((rgba >> 24) & 0xFF));
|
||||
batchVtxTexCoords.put(idx2, u);
|
||||
batchVtxTexCoords.put(idx2 + 1, v);
|
||||
batchVtxTexBounds.put(idx4, uMin);
|
||||
batchVtxTexBounds.put(idx4 + 1, uMax);
|
||||
batchVtxTexBounds.put(idx4 + 2, vMin);
|
||||
batchVtxTexBounds.put(idx4 + 3, vMax);
|
||||
vtxWriterIndex++;
|
||||
}
|
||||
|
||||
private void pushUntexRect(float x, float y, float w, float h, int rgba) {
|
||||
final int vtxId = vtxWriterIndex;
|
||||
pushVtx(x, y, rgba, 0, 0);
|
||||
pushVtx(x, y + h, rgba, 0, 0);
|
||||
pushVtx(x + w, y, rgba, 0, 0);
|
||||
pushVtx(x + w, y + h, rgba, 0, 0);
|
||||
pushVtx(x, y, rgba, 0, 0, 0, 0, 0, 0);
|
||||
pushVtx(x, y + h, rgba, 0, 0, 0, 0, 0, 0);
|
||||
pushVtx(x + w, y, rgba, 0, 0, 0, 0, 0, 0);
|
||||
pushVtx(x + w, y + h, rgba, 0, 0, 0, 0, 0, 0);
|
||||
pushQuadIdx(vtxId);
|
||||
}
|
||||
|
||||
@@ -241,6 +264,9 @@ public class BatchingFontRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
int lastActiveProgram;
|
||||
int fontAAModeLast = -1;
|
||||
int fontAAStrengthLast = -1;
|
||||
private void flushBatch() {
|
||||
// Sort&Draw
|
||||
batchCommands.sort(FontDrawCmd.DRAW_ORDER_COMPARATOR);
|
||||
@@ -253,9 +279,23 @@ public class BatchingFontRenderer {
|
||||
GLStateManager.enableTexture();
|
||||
GLStateManager.enableAlphaTest();
|
||||
GLStateManager.enableBlend();
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
GLStateManager.tryBlendFuncSeparate(blendSrcRGB, blendDstRGB, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
GLStateManager.glShadeModel(GL11.GL_FLAT);
|
||||
|
||||
if (FontConfig.fontAAMode != 0) {
|
||||
GL20.glVertexAttribPointer(texBoundAttrLocation, 4, false, 0, batchVtxTexBounds);
|
||||
GL20.glEnableVertexAttribArray(texBoundAttrLocation);
|
||||
lastActiveProgram = GLStateManager.getActiveProgram();
|
||||
GLStateManager.glUseProgram(fontShaderId);
|
||||
if (FontConfig.fontAAMode != fontAAModeLast) {
|
||||
fontAAModeLast = FontConfig.fontAAMode;
|
||||
GL20.glUniform1i(AAMode, FontConfig.fontAAMode);
|
||||
}
|
||||
if (FontConfig.fontAAStrength != fontAAStrengthLast) {
|
||||
fontAAStrengthLast = FontConfig.fontAAStrength;
|
||||
GL20.glUniform1f(AAStrength, FontConfig.fontAAStrength / 120.f);
|
||||
}
|
||||
}
|
||||
GL11.glTexCoordPointer(2, 0, batchVtxTexCoords);
|
||||
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, batchVtxColors);
|
||||
@@ -284,20 +324,11 @@ public class BatchingFontRenderer {
|
||||
batchIndices.limit(cmd.startVtx + cmd.idxCount);
|
||||
batchIndices.position(cmd.startVtx);
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
int scaleFactor = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight).getScaleFactor();
|
||||
boolean shouldApplyFilter = cmd.isUnicode && scaleFactor % 2 != 0;
|
||||
|
||||
if (shouldApplyFilter) {
|
||||
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
|
||||
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
|
||||
}
|
||||
GL11.glDrawElements(GL11.GL_TRIANGLES, batchIndices);
|
||||
|
||||
if (shouldApplyFilter) {
|
||||
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
|
||||
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
|
||||
}
|
||||
}
|
||||
if (FontConfig.fontAAMode != 0) {
|
||||
GLStateManager.glUseProgram(lastActiveProgram);
|
||||
GL20.glDisableVertexAttribArray(texBoundAttrLocation);
|
||||
}
|
||||
|
||||
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
@@ -326,17 +357,28 @@ public class BatchingFontRenderer {
|
||||
return (what >= fromInclusive) && (what <= toInclusive);
|
||||
}
|
||||
|
||||
private ResourceLocation getUnicodePageLocation(int page) {
|
||||
final ResourceLocation lookup = unicodePageLocations[page];
|
||||
if (lookup == null) {
|
||||
final ResourceLocation rl = new ResourceLocation(String.format(
|
||||
"textures/font/unicode_page_%02x.png",
|
||||
page));
|
||||
unicodePageLocations[page] = rl;
|
||||
return rl;
|
||||
} else {
|
||||
return lookup;
|
||||
}
|
||||
public boolean forceDefaults() {
|
||||
return this.isSGA || this.isSplash;
|
||||
}
|
||||
|
||||
public float getGlyphScaleX() {
|
||||
return forceDefaults() ? 1 : (float) (FontConfig.glyphScale * Math.pow(2, FontConfig.glyphAspect)) * (FontStrategist.customFontInUse ? 1.5f : 1);
|
||||
}
|
||||
|
||||
public float getGlyphScaleY() {
|
||||
return forceDefaults() ? 1 : (float) (FontConfig.glyphScale / Math.pow(2, FontConfig.glyphAspect)) * (FontStrategist.customFontInUse ? 1.5f : 1);
|
||||
}
|
||||
|
||||
public float getGlyphSpacing() {
|
||||
return forceDefaults() ? 0 : FontConfig.glyphSpacing;
|
||||
}
|
||||
|
||||
public float getWhitespaceScale() {
|
||||
return forceDefaults() ? 1 : FontConfig.whitespaceScale;
|
||||
}
|
||||
|
||||
public float getShadowOffset() {
|
||||
return forceDefaults() ? 1 : FontConfig.fontShadowOffset;
|
||||
}
|
||||
|
||||
private static final char FORMATTING_CHAR = 167; // §
|
||||
@@ -349,6 +391,9 @@ public class BatchingFontRenderer {
|
||||
}
|
||||
final int shadowColor = (color & 0xfcfcfc) >> 2 | color & 0xff000000;
|
||||
|
||||
FontProviderMC.get(this.isSGA).charWidth = this.charWidth;
|
||||
FontProviderMC.get(this.isSGA).locationFontTexture = this.locationFontTexture;
|
||||
|
||||
this.beginBatch();
|
||||
float curX = anchorX;
|
||||
try {
|
||||
@@ -368,10 +413,14 @@ public class BatchingFontRenderer {
|
||||
boolean curStrikethrough = false;
|
||||
boolean curUnderline = false;
|
||||
|
||||
final float underlineY = anchorY + underlying.FONT_HEIGHT - 1.0f;
|
||||
final float glyphScaleY = getGlyphScaleY();
|
||||
final float heightNorth = anchorY + (underlying.FONT_HEIGHT - 1.0f) * (0.5f - glyphScaleY / 2);
|
||||
final float heightSouth = (underlying.FONT_HEIGHT - 1.0f) * glyphScaleY;
|
||||
|
||||
final float underlineY = heightNorth + (underlying.FONT_HEIGHT - 1.0f) * glyphScaleY;
|
||||
float underlineStartX = 0.0f;
|
||||
float underlineEndX = 0.0f;
|
||||
final float strikethroughY = anchorY + (float) (underlying.FONT_HEIGHT / 2) - 1.0F;
|
||||
final float strikethroughY = heightNorth + ((float) (underlying.FONT_HEIGHT / 2) - 1.0f) * glyphScaleY;
|
||||
float strikethroughStartX = 0.0f;
|
||||
float strikethroughEndX = 0.0f;
|
||||
|
||||
@@ -383,7 +432,7 @@ public class BatchingFontRenderer {
|
||||
|
||||
if (curUnderline && underlineStartX != underlineEndX) {
|
||||
final int ulIdx = idxWriterIndex;
|
||||
pushUntexRect(underlineStartX, underlineY, underlineEndX - underlineStartX, 1.0f, curColor);
|
||||
pushUntexRect(underlineStartX, underlineY, underlineEndX - underlineStartX, glyphScaleY, curColor);
|
||||
pushDrawCmd(ulIdx, 6, null, false);
|
||||
underlineStartX = underlineEndX;
|
||||
}
|
||||
@@ -393,7 +442,7 @@ public class BatchingFontRenderer {
|
||||
strikethroughStartX,
|
||||
strikethroughY,
|
||||
strikethroughEndX - strikethroughStartX,
|
||||
1.0f,
|
||||
glyphScaleY,
|
||||
curColor);
|
||||
pushDrawCmd(ulIdx, 6, null, false);
|
||||
strikethroughStartX = strikethroughEndX;
|
||||
@@ -440,67 +489,27 @@ public class BatchingFontRenderer {
|
||||
continue;
|
||||
}
|
||||
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
if (curRandom && lutIndex != -1) {
|
||||
int randomReplacementIndex;
|
||||
do {
|
||||
randomReplacementIndex = fontRandom.nextInt(this.charWidth.length);
|
||||
} while (this.charWidth[lutIndex] != this.charWidth[randomReplacementIndex]);
|
||||
|
||||
lutIndex = randomReplacementIndex;
|
||||
chr = MCFONT_CHARS.charAt(lutIndex);
|
||||
if (curRandom) {
|
||||
chr = FontProviderMC.get(this.isSGA).getRandomReplacement(chr);
|
||||
}
|
||||
|
||||
FontProvider fontProvider = FontStrategist.getFontProvider(this, chr, FontConfig.enableCustomFont, unicodeFlag);
|
||||
|
||||
// Check ASCII space, NBSP, NNBSP
|
||||
if (chr == ' ' || chr == '\u00A0' || chr == '\u202F') {
|
||||
curX += 4;
|
||||
curX += 4 * this.getWhitespaceScale();
|
||||
continue;
|
||||
}
|
||||
|
||||
final float uStart;
|
||||
final float vStart;
|
||||
final float xAdvance;
|
||||
final float glyphW;
|
||||
final float uSz;
|
||||
final float vSz;
|
||||
final float uStart = fontProvider.getUStart(chr);
|
||||
final float vStart = fontProvider.getVStart(chr);
|
||||
final float xAdvance = fontProvider.getXAdvance(chr) * getGlyphScaleX();
|
||||
final float glyphW = fontProvider.getGlyphW(chr) * getGlyphScaleX();
|
||||
final float uSz = fontProvider.getUSize(chr);
|
||||
final float vSz = fontProvider.getVSize(chr);
|
||||
final float itOff = curItalic ? 1.0F : 0.0F; // italic offset
|
||||
final float shadowOffset;
|
||||
final ResourceLocation texture;
|
||||
|
||||
if (lutIndex == -1 || unicodeFlag) {
|
||||
if (glyphWidth[chr] == 0) {
|
||||
continue;
|
||||
}
|
||||
// Draw unicode char
|
||||
shadowOffset = 0.5F;
|
||||
final int uniPage = chr / 256;
|
||||
texture = getUnicodePageLocation(uniPage);
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
uStart = ((float) (chr % 16 * 16) + startColumnF + 0.21f) / 256.0f;
|
||||
vStart = ((float) ((chr & 255) / 16 * 16) + 0.21f) / 256.0f;
|
||||
final float chrWidth = endColumnF - startColumnF - 0.02F;
|
||||
glyphW = chrWidth / 2.0f + 1.0f;
|
||||
xAdvance = (endColumnF - startColumnF) / 2.0F + 1.0F;
|
||||
uSz = (chrWidth - 0.42f) / 256.0f;
|
||||
vSz = (16.0f - 0.42f) / 256.0f;
|
||||
|
||||
} else {
|
||||
// Draw "ASCII" char
|
||||
shadowOffset = 1.0F;
|
||||
uStart = ((lutIndex % 16) * 8) / 128.0F;
|
||||
vStart = (float) ((lutIndex / 16) * 8) / 128.0F;
|
||||
xAdvance = this.charWidth[lutIndex];
|
||||
if (xAdvance == 0) {
|
||||
continue;
|
||||
}
|
||||
glyphW = xAdvance - 0.01F;
|
||||
uSz = (glyphW - 1.0F) / 128.0F;
|
||||
vSz = 7.99F / 128.0F;
|
||||
texture = locationFontTexture;
|
||||
}
|
||||
final float shadowOffset = fontProvider.getShadowOffset();
|
||||
final ResourceLocation texture = fontProvider.getTexture(chr);
|
||||
|
||||
final int vtxId = vtxWriterIndex;
|
||||
final int idxId = idxWriterIndex;
|
||||
@@ -508,80 +517,49 @@ public class BatchingFontRenderer {
|
||||
int vtxCount = 0;
|
||||
|
||||
if (enableShadow) {
|
||||
pushVtx(curX + itOff + shadowOffset, anchorY + shadowOffset, curShadowColor, uStart, vStart);
|
||||
pushVtx(
|
||||
curX - itOff + shadowOffset,
|
||||
anchorY + 7.99F + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart,
|
||||
vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F + itOff + shadowOffset,
|
||||
anchorY + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart + uSz,
|
||||
vStart);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff + shadowOffset,
|
||||
anchorY + 7.99F + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart + uSz,
|
||||
vStart + vSz);
|
||||
pushVtx(curX + itOff + shadowOffset, heightNorth + shadowOffset, curShadowColor, uStart, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX - itOff + shadowOffset, heightNorth + heightSouth + shadowOffset, curShadowColor, uStart, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F + itOff + shadowOffset, heightNorth + shadowOffset, curShadowColor, uStart + uSz, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff + shadowOffset, heightNorth + heightSouth + shadowOffset, curShadowColor, uStart + uSz, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushQuadIdx(vtxId + vtxCount);
|
||||
vtxCount += 4;
|
||||
|
||||
if (curBold) {
|
||||
final float shadowOffset2 = 2.0f * shadowOffset;
|
||||
pushVtx(curX + itOff + shadowOffset2, anchorY + shadowOffset, curShadowColor, uStart, vStart);
|
||||
pushVtx(
|
||||
curX - itOff + shadowOffset2,
|
||||
anchorY + 7.99F + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart,
|
||||
vStart + vSz);
|
||||
pushVtx(
|
||||
curX + glyphW - 1.0F + itOff + shadowOffset2,
|
||||
anchorY + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart + uSz,
|
||||
vStart);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff + shadowOffset2,
|
||||
anchorY + 7.99F + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart + uSz,
|
||||
vStart + vSz);
|
||||
pushVtx(curX + itOff + shadowOffset2, heightNorth + shadowOffset, curShadowColor, uStart, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX - itOff + shadowOffset2, heightNorth + heightSouth + shadowOffset, curShadowColor, uStart, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F + itOff + shadowOffset2, heightNorth + shadowOffset, curShadowColor, uStart + uSz, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff + shadowOffset2, heightNorth + heightSouth + shadowOffset, curShadowColor, uStart + uSz, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushQuadIdx(vtxId + vtxCount);
|
||||
vtxCount += 4;
|
||||
}
|
||||
}
|
||||
|
||||
pushVtx(curX + itOff, anchorY, curColor, uStart, vStart);
|
||||
pushVtx(curX - itOff, anchorY + 7.99F, curColor, uStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F + itOff, anchorY, curColor, uStart + uSz, vStart);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff, anchorY + 7.99F, curColor, uStart + uSz, vStart + vSz);
|
||||
pushVtx(curX + itOff, heightNorth, curColor, uStart, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX - itOff, heightNorth + heightSouth, curColor, uStart, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F + itOff, heightNorth, curColor, uStart + uSz, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff, heightNorth + heightSouth, curColor, uStart + uSz, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushQuadIdx(vtxId + vtxCount);
|
||||
vtxCount += 4;
|
||||
|
||||
if (curBold) {
|
||||
pushVtx(shadowOffset + curX + itOff, anchorY, curColor, uStart, vStart);
|
||||
pushVtx(shadowOffset + curX - itOff, anchorY + 7.99F, curColor, uStart, vStart + vSz);
|
||||
pushVtx(shadowOffset + curX + glyphW - 1.0F + itOff, anchorY, curColor, uStart + uSz, vStart);
|
||||
pushVtx(shadowOffset + curX + glyphW - 1.0F - itOff,
|
||||
anchorY + 7.99F,
|
||||
curColor,
|
||||
uStart + uSz,
|
||||
vStart + vSz);
|
||||
pushVtx(shadowOffset + curX + itOff, heightNorth, curColor, uStart, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(shadowOffset + curX - itOff, heightNorth + heightSouth, curColor, uStart, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(shadowOffset + curX + glyphW - 1.0F + itOff, heightNorth, curColor, uStart + uSz, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(shadowOffset + curX + glyphW - 1.0F - itOff, heightNorth + heightSouth, curColor, uStart + uSz, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushQuadIdx(vtxId + vtxCount);
|
||||
vtxCount += 4;
|
||||
}
|
||||
|
||||
pushDrawCmd(idxId, vtxCount / 2 * 3, texture, chr > 255);
|
||||
curX += xAdvance + (curBold ? shadowOffset : 0.0f);
|
||||
curX += (xAdvance + (curBold ? shadowOffset : 0.0f)) + getGlyphSpacing();
|
||||
underlineEndX = curX;
|
||||
strikethroughEndX = curX;
|
||||
}
|
||||
|
||||
if (curUnderline && underlineStartX != underlineEndX) {
|
||||
final int ulIdx = idxWriterIndex;
|
||||
pushUntexRect(underlineStartX, underlineY, underlineEndX - underlineStartX, 1.0f, curColor);
|
||||
pushUntexRect(underlineStartX, underlineY, underlineEndX - underlineStartX, glyphScaleY, curColor);
|
||||
pushDrawCmd(ulIdx, 6, null, false);
|
||||
}
|
||||
if (curStrikethrough && strikethroughStartX != strikethroughEndX) {
|
||||
@@ -590,7 +568,7 @@ public class BatchingFontRenderer {
|
||||
strikethroughStartX,
|
||||
strikethroughY,
|
||||
strikethroughEndX - strikethroughStartX,
|
||||
1.0f,
|
||||
glyphScaleY,
|
||||
curColor);
|
||||
pushDrawCmd(ulIdx, 6, null, false);
|
||||
}
|
||||
@@ -601,4 +579,25 @@ public class BatchingFontRenderer {
|
||||
return curX + (enableShadow ? 1.0f : 0.0f);
|
||||
}
|
||||
|
||||
public float getCharWidthFine(char chr) {
|
||||
if (chr == FORMATTING_CHAR) { return -1; }
|
||||
|
||||
if (chr == ' ' || chr == '\u00A0' || chr == '\u202F') {
|
||||
return 4 * this.getWhitespaceScale();
|
||||
}
|
||||
|
||||
FontProvider fp = FontStrategist.getFontProvider(this, chr, FontConfig.enableCustomFont, underlying.getUnicodeFlag());
|
||||
|
||||
return fp.getXAdvance(chr) * this.getGlyphScaleX();
|
||||
}
|
||||
|
||||
public void overrideBlendFunc(int srcRgb, int dstRgb) {
|
||||
blendSrcRGB = srcRgb;
|
||||
blendDstRGB = dstRgb;
|
||||
}
|
||||
|
||||
public void resetBlendFunc() {
|
||||
blendSrcRGB = GL11.GL_SRC_ALPHA;
|
||||
blendDstRGB = GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface FontProvider {
|
||||
|
||||
/**
|
||||
* For use with §k. Should fetch a character of the same width as provided.
|
||||
*/
|
||||
char getRandomReplacement(char chr);
|
||||
boolean isGlyphAvailable(char chr);
|
||||
float getUStart(char chr);
|
||||
float getVStart(char chr);
|
||||
float getXAdvance(char chr);
|
||||
float getGlyphW(char chr);
|
||||
float getUSize(char chr);
|
||||
float getVSize(char chr);
|
||||
float getShadowOffset();
|
||||
ResourceLocation getTexture(char chr);
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import lombok.Setter;
|
||||
import lombok.Value;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class FontProviderCustom implements FontProvider {
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
public static final String FONT_DIR = "fonts/custom/";
|
||||
static final int ATLAS_SIZE = 128;
|
||||
static final int ATLAS_COUNT = 512;
|
||||
private final byte id; // 0 - primary font, 1 - fallback font
|
||||
private FontAtlas[] fontAtlases = new FontAtlas[ATLAS_COUNT];
|
||||
private float currentFontQuality = FontConfig.customFontQuality;
|
||||
@Setter
|
||||
private Font font;
|
||||
|
||||
private FontProviderCustom(byte id) {
|
||||
this.id = id;
|
||||
Font[] availableFonts = FontStrategist.getAvailableFonts();
|
||||
if (availableFonts.length == 0) {
|
||||
LOGGER.fatal("There seem to be no fonts available on this system! Disabling custom font and throwing an exception in an attempt to restore the session.");
|
||||
FontConfig.enableCustomFont = false;
|
||||
ConfigurationManager.save(FontConfig.class);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
String myFontName = switch (this.id) {
|
||||
case 0 -> FontConfig.customFontNamePrimary;
|
||||
case 1 -> FontConfig.customFontNameFallback;
|
||||
default -> null;
|
||||
};
|
||||
if (Objects.equals(myFontName, "(none)")) {
|
||||
font = null;
|
||||
return;
|
||||
}
|
||||
int fontPos = -1;
|
||||
for (int i = 0; i < availableFonts.length; i++) {
|
||||
if (Objects.equals(myFontName, availableFonts[i].getFontName())) {
|
||||
fontPos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fontPos == -1) {
|
||||
LOGGER.info("Could not find previously set font \"{}\". ", myFontName);
|
||||
font = null;
|
||||
return;
|
||||
}
|
||||
font = availableFonts[fontPos].deriveFont(currentFontQuality);
|
||||
}
|
||||
private static class InstLoader {
|
||||
static final FontProviderCustom instance0 = new FontProviderCustom((byte)0);
|
||||
static final FontProviderCustom instance1 = new FontProviderCustom((byte)1);
|
||||
}
|
||||
public static FontProviderCustom getPrimary() { return InstLoader.instance0; }
|
||||
public static FontProviderCustom getFallback() { return InstLoader.instance1; }
|
||||
|
||||
public void reloadFont(int fontID) {
|
||||
currentFontQuality = FontConfig.customFontQuality;
|
||||
font = FontStrategist.getAvailableFonts()[fontID].deriveFont(currentFontQuality);
|
||||
|
||||
File[] files = new File(getFontDir()).listFiles();
|
||||
if (files != null) {
|
||||
for (File f : files) {
|
||||
if (!Files.isSymbolicLink(f.toPath())) {
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextureManager tm = Minecraft.getMinecraft().getTextureManager();
|
||||
Map mapTextureObjects = tm.mapTextureObjects;
|
||||
for (int i = 0; i < ATLAS_COUNT; i++) {
|
||||
ResourceLocation key = new ResourceLocation(getAtlasResourceName(i));
|
||||
if (mapTextureObjects.containsKey(key)) {
|
||||
ITextureObject obj = (ITextureObject) mapTextureObjects.get(key);
|
||||
TextureUtil.deleteTexture(obj.getGlTextureId());
|
||||
mapTextureObjects.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
fontAtlases = new FontAtlas[ATLAS_COUNT];
|
||||
}
|
||||
|
||||
private String getFontDir() {
|
||||
return FONT_DIR + "f" + this.id + "/";
|
||||
}
|
||||
|
||||
private String getAtlasFilename(int atlasId) {
|
||||
return "f" + this.id + "p" + atlasId;
|
||||
}
|
||||
|
||||
String getAtlasResourceName(int atlasId) {
|
||||
return "minecraft:angelica_c" + getAtlasFilename(atlasId);
|
||||
}
|
||||
|
||||
String getAtlasFullPath(int atlasId) {
|
||||
return getFontDir() + getAtlasFilename(atlasId) + ".png";
|
||||
}
|
||||
|
||||
@Value
|
||||
private class GlyphData {
|
||||
float uStart;
|
||||
float vStart;
|
||||
float xAdvance;
|
||||
float glyphW;
|
||||
float uSz;
|
||||
float vSz;
|
||||
}
|
||||
|
||||
private class FontAtlas {
|
||||
|
||||
GlyphData[] glyphData = new GlyphData[ATLAS_SIZE];
|
||||
private ResourceLocation texture;
|
||||
private final int id;
|
||||
|
||||
FontAtlas(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
void construct(Font font) {
|
||||
float separator = currentFontQuality / 3f;
|
||||
|
||||
BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = image.createGraphics();
|
||||
g2d.setFont(font);
|
||||
FontMetrics fm = g2d.getFontMetrics();
|
||||
g2d.dispose();
|
||||
int width = 0;
|
||||
int actualChars = 0;
|
||||
for (int i = 0; i < ATLAS_SIZE; i++) {
|
||||
final char ch = (char)(i + ATLAS_SIZE * this.id);
|
||||
if (font.canDisplay(ch)) {
|
||||
width += (int) (separator + fm.charWidth(ch));
|
||||
actualChars++;
|
||||
}
|
||||
}
|
||||
if (actualChars == 0) {
|
||||
return;
|
||||
}
|
||||
final int atlasTilesX = (int) Math.ceil(Math.sqrt(actualChars) * 1.5f);
|
||||
final int atlasTilesY = (int) Math.ceil((double) actualChars / atlasTilesX);
|
||||
LOGGER.info("constructing custom font atlas (ID {}) of nominal size {} chars, actual: {}, {} rows by {} columns",
|
||||
this.id, ATLAS_SIZE, actualChars, atlasTilesX, atlasTilesY);
|
||||
width = 0;
|
||||
actualChars = 0;
|
||||
int maxRowWidth = 0;
|
||||
for (int i = 0; i < ATLAS_SIZE; i++) {
|
||||
if (actualChars % atlasTilesX == 0) {
|
||||
maxRowWidth = Math.max(maxRowWidth, width);
|
||||
width = 0;
|
||||
}
|
||||
final char ch = (char)(i + ATLAS_SIZE * this.id);
|
||||
if (font.canDisplay(ch)) {
|
||||
width += (int) (separator + fm.charWidth(ch));
|
||||
actualChars++;
|
||||
}
|
||||
}
|
||||
maxRowWidth = Math.max(maxRowWidth, width);
|
||||
|
||||
final int lineHeight = fm.getHeight();
|
||||
final float desc = fm.getDescent();
|
||||
|
||||
final int imageWidth = (int) (maxRowWidth + separator);
|
||||
final int imageHeight = (int) ((separator + lineHeight) * atlasTilesY + separator);
|
||||
|
||||
image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_ARGB);
|
||||
g2d = image.createGraphics();
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
g2d.setFont(font);
|
||||
fm = g2d.getFontMetrics();
|
||||
|
||||
int tileX = 0, tileY = 0; // position in atlas tiles
|
||||
int imgX = (int) separator; // position in pixels
|
||||
|
||||
for (int i = 0; i < ATLAS_SIZE; i++) {
|
||||
final char ch = (char)(i + ATLAS_SIZE * this.id);
|
||||
if (!font.canDisplay(ch)) { continue; }
|
||||
|
||||
if (tileX >= atlasTilesX) {
|
||||
tileX = 0;
|
||||
imgX = (int) separator;
|
||||
tileY++;
|
||||
}
|
||||
|
||||
final int charWidth = fm.charWidth(ch);
|
||||
final float charAspectRatio = (float) charWidth / lineHeight;
|
||||
final float inset = currentFontQuality / 16;
|
||||
g2d.drawString(Character.toString(ch), imgX, (lineHeight + separator) * (tileY + 1) - desc);
|
||||
final float uStart = (float) (imgX - inset * charAspectRatio) / imageWidth;
|
||||
final float vStart = ((lineHeight + separator) * (tileY + 1) - lineHeight - inset) / imageHeight;
|
||||
final float xAdvance = charAspectRatio * 8 * charWidth / (charWidth + 2 * inset * charAspectRatio);
|
||||
final float glyphW = charAspectRatio * 8 + 1;
|
||||
final float uSz = (float) (charWidth + 2 * inset * charAspectRatio) / imageWidth;
|
||||
final float vSz = (float) (lineHeight + 2 * inset) / imageHeight;
|
||||
glyphData[i] = new GlyphData(uStart, vStart, xAdvance, glyphW, uSz, vSz);
|
||||
imgX += (int) (charWidth + separator);
|
||||
tileX++;
|
||||
}
|
||||
g2d.dispose();
|
||||
try {
|
||||
LOGGER.info("writing custom font atlas texture ({}x{} px) to {}", imageWidth, imageHeight, getAtlasFullPath(this.id));
|
||||
Files.createDirectories(Paths.get(getFontDir()));
|
||||
ImageIO.write(image, "png", new File(getAtlasFullPath(this.id)));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.texture = new ResourceLocation(getAtlasResourceName(this.id));
|
||||
}
|
||||
}
|
||||
|
||||
private FontAtlas getAtlas(char chr) {
|
||||
int id = chr / ATLAS_SIZE;
|
||||
FontAtlas fa = fontAtlases[id];
|
||||
if (fa == null) {
|
||||
fa = new FontAtlas(id);
|
||||
fa.construct(font);
|
||||
}
|
||||
fontAtlases[id] = fa;
|
||||
return fa;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlyphAvailable(char chr) {
|
||||
if (font == null) { return false; }
|
||||
return (getAtlas(chr).glyphData[chr % ATLAS_SIZE] != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getRandomReplacement(char chr) {
|
||||
return chr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getUStart(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].uStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVStart(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].vStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getXAdvance(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].xAdvance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGlyphW(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].glyphW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getUSize(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].uSz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVSize(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].vSz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowOffset() {
|
||||
return FontConfig.fontShadowOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(char chr) {
|
||||
return getAtlas(chr).texture;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import it.unimi.dsi.fastutil.chars.Char2ShortOpenHashMap;
|
||||
import jss.util.RandomXoshiro256StarStar;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public final class FontProviderMC implements FontProvider {
|
||||
|
||||
/**
|
||||
* The full list of characters present in the default Minecraft font, excluding the Unicode font
|
||||
*/
|
||||
@SuppressWarnings("UnnecessaryUnicodeEscape")
|
||||
private static final String MCFONT_CHARS = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000";
|
||||
|
||||
private FontProviderMC() {}
|
||||
private static class InstLoader {
|
||||
static final FontProviderMC instance = new FontProviderMC();
|
||||
static final FontProviderMC instanceSGA = new FontProviderMC();
|
||||
}
|
||||
public static FontProviderMC get(boolean isSGA) {
|
||||
return (isSGA ? InstLoader.instanceSGA : InstLoader.instance);
|
||||
}
|
||||
|
||||
private static final Char2ShortOpenHashMap MCFONT_ASCII_MAP = new Char2ShortOpenHashMap();
|
||||
ResourceLocation locationFontTexture = null;
|
||||
private final RandomXoshiro256StarStar fontRandom = new RandomXoshiro256StarStar();
|
||||
public int[] charWidth;
|
||||
|
||||
static {
|
||||
for (short i = 0; i < MCFONT_CHARS.length(); i++) {
|
||||
MCFONT_ASCII_MAP.put(MCFONT_CHARS.charAt(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
public int lookupMcFontPosition(char ch) {
|
||||
if (isGlyphAvailable(ch)) {
|
||||
return MCFONT_ASCII_MAP.get(ch);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlyphAvailable(char chr) {
|
||||
return MCFONT_ASCII_MAP.containsKey(chr);
|
||||
}
|
||||
|
||||
public char getRandomReplacement(char chr){
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
if (lutIndex != -1) {
|
||||
int randomReplacementIndex;
|
||||
do {
|
||||
randomReplacementIndex = fontRandom.nextInt(this.charWidth.length);
|
||||
} while (this.charWidth[lutIndex] != this.charWidth[randomReplacementIndex]);
|
||||
|
||||
lutIndex = randomReplacementIndex;
|
||||
return MCFONT_CHARS.charAt(lutIndex);
|
||||
}
|
||||
return chr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getUStart(char chr) {
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
return ((lutIndex % 16) * 8) / 128.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVStart(char chr) {
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
return (float) ((lutIndex / 16) * 8) / 128.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getXAdvance(char chr) {
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
return charWidth[lutIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGlyphW(char chr) {
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
return charWidth[lutIndex] - 0.01F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getUSize(char chr) {
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
return (charWidth[lutIndex] - 1.01F) / 128.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVSize(char chr) {
|
||||
return 7.99F / 128.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowOffset() {
|
||||
return FontConfig.fontShadowOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(char chr) {
|
||||
return locationFontTexture;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public final class FontProviderUnicode implements FontProvider {
|
||||
|
||||
private FontProviderUnicode() {}
|
||||
private static class InstLoader { static final FontProviderUnicode instance = new FontProviderUnicode(); }
|
||||
public static FontProviderUnicode get() { return FontProviderUnicode.InstLoader.instance; }
|
||||
|
||||
private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256];
|
||||
public byte[] glyphWidth;
|
||||
|
||||
private ResourceLocation getUnicodePageLocation(int page) {
|
||||
final ResourceLocation lookup = unicodePageLocations[page];
|
||||
if (lookup == null) {
|
||||
final ResourceLocation rl = new ResourceLocation(String.format(
|
||||
"textures/font/unicode_page_%02x.png",
|
||||
page));
|
||||
unicodePageLocations[page] = rl;
|
||||
return rl;
|
||||
} else {
|
||||
return lookup;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlyphAvailable(char chr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getRandomReplacement(char chr) {
|
||||
return chr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getUStart(char chr) {
|
||||
final float startColumnF = (float)(this.glyphWidth[chr] >>> 4);
|
||||
return ((float) (chr % 16 * 16) + startColumnF + 0.21f) / 256.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVStart(char chr) {
|
||||
return ((float) ((chr & 255) / 16 * 16) + 0.21f) / 256.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getXAdvance(char chr) {
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
return (endColumnF - startColumnF) / 2.0F + 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGlyphW(char chr) {
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
final float chrWidth = endColumnF - startColumnF - 0.02F;
|
||||
return chrWidth / 2.0f + 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getUSize(char chr) {
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
final float chrWidth = endColumnF - startColumnF - 0.02F;
|
||||
return (chrWidth - 0.42f) / 256.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVSize(char chr) {
|
||||
return (16.0f - 0.42f) / 256.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowOffset() {
|
||||
return FontConfig.fontShadowOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(char chr) {
|
||||
final int uniPage = chr / 256;
|
||||
return getUnicodePageLocation(uniPage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ResourceAccessor;
|
||||
import cpw.mods.fml.client.SplashProgress;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.resources.DefaultResourcePack;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class FontStrategist {
|
||||
|
||||
@Getter
|
||||
private static final Font[] availableFonts;
|
||||
public static final Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
public static boolean customFontInUse;
|
||||
|
||||
static {
|
||||
// get available fonts without duplicates (250 copies of dialog.plain need not apply)
|
||||
Font[] availableFontsDirty = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
|
||||
HashMap<String, Font> fontSet = new HashMap<>();
|
||||
HashMultiset<String> duplicates = HashMultiset.create(); // for debugging
|
||||
|
||||
for (Font font : availableFontsDirty) {
|
||||
String fontName = font.getFontName();
|
||||
if (fontSet.containsKey(fontName)) {
|
||||
duplicates.add(fontName);
|
||||
} else {
|
||||
fontSet.put(fontName, font);
|
||||
}
|
||||
}
|
||||
|
||||
if (!duplicates.isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder(duplicates.size() + " duplicate font(s) found in the list reported by Java: ");
|
||||
for (Iterator<String> iter = duplicates.stream().distinct().iterator(); iter.hasNext(); ) {
|
||||
String dupe = iter.next();
|
||||
sb.append(duplicates.count(dupe)).append("x ").append(dupe);
|
||||
if (iter.hasNext()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
sb.append(". Some fonts may be missing from the font selection menu.");
|
||||
LOGGER.warn(sb.toString());
|
||||
}
|
||||
|
||||
availableFonts = fontSet.values().stream().sorted(Comparator.comparing(Font::getFontName)).toArray(Font[]::new);
|
||||
|
||||
// create and add the resource pack that provides fonts
|
||||
HashMap<String, File> packMap = new HashMap<>();
|
||||
for (int i = 0; i < FontProviderCustom.ATLAS_COUNT; i++) {
|
||||
packMap.put(FontProviderCustom.getPrimary().getAtlasResourceName(i), new File(FontProviderCustom.getPrimary().getAtlasFullPath(i)));
|
||||
packMap.put(FontProviderCustom.getFallback().getAtlasResourceName(i), new File(FontProviderCustom.getFallback().getAtlasFullPath(i)));
|
||||
}
|
||||
|
||||
DefaultResourcePack fontResourcePack = new DefaultResourcePack(packMap);
|
||||
List defaultResourcePacks = ((ResourceAccessor) Minecraft.getMinecraft()).angelica$getDefaultResourcePacks();
|
||||
defaultResourcePacks.add(fontResourcePack);
|
||||
Minecraft.getMinecraft().refreshResources();
|
||||
|
||||
// determine if a custom font is in use based on config values
|
||||
boolean primaryFontFound = false;
|
||||
boolean fallbackFontFound = false;
|
||||
for (Font availableFont : availableFonts) {
|
||||
if (Objects.equals(FontConfig.customFontNamePrimary, availableFont.getFontName())) {
|
||||
primaryFontFound = true;
|
||||
break;
|
||||
}
|
||||
if (Objects.equals(FontConfig.customFontNameFallback, availableFont.getFontName())) {
|
||||
fallbackFontFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
customFontInUse = (FontConfig.enableCustomFont && (primaryFontFound || fallbackFontFound));
|
||||
}
|
||||
|
||||
/**
|
||||
Lets you get a FontProvider per char while respecting font priority and fallbacks, the unicode flag, whether or not
|
||||
SGA is on, if we're in a splash screen, if a font can even display a character in the first place, etc.
|
||||
*/
|
||||
public static FontProvider getFontProvider(BatchingFontRenderer me, char chr, boolean customFontEnabled, boolean forceUnicode) {
|
||||
if (me.isSGA && FontProviderMC.get(true).isGlyphAvailable(chr)) {
|
||||
return FontProviderMC.get(true);
|
||||
}
|
||||
if (customFontEnabled && !me.isSplash) {
|
||||
FontProvider fp;
|
||||
fp = FontProviderCustom.getPrimary();
|
||||
if (fp.isGlyphAvailable(chr)) { return fp; }
|
||||
fp = FontProviderCustom.getFallback();
|
||||
if (fp.isGlyphAvailable(chr)) { return fp; }
|
||||
return FontProviderUnicode.get();
|
||||
} else {
|
||||
if (!forceUnicode && FontProviderMC.get(false).isGlyphAvailable(chr)) {
|
||||
return FontProviderMC.get(false);
|
||||
} else {
|
||||
return FontProviderUnicode.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void reloadCustomFontProviders() {
|
||||
FontProviderCustom.getPrimary().setFont(null);
|
||||
FontProviderCustom.getFallback().setFont(null);
|
||||
boolean primaryFontFound = false;
|
||||
boolean fallbackFontFound = false;
|
||||
for (int i = 0; i < availableFonts.length; i++) {
|
||||
if (Objects.equals(FontConfig.customFontNamePrimary, availableFonts[i].getFontName())) {
|
||||
FontProviderCustom.getPrimary().reloadFont(i);
|
||||
primaryFontFound = true;
|
||||
}
|
||||
if (Objects.equals(FontConfig.customFontNameFallback, availableFonts[i].getFontName())) {
|
||||
FontProviderCustom.getFallback().reloadFont(i);
|
||||
fallbackFontFound = true;
|
||||
}
|
||||
if (primaryFontFound && fallbackFontFound) { break; }
|
||||
}
|
||||
customFontInUse = (FontConfig.enableCustomFont && (primaryFontFound || fallbackFontFound));
|
||||
}
|
||||
|
||||
public static boolean isSplashFontRendererActive(FontRenderer fontRenderer) {
|
||||
// noinspection deprecation
|
||||
boolean active = fontRenderer instanceof SplashProgress.SplashFontRenderer;
|
||||
|
||||
try {
|
||||
Class<?> customSplashClass = Class.forName("gkappa.modernsplash.CustomSplash$SplashFontRenderer");
|
||||
active = active || customSplashClass.isInstance(fontRenderer);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
package com.gtnewhorizons.angelica.client.gui;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigException;
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
|
||||
import com.gtnewhorizons.angelica.client.font.FontStrategist;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import net.coderbot.iris.gui.element.widget.IrisButton;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiSlot;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FontConfigScreen extends GuiScreen {
|
||||
|
||||
private static final Font[] availableFonts = FontStrategist.getAvailableFonts();
|
||||
private final GuiScreen parent;
|
||||
private final String title;
|
||||
private final String searchPrompt;
|
||||
private String currentPrimaryFontName;
|
||||
private String currentFallbackFontName;
|
||||
private FontList fontList;
|
||||
private int selectedPrimaryFontListPos = -1;
|
||||
private int selectedFallbackFontListPos = -1;
|
||||
private ArrayList<Font> displayedFonts;
|
||||
private GuiTextField searchBox;
|
||||
|
||||
public FontConfigScreen(GuiScreen parent) {
|
||||
this.title = I18n.format("options.angelica.fontconfig.title");
|
||||
this.searchPrompt = I18n.format("options.angelica.fontconfig.searchprompt");
|
||||
this.parent = parent;
|
||||
this.currentPrimaryFontName = FontConfig.customFontNamePrimary;
|
||||
this.currentFallbackFontName = FontConfig.customFontNameFallback;
|
||||
this.displayedFonts = new ArrayList<>(Arrays.asList(availableFonts));
|
||||
for (int i = 0; i < availableFonts.length; i++) {
|
||||
if (Objects.equals(this.currentPrimaryFontName, availableFonts[i].getFontName())) {
|
||||
selectedPrimaryFontListPos = i;
|
||||
}
|
||||
if (Objects.equals(this.currentFallbackFontName, availableFonts[i].getFontName())) {
|
||||
selectedFallbackFontListPos = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SliderClone.Option optFontQuality = new SliderClone.Option(6, 72, 6);
|
||||
SliderClone.Option optShadowOffset = new SliderClone.Option(0, 2, 0.05f);
|
||||
SliderClone.Option optGlyphAspect = new SliderClone.Option(-1, 1, 0.05f);
|
||||
SliderClone.Option optGlyphScale = new SliderClone.Option(0.1f, 3, 0.05f);
|
||||
SliderClone.Option optWhitespaceScale = new SliderClone.Option(0.1f, 3, 0.05f);
|
||||
SliderClone.Option optGlyphSpacing = new SliderClone.Option(-2f, 2f, 0.05f);
|
||||
SliderClone.Option optFontAAMode = new SliderClone.Option(0, 2, 1);
|
||||
SliderClone.Option optFontAAStrength = new SliderClone.Option(1, 24, 1);
|
||||
|
||||
public void initGui() {
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
searchBox = new GuiTextField(this.fontRendererObj, this.width / 2 - 120, 24, 240, 20);
|
||||
searchBox.setMaxStringLength(64);
|
||||
fontList = new FontList();
|
||||
initButtons();
|
||||
}
|
||||
|
||||
private void initButtons() {
|
||||
this.buttonList.add(new IrisButton(this.width / 2 - 81 - 165, this.height - 20 - 7, 162, 20,
|
||||
FontConfig.enableCustomFont ? I18n.format("options.angelica.fontconfig.disable_custom_font") :
|
||||
I18n.format("options.angelica.fontconfig.enable_custom_font"), this::toggleCustomFont));
|
||||
this.buttonList.add(new IrisButton(this.width / 2 - 80, this.height - 20 - 7, 160, 20,
|
||||
I18n.format("options.angelica.fontconfig.reset_values"), this::resetValues));
|
||||
this.buttonList.add(new IrisButton(this.width / 2 - 81 + 165, this.height - 20 - 7, 162, 20,
|
||||
I18n.format("gui.done"), button -> this.onClose()));
|
||||
|
||||
// might refactor later, feeling too lazy at the moment
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 - 186, this.height - 40 - 11, 120, 20,
|
||||
optFontQuality, FontConfig.customFontQuality, this::setFontQuality,
|
||||
value -> I18n.format("options.angelica.fontconfig.font_quality", String.format("%2.0f", value)),
|
||||
"options.angelica.fontconfig.font_quality.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 - 186, this.height - 60 - 15, 120, 20,
|
||||
optShadowOffset, FontConfig.fontShadowOffset, value -> FontConfig.fontShadowOffset = value,
|
||||
value -> I18n.format("options.angelica.fontconfig.shadow_offset", String.format("x%3.2f", value)),
|
||||
"options.angelica.fontconfig.shadow_offset.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 - 62, this.height - 40 - 11, 120, 20,
|
||||
optGlyphAspect, FontConfig.glyphAspect, value -> FontConfig.glyphAspect = value,
|
||||
value -> I18n.format("options.angelica.fontconfig.glyph_aspect", String.format("%3.2f", value)),
|
||||
"options.angelica.fontconfig.glyph_aspect.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 - 62, this.height - 60 - 15, 120, 20,
|
||||
optGlyphScale, FontConfig.glyphScale, value -> FontConfig.glyphScale = value,
|
||||
value -> I18n.format("options.angelica.fontconfig.glyph_scale", String.format("x%3.2f", value)),
|
||||
"options.angelica.fontconfig.glyph_scale.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 + 62, this.height - 40 - 11, 120, 20,
|
||||
optWhitespaceScale, FontConfig.whitespaceScale, value -> FontConfig.whitespaceScale = value,
|
||||
value -> I18n.format("options.angelica.fontconfig.whitespace_scale", String.format("x%3.2f", value)),
|
||||
"options.angelica.fontconfig.whitespace_scale.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 + 62, this.height - 60 - 15, 120, 20,
|
||||
optGlyphSpacing, FontConfig.glyphSpacing, value -> FontConfig.glyphSpacing = value,
|
||||
value -> I18n.format("options.angelica.fontconfig.glyph_spacing", String.format("%3.2f", value)),
|
||||
"options.angelica.fontconfig.glyph_spacing.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 + 186, this.height - 40 - 11, 120, 20,
|
||||
optFontAAStrength, FontConfig.fontAAStrength, value -> FontConfig.fontAAStrength = value.intValue(),
|
||||
value -> I18n.format("options.angelica.fontconfig.font_aa_strength", String.format("%.0f", value)),
|
||||
"options.angelica.fontconfig.font_aa_strength.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 + 186, this.height - 60 - 15, 120, 20,
|
||||
optFontAAMode, FontConfig.fontAAMode, value -> FontConfig.fontAAMode = value.intValue(),
|
||||
this::fontAAModeFormat,
|
||||
"options.angelica.fontconfig.aamode.tooltip"));
|
||||
}
|
||||
|
||||
private void onClose() {
|
||||
applyChanges(true);
|
||||
this.mc.displayGuiScreen(parent);
|
||||
}
|
||||
|
||||
private void applyChanges(boolean finalApply) {
|
||||
int pos;
|
||||
pos = selectedPrimaryFontListPos;
|
||||
if (pos >= 0 && pos < displayedFonts.size()) {
|
||||
FontConfig.customFontNamePrimary = displayedFonts.get(pos).getFontName();
|
||||
}
|
||||
pos = selectedFallbackFontListPos;
|
||||
if (pos >= 0 && pos < displayedFonts.size()) {
|
||||
FontConfig.customFontNameFallback = displayedFonts.get(pos).getFontName();
|
||||
}
|
||||
|
||||
FontStrategist.reloadCustomFontProviders();
|
||||
|
||||
if (finalApply) {
|
||||
ConfigurationManager.save(FontConfig.class);
|
||||
}
|
||||
}
|
||||
|
||||
private void resetValues(IrisButton button) {
|
||||
try {
|
||||
ConfigurationManager.getConfigElements(FontConfig.class).forEach(elem -> elem.set(elem.getDefault()));
|
||||
} catch (ConfigException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
selectedPrimaryFontListPos = -1;
|
||||
selectedFallbackFontListPos = -1;
|
||||
FontStrategist.customFontInUse = false;
|
||||
super.buttonList.clear();
|
||||
this.initButtons();
|
||||
}
|
||||
|
||||
private void toggleCustomFont(IrisButton button) {
|
||||
FontConfig.enableCustomFont = !FontConfig.enableCustomFont;
|
||||
applyChanges(false);
|
||||
button.displayString = FontConfig.enableCustomFont ?
|
||||
I18n.format("options.angelica.fontconfig.disable_custom_font") :
|
||||
I18n.format("options.angelica.fontconfig.enable_custom_font");
|
||||
}
|
||||
|
||||
private int qualityLast = FontConfig.customFontQuality;
|
||||
|
||||
private void setFontQuality(float quality) {
|
||||
FontConfig.customFontQuality = (int) quality;
|
||||
if (qualityLast != (int) quality) {
|
||||
applyChanges(false);
|
||||
}
|
||||
qualityLast = (int) quality;
|
||||
}
|
||||
|
||||
private String fontAAModeFormat(float AAmode) {
|
||||
return switch ((int) AAmode) {
|
||||
case 2 -> I18n.format("options.angelica.fontconfig.aamode.aa_16x");
|
||||
case 1 -> I18n.format("options.angelica.fontconfig.aamode.aa_4x");
|
||||
default -> I18n.format("options.angelica.fontconfig.aamode.aa_none");
|
||||
};
|
||||
}
|
||||
|
||||
private float lastMouseX = 0;
|
||||
private float lastMouseY = 0;
|
||||
private long lastStillTime = 0;
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float delta) {
|
||||
super.drawDefaultBackground();
|
||||
fontList.drawScreen(mouseX, mouseY, delta);
|
||||
searchBox.drawTextBox();
|
||||
// I bet you thought this was drawn inside the search box, not on top of it.
|
||||
if (!this.searchBox.isFocused() && this.searchBox.getText().isEmpty()) {
|
||||
this.drawCenteredString(this.fontRendererObj, this.searchPrompt,
|
||||
this.searchBox.xPosition + this.fontRendererObj.getStringWidth(this.searchPrompt) / 2 + 4,
|
||||
this.searchBox.yPosition + this.searchBox.height / 2 - 4, 0xFFFFFF);
|
||||
}
|
||||
drawCenteredString(this.fontRendererObj, this.title, (int) (this.width * 0.5), 8, 0xFFFFFF);
|
||||
drawCenteredString(this.fontRendererObj, I18n.format("options.angelica.fontconfig.currentfonts",
|
||||
FontConfig.customFontNamePrimary, FontConfig.customFontNameFallback), (int) (this.width * 0.5), this.height - 92, 0xFFFFFF);
|
||||
super.drawScreen(mouseX, mouseY, delta);
|
||||
|
||||
for (GuiButton guiButton : buttonList) {
|
||||
if (!(guiButton instanceof SliderClone slider)) { continue; }
|
||||
final int top = slider.yPosition;
|
||||
final int bot = slider.yPosition + slider.height;
|
||||
final int left = slider.xPosition;
|
||||
final int right = slider.xPosition + slider.width;
|
||||
if (mouseY < top || mouseY >= bot || mouseX < left || mouseX >= right) { continue; }
|
||||
if (mouseX == lastMouseX && mouseY == lastMouseY) {
|
||||
if (lastStillTime == 0) {
|
||||
lastStillTime = System.currentTimeMillis();
|
||||
}
|
||||
if (lastStillTime + 500L < System.currentTimeMillis()) {
|
||||
displayTooltip(mouseX, mouseY, slider.tooltipKey);
|
||||
}
|
||||
} else {
|
||||
lastStillTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
lastMouseX = mouseX;
|
||||
lastMouseY = mouseY;
|
||||
}
|
||||
|
||||
private void displayTooltip(int x, int y, String langKey) {
|
||||
List<String> lines = this.fontRendererObj.listFormattedStringToWidth(I18n.format(langKey), this.width / 2);
|
||||
this.drawHoveringText(lines, x, y, this.fontRendererObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guiButton) {
|
||||
if (guiButton.enabled) {
|
||||
if (guiButton instanceof IrisButton irisButton) {
|
||||
irisButton.onPress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) {
|
||||
if (this.searchBox.isFocused()) {
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
this.searchBox.setFocused(false);
|
||||
}
|
||||
this.searchBox.textboxKeyTyped(typedChar, keyCode);
|
||||
this.displayedFonts = filterFonts(this.searchBox.getText().toLowerCase());
|
||||
}
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
this.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.searchBox.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.fontList.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
this.searchBox.updateCursorCounter();
|
||||
}
|
||||
|
||||
// this could be more efficient, but it's good enough as is
|
||||
private ArrayList<Font> filterFonts(String search) {
|
||||
ArrayList<Font> results;
|
||||
if (search == null || search.isEmpty()) {
|
||||
results = new ArrayList<>(Arrays.asList(availableFonts));
|
||||
} else {
|
||||
results = Arrays.stream(availableFonts).filter((font -> font.getFontName().toLowerCase().contains(search))).collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
selectedPrimaryFontListPos = -1;
|
||||
selectedFallbackFontListPos = -1;
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
if (Objects.equals(currentPrimaryFontName, results.get(i).getFontName())) {
|
||||
selectedPrimaryFontListPos = i;
|
||||
}
|
||||
if (Objects.equals(currentFallbackFontName, results.get(i).getFontName())) {
|
||||
selectedFallbackFontListPos = i;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
class FontList extends GuiSlot {
|
||||
|
||||
public FontList() {
|
||||
super(FontConfigScreen.this.mc, FontConfigScreen.this.width, FontConfigScreen.this.height, 52, FontConfigScreen.this.height - 100, 18);
|
||||
}
|
||||
|
||||
private void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
if (mouseY < this.top || mouseY > this.bottom) { return; }
|
||||
|
||||
int listLeftBound = this.width / 2 - this.getListWidth() / 2;
|
||||
int listRightBound = this.width / 2 + this.getListWidth() / 2;
|
||||
if (mouseX < listLeftBound || mouseX > listRightBound) { return; }
|
||||
|
||||
int mousePosInList = mouseY - this.top - this.headerPadding + (int)this.amountScrolled - 4;
|
||||
int slotIndex = mousePosInList / this.slotHeight;
|
||||
if (slotIndex < 0 || slotIndex >= this.getSize()) { return; }
|
||||
|
||||
if (mouseButton == 0) {
|
||||
onElemClicked(slotIndex, false);
|
||||
} else if (mouseButton == 1) {
|
||||
onElemClicked(slotIndex, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void onElemClicked(int index, boolean rightClick) {
|
||||
if (!rightClick) {
|
||||
selectedPrimaryFontListPos = index;
|
||||
currentPrimaryFontName = displayedFonts.get(index).getFontName();
|
||||
} else {
|
||||
selectedFallbackFontListPos = index;
|
||||
currentFallbackFontName = displayedFonts.get(index).getFontName();
|
||||
}
|
||||
applyChanges(false);
|
||||
}
|
||||
|
||||
protected boolean isSelected(int index) {
|
||||
return (index == selectedPrimaryFontListPos || index == selectedFallbackFontListPos);
|
||||
}
|
||||
|
||||
protected int getSize() {
|
||||
return displayedFonts.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentHeight() {
|
||||
return this.getSize() * 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getScrollBarX() {
|
||||
return this.width * 11 / 12 - 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getListWidth() {
|
||||
return this.width * 2 / 3;
|
||||
}
|
||||
|
||||
// see onElemClicked for the proper version that supports right-clicking
|
||||
protected void elementClicked(int index, boolean doubleClicked, int mouseX, int mouseY) {}
|
||||
|
||||
protected void drawBackground() {
|
||||
drawDefaultBackground();
|
||||
}
|
||||
|
||||
protected void drawSlot(int index, int x, int y, int p_148126_4_, Tessellator tessellator, int p_148126_6_, int p_148126_7_) {
|
||||
int color = 0xffffff;
|
||||
if (index == selectedPrimaryFontListPos) {
|
||||
color &= 0xffff55;
|
||||
}
|
||||
if (index == selectedFallbackFontListPos) {
|
||||
color &= 0x55ffff;
|
||||
}
|
||||
drawCenteredString(fontRendererObj, displayedFonts.get(index).getFontName(), this.width / 2, y + 1, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.gtnewhorizons.angelica.client.gui;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class SliderClone extends GuiButton {
|
||||
|
||||
private final Function<Float, String> displayStringFormatter;
|
||||
private final Consumer<Float> valueSetter;
|
||||
private final Option option;
|
||||
private float sliderPercentage;
|
||||
public final String tooltipKey;
|
||||
public boolean mouseDragging;
|
||||
|
||||
@AllArgsConstructor
|
||||
public static class Option {
|
||||
float min;
|
||||
float max;
|
||||
float step;
|
||||
|
||||
float denormalize(float alpha) {
|
||||
float lerp = min * (1 - alpha) + max * alpha;
|
||||
return Math.round(lerp / step) * step;
|
||||
}
|
||||
float normalize(float value) {
|
||||
return (value - min) / (max - min);
|
||||
}
|
||||
}
|
||||
|
||||
public SliderClone(int x, int y, int width, int height, Option option, float initialValue,
|
||||
Consumer<Float> setter, Function<Float, String> formatter, String tooltipKey) {
|
||||
super(0, x, y, width, height, "");
|
||||
this.option = option;
|
||||
this.sliderPercentage = option.normalize(initialValue);
|
||||
this.displayString = formatter.apply(initialValue);
|
||||
this.valueSetter = setter;
|
||||
this.displayStringFormatter = formatter;
|
||||
this.tooltipKey = tooltipKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 0 if the button is disabled, 1 if the mouse is NOT hovering over this button and 2 if it IS hovering over
|
||||
* this button.
|
||||
*/
|
||||
public int getHoverState(boolean mouseOver) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e).
|
||||
*/
|
||||
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (this.visible) {
|
||||
if (this.mouseDragging) {
|
||||
this.sliderPercentage = (float)(mouseX - (this.xPosition + 4)) / (float)(this.width - 8);
|
||||
|
||||
if (this.sliderPercentage < 0.0F) {
|
||||
this.sliderPercentage = 0.0F;
|
||||
}
|
||||
|
||||
if (this.sliderPercentage > 1.0F) {
|
||||
this.sliderPercentage = 1.0F;
|
||||
}
|
||||
|
||||
float f = this.option.denormalize(this.sliderPercentage);
|
||||
valueSetter.accept(f);
|
||||
this.sliderPercentage = this.option.normalize(f);
|
||||
this.displayString = displayStringFormatter.apply(f);
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.drawTexturedModalRect(this.xPosition + (int)(this.sliderPercentage * (float)(this.width - 8)), this.yPosition, 0, 66, 4, 20);
|
||||
this.drawTexturedModalRect(this.xPosition + (int)(this.sliderPercentage * (float)(this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the mouse has been pressed on this control. Equivalent of MouseListener.mousePressed(MouseEvent e).
|
||||
*/
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (super.mousePressed(mc, mouseX, mouseY)) {
|
||||
this.sliderPercentage = (float)(mouseX - (this.xPosition + 4)) / (float)(this.width - 8);
|
||||
|
||||
if (this.sliderPercentage < 0.0F) {
|
||||
this.sliderPercentage = 0.0F;
|
||||
}
|
||||
|
||||
if (this.sliderPercentage > 1.0F) {
|
||||
this.sliderPercentage = 1.0F;
|
||||
}
|
||||
|
||||
float f = this.option.denormalize(this.sliderPercentage);
|
||||
valueSetter.accept(f);
|
||||
this.sliderPercentage = this.option.normalize(f);
|
||||
this.displayString = displayStringFormatter.apply(f);
|
||||
this.mouseDragging = true;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the mouse button is released. Equivalent of MouseListener.mouseReleased(MouseEvent e).
|
||||
*/
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
this.mouseDragging = false;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,20 @@
|
||||
package com.gtnewhorizons.angelica.common;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadProvider;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.DirectionUtil;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ModeledBlock;
|
||||
import com.gtnewhorizons.angelica.utils.AssetLoader;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import static com.gtnewhorizon.gtnhlib.client.model.ModelISBRH.JSON_ISBRH_ID;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.gtnewhorizons.angelica.models.VanillaModels.LECTERN;
|
||||
|
||||
public class BlockTest extends Block implements ModeledBlock {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private QuadProvider model;
|
||||
/// Unline {@link BlockError}, this *is* registered on both sides. It's intended to test functionality in a SP
|
||||
/// development environment.
|
||||
public class BlockTest extends Block {
|
||||
|
||||
public BlockTest() {
|
||||
|
||||
super(Material.rock);
|
||||
this.setBlockTextureName("missingno");
|
||||
this.setModel((world, pos, block, meta, dir, random, color, quadPool) -> {
|
||||
if (meta < 2 || meta > 5) meta = 2;
|
||||
return LECTERN.models[meta - 2].getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
});
|
||||
super(Material.wood);
|
||||
setHardness(0.7f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,13 +22,6 @@ public class BlockTest extends Block implements ModeledBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
for (String s : AssetLoader.testTexs) {
|
||||
reg.registerIcon(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
|
||||
*/
|
||||
@@ -50,11 +29,16 @@ public class BlockTest extends Block implements ModeledBlock {
|
||||
public int onBlockPlaced(@NotNull World worldIn, int x, int y, int z, int side, float subX, float subY, float subZ, int meta) {
|
||||
|
||||
// Face NORTH if placed up or down
|
||||
final ForgeDirection s = DirectionUtil.ALL_DIRECTIONS[side];
|
||||
final var s = ForgeDirection.getOrientation(side);
|
||||
if (s == ForgeDirection.UP || s == ForgeDirection.DOWN)
|
||||
return 2;
|
||||
|
||||
// Face the placed side
|
||||
return side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return JSON_ISBRH_ID;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
public class BufferWriter {
|
||||
// Adapted from Neodymium
|
||||
|
||||
private final ByteBuffer buf;
|
||||
|
||||
private final FloatBuffer floatBuffer;
|
||||
private final ShortBuffer shortBuffer;
|
||||
private final IntBuffer intBuffer;
|
||||
|
||||
public BufferWriter(ByteBuffer buf) {
|
||||
this.buf = buf;
|
||||
this.floatBuffer = buf.asFloatBuffer();
|
||||
this.shortBuffer = buf.asShortBuffer();
|
||||
this.intBuffer = buf.asIntBuffer();
|
||||
}
|
||||
|
||||
private void incrementPosition(int add) {
|
||||
buf.position(buf.position() + add);
|
||||
floatBuffer.position(buf.position() / 4);
|
||||
shortBuffer.position(buf.position() / 2);
|
||||
intBuffer.position(buf.position() / 4);
|
||||
}
|
||||
|
||||
public void writeFloat(float x) {
|
||||
try {
|
||||
floatBuffer.put(x);
|
||||
|
||||
incrementPosition(4);
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void writeInt(int x) {
|
||||
intBuffer.put(x);
|
||||
|
||||
incrementPosition(4);
|
||||
}
|
||||
|
||||
public void writeByte(byte x) {
|
||||
buf.put(x); // this increments the buffer position by 1
|
||||
|
||||
incrementPosition(0);
|
||||
}
|
||||
|
||||
public int position() {
|
||||
return buf.position();
|
||||
}
|
||||
|
||||
public void writeShort(short s) {
|
||||
shortBuffer.put(s);
|
||||
|
||||
incrementPosition(2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.writers.IWriteQuads;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ItemVBOQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public ItemVBOQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(QuadView quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(QuadView quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(QuadView quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
|
||||
// Normals + Padding
|
||||
buf.putInt(quad.getNormal(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.writers.IWriteQuads;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionColorTextureQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionColorTextureQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(QuadView quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(QuadView quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(QuadView quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Color
|
||||
buf.putInt(quad.getColor(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.writers.IWriteQuads;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(QuadView quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(QuadView quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(QuadView quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.writers.IWriteQuads;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionTextureColorQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionTextureColorQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(QuadView quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(QuadView quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(QuadView quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
|
||||
// Color
|
||||
buf.putInt(quad.getColor(idx));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.writers.IWriteQuads;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionTextureQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionTextureQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(QuadView quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(QuadView quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(QuadView quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public class AngelicaConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableSodiumFluidRendering;
|
||||
|
||||
@Config.Comment("Inject QuadProvider rendering into some vanilla blocks")
|
||||
@Config.Comment("Inject BakedModel rendering into some vanilla blocks")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean injectQPRendering;
|
||||
@@ -143,15 +143,15 @@ public class AngelicaConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableZoom;
|
||||
|
||||
@Config.Comment("Optimizes in-world item rendering [Experimental]")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.Comment("Optimizes in-world item rendering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean optimizeInWorldItemRendering_WIP;
|
||||
public static boolean optimizeInWorldItemRendering;
|
||||
|
||||
@Config.Comment("Max amount of display lists to cache for optimized item rendering. Higher number will use more VRAM")
|
||||
@Config.DefaultInt(256)
|
||||
@Config.RangeInt(min = 64, max = 1024)
|
||||
public static int itemRendererDisplayListCacheSize;
|
||||
@Config.Comment("Upper limit for the amount of VBO's to cache for optimized item rendering. Higher number can potentially use more VRAM.")
|
||||
@Config.DefaultInt(512)
|
||||
@Config.RangeInt(min = 256, max = 1024)
|
||||
public static int itemRendererCacheSize;
|
||||
|
||||
@Config.Comment("Render distance for the spinning mob inside mod spawners")
|
||||
@Config.DefaultDouble(16D)
|
||||
@@ -166,4 +166,8 @@ public class AngelicaConfig {
|
||||
@Config.Comment("Allows unicode languages to use an odd gui scale")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean removeUnicodeEvenScaling;
|
||||
|
||||
@Config.Comment("Register HardcodedCustomUniforms in Iris Shaders. May help with compatibility in certain shader packs")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean enableHardcodedCustomUniforms;
|
||||
}
|
||||
@@ -6,6 +6,12 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class AngelicaGuiConfig extends SimpleGuiConfig {
|
||||
public AngelicaGuiConfig(GuiScreen parent) throws ConfigException {
|
||||
super(parent, AngelicaConfig.class, "angelica", "Angelica");
|
||||
super(parent,
|
||||
"angelica",
|
||||
"Angelica",
|
||||
true,
|
||||
AngelicaConfig.class,
|
||||
FontConfig.class
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.Config;
|
||||
|
||||
@Config(modid = "angelica", category = "customfont")
|
||||
public class FontConfig {
|
||||
@Config.Comment("Whether or not to use custom fonts when drawing text.")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean enableCustomFont;
|
||||
|
||||
@Config.Comment("Name of the primary custom font. Best not to set it from here.")
|
||||
@Config.DefaultString("(none)")
|
||||
public static String customFontNamePrimary;
|
||||
|
||||
@Config.Comment("Name of the fallback custom font. Best not to set it from here.")
|
||||
@Config.DefaultString("(none)")
|
||||
public static String customFontNameFallback;
|
||||
|
||||
@Config.Comment("The quality at which custom fonts are rendered, making them less pixelated but increasing memory usage.")
|
||||
@Config.DefaultInt(30)
|
||||
@Config.RangeInt(min = 6, max = 72)
|
||||
public static int customFontQuality;
|
||||
|
||||
@Config.Comment("Controls the distance at which the font's shadow is drawn.")
|
||||
@Config.DefaultFloat(1F)
|
||||
@Config.RangeFloat(min = 0F, max = 2F)
|
||||
public static float fontShadowOffset;
|
||||
|
||||
@Config.Comment("Influences the aspect ratio of each glyph.")
|
||||
@Config.DefaultFloat(0F)
|
||||
@Config.RangeFloat(min = -1F, max = 1F)
|
||||
public static float glyphAspect;
|
||||
|
||||
@Config.Comment("Scale of each glyph, whitespace excluded.")
|
||||
@Config.DefaultFloat(1F)
|
||||
@Config.RangeFloat(min = 0.1F, max = 3F)
|
||||
public static float glyphScale;
|
||||
|
||||
@Config.Comment("Whitespace scale.")
|
||||
@Config.DefaultFloat(1F)
|
||||
@Config.RangeFloat(min = 0.1F, max = 3F)
|
||||
public static float whitespaceScale;
|
||||
|
||||
@Config.Comment("Adds extra spacing between glyphs.")
|
||||
@Config.DefaultFloat(0F)
|
||||
@Config.RangeFloat(min = -2F, max = 2F)
|
||||
public static float glyphSpacing;
|
||||
|
||||
@Config.Comment("Controls font antialiasing. 0 = none, 1 = 4x MSAA, 2 = 16x MSAA.")
|
||||
@Config.DefaultInt(2)
|
||||
@Config.RangeInt(min = 0, max = 2)
|
||||
public static int fontAAMode;
|
||||
|
||||
@Config.Comment("Affects font antialiasing sample spacing. Higher values increase blur.")
|
||||
@Config.DefaultInt(7)
|
||||
@Config.RangeInt(min = 1, max = 24)
|
||||
public static int fontAAStrength;
|
||||
}
|
||||
@@ -43,6 +43,20 @@ public class Feature {
|
||||
}
|
||||
|
||||
private static final Map<Integer, Set<IStateStack<?>>> attribToFeatures = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Helper method to add all texture gen states (S, T, R, Q) for all texture units to a collection.
|
||||
* Used by both GL_ENABLE_BIT and GL_TEXTURE_BIT.
|
||||
*/
|
||||
private static void addTextureGenStates(Set<IStateStack<?>> collection) {
|
||||
for(int i = 0 ; i < GLStateManager.MAX_TEXTURE_UNITS; i++) {
|
||||
collection.add(GLStateManager.textures.getTexGenSStates(i));
|
||||
collection.add(GLStateManager.textures.getTexGenTStates(i));
|
||||
collection.add(GLStateManager.textures.getTexGenRStates(i));
|
||||
collection.add(GLStateManager.textures.getTexGenQStates(i));
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
attribToFeatures.put(GL11.GL_COLOR_BUFFER_BIT, ImmutableSet.of(
|
||||
GLStateManager.alphaTest // GL_ALPHA_TEST enable bit
|
||||
@@ -51,10 +65,10 @@ public class Feature {
|
||||
, GLStateManager.blendState // Blending source and destination functions
|
||||
// Constant blend color
|
||||
// Blending equation
|
||||
// GL_DITHER enable bit
|
||||
// GL_DRAW_BUFFER setting
|
||||
// GL_COLOR_LOGIC_OP enable bit
|
||||
// GL_INDEX_LOGIC_OP enable bit
|
||||
, GLStateManager.colorLogicOpState // GL_COLOR_LOGIC_OP enable bit
|
||||
, GLStateManager.ditherState // GL_DITHER enable bit
|
||||
, GLStateManager.drawBuffer // GL_DRAW_BUFFER setting
|
||||
, GLStateManager.indexLogicOpState // GL_INDEX_LOGIC_OP enable bit
|
||||
// Logic op function
|
||||
, GLStateManager.colorMask // Color-mode and index-mode writemasks
|
||||
, GLStateManager.clearColor // Color-mode and index-mode clear values
|
||||
@@ -80,14 +94,15 @@ public class Feature {
|
||||
|
||||
final HashSet<IStateStack<?>> enableBits = new HashSet<>(ImmutableSet.of(
|
||||
GLStateManager.alphaTest // GL_ALPHA_TEST flag
|
||||
// GL_AUTO_NORMAL flag
|
||||
, GLStateManager.autoNormalState // GL_AUTO_NORMAL flag
|
||||
, GLStateManager.blendMode // GL_BLEND flag
|
||||
// Enable bits for the user-definable clipping planes
|
||||
, GLStateManager.colorLogicOpState // GL_COLOR_LOGIC_OP flag
|
||||
, GLStateManager.colorMaterial // GL_COLOR_MATERIAL
|
||||
, GLStateManager.cullState // GL_CULL_FACE flag
|
||||
, GLStateManager.depthTest // GL_DEPTH_TEST flag
|
||||
// GL_DITHER flag
|
||||
, GLStateManager.ditherState // GL_DITHER flag
|
||||
, GLStateManager.fogMode // GL_FOG flag
|
||||
, GLStateManager.indexLogicOpState // GL_INDEX_LOGIC_OP flag
|
||||
, GLStateManager.lightStates[0] // GL_LIGHT0
|
||||
, GLStateManager.lightStates[1] // GL_LIGHT1
|
||||
, GLStateManager.lightStates[2] // GL_LIGHT2
|
||||
@@ -97,36 +112,57 @@ public class Feature {
|
||||
, GLStateManager.lightStates[6] // GL_LIGHT6
|
||||
, GLStateManager.lightStates[7] // GL_LIGHT7
|
||||
, GLStateManager.lightingState // GL_LIGHTING flag
|
||||
// GL_LINE_SMOOTH flag
|
||||
// GL_LINE_STIPPLE flag
|
||||
// GL_INDEX_LOGIC_OP flag
|
||||
// GL_COLOR_LOGIC_OP flag
|
||||
// GL_MAP1_x where x is a map type
|
||||
// GL_MAP2_x where x is a map type
|
||||
// GL_MULTISAMPLE flag
|
||||
// GL_NORMALIZE flag
|
||||
// GL_POINT_SMOOTH flag
|
||||
// GL_POLYGON_OFFSET_LINE flag
|
||||
// GL_POLYGON_OFFSET_FILL flag
|
||||
// GL_POLYGON_OFFSET_POINT flag
|
||||
// GL_POLYGON_SMOOTH flag
|
||||
// GL_POLYGON_STIPPLE flag
|
||||
// GL_SAMPLE_ALPHA_TO_COVERAGE flag
|
||||
// GL_SAMPLE_ALPHA_TO_ONE flag
|
||||
// GL_SAMPLE_COVERAGE flag
|
||||
, GLStateManager.lineSmoothState // GL_LINE_SMOOTH flag
|
||||
, GLStateManager.lineStippleState // GL_LINE_STIPPLE flag
|
||||
, GLStateManager.map1Color4State // GL_MAP1_COLOR_4
|
||||
, GLStateManager.map1IndexState // GL_MAP1_INDEX
|
||||
, GLStateManager.map1NormalState // GL_MAP1_NORMAL
|
||||
, GLStateManager.map1TextureCoord1State // GL_MAP1_TEXTURE_COORD_1
|
||||
, GLStateManager.map1TextureCoord2State // GL_MAP1_TEXTURE_COORD_2
|
||||
, GLStateManager.map1TextureCoord3State // GL_MAP1_TEXTURE_COORD_3
|
||||
, GLStateManager.map1TextureCoord4State // GL_MAP1_TEXTURE_COORD_4
|
||||
, GLStateManager.map1Vertex3State // GL_MAP1_VERTEX_3
|
||||
, GLStateManager.map1Vertex4State // GL_MAP1_VERTEX_4
|
||||
, GLStateManager.map2Color4State // GL_MAP2_COLOR_4
|
||||
, GLStateManager.map2IndexState // GL_MAP2_INDEX
|
||||
, GLStateManager.map2NormalState // GL_MAP2_NORMAL
|
||||
, GLStateManager.map2TextureCoord1State // GL_MAP2_TEXTURE_COORD_1
|
||||
, GLStateManager.map2TextureCoord2State // GL_MAP2_TEXTURE_COORD_2
|
||||
, GLStateManager.map2TextureCoord3State // GL_MAP2_TEXTURE_COORD_3
|
||||
, GLStateManager.map2TextureCoord4State // GL_MAP2_TEXTURE_COORD_4
|
||||
, GLStateManager.map2Vertex3State // GL_MAP2_VERTEX_3
|
||||
, GLStateManager.map2Vertex4State // GL_MAP2_VERTEX_4
|
||||
, GLStateManager.multisampleState // GL_MULTISAMPLE flag
|
||||
, GLStateManager.normalizeState // GL_NORMALIZE flag
|
||||
, GLStateManager.pointSmoothState // GL_POINT_SMOOTH flag
|
||||
, GLStateManager.polygonOffsetPointState // GL_POLYGON_OFFSET_POINT flag
|
||||
, GLStateManager.polygonOffsetLineState // GL_POLYGON_OFFSET_LINE flag
|
||||
, GLStateManager.polygonOffsetFillState // GL_POLYGON_OFFSET_FILL flag
|
||||
, GLStateManager.polygonSmoothState // GL_POLYGON_SMOOTH flag
|
||||
, GLStateManager.polygonStippleState // GL_POLYGON_STIPPLE flag
|
||||
, GLStateManager.rescaleNormalState // GL_RESCALE_NORMAL flag
|
||||
, GLStateManager.sampleAlphaToCoverageState // GL_SAMPLE_ALPHA_TO_COVERAGE flag
|
||||
, GLStateManager.sampleAlphaToOneState // GL_SAMPLE_ALPHA_TO_ONE flag
|
||||
, GLStateManager.sampleCoverageState // GL_SAMPLE_COVERAGE flag
|
||||
, GLStateManager.scissorTest // GL_SCISSOR_TEST flag
|
||||
// GL_STENCIL_TEST flag
|
||||
// GL_TEXTURE_1D flag
|
||||
// GL_TEXTURE_2D flag - Below
|
||||
// GL_TEXTURE_3D flag
|
||||
// Flags GL_TEXTURE_GEN_x where x is S, T, R, or Q
|
||||
, GLStateManager.stencilTest // GL_STENCIL_TEST flag
|
||||
));
|
||||
|
||||
// GL_TEXTURE_2D flag
|
||||
for(int i = 0 ; i < GLStateManager.MAX_TEXTURE_UNITS; i++) {
|
||||
enableBits.add(GLStateManager.textures.getTextureUnitStates(i));
|
||||
// Enable bits for the user-definable clipping planes
|
||||
for(int i = 0; i < GLStateManager.clipPlaneStates.length; i++) {
|
||||
enableBits.add(GLStateManager.clipPlaneStates[i]);
|
||||
}
|
||||
|
||||
// GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D flags
|
||||
for(int i = 0 ; i < GLStateManager.MAX_TEXTURE_UNITS; i++) {
|
||||
enableBits.add(GLStateManager.textures.getTexture1DStates(i));
|
||||
enableBits.add(GLStateManager.textures.getTextureUnitStates(i));
|
||||
enableBits.add(GLStateManager.textures.getTexture3DStates(i));
|
||||
}
|
||||
|
||||
// Flags GL_TEXTURE_GEN_x where x is S, T, R, or Q
|
||||
addTextureGenStates(enableBits);
|
||||
|
||||
attribToFeatures.put(GL11.GL_ENABLE_BIT, enableBits);
|
||||
attribToFeatures.put(GL11.GL_EVAL_BIT, ImmutableSet.of(
|
||||
// GL_MAP1_x enable bits, where x is a map type
|
||||
@@ -268,13 +304,16 @@ public class Feature {
|
||||
// textureAttribs.add(GLStateManager.textures.getInfo(i))
|
||||
}
|
||||
|
||||
// Enable bits GL_TEXTURE_GEN_x where x is S, T, R, or Q
|
||||
addTextureGenStates(textureAttribs);
|
||||
|
||||
attribToFeatures.put(GL11.GL_TEXTURE_BIT, textureAttribs);
|
||||
|
||||
attribToFeatures.put(GL11.GL_TRANSFORM_BIT, ImmutableSet.of(
|
||||
// Coefficients of the six clipping planes
|
||||
// Enable bits for the user-definable clipping planes
|
||||
GLStateManager.matrixMode
|
||||
// GL_NORMALIZE flag
|
||||
, GLStateManager.normalizeState // GL_NORMALIZE flag
|
||||
, GLStateManager.rescaleNormalState // GL_RESCALE_NORMAL flag
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_VIEWPORT_BIT, ImmutableSet.of(
|
||||
|
||||
@@ -81,8 +81,23 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
import static com.gtnewhorizons.angelica.glsm.Vendor.AMD;
|
||||
import static com.gtnewhorizons.angelica.glsm.Vendor.INTEL;
|
||||
import static com.gtnewhorizons.angelica.glsm.Vendor.MESA;
|
||||
import static com.gtnewhorizons.angelica.glsm.Vendor.NVIDIA;
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
/**
|
||||
* OpenGL State Manager - Provides cached state tracking and management for OpenGL operations.
|
||||
*
|
||||
* <p><b>IMPORTANT INITIALIZATION ORDER:</b></p>
|
||||
* <ul>
|
||||
* <li>This class performs GL queries in static initializers (MAX_CLIP_PLANES, MAX_TEXTURE_UNITS, etc.)</li>
|
||||
* <li>The class MUST NOT be loaded until after the GL context has been created and made current</li>
|
||||
* <li>Violating this requirement will cause crashes with "No current context" or return invalid values</li>
|
||||
* <li>Call {@link #preInit()} after GL context creation to initialize runtime state</li>
|
||||
* </ul>
|
||||
*/
|
||||
@SuppressWarnings("unused") // Used in ASM
|
||||
public class GLStateManager {
|
||||
public static ContextCapabilities capabilities;
|
||||
@@ -94,13 +109,14 @@ public class GLStateManager {
|
||||
public static final int MAX_PROJECTION_STACK_DEPTH = GL11.glGetInteger(GL11.GL_MAX_PROJECTION_STACK_DEPTH);
|
||||
public static final int MAX_TEXTURE_STACK_DEPTH = GL11.glGetInteger(GL11.GL_MAX_TEXTURE_STACK_DEPTH);
|
||||
public static final int MAX_TEXTURE_UNITS = GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS);
|
||||
public static final int MAX_CLIP_PLANES = GL11.glGetInteger(GL11.GL_MAX_CLIP_PLANES);
|
||||
|
||||
public static final GLFeatureSet HAS_MULTIPLE_SET = new GLFeatureSet();
|
||||
|
||||
@Getter protected static boolean NVIDIA;
|
||||
@Getter protected static boolean AMD;
|
||||
@Getter protected static boolean INTEL;
|
||||
@Getter protected static boolean MESA;
|
||||
@Getter private static Vendor VENDOR;
|
||||
|
||||
// This setting varies depending on driver, so it gets queried at runtime
|
||||
public static final int DEFAULT_DRAW_BUFFER = GL11.glGetInteger(GL11.GL_DRAW_BUFFER);
|
||||
|
||||
// GLStateManager State Trackers
|
||||
private static final IntStack attribs = new IntArrayList(MAX_ATTRIB_STACK_DEPTH);
|
||||
@@ -119,12 +135,58 @@ public class GLStateManager {
|
||||
@Getter protected static final Color4Stack color = new Color4Stack();
|
||||
@Getter protected static final Color4Stack clearColor = new Color4Stack(new Color4(0.0F, 0.0F, 0.0F, 0.0F));
|
||||
@Getter protected static final ColorMaskStack colorMask = new ColorMaskStack();
|
||||
@Getter protected static final IntegerStateStack drawBuffer = new IntegerStateStack(DEFAULT_DRAW_BUFFER);
|
||||
@Getter protected static final BooleanStateStack cullState = new BooleanStateStack(GL11.GL_CULL_FACE);
|
||||
@Getter protected static final AlphaStateStack alphaState = new AlphaStateStack();
|
||||
@Getter protected static final BooleanStateStack alphaTest = new BooleanStateStack(GL11.GL_ALPHA_TEST);
|
||||
|
||||
@Getter protected static final BooleanStateStack lightingState = new BooleanStateStack(GL11.GL_LIGHTING);
|
||||
@Getter protected static final BooleanStateStack rescaleNormalState = new BooleanStateStack(GL12.GL_RESCALE_NORMAL);
|
||||
@Getter protected static final BooleanStateStack normalizeState = new BooleanStateStack(GL11.GL_NORMALIZE);
|
||||
|
||||
// Additional enable bit states tracked by GL_ENABLE_BIT
|
||||
@Getter protected static final BooleanStateStack ditherState = new BooleanStateStack(GL11.GL_DITHER, true); // Defaults to true per OpenGL spec
|
||||
@Getter protected static final BooleanStateStack stencilTest = new BooleanStateStack(GL11.GL_STENCIL_TEST);
|
||||
@Getter protected static final BooleanStateStack lineSmoothState = new BooleanStateStack(GL11.GL_LINE_SMOOTH);
|
||||
@Getter protected static final BooleanStateStack lineStippleState = new BooleanStateStack(GL11.GL_LINE_STIPPLE);
|
||||
@Getter protected static final BooleanStateStack pointSmoothState = new BooleanStateStack(GL11.GL_POINT_SMOOTH);
|
||||
@Getter protected static final BooleanStateStack polygonSmoothState = new BooleanStateStack(GL11.GL_POLYGON_SMOOTH);
|
||||
@Getter protected static final BooleanStateStack polygonStippleState = new BooleanStateStack(GL11.GL_POLYGON_STIPPLE);
|
||||
@Getter protected static final BooleanStateStack multisampleState = new BooleanStateStack(GL13.GL_MULTISAMPLE, true); // Defaults to true per OpenGL spec
|
||||
@Getter protected static final BooleanStateStack sampleAlphaToCoverageState = new BooleanStateStack(GL13.GL_SAMPLE_ALPHA_TO_COVERAGE);
|
||||
@Getter protected static final BooleanStateStack sampleAlphaToOneState = new BooleanStateStack(GL13.GL_SAMPLE_ALPHA_TO_ONE);
|
||||
@Getter protected static final BooleanStateStack sampleCoverageState = new BooleanStateStack(GL13.GL_SAMPLE_COVERAGE);
|
||||
@Getter protected static final BooleanStateStack colorLogicOpState = new BooleanStateStack(GL11.GL_COLOR_LOGIC_OP);
|
||||
@Getter protected static final BooleanStateStack indexLogicOpState = new BooleanStateStack(GL11.GL_INDEX_LOGIC_OP);
|
||||
|
||||
// Polygon offset states
|
||||
@Getter protected static final BooleanStateStack polygonOffsetPointState = new BooleanStateStack(GL11.GL_POLYGON_OFFSET_POINT);
|
||||
@Getter protected static final BooleanStateStack polygonOffsetLineState = new BooleanStateStack(GL11.GL_POLYGON_OFFSET_LINE);
|
||||
@Getter protected static final BooleanStateStack polygonOffsetFillState = new BooleanStateStack(GL11.GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
// Evaluator states
|
||||
@Getter protected static final BooleanStateStack autoNormalState = new BooleanStateStack(GL11.GL_AUTO_NORMAL);
|
||||
@Getter protected static final BooleanStateStack map1Color4State = new BooleanStateStack(GL11.GL_MAP1_COLOR_4);
|
||||
@Getter protected static final BooleanStateStack map1IndexState = new BooleanStateStack(GL11.GL_MAP1_INDEX);
|
||||
@Getter protected static final BooleanStateStack map1NormalState = new BooleanStateStack(GL11.GL_MAP1_NORMAL);
|
||||
@Getter protected static final BooleanStateStack map1TextureCoord1State = new BooleanStateStack(GL11.GL_MAP1_TEXTURE_COORD_1);
|
||||
@Getter protected static final BooleanStateStack map1TextureCoord2State = new BooleanStateStack(GL11.GL_MAP1_TEXTURE_COORD_2);
|
||||
@Getter protected static final BooleanStateStack map1TextureCoord3State = new BooleanStateStack(GL11.GL_MAP1_TEXTURE_COORD_3);
|
||||
@Getter protected static final BooleanStateStack map1TextureCoord4State = new BooleanStateStack(GL11.GL_MAP1_TEXTURE_COORD_4);
|
||||
@Getter protected static final BooleanStateStack map1Vertex3State = new BooleanStateStack(GL11.GL_MAP1_VERTEX_3);
|
||||
@Getter protected static final BooleanStateStack map1Vertex4State = new BooleanStateStack(GL11.GL_MAP1_VERTEX_4);
|
||||
@Getter protected static final BooleanStateStack map2Color4State = new BooleanStateStack(GL11.GL_MAP2_COLOR_4);
|
||||
@Getter protected static final BooleanStateStack map2IndexState = new BooleanStateStack(GL11.GL_MAP2_INDEX);
|
||||
@Getter protected static final BooleanStateStack map2NormalState = new BooleanStateStack(GL11.GL_MAP2_NORMAL);
|
||||
@Getter protected static final BooleanStateStack map2TextureCoord1State = new BooleanStateStack(GL11.GL_MAP2_TEXTURE_COORD_1);
|
||||
@Getter protected static final BooleanStateStack map2TextureCoord2State = new BooleanStateStack(GL11.GL_MAP2_TEXTURE_COORD_2);
|
||||
@Getter protected static final BooleanStateStack map2TextureCoord3State = new BooleanStateStack(GL11.GL_MAP2_TEXTURE_COORD_3);
|
||||
@Getter protected static final BooleanStateStack map2TextureCoord4State = new BooleanStateStack(GL11.GL_MAP2_TEXTURE_COORD_4);
|
||||
@Getter protected static final BooleanStateStack map2Vertex3State = new BooleanStateStack(GL11.GL_MAP2_VERTEX_3);
|
||||
@Getter protected static final BooleanStateStack map2Vertex4State = new BooleanStateStack(GL11.GL_MAP2_VERTEX_4);
|
||||
|
||||
// Clip plane states
|
||||
@Getter protected static final BooleanStateStack[] clipPlaneStates = new BooleanStateStack[MAX_CLIP_PLANES];
|
||||
|
||||
@Getter protected static final MatrixModeStack matrixMode = new MatrixModeStack();
|
||||
@Getter protected static final Matrix4fStack modelViewMatrix = new Matrix4fStack(MAX_MODELVIEW_STACK_DEPTH);
|
||||
@@ -148,8 +210,12 @@ public class GLStateManager {
|
||||
lightDataStates[i] = new LightStateStack(GL11.GL_LIGHT0 + i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_CLIP_PLANES; i++) {
|
||||
clipPlaneStates[i] = new BooleanStateStack(GL11.GL_CLIP_PLANE0 + i);
|
||||
}
|
||||
|
||||
try {
|
||||
Field curr = ReflectionHelper.findField(Matrix4fStack.class, "curr");
|
||||
final Field curr = ReflectionHelper.findField(Matrix4fStack.class, "curr");
|
||||
curr.setAccessible(true);
|
||||
MAT4_STACK_CURR_DEPTH = MethodHandles.lookup().unreflectGetter(curr);
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -167,11 +233,11 @@ public class GLStateManager {
|
||||
attribs.popInt();
|
||||
}
|
||||
|
||||
List<IStateStack<?>> stacks = Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS);
|
||||
int size = stacks.size();
|
||||
final List<IStateStack<?>> stacks = Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS);
|
||||
final int size = stacks.size();
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
IStateStack<?> stack = stacks.get(i);
|
||||
final IStateStack<?> stack = stacks.get(i);
|
||||
|
||||
while(!stack.isEmpty()) {
|
||||
stack.pop();
|
||||
@@ -245,16 +311,12 @@ public class GLStateManager {
|
||||
.addFeature(GL11.GL_VIEWPORT);
|
||||
|
||||
String glVendor = GL11.glGetString(GL11.GL_VENDOR);
|
||||
NVIDIA = glVendor.toLowerCase().contains("nvidia");
|
||||
AMD = glVendor.toLowerCase().contains("ati") || glVendor.toLowerCase().contains("amd");
|
||||
INTEL = glVendor.toLowerCase().contains("intel");
|
||||
MESA = glVendor.toLowerCase().contains("mesa");
|
||||
VENDOR = Vendor.getVendor(glVendor.toLowerCase());
|
||||
|
||||
if(AMD) {
|
||||
if (vendorIsAMD()) {
|
||||
// AMD Drivers seem to default to 0 for the matrix mode, so we need to set it to the default
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
@@ -300,12 +362,23 @@ public class GLStateManager {
|
||||
|
||||
// LWJGL Overrides
|
||||
public static void glEnable(int cap) {
|
||||
// Handle clip planes dynamically (supports up to MAX_CLIP_PLANES)
|
||||
if (cap >= GL11.GL_CLIP_PLANE0 && cap < GL11.GL_CLIP_PLANE0 + MAX_CLIP_PLANES) {
|
||||
clipPlaneStates[cap - GL11.GL_CLIP_PLANE0].enable();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (cap) {
|
||||
case GL11.GL_ALPHA_TEST -> enableAlphaTest();
|
||||
case GL11.GL_AUTO_NORMAL -> autoNormalState.enable();
|
||||
case GL11.GL_BLEND -> enableBlend();
|
||||
case GL11.GL_COLOR_MATERIAL -> enableColorMaterial();
|
||||
case GL11.GL_COLOR_LOGIC_OP -> colorLogicOpState.enable();
|
||||
case GL11.GL_CULL_FACE -> enableCull();
|
||||
case GL11.GL_DEPTH_TEST -> enableDepthTest();
|
||||
case GL11.GL_DITHER -> ditherState.enable();
|
||||
case GL11.GL_FOG -> enableFog();
|
||||
case GL11.GL_INDEX_LOGIC_OP -> indexLogicOpState.enable();
|
||||
case GL11.GL_LIGHTING -> enableLighting();
|
||||
case GL11.GL_LIGHT0 -> enableLight(0);
|
||||
case GL11.GL_LIGHT1 -> enableLight(1);
|
||||
@@ -315,21 +388,69 @@ public class GLStateManager {
|
||||
case GL11.GL_LIGHT5 -> enableLight(5);
|
||||
case GL11.GL_LIGHT6 -> enableLight(6);
|
||||
case GL11.GL_LIGHT7 -> enableLight(7);
|
||||
case GL11.GL_COLOR_MATERIAL -> enableColorMaterial();
|
||||
case GL11.GL_SCISSOR_TEST -> enableScissorTest();
|
||||
case GL11.GL_TEXTURE_2D -> enableTexture();
|
||||
case GL11.GL_LINE_SMOOTH -> lineSmoothState.enable();
|
||||
case GL11.GL_LINE_STIPPLE -> lineStippleState.enable();
|
||||
case GL11.GL_MAP1_COLOR_4 -> map1Color4State.enable();
|
||||
case GL11.GL_MAP1_INDEX -> map1IndexState.enable();
|
||||
case GL11.GL_MAP1_NORMAL -> map1NormalState.enable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_1 -> map1TextureCoord1State.enable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_2 -> map1TextureCoord2State.enable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_3 -> map1TextureCoord3State.enable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_4 -> map1TextureCoord4State.enable();
|
||||
case GL11.GL_MAP1_VERTEX_3 -> map1Vertex3State.enable();
|
||||
case GL11.GL_MAP1_VERTEX_4 -> map1Vertex4State.enable();
|
||||
case GL11.GL_MAP2_COLOR_4 -> map2Color4State.enable();
|
||||
case GL11.GL_MAP2_INDEX -> map2IndexState.enable();
|
||||
case GL11.GL_MAP2_NORMAL -> map2NormalState.enable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_1 -> map2TextureCoord1State.enable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_2 -> map2TextureCoord2State.enable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_3 -> map2TextureCoord3State.enable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_4 -> map2TextureCoord4State.enable();
|
||||
case GL11.GL_MAP2_VERTEX_3 -> map2Vertex3State.enable();
|
||||
case GL11.GL_MAP2_VERTEX_4 -> map2Vertex4State.enable();
|
||||
case GL13.GL_MULTISAMPLE -> multisampleState.enable();
|
||||
case GL11.GL_NORMALIZE -> normalizeState.enable();
|
||||
case GL11.GL_POINT_SMOOTH -> pointSmoothState.enable();
|
||||
case GL11.GL_POLYGON_OFFSET_POINT -> polygonOffsetPointState.enable();
|
||||
case GL11.GL_POLYGON_OFFSET_LINE -> polygonOffsetLineState.enable();
|
||||
case GL11.GL_POLYGON_OFFSET_FILL -> polygonOffsetFillState.enable();
|
||||
case GL11.GL_POLYGON_SMOOTH -> polygonSmoothState.enable();
|
||||
case GL11.GL_POLYGON_STIPPLE -> polygonStippleState.enable();
|
||||
case GL12.GL_RESCALE_NORMAL -> enableRescaleNormal();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_COVERAGE -> sampleAlphaToCoverageState.enable();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_ONE -> sampleAlphaToOneState.enable();
|
||||
case GL13.GL_SAMPLE_COVERAGE -> sampleCoverageState.enable();
|
||||
case GL11.GL_SCISSOR_TEST -> enableScissorTest();
|
||||
case GL11.GL_STENCIL_TEST -> stencilTest.enable();
|
||||
case GL11.GL_TEXTURE_1D -> textures.getTexture1DStates(activeTextureUnit.getValue()).enable();
|
||||
case GL11.GL_TEXTURE_2D -> enableTexture();
|
||||
case GL12.GL_TEXTURE_3D -> textures.getTexture3DStates(activeTextureUnit.getValue()).enable();
|
||||
case GL11.GL_TEXTURE_GEN_S -> textures.getTexGenSStates(activeTextureUnit.getValue()).enable();
|
||||
case GL11.GL_TEXTURE_GEN_T -> textures.getTexGenTStates(activeTextureUnit.getValue()).enable();
|
||||
case GL11.GL_TEXTURE_GEN_R -> textures.getTexGenRStates(activeTextureUnit.getValue()).enable();
|
||||
case GL11.GL_TEXTURE_GEN_Q -> textures.getTexGenQStates(activeTextureUnit.getValue()).enable();
|
||||
default -> GL11.glEnable(cap);
|
||||
}
|
||||
}
|
||||
|
||||
public static void glDisable(int cap) {
|
||||
// Handle clip planes dynamically (supports up to MAX_CLIP_PLANES)
|
||||
if (cap >= GL11.GL_CLIP_PLANE0 && cap < GL11.GL_CLIP_PLANE0 + MAX_CLIP_PLANES) {
|
||||
clipPlaneStates[cap - GL11.GL_CLIP_PLANE0].disable();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (cap) {
|
||||
case GL11.GL_ALPHA_TEST -> disableAlphaTest();
|
||||
case GL11.GL_AUTO_NORMAL -> autoNormalState.disable();
|
||||
case GL11.GL_BLEND -> disableBlend();
|
||||
case GL11.GL_COLOR_MATERIAL -> disableColorMaterial();
|
||||
case GL11.GL_COLOR_LOGIC_OP -> colorLogicOpState.disable();
|
||||
case GL11.GL_CULL_FACE -> disableCull();
|
||||
case GL11.GL_DEPTH_TEST -> disableDepthTest();
|
||||
case GL11.GL_DITHER -> ditherState.disable();
|
||||
case GL11.GL_FOG -> disableFog();
|
||||
case GL11.GL_INDEX_LOGIC_OP -> indexLogicOpState.disable();
|
||||
case GL11.GL_LIGHTING -> disableLighting();
|
||||
case GL11.GL_LIGHT0 -> disableLight(0);
|
||||
case GL11.GL_LIGHT1 -> disableLight(1);
|
||||
@@ -339,10 +460,47 @@ public class GLStateManager {
|
||||
case GL11.GL_LIGHT5 -> disableLight(5);
|
||||
case GL11.GL_LIGHT6 -> disableLight(6);
|
||||
case GL11.GL_LIGHT7 -> disableLight(7);
|
||||
case GL11.GL_COLOR_MATERIAL -> disableColorMaterial();
|
||||
case GL11.GL_SCISSOR_TEST -> disableScissorTest();
|
||||
case GL11.GL_TEXTURE_2D -> disableTexture();
|
||||
case GL11.GL_LINE_SMOOTH -> lineSmoothState.disable();
|
||||
case GL11.GL_LINE_STIPPLE -> lineStippleState.disable();
|
||||
case GL11.GL_MAP1_COLOR_4 -> map1Color4State.disable();
|
||||
case GL11.GL_MAP1_INDEX -> map1IndexState.disable();
|
||||
case GL11.GL_MAP1_NORMAL -> map1NormalState.disable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_1 -> map1TextureCoord1State.disable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_2 -> map1TextureCoord2State.disable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_3 -> map1TextureCoord3State.disable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_4 -> map1TextureCoord4State.disable();
|
||||
case GL11.GL_MAP1_VERTEX_3 -> map1Vertex3State.disable();
|
||||
case GL11.GL_MAP1_VERTEX_4 -> map1Vertex4State.disable();
|
||||
case GL11.GL_MAP2_COLOR_4 -> map2Color4State.disable();
|
||||
case GL11.GL_MAP2_INDEX -> map2IndexState.disable();
|
||||
case GL11.GL_MAP2_NORMAL -> map2NormalState.disable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_1 -> map2TextureCoord1State.disable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_2 -> map2TextureCoord2State.disable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_3 -> map2TextureCoord3State.disable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_4 -> map2TextureCoord4State.disable();
|
||||
case GL11.GL_MAP2_VERTEX_3 -> map2Vertex3State.disable();
|
||||
case GL11.GL_MAP2_VERTEX_4 -> map2Vertex4State.disable();
|
||||
case GL13.GL_MULTISAMPLE -> multisampleState.disable();
|
||||
case GL11.GL_NORMALIZE -> normalizeState.disable();
|
||||
case GL11.GL_POINT_SMOOTH -> pointSmoothState.disable();
|
||||
case GL11.GL_POLYGON_OFFSET_POINT -> polygonOffsetPointState.disable();
|
||||
case GL11.GL_POLYGON_OFFSET_LINE -> polygonOffsetLineState.disable();
|
||||
case GL11.GL_POLYGON_OFFSET_FILL -> polygonOffsetFillState.disable();
|
||||
case GL11.GL_POLYGON_SMOOTH -> polygonSmoothState.disable();
|
||||
case GL11.GL_POLYGON_STIPPLE -> polygonStippleState.disable();
|
||||
case GL12.GL_RESCALE_NORMAL -> disableRescaleNormal();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_COVERAGE -> sampleAlphaToCoverageState.disable();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_ONE -> sampleAlphaToOneState.disable();
|
||||
case GL13.GL_SAMPLE_COVERAGE -> sampleCoverageState.disable();
|
||||
case GL11.GL_SCISSOR_TEST -> disableScissorTest();
|
||||
case GL11.GL_STENCIL_TEST -> stencilTest.disable();
|
||||
case GL11.GL_TEXTURE_1D -> textures.getTexture1DStates(activeTextureUnit.getValue()).disable();
|
||||
case GL11.GL_TEXTURE_2D -> disableTexture();
|
||||
case GL12.GL_TEXTURE_3D -> textures.getTexture3DStates(activeTextureUnit.getValue()).disable();
|
||||
case GL11.GL_TEXTURE_GEN_S -> textures.getTexGenSStates(activeTextureUnit.getValue()).disable();
|
||||
case GL11.GL_TEXTURE_GEN_T -> textures.getTexGenTStates(activeTextureUnit.getValue()).disable();
|
||||
case GL11.GL_TEXTURE_GEN_R -> textures.getTexGenRStates(activeTextureUnit.getValue()).disable();
|
||||
case GL11.GL_TEXTURE_GEN_Q -> textures.getTexGenQStates(activeTextureUnit.getValue()).disable();
|
||||
default -> GL11.glDisable(cap);
|
||||
}
|
||||
}
|
||||
@@ -351,12 +509,22 @@ public class GLStateManager {
|
||||
if(shouldBypassCache()) {
|
||||
return GL11.glIsEnabled(cap);
|
||||
}
|
||||
// Handle clip planes dynamically (supports up to MAX_CLIP_PLANES)
|
||||
if (cap >= GL11.GL_CLIP_PLANE0 && cap < GL11.GL_CLIP_PLANE0 + MAX_CLIP_PLANES) {
|
||||
return clipPlaneStates[cap - GL11.GL_CLIP_PLANE0].isEnabled();
|
||||
}
|
||||
|
||||
return switch (cap) {
|
||||
case GL11.GL_ALPHA_TEST -> alphaTest.isEnabled();
|
||||
case GL11.GL_AUTO_NORMAL -> autoNormalState.isEnabled();
|
||||
case GL11.GL_BLEND -> blendMode.isEnabled();
|
||||
case GL11.GL_COLOR_MATERIAL -> colorMaterial.isEnabled();
|
||||
case GL11.GL_COLOR_LOGIC_OP -> colorLogicOpState.isEnabled();
|
||||
case GL11.GL_CULL_FACE -> cullState.isEnabled();
|
||||
case GL11.GL_DEPTH_TEST -> depthTest.isEnabled();
|
||||
case GL11.GL_DITHER -> ditherState.isEnabled();
|
||||
case GL11.GL_FOG -> fogMode.isEnabled();
|
||||
case GL11.GL_INDEX_LOGIC_OP -> indexLogicOpState.isEnabled();
|
||||
case GL11.GL_LIGHTING -> lightingState.isEnabled();
|
||||
case GL11.GL_LIGHT0 -> lightStates[0].isEnabled();
|
||||
case GL11.GL_LIGHT1 -> lightStates[1].isEnabled();
|
||||
@@ -366,10 +534,47 @@ public class GLStateManager {
|
||||
case GL11.GL_LIGHT5 -> lightStates[5].isEnabled();
|
||||
case GL11.GL_LIGHT6 -> lightStates[6].isEnabled();
|
||||
case GL11.GL_LIGHT7 -> lightStates[7].isEnabled();
|
||||
case GL11.GL_COLOR_MATERIAL -> colorMaterial.isEnabled();
|
||||
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
|
||||
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_LINE_SMOOTH -> lineSmoothState.isEnabled();
|
||||
case GL11.GL_LINE_STIPPLE -> lineStippleState.isEnabled();
|
||||
case GL11.GL_MAP1_COLOR_4 -> map1Color4State.isEnabled();
|
||||
case GL11.GL_MAP1_INDEX -> map1IndexState.isEnabled();
|
||||
case GL11.GL_MAP1_NORMAL -> map1NormalState.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_1 -> map1TextureCoord1State.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_2 -> map1TextureCoord2State.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_3 -> map1TextureCoord3State.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_4 -> map1TextureCoord4State.isEnabled();
|
||||
case GL11.GL_MAP1_VERTEX_3 -> map1Vertex3State.isEnabled();
|
||||
case GL11.GL_MAP1_VERTEX_4 -> map1Vertex4State.isEnabled();
|
||||
case GL11.GL_MAP2_COLOR_4 -> map2Color4State.isEnabled();
|
||||
case GL11.GL_MAP2_INDEX -> map2IndexState.isEnabled();
|
||||
case GL11.GL_MAP2_NORMAL -> map2NormalState.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_1 -> map2TextureCoord1State.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_2 -> map2TextureCoord2State.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_3 -> map2TextureCoord3State.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_4 -> map2TextureCoord4State.isEnabled();
|
||||
case GL11.GL_MAP2_VERTEX_3 -> map2Vertex3State.isEnabled();
|
||||
case GL11.GL_MAP2_VERTEX_4 -> map2Vertex4State.isEnabled();
|
||||
case GL13.GL_MULTISAMPLE -> multisampleState.isEnabled();
|
||||
case GL11.GL_NORMALIZE -> normalizeState.isEnabled();
|
||||
case GL11.GL_POINT_SMOOTH -> pointSmoothState.isEnabled();
|
||||
case GL11.GL_POLYGON_OFFSET_POINT -> polygonOffsetPointState.isEnabled();
|
||||
case GL11.GL_POLYGON_OFFSET_LINE -> polygonOffsetLineState.isEnabled();
|
||||
case GL11.GL_POLYGON_OFFSET_FILL -> polygonOffsetFillState.isEnabled();
|
||||
case GL11.GL_POLYGON_SMOOTH -> polygonSmoothState.isEnabled();
|
||||
case GL11.GL_POLYGON_STIPPLE -> polygonStippleState.isEnabled();
|
||||
case GL12.GL_RESCALE_NORMAL -> rescaleNormalState.isEnabled();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_COVERAGE -> sampleAlphaToCoverageState.isEnabled();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_ONE -> sampleAlphaToOneState.isEnabled();
|
||||
case GL13.GL_SAMPLE_COVERAGE -> sampleCoverageState.isEnabled();
|
||||
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
|
||||
case GL11.GL_STENCIL_TEST -> stencilTest.isEnabled();
|
||||
case GL11.GL_TEXTURE_1D -> textures.getTexture1DStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL12.GL_TEXTURE_3D -> textures.getTexture3DStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_S -> textures.getTexGenSStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_T -> textures.getTexGenTStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_R -> textures.getTexGenRStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_Q -> textures.getTexGenQStates(activeTextureUnit.getValue()).isEnabled();
|
||||
default -> GL11.glIsEnabled(cap);
|
||||
};
|
||||
}
|
||||
@@ -378,13 +583,23 @@ public class GLStateManager {
|
||||
if(shouldBypassCache()) {
|
||||
return GL11.glGetBoolean(pname);
|
||||
}
|
||||
// Handle clip planes dynamically (supports up to MAX_CLIP_PLANES)
|
||||
if (pname >= GL11.GL_CLIP_PLANE0 && pname < GL11.GL_CLIP_PLANE0 + MAX_CLIP_PLANES) {
|
||||
return clipPlaneStates[pname - GL11.GL_CLIP_PLANE0].isEnabled();
|
||||
}
|
||||
|
||||
return switch (pname) {
|
||||
case GL11.GL_ALPHA_TEST -> alphaTest.isEnabled();
|
||||
case GL11.GL_AUTO_NORMAL -> autoNormalState.isEnabled();
|
||||
case GL11.GL_BLEND -> blendMode.isEnabled();
|
||||
case GL11.GL_COLOR_MATERIAL -> colorMaterial.isEnabled();
|
||||
case GL11.GL_COLOR_LOGIC_OP -> colorLogicOpState.isEnabled();
|
||||
case GL11.GL_CULL_FACE -> cullState.isEnabled();
|
||||
case GL11.GL_DEPTH_TEST -> depthTest.isEnabled();
|
||||
case GL11.GL_DEPTH_WRITEMASK -> depthState.isEnabled();
|
||||
case GL11.GL_DITHER -> ditherState.isEnabled();
|
||||
case GL11.GL_FOG -> fogMode.isEnabled();
|
||||
case GL11.GL_INDEX_LOGIC_OP -> indexLogicOpState.isEnabled();
|
||||
case GL11.GL_LIGHTING -> lightingState.isEnabled();
|
||||
case GL11.GL_LIGHT0 -> lightStates[0].isEnabled();
|
||||
case GL11.GL_LIGHT1 -> lightStates[1].isEnabled();
|
||||
@@ -394,10 +609,47 @@ public class GLStateManager {
|
||||
case GL11.GL_LIGHT5 -> lightStates[5].isEnabled();
|
||||
case GL11.GL_LIGHT6 -> lightStates[6].isEnabled();
|
||||
case GL11.GL_LIGHT7 -> lightStates[7].isEnabled();
|
||||
case GL11.GL_COLOR_MATERIAL -> colorMaterial.isEnabled();
|
||||
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
|
||||
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_LINE_SMOOTH -> lineSmoothState.isEnabled();
|
||||
case GL11.GL_LINE_STIPPLE -> lineStippleState.isEnabled();
|
||||
case GL11.GL_MAP1_COLOR_4 -> map1Color4State.isEnabled();
|
||||
case GL11.GL_MAP1_INDEX -> map1IndexState.isEnabled();
|
||||
case GL11.GL_MAP1_NORMAL -> map1NormalState.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_1 -> map1TextureCoord1State.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_2 -> map1TextureCoord2State.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_3 -> map1TextureCoord3State.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_4 -> map1TextureCoord4State.isEnabled();
|
||||
case GL11.GL_MAP1_VERTEX_3 -> map1Vertex3State.isEnabled();
|
||||
case GL11.GL_MAP1_VERTEX_4 -> map1Vertex4State.isEnabled();
|
||||
case GL11.GL_MAP2_COLOR_4 -> map2Color4State.isEnabled();
|
||||
case GL11.GL_MAP2_INDEX -> map2IndexState.isEnabled();
|
||||
case GL11.GL_MAP2_NORMAL -> map2NormalState.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_1 -> map2TextureCoord1State.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_2 -> map2TextureCoord2State.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_3 -> map2TextureCoord3State.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_4 -> map2TextureCoord4State.isEnabled();
|
||||
case GL11.GL_MAP2_VERTEX_3 -> map2Vertex3State.isEnabled();
|
||||
case GL11.GL_MAP2_VERTEX_4 -> map2Vertex4State.isEnabled();
|
||||
case GL13.GL_MULTISAMPLE -> multisampleState.isEnabled();
|
||||
case GL11.GL_NORMALIZE -> normalizeState.isEnabled();
|
||||
case GL11.GL_POINT_SMOOTH -> pointSmoothState.isEnabled();
|
||||
case GL11.GL_POLYGON_OFFSET_POINT -> polygonOffsetPointState.isEnabled();
|
||||
case GL11.GL_POLYGON_OFFSET_LINE -> polygonOffsetLineState.isEnabled();
|
||||
case GL11.GL_POLYGON_OFFSET_FILL -> polygonOffsetFillState.isEnabled();
|
||||
case GL11.GL_POLYGON_SMOOTH -> polygonSmoothState.isEnabled();
|
||||
case GL11.GL_POLYGON_STIPPLE -> polygonStippleState.isEnabled();
|
||||
case GL12.GL_RESCALE_NORMAL -> rescaleNormalState.isEnabled();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_COVERAGE -> sampleAlphaToCoverageState.isEnabled();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_ONE -> sampleAlphaToOneState.isEnabled();
|
||||
case GL13.GL_SAMPLE_COVERAGE -> sampleCoverageState.isEnabled();
|
||||
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
|
||||
case GL11.GL_STENCIL_TEST -> stencilTest.isEnabled();
|
||||
case GL11.GL_TEXTURE_1D -> textures.getTexture1DStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL12.GL_TEXTURE_3D -> textures.getTexture3DStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_S -> textures.getTexGenSStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_T -> textures.getTexGenTStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_R -> textures.getTexGenRStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_Q -> textures.getTexGenQStates(activeTextureUnit.getValue()).isEnabled();
|
||||
default -> GL11.glGetBoolean(pname);
|
||||
};
|
||||
}
|
||||
@@ -997,7 +1249,7 @@ public class GLStateManager {
|
||||
i = mipmap ? GL11.GL_LINEAR_MIPMAP_LINEAR : GL11.GL_LINEAR;
|
||||
j = GL11.GL_LINEAR;
|
||||
} else {
|
||||
i = mipmap ? GL11.GL_NEAREST_MIPMAP_LINEAR : GL11.GL_NEAREST;
|
||||
i = mipmap ? GL11.GL_LINEAR_MIPMAP_LINEAR : GL11.GL_NEAREST;
|
||||
j = GL11.GL_NEAREST;
|
||||
}
|
||||
glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, i);
|
||||
@@ -1885,6 +2137,20 @@ public class GLStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean vendorIsAMD() {
|
||||
return VENDOR == AMD;
|
||||
}
|
||||
|
||||
public static boolean vendorIsIntel() {
|
||||
return VENDOR == INTEL;
|
||||
}
|
||||
|
||||
public static boolean vendorIsMesa() {
|
||||
return VENDOR == MESA;
|
||||
}
|
||||
|
||||
public static boolean vendorIsNVIDIA() {
|
||||
return VENDOR == NVIDIA;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
/// Matches
|
||||
public enum Vendor {
|
||||
AMD("amd"),
|
||||
INTEL("intel"),
|
||||
MESA("mesa"),
|
||||
NVIDIA("nvidia"),
|
||||
UNKNOWN("");
|
||||
|
||||
final String[] names;
|
||||
|
||||
Vendor(String... names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
public static Vendor getVendor(String vendorString) {
|
||||
for (var v : values()) {
|
||||
for (var name : v.names) {
|
||||
if (vendorString.contains(name)) return v;
|
||||
}
|
||||
}
|
||||
|
||||
// Shouldn't be needed as "" matches everything, but sanity checks good.
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,20 @@ public class BooleanStateStack extends BooleanState implements IStateStack<Boole
|
||||
protected int pointer;
|
||||
|
||||
public BooleanStateStack(int glCap) {
|
||||
// Most booleans default to false
|
||||
this(glCap, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a BooleanStateStack with a custom initial state.
|
||||
* Useful for GL states that default to true (e.g., GL_DITHER, GL_MULTISAMPLE).
|
||||
*
|
||||
* @param glCap GL capability constant
|
||||
* @param initialState initial enabled state
|
||||
*/
|
||||
public BooleanStateStack(int glCap, boolean initialState) {
|
||||
super(glCap);
|
||||
this.enabled = initialState;
|
||||
stack = new BooleanState[GLStateManager.MAX_ATTRIB_STACK_DEPTH];
|
||||
for (int i = 0; i < GLStateManager.MAX_ATTRIB_STACK_DEPTH; i++) {
|
||||
stack[i] = new BooleanState(glCap);
|
||||
@@ -34,7 +47,7 @@ public class BooleanStateStack extends BooleanState implements IStateStack<Boole
|
||||
}
|
||||
|
||||
set(stack[--pointer]);
|
||||
if (GLStateManager.isAMD() && glCap == GL11.GL_BLEND) {
|
||||
if (GLStateManager.vendorIsAMD() && glCap == GL11.GL_BLEND) {
|
||||
setEnabled(enabled);
|
||||
}
|
||||
return this;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class BooleanState implements ISettableState<BooleanState> {
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (GLStateManager.shouldBypassCache() || enabled != this.enabled || (this.glCap == GL11.GL_BLEND && GLStateManager.isAMD() && GLStateManager.isPoppingAttributes())) {
|
||||
if (GLStateManager.shouldBypassCache() || enabled != this.enabled || (this.glCap == GL11.GL_BLEND && GLStateManager.vendorIsAMD() && GLStateManager.isPoppingAttributes())) {
|
||||
this.enabled = enabled;
|
||||
if (enabled) {
|
||||
GL11.glEnable(this.glCap);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class MaterialState implements ISettableState<MaterialState> {
|
||||
// glMaterial specifically for GL_COLOR_INDEXES. Other drivers do not do this.
|
||||
// This probably breaks things but who knows, GLSM is setup to track to what the
|
||||
// driver is doing for it right now.
|
||||
if (GLStateManager.isNVIDIA()) {
|
||||
if (GLStateManager.vendorIsNVIDIA()) {
|
||||
vector3f.set(newBuffer.get(0), newBuffer.get(2), newBuffer.get(1));
|
||||
} else {
|
||||
vector3f.set(newBuffer);
|
||||
|
||||
@@ -6,21 +6,40 @@ import com.gtnewhorizons.angelica.glsm.stacks.TextureBindingStack;
|
||||
import lombok.Getter;
|
||||
import org.joml.Matrix4fStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class TextureUnitArray {
|
||||
private final TextureBindingStack[] bindings;
|
||||
private final BooleanStateStack[] states;
|
||||
private final BooleanStateStack[] texture1DStates;
|
||||
private final BooleanStateStack[] texture3DStates;
|
||||
private final BooleanStateStack[] texGenSStates;
|
||||
private final BooleanStateStack[] texGenTStates;
|
||||
private final BooleanStateStack[] texGenRStates;
|
||||
private final BooleanStateStack[] texGenQStates;
|
||||
@Getter
|
||||
public final Matrix4fStack[] textureMatricies;
|
||||
|
||||
public TextureUnitArray() {
|
||||
bindings = new TextureBindingStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
states = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texture1DStates = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texture3DStates = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texGenSStates = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texGenTStates = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texGenRStates = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texGenQStates = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
textureMatricies = new Matrix4fStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
|
||||
for (int i = 0; i < GLStateManager.MAX_TEXTURE_UNITS; i++) {
|
||||
bindings[i] = new TextureBindingStack();
|
||||
states[i] = new BooleanStateStack(GL11.GL_TEXTURE_2D);
|
||||
texture1DStates[i] = new BooleanStateStack(GL11.GL_TEXTURE_1D);
|
||||
texture3DStates[i] = new BooleanStateStack(GL12.GL_TEXTURE_3D);
|
||||
texGenSStates[i] = new BooleanStateStack(GL11.GL_TEXTURE_GEN_S);
|
||||
texGenTStates[i] = new BooleanStateStack(GL11.GL_TEXTURE_GEN_T);
|
||||
texGenRStates[i] = new BooleanStateStack(GL11.GL_TEXTURE_GEN_R);
|
||||
texGenQStates[i] = new BooleanStateStack(GL11.GL_TEXTURE_GEN_Q);
|
||||
textureMatricies[i] = new Matrix4fStack(GLStateManager.MAX_TEXTURE_STACK_DEPTH);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +52,30 @@ public class TextureUnitArray {
|
||||
return states[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexture1DStates(int index) {
|
||||
return texture1DStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexture3DStates(int index) {
|
||||
return texture3DStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexGenSStates(int index) {
|
||||
return texGenSStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexGenTStates(int index) {
|
||||
return texGenTStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexGenRStates(int index) {
|
||||
return texGenRStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexGenQStates(int index) {
|
||||
return texGenQStates[index];
|
||||
}
|
||||
|
||||
public Matrix4fStack getTextureUnitMatrix(int index) {
|
||||
return textureMatricies[index];
|
||||
}
|
||||
@@ -44,6 +87,12 @@ public class TextureUnitArray {
|
||||
for (int i = 0; i < GLStateManager.MAX_TEXTURE_UNITS; i++) {
|
||||
if (!bindings[i].sameAs(textureUnitArray.bindings[i])) return false;
|
||||
if (!states[i].sameAs(textureUnitArray.states[i])) return false;
|
||||
if (!texture1DStates[i].sameAs(textureUnitArray.texture1DStates[i])) return false;
|
||||
if (!texture3DStates[i].sameAs(textureUnitArray.texture3DStates[i])) return false;
|
||||
if (!texGenSStates[i].sameAs(textureUnitArray.texGenSStates[i])) return false;
|
||||
if (!texGenTStates[i].sameAs(textureUnitArray.texGenTStates[i])) return false;
|
||||
if (!texGenRStates[i].sameAs(textureUnitArray.texGenRStates[i])) return false;
|
||||
if (!texGenQStates[i].sameAs(textureUnitArray.texGenQStates[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class TextureInfo {
|
||||
protected int width = -1;
|
||||
protected int height = -1;
|
||||
|
||||
@Getter @Setter protected int minFilter = GL11.GL_NEAREST_MIPMAP_LINEAR;
|
||||
@Getter @Setter protected int minFilter = GL11.GL_LINEAR_MIPMAP_LINEAR;
|
||||
@Getter @Setter protected int magFilter = GL11.GL_LINEAR;
|
||||
@Getter @Setter protected int wrapS = GL11.GL_REPEAT;
|
||||
@Getter @Setter protected int wrapT = GL11.GL_REPEAT;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.gtnewhorizon.gtnhmixins.builders.IMixins;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.ITransformers;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.Mixins;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.CompatHandlers;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
@@ -57,6 +58,7 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
// Angelica Config
|
||||
ConfigurationManager.registerConfig(AngelicaConfig.class);
|
||||
ConfigurationManager.registerConfig(CompatConfig.class);
|
||||
ConfigurationManager.registerConfig(FontConfig.class);
|
||||
MCPatcherForgeConfig.registerConfig();
|
||||
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||
final Configuration config = ctx.getConfiguration();
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ public final class AngelicaRedirector {
|
||||
"net/minecraft/block/material/"
|
||||
};
|
||||
|
||||
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(GL11, GL13, GL14, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, BlockPackage, Project);
|
||||
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(GL11, GL13, GL14, GL20, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, BlockPackage, Project);
|
||||
private static final Map<String, Map<String, String>> methodRedirects = new HashMap<>();
|
||||
private static final Map<Integer, String> glCapRedirects = new HashMap<>();
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ public enum Mixins implements IMixins {
|
||||
.addClientMixins(
|
||||
"angelica.fontrenderer.MixinGuiIngameForge"
|
||||
, "angelica.fontrenderer.MixinFontRenderer"
|
||||
, "angelica.fontrenderer.MixinMCResourceAccessor"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -88,10 +89,10 @@ public enum Mixins implements IMixins {
|
||||
.addClientMixins("angelica.optimizations.MixinRenderGlobal_ItemRenderDist")
|
||||
.setApplyIf(() -> AngelicaConfig.dynamicItemRenderDistance)),
|
||||
|
||||
ANGELICA_ITEM_DISPLAY_LIST_OPTIMIZATION(new MixinBuilder("Optimized item rendering by wrapping them with display lists")
|
||||
ANGELICA_ITEM_RENDERER_OPTIMIZATION(new MixinBuilder("Optimizes in-world item rendering")
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins("angelica.itemrenderer.MixinItemRenderer")
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeInWorldItemRendering_WIP)),
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeInWorldItemRendering)),
|
||||
|
||||
// Not compatible with the lwjgl debug callbacks, so disable if that's enabled
|
||||
ARCHAIC_SPLASH(new MixinBuilder()
|
||||
@@ -574,13 +575,6 @@ public enum Mixins implements IMixins {
|
||||
.addClientMixins("mcpatcherforge.ctm_cc.MixinTextureMap")
|
||||
),
|
||||
//End from NotFine
|
||||
|
||||
QPR(new MixinBuilder("Adds a QuadProvider field to blocks without populating it")
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins(
|
||||
"angelica.models.MixinBlock",
|
||||
"angelica.models.MixinBlockOldLeaf")),
|
||||
|
||||
;
|
||||
|
||||
private final MixinBuilder builder;
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadProvider;
|
||||
|
||||
public interface ModeledBlock {
|
||||
|
||||
QuadProvider getModel();
|
||||
void setModel(QuadProvider model);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ResourceAccessor {
|
||||
List angelica$getDefaultResourcePacks();
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.models;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.IBlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.ModelLoader;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.Variant;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.json.ModelLocation;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.template.BlockColoredCube;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.template.BlockStaticCube;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.template.Column3Rot;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.template.Model4Rot;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadProvider;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class VanillaModels {
|
||||
|
||||
private static boolean init = false;
|
||||
|
||||
public static final BlockStaticCube STONE = new BlockStaticCube("stone");
|
||||
public static final BlockStaticCube GLASS = new BlockStaticCube("glass");
|
||||
|
||||
public static BlockColoredCube OAK_LEAVES;
|
||||
public static BlockColoredCube SPRUCE_LEAVES;
|
||||
public static BlockColoredCube BIRCH_LEAVES;
|
||||
public static BlockColoredCube JUNGLE_LEAVES;
|
||||
public static QuadProvider OLD_LEAF = new QuadProvider() {
|
||||
@Override
|
||||
public int getColor(IBlockAccess world, IBlockPos pos, Block block, int meta, Random random) {
|
||||
return QuadProvider.getDefaultColor(world, pos, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuadView> getQuads(IBlockAccess world, IBlockPos pos, Block block, int meta, ForgeDirection dir, Random random, int color, Supplier<QuadView> quadPool) {
|
||||
return (switch (meta % 4) {
|
||||
case 0 -> OAK_LEAVES;
|
||||
case 1 -> SPRUCE_LEAVES;
|
||||
case 2 -> BIRCH_LEAVES;
|
||||
case 3 -> JUNGLE_LEAVES;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
}).getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
}
|
||||
};
|
||||
|
||||
public static BlockColoredCube ACACIA_LEAVES;
|
||||
public static BlockColoredCube DARK_OAK_LEAVES;
|
||||
public static QuadProvider NEW_LEAF = new QuadProvider() {
|
||||
@Override
|
||||
public int getColor(IBlockAccess world, IBlockPos pos, Block block, int meta, Random random) {
|
||||
return QuadProvider.getDefaultColor(world, pos, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuadView> getQuads(IBlockAccess world, IBlockPos pos, Block block, int meta, ForgeDirection dir, Random random, int color, Supplier<QuadView> quadPool) {
|
||||
return (switch (meta % 2) {
|
||||
case 0 -> ACACIA_LEAVES;
|
||||
case 1 -> DARK_OAK_LEAVES;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
}).getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
}
|
||||
};
|
||||
|
||||
public static Column3Rot OAK_LOG;
|
||||
public static Column3Rot SPRUCE_LOG;
|
||||
public static Column3Rot BIRCH_LOG;
|
||||
public static Column3Rot JUNGLE_LOG;
|
||||
public static BlockStaticCube OAK_WOOD;
|
||||
public static BlockStaticCube BIRCH_WOOD;
|
||||
public static BlockStaticCube SPRUCE_WOOD;
|
||||
public static BlockStaticCube JUNGLE_WOOD;
|
||||
public static QuadProvider OLD_LOG = new QuadProvider() {
|
||||
@Override
|
||||
public List<QuadView> getQuads(IBlockAccess world, IBlockPos pos, Block block, int meta, ForgeDirection dir, Random random, int color, Supplier<QuadView> quadPool) {
|
||||
|
||||
if (meta > 11) {
|
||||
return (switch (meta) {
|
||||
case 12 -> OAK_WOOD;
|
||||
case 13 -> SPRUCE_WOOD;
|
||||
case 14 -> BIRCH_WOOD;
|
||||
case 15 -> JUNGLE_WOOD;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
}).getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
}
|
||||
|
||||
Column3Rot ret = switch (meta % 4) {
|
||||
case 0 -> OAK_LOG;
|
||||
case 1 -> SPRUCE_LOG;
|
||||
case 2 -> BIRCH_LOG;
|
||||
case 3 -> JUNGLE_LOG;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
};
|
||||
|
||||
return (switch (meta / 4) {
|
||||
case 0 -> ret.updown();
|
||||
case 1 -> ret.eastwest();
|
||||
case 2 -> ret.northsouth();
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
}).getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
}
|
||||
};
|
||||
|
||||
public static Column3Rot ACACIA_LOG;
|
||||
public static Column3Rot DARK_OAK_LOG;
|
||||
public static BlockStaticCube ACACIA_WOOD;
|
||||
public static BlockStaticCube DARK_OAK_WOOD;
|
||||
public static QuadProvider NEW_LOG = new QuadProvider() {
|
||||
@Override
|
||||
public List<QuadView> getQuads(IBlockAccess world, IBlockPos pos, Block block, int meta, ForgeDirection dir, Random random, int color, Supplier<QuadView> quadPool) {
|
||||
|
||||
if (meta > 11) {
|
||||
return (switch (meta) {
|
||||
case 12 -> ACACIA_WOOD;
|
||||
case 13 -> DARK_OAK_WOOD;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
}).getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
}
|
||||
|
||||
Column3Rot ret = switch (meta % 4) {
|
||||
case 0 -> ACACIA_LOG;
|
||||
case 1 -> DARK_OAK_LOG;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
};
|
||||
|
||||
return (switch (meta / 4) {
|
||||
case 0 -> ret.updown();
|
||||
case 1 -> ret.eastwest();
|
||||
case 2 -> ret.northsouth();
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
}).getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
}
|
||||
};
|
||||
|
||||
public static final Variant workbench = new Variant(
|
||||
new ModelLocation("block/crafting_table"),
|
||||
0,
|
||||
0,
|
||||
true
|
||||
);
|
||||
public static QuadProvider WORKBENCH;
|
||||
|
||||
public static Model4Rot LECTERN;
|
||||
|
||||
public static void init() {
|
||||
|
||||
if (init) {
|
||||
throw new RuntimeException("Vanilla models were baked twice!");
|
||||
}
|
||||
|
||||
if (AngelicaConfig.injectQPRendering) {
|
||||
|
||||
ACACIA_LEAVES = new BlockColoredCube("leaves_acacia");
|
||||
BIRCH_LEAVES = new BlockColoredCube("leaves_birch");
|
||||
DARK_OAK_LEAVES = new BlockColoredCube("leaves_big_oak");
|
||||
JUNGLE_LEAVES = new BlockColoredCube("leaves_jungle");
|
||||
OAK_LEAVES = new BlockColoredCube("leaves_oak");
|
||||
SPRUCE_LEAVES = new BlockColoredCube("leaves_spruce");
|
||||
|
||||
ACACIA_LOG = new Column3Rot(new ModelLocation("block/acacia_log"));
|
||||
BIRCH_LOG = new Column3Rot(new ModelLocation("block/birch_log"));
|
||||
DARK_OAK_LOG = new Column3Rot(new ModelLocation("block/dark_oak_log"));
|
||||
JUNGLE_LOG = new Column3Rot(new ModelLocation("block/jungle_log"));
|
||||
OAK_LOG = new Column3Rot(new ModelLocation("block/oak_log"));
|
||||
SPRUCE_LOG = new Column3Rot(new ModelLocation("block/spruce_log"));
|
||||
|
||||
ACACIA_WOOD = new BlockStaticCube("log_acacia");
|
||||
BIRCH_WOOD = new BlockStaticCube("log_birch");
|
||||
DARK_OAK_WOOD = new BlockStaticCube("log_big_oak");
|
||||
JUNGLE_WOOD = new BlockStaticCube("log_jungle");
|
||||
OAK_WOOD = new BlockStaticCube("log_oak");
|
||||
SPRUCE_WOOD = new BlockStaticCube("log_spruce");
|
||||
|
||||
ModelLoader.registerModels(VanillaModels::loadModels,
|
||||
workbench);
|
||||
}
|
||||
|
||||
if (AngelicaConfig.enableTestBlocks)
|
||||
LECTERN = new Model4Rot(new ModelLocation("block/lectern"));
|
||||
|
||||
init = true;
|
||||
}
|
||||
|
||||
public static void loadModels() {
|
||||
WORKBENCH = ModelLoader.getModel(workbench);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.gtnewhorizons.angelica.proxy;
|
||||
|
||||
import static com.gtnewhorizons.angelica.AngelicaMod.MOD_ID;
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.loading.ModelRegistry;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
@@ -12,15 +14,13 @@ import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import com.gtnewhorizons.angelica.debug.F3Direction;
|
||||
import com.gtnewhorizons.angelica.debug.FrametimeGraph;
|
||||
import com.gtnewhorizons.angelica.debug.TPSGraph;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IGameSettingsExt;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.debug.OpenGLDebugging;
|
||||
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
|
||||
import com.gtnewhorizons.angelica.models.VanillaModels;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IGameSettingsExt;
|
||||
import com.gtnewhorizons.angelica.render.CloudRenderer;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
import com.gtnewhorizons.angelica.utils.AssetLoader;
|
||||
import com.gtnewhorizons.angelica.zoom.Zoom;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
@@ -76,7 +76,7 @@ public class ClientProxy extends CommonProxy {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
AssetLoader.load();
|
||||
ModelRegistry.registerModid(MOD_ID);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -139,8 +139,6 @@ public class ClientProxy extends CommonProxy {
|
||||
glsmKeyBinding = new KeyBinding("Print GLSM Debug", Keyboard.KEY_NONE, "Angelica");
|
||||
ClientRegistry.registerKeyBinding(glsmKeyBinding);
|
||||
|
||||
VanillaModels.init();
|
||||
|
||||
if (ModStatus.isBetterCrashesLoaded) {
|
||||
BetterCrashesCompat.init();
|
||||
}
|
||||
@@ -308,9 +306,14 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onGuiOpen(GuiOpenEvent event) {
|
||||
if (!event.isCanceled() && event.gui instanceof GuiMainMenu && gameStartTime == -1) {
|
||||
gameStartTime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000f;
|
||||
LOGGER.info("The game loaded in {} seconds.", gameStartTime);
|
||||
if (!event.isCanceled()) {
|
||||
if (event.gui instanceof GuiMainMenu && gameStartTime == -1 ) {
|
||||
gameStartTime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000f;
|
||||
LOGGER.info("The game loaded in {} seconds.", gameStartTime);
|
||||
}
|
||||
|
||||
// force reset zoom when a GUI is opened
|
||||
if (AngelicaConfig.enableZoom && event.gui != null) Zoom.resetZoom();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -242,7 +242,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
GraphicsQualityOff cloudGraphicsQuality = (GraphicsQualityOff)Settings.MODE_CLOUDS.option.getStore();
|
||||
final int cloudQualitySetting = cloudGraphicsQuality == GraphicsQualityOff.FANCY
|
||||
|| cloudGraphicsQuality == GraphicsQualityOff.DEFAULT && mc.gameSettings.fancyGraphics ? 2 : 1;
|
||||
final boolean newEnabled = mc.gameSettings.shouldRenderClouds()
|
||||
final boolean newEnabled = cloudGraphicsQuality != GraphicsQualityOff.OFF
|
||||
&& mc.gameSettings.shouldRenderClouds()
|
||||
&& mc.theWorld != null
|
||||
&& mc.theWorld.provider.isSurfaceWorld();
|
||||
final int targetDistance = Math.max(mc.gameSettings.renderDistanceChunks, (int)Settings.RENDER_DISTANCE_CLOUDS.option.getStore());
|
||||
|
||||
@@ -25,87 +25,158 @@
|
||||
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import lombok.AccessLevel;
|
||||
import it.unimi.dsi.fastutil.HashCommon;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.val;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
public class ItemRenderListManager {
|
||||
// Least used element is at position 0. This is in theory slightly faster.
|
||||
private static final Object2ObjectLinkedOpenHashMap<ItemProp, CachedVBO> vboCache = new Object2ObjectLinkedOpenHashMap<>(64);
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
// Formula: (widthSubdivisions * 2 + heightSubdivisions * 2 + 2) * 4 * vertexSize
|
||||
// Using 256 as both variables due to enchants, to prevent later re-allocations.
|
||||
private static ByteBuffer quadBuffer = BufferUtils.createByteBuffer(
|
||||
(1026 * DefaultVertexFormat.POSITION_TEXTURE_NORMAL.getVertexSize()) << 2
|
||||
);
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ItemRenderListManager implements IResourceManagerReloadListener {
|
||||
public static final ItemRenderListManager INSTANCE = new ItemRenderListManager();
|
||||
// 1 minute
|
||||
private static final int EXPIRY_TICKS = 1_200;
|
||||
private static int smallestExpiry;
|
||||
|
||||
private final Map<ItemProp, Integer> theMap = new HashMap<>();
|
||||
private final List<ItemProp> propList = new ArrayList<>();
|
||||
private final ItemProp prop = new ItemProp();
|
||||
private int list = 0;
|
||||
private static final ItemProp prop = new ItemProp();
|
||||
|
||||
public boolean pre(float a, float b, float c, float d, int e, int f, float g) {
|
||||
prop.set(a, b, c, d, e, f, g);
|
||||
if (theMap.containsKey(prop)) {
|
||||
val list = theMap.get(prop);
|
||||
propList.add(propList.remove(propList.indexOf(prop)));
|
||||
GL11.glCallList(list);
|
||||
return true;
|
||||
} else {
|
||||
if (propList.size() >= AngelicaConfig.itemRendererDisplayListCacheSize) {
|
||||
val oldProp = propList.remove(0);
|
||||
GLAllocation.deleteDisplayLists(theMap.remove(oldProp));
|
||||
public static VertexBuffer pre(float minU, float minV, float maxU, float maxV, int widthSubdivisions, int heightSubdivisions, float thickness) {
|
||||
prop.set(minU, minV, maxU, maxV, widthSubdivisions, heightSubdivisions, thickness);
|
||||
|
||||
if (!vboCache.isEmpty()) {
|
||||
|
||||
final CachedVBO vbo = vboCache.getAndMoveToLast(prop);
|
||||
|
||||
if (vbo != null) {
|
||||
final int time = getElapsedTicks();
|
||||
vbo.render(time);
|
||||
|
||||
// Prevent constant map lookups by only storing the expiry of the least recently used entry
|
||||
if (time > smallestExpiry && time > (smallestExpiry = (vboCache.get(vboCache.firstKey()).expiry + 20))) {
|
||||
vboCache.removeFirst().delete();
|
||||
if (!vboCache.isEmpty()) {
|
||||
smallestExpiry = vboCache.get(vboCache.firstKey()).expiry + 20;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
list = GLAllocation.generateDisplayLists(1);
|
||||
val newProp = new ItemProp(prop);
|
||||
theMap.put(newProp, list);
|
||||
propList.add(newProp);
|
||||
GL11.glNewList(list, GL11.GL_COMPILE);
|
||||
return false;
|
||||
}
|
||||
|
||||
final CachedVBO vbo;
|
||||
if (vboCache.size() >= AngelicaConfig.itemRendererCacheSize) {
|
||||
final ItemProp oldestProp = vboCache.firstKey();
|
||||
vbo = vboCache.removeFirst();
|
||||
oldestProp.set(prop);
|
||||
vboCache.put(oldestProp, vbo);
|
||||
} else {
|
||||
vbo = new CachedVBO();
|
||||
vboCache.put(new ItemProp(prop), vbo);
|
||||
}
|
||||
|
||||
vbo.expiry = getElapsedTicks() + EXPIRY_TICKS;
|
||||
|
||||
TessellatorManager.startCapturing();
|
||||
|
||||
return vbo.vertexBuffer;
|
||||
}
|
||||
|
||||
public void post() {
|
||||
GL11.glEndList();
|
||||
GL11.glCallList(list);
|
||||
public static void post(CapturingTessellator tessellator, VertexBuffer vbo) {
|
||||
final var quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
final int size = quads.size();
|
||||
|
||||
final int needed = (DefaultVertexFormat.POSITION_TEXTURE_NORMAL.getVertexSize() * size) << 2;
|
||||
if (quadBuffer.capacity() < needed) {
|
||||
quadBuffer = BufferUtils.createByteBuffer(HashCommon.nextPowerOfTwo(needed));
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
DefaultVertexFormat.POSITION_TEXTURE_NORMAL.writeQuad(quads.get(i), quadBuffer);
|
||||
}
|
||||
|
||||
quadBuffer.flip();
|
||||
vbo.upload(quadBuffer);
|
||||
quadBuffer.clear();
|
||||
|
||||
tessellator.clearQuads();
|
||||
vbo.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager p_110549_1_) {
|
||||
propList.clear();
|
||||
theMap.forEach((key, value) -> GLAllocation.deleteDisplayLists(value));
|
||||
theMap.clear();
|
||||
private static int getElapsedTicks() {
|
||||
return Minecraft.getMinecraft().thePlayer.ticksExisted;
|
||||
}
|
||||
|
||||
private static final class CachedVBO {
|
||||
private VertexBuffer vertexBuffer;
|
||||
private int expiry;
|
||||
|
||||
public CachedVBO() {
|
||||
this.vertexBuffer = new VertexBuffer(DefaultVertexFormat.POSITION_TEXTURE_NORMAL, GL11.GL_QUADS);
|
||||
}
|
||||
|
||||
private void render(int elapsedTicks) {
|
||||
vertexBuffer.render();
|
||||
expiry = elapsedTicks + EXPIRY_TICKS;
|
||||
}
|
||||
|
||||
private void delete() {
|
||||
vertexBuffer.close();
|
||||
vertexBuffer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class ItemProp {
|
||||
private float a;
|
||||
private float b;
|
||||
private float c;
|
||||
private float d;
|
||||
private int e;
|
||||
private int f;
|
||||
private float g;
|
||||
private static final class ItemProp {
|
||||
private float minU;
|
||||
private float minV;
|
||||
private float maxU;
|
||||
private float maxV;
|
||||
private int widthSubdivisions;
|
||||
private int heightSubdivisions;
|
||||
private float thickness;
|
||||
|
||||
public ItemProp(ItemProp old) {
|
||||
set(old.a, old.b, old.c, old.d, old.e, old.f, old.g);
|
||||
set(
|
||||
old.minU, old.minV,
|
||||
old.maxU, old.maxV,
|
||||
old.widthSubdivisions, old.heightSubdivisions,
|
||||
old.thickness
|
||||
);
|
||||
}
|
||||
|
||||
public void set(float a, float b, float c, float d, int e, int f, float g) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
this.e = e;
|
||||
this.f = f;
|
||||
this.g = g;
|
||||
public void set(ItemProp other) {
|
||||
set(
|
||||
other.minU, other.minV,
|
||||
other.maxU, other.maxV,
|
||||
other.widthSubdivisions, other.heightSubdivisions,
|
||||
other.thickness
|
||||
);
|
||||
}
|
||||
|
||||
public void set(float minU, float minV, float maxU, float maxV, int widthSubdivisions, int heightSubdivisions, float thickness) {
|
||||
this.minU = minU;
|
||||
this.minV = minV;
|
||||
this.maxU = maxU;
|
||||
this.maxV = maxV;
|
||||
this.widthSubdivisions = widthSubdivisions;
|
||||
this.heightSubdivisions = heightSubdivisions;
|
||||
this.thickness = thickness;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.utils;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import glowredman.txloader.Asset;
|
||||
import glowredman.txloader.TXLoaderCore;
|
||||
|
||||
public class AssetLoader {
|
||||
|
||||
// Texture paths from modern, starting with "minecraft/textures/"
|
||||
public static final String[] injectTexs = {
|
||||
"block/stone",
|
||||
"block/crafting_table_front",
|
||||
"block/crafting_table_side",
|
||||
"block/crafting_table_top",
|
||||
"block/oak_planks",
|
||||
"block/acacia_log_top",
|
||||
"block/acacia_log",
|
||||
"block/birch_log_top",
|
||||
"block/birch_log",
|
||||
"block/dark_oak_log_top",
|
||||
"block/dark_oak_log",
|
||||
"block/jungle_log_top",
|
||||
"block/jungle_log",
|
||||
"block/oak_log_top",
|
||||
"block/oak_log",
|
||||
"block/spruce_log_top",
|
||||
"block/spruce_log"
|
||||
};
|
||||
|
||||
// Any equivalents from 7.10, starting with "minecraft/"
|
||||
// This can't be automatic because some of them are inconsistent
|
||||
public static final String[] oldInjectTexs = {
|
||||
"blocks/stone",
|
||||
"blocks/crafting_table_front",
|
||||
"blocks/crafting_table_side",
|
||||
"blocks/crafting_table_top",
|
||||
"blocks/planks_oak",
|
||||
"blocks/log_acacia_top",
|
||||
"blocks/log_acacia",
|
||||
"blocks/log_birch_top",
|
||||
"blocks/log_birch",
|
||||
"blocks/log_big_oak_top",
|
||||
"blocks/log_big_oak",
|
||||
"blocks/log_jungle_top",
|
||||
"blocks/log_jungle",
|
||||
"blocks/log_oak_top",
|
||||
"blocks/log_oak",
|
||||
"blocks/log_spruce_top",
|
||||
"blocks/log_spruce"
|
||||
};
|
||||
|
||||
public static final String[] testTexs = {
|
||||
"block/lectern_base",
|
||||
"block/lectern_front",
|
||||
"block/lectern_base",
|
||||
"block/lectern_sides",
|
||||
"block/lectern_top",
|
||||
"block/oak_planks"
|
||||
};
|
||||
|
||||
public static void load() {
|
||||
|
||||
if (AngelicaConfig.injectQPRendering || AngelicaConfig.enableTestBlocks) {
|
||||
addModelAssets(
|
||||
"block/block",
|
||||
"block/cube",
|
||||
"block/cube_all",
|
||||
"block/cube_column"
|
||||
);
|
||||
}
|
||||
|
||||
// For textures, we first clone old assets to their locations in modern, then copy any modern textures we don't
|
||||
// have equivalents for (only the lectern rn). Models are always downloaded, 7.10 doesn't have any.
|
||||
if (AngelicaConfig.injectQPRendering) {
|
||||
addModelAssets(
|
||||
"block/stone",
|
||||
"block/crafting_table",
|
||||
"block/acacia_log",
|
||||
"block/birch_log",
|
||||
"block/dark_oak_log",
|
||||
"block/jungle_log",
|
||||
"block/oak_log",
|
||||
"block/spruce_log");
|
||||
addTexAssets(oldInjectTexs, injectTexs, "1.7.10");
|
||||
}
|
||||
|
||||
if (AngelicaConfig.enableTestBlocks) {
|
||||
addModelAssets("block/lectern");
|
||||
addTexAssets(testTexs, testTexs, "1.20.4");
|
||||
}
|
||||
}
|
||||
|
||||
private static void addModelAssets(String... resourcePaths) {
|
||||
for (String path : resourcePaths) {
|
||||
TXLoaderCore.getAssetBuilder("minecraft/models/" + path + ".json")
|
||||
.setVersion("1.20.4")
|
||||
.setSource(Asset.Source.CLIENT)
|
||||
.add();
|
||||
}
|
||||
}
|
||||
|
||||
private static void addTexAssets(String[] resourcePaths, String[] destPaths, String version) {
|
||||
for (int i = 0; i < resourcePaths.length; ++i) {
|
||||
TXLoaderCore.getAssetBuilder("minecraft/textures/" + resourcePaths[i] + ".png")
|
||||
.setOverride("minecraft/textures/blocks/" + destPaths[i] + ".png")
|
||||
.setVersion(version)
|
||||
.setSource(Asset.Source.CLIENT)
|
||||
.add();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ObjectPooler<T> {
|
||||
private final Supplier<T> instanceSupplier;
|
||||
private final ArrayList<T> availableInstances;
|
||||
|
||||
public ObjectPooler(Supplier<T> instanceSupplier) {
|
||||
this.instanceSupplier = instanceSupplier;
|
||||
this.availableInstances = new ArrayList<>();
|
||||
}
|
||||
|
||||
public T getInstance() {
|
||||
if(this.availableInstances.isEmpty()) {
|
||||
return this.instanceSupplier.get();
|
||||
}
|
||||
return this.availableInstances.remove(this.availableInstances.size() - 1);
|
||||
}
|
||||
|
||||
public void releaseInstance(T instance) {
|
||||
this.availableInstances.add(instance);
|
||||
}
|
||||
}
|
||||
@@ -8,46 +8,75 @@ import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public class Zoom {
|
||||
|
||||
@Getter
|
||||
private static float zoom = 4.0F;
|
||||
@Getter
|
||||
private static final KeyBinding zoomKey = new KeyBinding("Zoom", 0, "key.categories.misc");
|
||||
|
||||
public static final float ZOOM_MIN = 1.0F;
|
||||
public static final float ZOOM_MAX = 64.0F;
|
||||
public static final float ZOOM_STEP = 1.2F;
|
||||
public static final float ZOOM_DEFAULT = 4.0F;
|
||||
|
||||
private static boolean lastSmoothCameraState = false;
|
||||
@Getter
|
||||
private static float zoom = ZOOM_DEFAULT;
|
||||
@Getter
|
||||
private static final KeyBinding zoomKey = new KeyBinding("Zoom", 0, "key.categories.misc");
|
||||
|
||||
private static boolean zoomEnabled = false;
|
||||
|
||||
public static void init() {
|
||||
ClientRegistry.registerKeyBinding(zoomKey);
|
||||
FMLCommonHandler.instance().bus().register(new Zoom());
|
||||
}
|
||||
|
||||
public static boolean isZoomedIn() {
|
||||
return zoomEnabled;
|
||||
}
|
||||
|
||||
public static void modifyZoom(int eventDWheel) {
|
||||
if (eventDWheel == 0) return;
|
||||
zoom = MathHelper.clamp_float((float) (zoom * Math.pow(ZOOM_STEP, Integer.signum(eventDWheel))), ZOOM_MIN, ZOOM_MAX);
|
||||
}
|
||||
|
||||
private static void resetMouseFilters(Minecraft mc) {
|
||||
if (mc.entityRenderer != null) {
|
||||
((IMouseFilterExt) mc.entityRenderer.mouseFilterXAxis).angelica$reset();
|
||||
((IMouseFilterExt) mc.entityRenderer.mouseFilterYAxis).angelica$reset();
|
||||
}
|
||||
}
|
||||
|
||||
public static void resetZoom() {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
zoomEnabled = false;
|
||||
zoom = ZOOM_DEFAULT;
|
||||
resetMouseFilters(mc);
|
||||
}
|
||||
|
||||
private void handleKeyEvent() {
|
||||
if (zoomKey.getKeyCode() == 0) return;
|
||||
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.currentScreen != null) return;
|
||||
|
||||
if (zoomKey.getIsKeyPressed()) {
|
||||
zoomEnabled = true;
|
||||
} else if (zoomEnabled) {
|
||||
resetZoom();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyPress(InputEvent.KeyInputEvent e) {
|
||||
final int keyCode = zoomKey.getKeyCode();
|
||||
if (keyCode == 0 || Keyboard.getEventKey() != keyCode || Keyboard.isRepeatEvent()) return;
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (Keyboard.getEventKeyState()) {
|
||||
lastSmoothCameraState = mc.gameSettings.smoothCamera;
|
||||
mc.gameSettings.smoothCamera = true;
|
||||
} else {
|
||||
zoom = 4.0F;
|
||||
if (mc.gameSettings.smoothCamera != lastSmoothCameraState) {
|
||||
((IMouseFilterExt) mc.entityRenderer.mouseFilterXAxis).angelica$reset();
|
||||
((IMouseFilterExt) mc.entityRenderer.mouseFilterYAxis).angelica$reset();
|
||||
}
|
||||
mc.gameSettings.smoothCamera = lastSmoothCameraState;
|
||||
handleKeyEvent();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMouseKeyPress(InputEvent.MouseInputEvent e) {
|
||||
// MouseInputEvent is also fired on mouse movement, which we don't care about, only mouse button presses, so
|
||||
// ensure that before any further key processing.
|
||||
if (Mouse.getEventButton() >= 0) {
|
||||
handleKeyEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class MipmapHelper {
|
||||
int mipmaps = useMipmapsForTexture(textureName) ? getMipmapLevels(width, height, 1) : 0;
|
||||
logger.finer("setupTexture(%s) %dx%d %d mipmaps", textureName, width, height, mipmaps);
|
||||
int magFilter = blur ? GL11.GL_LINEAR : GL11.GL_NEAREST;
|
||||
int minFilter = mipmaps > 0 ? GL11.GL_NEAREST_MIPMAP_LINEAR : magFilter;
|
||||
int minFilter = mipmaps > 0 ? GL11.GL_LINEAR_MIPMAP_LINEAR : magFilter;
|
||||
int wrap = clamp ? GL11.GL_CLAMP : GL11.GL_REPEAT;
|
||||
if (mipmaps > 0) {
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, mipmaps);
|
||||
|
||||
@@ -311,20 +311,18 @@ public class TexturePackAPI {
|
||||
public static void flushUnusedTextures() {
|
||||
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||
if (textureManager != null) {
|
||||
Set<ResourceLocation> texturesToUnload = new HashSet<>();
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Map.Entry<ResourceLocation, ITextureObject>> entrySet = textureManager.mapTextureObjects.entrySet();
|
||||
for (Map.Entry<ResourceLocation, ITextureObject> entry : entrySet) {
|
||||
ResourceLocation resource = entry.getKey();
|
||||
Map.Entry<ResourceLocation, ITextureObject>[] arr = (Map.Entry<ResourceLocation, ITextureObject>[])
|
||||
textureManager.mapTextureObjects.entrySet().toArray(new Map.Entry[0]);
|
||||
for (Map.Entry<ResourceLocation, ITextureObject> entry : arr) {
|
||||
ITextureObject texture = entry.getValue();
|
||||
if (texture instanceof SimpleTexture && !(texture instanceof ThreadDownloadImageData)
|
||||
&& !TexturePackAPI.hasResource(resource)) {
|
||||
texturesToUnload.add(resource);
|
||||
if (texture instanceof SimpleTexture && !(texture instanceof ThreadDownloadImageData)) {
|
||||
ResourceLocation resource = entry.getKey();
|
||||
if (!TexturePackAPI.hasResource(resource)) {
|
||||
unloadTexture(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ResourceLocation resource : texturesToUnload) {
|
||||
unloadTexture(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-5
@@ -1,5 +1,6 @@
|
||||
package me.flashyreese.mods.reeses_sodium_options.client.gui;
|
||||
|
||||
import com.gtnewhorizons.angelica.client.gui.FontConfigScreen;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Element;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import jss.notfine.gui.GuiCustomMenu;
|
||||
@@ -96,25 +97,35 @@ public class ReeseSodiumVideoOptionsScreen extends SodiumOptionsGUI {
|
||||
this.applyButton = new FlatButtonWidget(applyButtonDim, "Apply", this::applyChanges);
|
||||
this.closeButton = new FlatButtonWidget(closeButtonDim, "Close", this::onClose);
|
||||
|
||||
Dim2i searchTextFieldDim = new Dim2i(tabFrameDim.getOriginX(), tabFrameDim.getOriginY() - 26, tabFrameDim.getWidth(), 20);
|
||||
|
||||
|
||||
|
||||
basicFrameBuilder = this.parentBasicFrameBuilder(basicFrameDim, tabFrameDim);
|
||||
|
||||
if(AngelicaConfig.enableIris) {
|
||||
int cumulativeXShift = 0;
|
||||
|
||||
if (AngelicaConfig.enableIris) {
|
||||
//int size = this.client.textRenderer.getWidth(new TranslatableText(IrisApi.getInstance().getMainScreenLanguageKey()));
|
||||
final String irisText = I18n.format(IrisApi.getInstance().getMainScreenLanguageKey());
|
||||
final int size = this.mc.fontRenderer.getStringWidth(irisText);
|
||||
final Dim2i shaderPackButtonDim = new Dim2i(tabFrameDim.getLimitX() - size - 10, tabFrameDim.getOriginY() - 26, 10 + size, 20);
|
||||
cumulativeXShift += size + 12;
|
||||
|
||||
searchTextFieldDim = new Dim2i(tabFrameDim.getOriginX(), tabFrameDim.getOriginY() - 26, tabFrameDim.getWidth() - (tabFrameDim.getLimitX() - shaderPackButtonDim.getOriginX()) - 2, 20);
|
||||
|
||||
//FlatButtonWidget shaderPackButton = new FlatButtonWidget(shaderPackButtonDim, new TranslatableText(IrisApi.getInstance().getMainScreenLanguageKey()), () -> this.client.setScreen((Screen) IrisApi.getInstance().openMainIrisScreenObj(this)));
|
||||
final FlatButtonWidget shaderPackButton = new FlatButtonWidget(shaderPackButtonDim, irisText, () -> mc.displayGuiScreen(new ShaderPackScreen(this)));
|
||||
basicFrameBuilder.addChild(dim -> shaderPackButton);
|
||||
}
|
||||
|
||||
if (AngelicaConfig.enableFontRenderer) {
|
||||
final String fontConfigText = I18n.format("options.angelica.fontconfig");
|
||||
final int size = this.mc.fontRenderer.getStringWidth(fontConfigText);
|
||||
final Dim2i fontConfigButtonDim = new Dim2i(tabFrameDim.getLimitX() - size - 12 - cumulativeXShift, tabFrameDim.getOriginY() - 26, 12 + size, 20);
|
||||
cumulativeXShift += size + 14;
|
||||
|
||||
final FlatButtonWidget fontConfigButton = new FlatButtonWidget(fontConfigButtonDim, fontConfigText, () -> mc.displayGuiScreen(new FontConfigScreen(this)));
|
||||
basicFrameBuilder.addChild(dim -> fontConfigButton);
|
||||
}
|
||||
|
||||
Dim2i searchTextFieldDim = new Dim2i(tabFrameDim.getOriginX(), tabFrameDim.getOriginY() - 26, tabFrameDim.getWidth() - cumulativeXShift, 20);
|
||||
this.searchTextField = new SearchTextFieldComponent(searchTextFieldDim, this.pages, tabFrameSelectedTab,
|
||||
tabFrameScrollBarOffset, optionPageScrollBarOffset, tabFrameDim.getHeight(), this, lastSearch, lastSearchIndex);
|
||||
|
||||
|
||||
+2
-1
@@ -47,7 +47,8 @@ public class TabFrame extends AbstractFrame {
|
||||
this.tabSectionSelectedTab = tabSectionSelectedTab;
|
||||
|
||||
if (this.tabSectionSelectedTab.get() != null) {
|
||||
this.selectedTab = this.tabs.stream().filter(tab -> tab.getTitle().equals(this.tabSectionSelectedTab.get())).findAny().get();
|
||||
Optional<Tab<?>> possibleLastTab = this.tabs.stream().filter(tab -> tab.getTitle().equals(this.tabSectionSelectedTab.get())).findAny();
|
||||
possibleLastTab.ifPresent(tab -> this.selectedTab = tab);
|
||||
}
|
||||
|
||||
this.buildFrame();
|
||||
|
||||
@@ -397,9 +397,9 @@ public class SodiumGameOptionPages {
|
||||
.add(OptionImpl.createBuilder(int.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.itemdisplaylistcount"))
|
||||
.setTooltip(I18n.format("options.angelica.itemdisplaylistcount.tooltip"))
|
||||
.setControl(o -> new SliderControl(o, 0, 1024, 1, ControlValueFormatter.number()))
|
||||
.setControl(o -> new SliderControl(o, 256, 1024, 16, ControlValueFormatter.number()))
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> AngelicaConfig.itemRendererDisplayListCacheSize = value, options -> AngelicaConfig.itemRendererDisplayListCacheSize)
|
||||
.setBinding((opts, value) -> AngelicaConfig.itemRendererCacheSize = value, options -> AngelicaConfig.itemRendererCacheSize)
|
||||
.build()
|
||||
)
|
||||
.build());
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Light pipelines allow model quads for any location in the world to be lit using various backends, including fluids
|
||||
@@ -18,5 +18,5 @@ public interface LightPipeline {
|
||||
* @param face The pre-computed facing vector of the quad
|
||||
* @param shade True if the block is shaded by ambient occlusion
|
||||
*/
|
||||
void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade);
|
||||
void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ModelQuadFacing cullFace, ModelQuadFacing face, boolean shade);
|
||||
}
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.data;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import me.jellysquid.mods.sodium.client.util.StateUtil;
|
||||
import me.jellysquid.mods.sodium.client.world.WorldSlice;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* The light data cache is used to make accessing the light data and occlusion properties of blocks cheaper. The data
|
||||
@@ -26,15 +26,15 @@ public abstract class LightDataAccess {
|
||||
public static final ThreadLocal<BlockPos> DynamicLightsPos = ThreadLocal.withInitial(BlockPos::new);
|
||||
protected WorldSlice world;
|
||||
|
||||
public long get(int x, int y, int z, ForgeDirection d1, ForgeDirection d2) {
|
||||
return this.get(x + d1.offsetX + d2.offsetX, y + d1.offsetY + d2.offsetY, z + d1.offsetZ + d2.offsetZ);
|
||||
public long get(int x, int y, int z, ModelQuadFacing d1, ModelQuadFacing d2) {
|
||||
return this.get(x + d1.getStepX() + d2.getStepX(), y + d1.getStepY() + d2.getStepY(), z + d1.getStepZ() + d2.getStepZ());
|
||||
}
|
||||
|
||||
public long get(int x, int y, int z, ForgeDirection dir) {
|
||||
return this.get(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
||||
public long get(int x, int y, int z, ModelQuadFacing dir) {
|
||||
return this.get(x + dir.getStepX(), y + dir.getStepY(), z + dir.getStepZ());
|
||||
}
|
||||
|
||||
public long get(BlockPos pos, ForgeDirection dir) {
|
||||
public long get(BlockPos pos, ModelQuadFacing dir) {
|
||||
return this.get(pos.x, pos.y, pos.z, dir);
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -1,17 +1,17 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.flat;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import java.util.Arrays;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A light pipeline which implements "classic-style" lighting through simply using the light value of the adjacent
|
||||
* block to a face.
|
||||
@@ -27,7 +27,7 @@ public class FlatLightPipeline implements LightPipeline {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade) {
|
||||
public void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ModelQuadFacing cullFace, ModelQuadFacing face, boolean shade) {
|
||||
int lightmap;
|
||||
|
||||
// To match vanilla behavior, use the cull face if it exists/is available
|
||||
@@ -57,7 +57,7 @@ public class FlatLightPipeline implements LightPipeline {
|
||||
* behind tinted glass. {@link LightDataAccess} cannot efficiently store lightmaps computed with
|
||||
* inconsistent values so this method exists to mirror vanilla behavior as closely as possible.
|
||||
*/
|
||||
private int getOffsetLightmap(BlockPos pos, ForgeDirection face) {
|
||||
private int getOffsetLightmap(BlockPos pos, ModelQuadFacing face) {
|
||||
int lightmap = LightDataAccess.getLightMap(this.lightCache.get(pos, face));
|
||||
// If the block light is not 15 (max)...
|
||||
if ((lightmap & 0xF0) != 0xF0) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.smooth;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.getLightMap;
|
||||
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.unpackAO;
|
||||
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.unpackFO;
|
||||
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.unpackOP;
|
||||
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.getLightMap;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
|
||||
|
||||
class AoFaceData {
|
||||
public final int[] lm = new int[4];
|
||||
@@ -18,7 +18,7 @@ class AoFaceData {
|
||||
|
||||
private int flags;
|
||||
|
||||
public void initLightData(LightDataAccess cache, BlockPos pos, ForgeDirection direction, boolean offset) {
|
||||
public void initLightData(LightDataAccess cache, BlockPos pos, ModelQuadFacing direction, boolean offset) {
|
||||
final int x = pos.x;
|
||||
final int y = pos.y;
|
||||
final int z = pos.z;
|
||||
@@ -28,9 +28,9 @@ class AoFaceData {
|
||||
final int adjZ;
|
||||
|
||||
if (offset) {
|
||||
adjX = x + direction.offsetX;
|
||||
adjY = y + direction.offsetY;
|
||||
adjZ = z + direction.offsetZ;
|
||||
adjX = x + direction.getStepX();
|
||||
adjY = y + direction.getStepY();
|
||||
adjZ = z + direction.getStepZ();
|
||||
} else {
|
||||
adjX = x;
|
||||
adjY = y;
|
||||
@@ -50,7 +50,7 @@ class AoFaceData {
|
||||
|
||||
final float caao = unpackAO(adjWord);
|
||||
|
||||
ForgeDirection[] faces = AoNeighborInfo.get(direction).faces;
|
||||
var faces = AoNeighborInfo.get(direction).faces;
|
||||
|
||||
final long e0 = cache.get(adjX, adjY, adjZ, faces[0]);
|
||||
final int e0lm = getLightMap(e0);
|
||||
|
||||
+67
-59
@@ -1,17 +1,25 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.smooth;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.NEG_X;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.NEG_Y;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.NEG_Z;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.POS_X;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.POS_Y;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.POS_Z;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* The neighbor information for each face of a block, used when performing smooth lighting in order to calculate
|
||||
* the occlusion of each corner.
|
||||
*/
|
||||
enum AoNeighborInfo {
|
||||
DOWN(new ForgeDirection[] { ForgeDirection.WEST, ForgeDirection.EAST, ForgeDirection.NORTH, ForgeDirection.SOUTH }, 0.5F) {
|
||||
EAST(new ModelQuadFacing[] { NEG_Y, POS_Y, NEG_Z, POS_Z }, 0.6F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = z;
|
||||
final float v = 1.0f - x;
|
||||
final float v = 1.0f - y;
|
||||
|
||||
out[0] = v * u;
|
||||
out[1] = v * (1.0f - u);
|
||||
@@ -21,23 +29,23 @@ enum AoNeighborInfo {
|
||||
|
||||
@Override
|
||||
public void mapCorners(int[] lm0, float[] ao0, int[] lm1, float[] ao1) {
|
||||
lm1[0] = lm0[0];
|
||||
lm1[1] = lm0[1];
|
||||
lm1[2] = lm0[2];
|
||||
lm1[3] = lm0[3];
|
||||
lm1[1] = lm0[0];
|
||||
lm1[2] = lm0[1];
|
||||
lm1[3] = lm0[2];
|
||||
lm1[0] = lm0[3];
|
||||
|
||||
ao1[0] = ao0[0];
|
||||
ao1[1] = ao0[1];
|
||||
ao1[2] = ao0[2];
|
||||
ao1[3] = ao0[3];
|
||||
ao1[1] = ao0[0];
|
||||
ao1[2] = ao0[1];
|
||||
ao1[3] = ao0[2];
|
||||
ao1[0] = ao0[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return y;
|
||||
return 1.0f - x;
|
||||
}
|
||||
},
|
||||
UP(new ForgeDirection[] { ForgeDirection.EAST, ForgeDirection.WEST, ForgeDirection.NORTH, ForgeDirection.SOUTH }, 1.0F) {
|
||||
UP(new ModelQuadFacing[] { POS_X, NEG_X, NEG_Z, POS_Z }, 1.0F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = z;
|
||||
@@ -67,37 +75,7 @@ enum AoNeighborInfo {
|
||||
return 1.0f - y;
|
||||
}
|
||||
},
|
||||
NORTH(new ForgeDirection[] { ForgeDirection.UP, ForgeDirection.DOWN, ForgeDirection.EAST, ForgeDirection.WEST }, 0.8F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = 1.0f - x;
|
||||
final float v = y;
|
||||
|
||||
out[0] = v * u;
|
||||
out[1] = v * (1.0f - u);
|
||||
out[2] = (1.0f - v) * (1.0f - u);
|
||||
out[3] = (1.0f - v) * u;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapCorners(int[] lm0, float[] ao0, int[] lm1, float[] ao1) {
|
||||
lm1[3] = lm0[0];
|
||||
lm1[0] = lm0[1];
|
||||
lm1[1] = lm0[2];
|
||||
lm1[2] = lm0[3];
|
||||
|
||||
ao1[3] = ao0[0];
|
||||
ao1[0] = ao0[1];
|
||||
ao1[1] = ao0[2];
|
||||
ao1[2] = ao0[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return z;
|
||||
}
|
||||
},
|
||||
SOUTH(new ForgeDirection[] { ForgeDirection.WEST, ForgeDirection.EAST, ForgeDirection.DOWN, ForgeDirection.UP }, 0.8F) {
|
||||
SOUTH(new ModelQuadFacing[] { NEG_X, POS_X, NEG_Y, POS_Y }, 0.8F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = y;
|
||||
@@ -127,7 +105,7 @@ enum AoNeighborInfo {
|
||||
return 1.0f - z;
|
||||
}
|
||||
},
|
||||
WEST(new ForgeDirection[] { ForgeDirection.UP, ForgeDirection.DOWN, ForgeDirection.NORTH, ForgeDirection.SOUTH }, 0.6F) {
|
||||
WEST(new ModelQuadFacing[] { POS_Y, NEG_Y, NEG_Z, POS_Z }, 0.6F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = z;
|
||||
@@ -157,11 +135,11 @@ enum AoNeighborInfo {
|
||||
return x;
|
||||
}
|
||||
},
|
||||
EAST(new ForgeDirection[] { ForgeDirection.DOWN, ForgeDirection.UP, ForgeDirection.NORTH, ForgeDirection.SOUTH }, 0.6F) {
|
||||
DOWN(new ModelQuadFacing[] { NEG_X, POS_X, NEG_Z, POS_Z }, 0.5F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = z;
|
||||
final float v = 1.0f - y;
|
||||
final float v = 1.0f - x;
|
||||
|
||||
out[0] = v * u;
|
||||
out[1] = v * (1.0f - u);
|
||||
@@ -171,20 +149,50 @@ enum AoNeighborInfo {
|
||||
|
||||
@Override
|
||||
public void mapCorners(int[] lm0, float[] ao0, int[] lm1, float[] ao1) {
|
||||
lm1[1] = lm0[0];
|
||||
lm1[2] = lm0[1];
|
||||
lm1[3] = lm0[2];
|
||||
lm1[0] = lm0[3];
|
||||
lm1[0] = lm0[0];
|
||||
lm1[1] = lm0[1];
|
||||
lm1[2] = lm0[2];
|
||||
lm1[3] = lm0[3];
|
||||
|
||||
ao1[1] = ao0[0];
|
||||
ao1[2] = ao0[1];
|
||||
ao1[3] = ao0[2];
|
||||
ao1[0] = ao0[3];
|
||||
ao1[0] = ao0[0];
|
||||
ao1[1] = ao0[1];
|
||||
ao1[2] = ao0[2];
|
||||
ao1[3] = ao0[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return 1.0f - x;
|
||||
return y;
|
||||
}
|
||||
},
|
||||
NORTH(new ModelQuadFacing[] { POS_Y, NEG_Y, POS_X, NEG_X }, 0.8F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = 1.0f - x;
|
||||
final float v = y;
|
||||
|
||||
out[0] = v * u;
|
||||
out[1] = v * (1.0f - u);
|
||||
out[2] = (1.0f - v) * (1.0f - u);
|
||||
out[3] = (1.0f - v) * u;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapCorners(int[] lm0, float[] ao0, int[] lm1, float[] ao1) {
|
||||
lm1[3] = lm0[0];
|
||||
lm1[0] = lm0[1];
|
||||
lm1[1] = lm0[2];
|
||||
lm1[2] = lm0[3];
|
||||
|
||||
ao1[3] = ao0[0];
|
||||
ao1[0] = ao0[1];
|
||||
ao1[1] = ao0[2];
|
||||
ao1[2] = ao0[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return z;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -192,7 +200,7 @@ enum AoNeighborInfo {
|
||||
* The direction of each corner block from this face, which can be retrieved by offsetting the position of the origin
|
||||
* block by the direction vector.
|
||||
*/
|
||||
public final ForgeDirection[] faces;
|
||||
public final ModelQuadFacing[] faces;
|
||||
|
||||
/**
|
||||
* The constant brightness modifier for this face. This data exists to emulate the results of the OpenGL lighting
|
||||
@@ -200,7 +208,7 @@ enum AoNeighborInfo {
|
||||
*/
|
||||
public final float strength;
|
||||
|
||||
AoNeighborInfo(ForgeDirection[] directions, float strength) {
|
||||
AoNeighborInfo(ModelQuadFacing[] directions, float strength) {
|
||||
this.faces = directions;
|
||||
this.strength = strength;
|
||||
}
|
||||
@@ -243,7 +251,7 @@ enum AoNeighborInfo {
|
||||
/**
|
||||
* @return Returns the {@link AoNeighborInfo} which corresponds with the specified direction
|
||||
*/
|
||||
public static AoNeighborInfo get(ForgeDirection direction) {
|
||||
public static AoNeighborInfo get(@NotNull ModelQuadFacing direction) {
|
||||
return VALUES[direction.ordinal()];
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -2,14 +2,14 @@ package me.jellysquid.mods.sodium.client.model.light.smooth;
|
||||
|
||||
import com.google.common.math.DoubleMath;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade) {
|
||||
public void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ModelQuadFacing cullFace, ModelQuadFacing face, boolean shade) {
|
||||
this.updateCachedData(pos.asLong());
|
||||
|
||||
final int flags = quad.getFlags();
|
||||
@@ -107,7 +107,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
* have two contributing sides.
|
||||
* Flags: IS_ALIGNED, !IS_PARTIAL
|
||||
*/
|
||||
private void applyAlignedFullFace(AoNeighborInfo neighborInfo, BlockPos pos, ForgeDirection dir, QuadLightData out) {
|
||||
private void applyAlignedFullFace(AoNeighborInfo neighborInfo, BlockPos pos, ModelQuadFacing dir, QuadLightData out) {
|
||||
final AoFaceData faceData = this.getCachedFaceData(pos, dir, true);
|
||||
neighborInfo.mapCorners(faceData.lm, faceData.ao, out.lm, out.br);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
* Calculates the light data for a grid-aligned quad that does not cover the entire block volume's face.
|
||||
* Flags: IS_ALIGNED, IS_PARTIAL
|
||||
*/
|
||||
private void applyAlignedPartialFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ForgeDirection dir, QuadLightData out) {
|
||||
private void applyAlignedPartialFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ModelQuadFacing dir, QuadLightData out) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting
|
||||
final float cx = clamp(quad.getX(i));
|
||||
@@ -130,13 +130,13 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is the same as {@link #applyNonParallelFace(AoNeighborInfo, ModelQuadView, BlockPos, ForgeDirection,
|
||||
* This method is the same as {@link #applyNonParallelFace(AoNeighborInfo, ModelQuadView, BlockPos, ModelQuadFacing,
|
||||
* QuadLightData)} but with the check for a depth of approximately 0 removed. If the quad is parallel but not
|
||||
* aligned, all of its vertices will have the same depth and this depth must be approximately greater than 0,
|
||||
* meaning the check for 0 will always return false.
|
||||
* Flags: !IS_ALIGNED, IS_PARALLEL
|
||||
*/
|
||||
private void applyParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ForgeDirection dir, QuadLightData out) {
|
||||
private void applyParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ModelQuadFacing dir, QuadLightData out) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting
|
||||
final float cx = clamp(quad.getX(i));
|
||||
@@ -163,7 +163,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
/**
|
||||
* Flags: !IS_ALIGNED, !IS_PARALLEL
|
||||
*/
|
||||
private void applyNonParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ForgeDirection dir, QuadLightData out) {
|
||||
private void applyNonParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ModelQuadFacing dir, QuadLightData out) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting
|
||||
final float cx = clamp(quad.getX(i));
|
||||
@@ -188,7 +188,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
private void applyAlignedPartialFaceVertex(BlockPos pos, ForgeDirection dir, float[] w, int i, QuadLightData out, boolean offset) {
|
||||
private void applyAlignedPartialFaceVertex(BlockPos pos, ModelQuadFacing dir, float[] w, int i, QuadLightData out, boolean offset) {
|
||||
final AoFaceData faceData = this.getCachedFaceData(pos, dir, offset);
|
||||
|
||||
if (!faceData.hasUnpackedLightData()) {
|
||||
@@ -203,7 +203,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
out.lm[i] = getLightMapCoord(sl, bl);
|
||||
}
|
||||
|
||||
private void applyInsetPartialFaceVertex(BlockPos pos, ForgeDirection dir, float n1d, float n2d, float[] w, int i, QuadLightData out) {
|
||||
private void applyInsetPartialFaceVertex(BlockPos pos, ModelQuadFacing dir, float n1d, float n2d, float[] w, int i, QuadLightData out) {
|
||||
final AoFaceData n1 = this.getCachedFaceData(pos, dir, false);
|
||||
|
||||
if (!n1.hasUnpackedLightData()) {
|
||||
@@ -225,7 +225,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
out.lm[i] = getLightMapCoord(sl, bl);
|
||||
}
|
||||
|
||||
private void applySidedBrightness(QuadLightData out, ForgeDirection face, boolean shade) {
|
||||
private void applySidedBrightness(QuadLightData out, ModelQuadFacing face, boolean shade) {
|
||||
if(AngelicaConfig.enableIris && BlockRenderingSettings.INSTANCE.shouldDisableDirectionalShading()) {
|
||||
return;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
/**
|
||||
* Returns the cached data for a given facing or calculates it if it hasn't been cached.
|
||||
*/
|
||||
private AoFaceData getCachedFaceData(BlockPos pos, ForgeDirection face, boolean offset) {
|
||||
private AoFaceData getCachedFaceData(BlockPos pos, ModelQuadFacing face, boolean offset) {
|
||||
|
||||
final AoFaceData data = this.cachedFaceData[offset ? face.ordinal() : face.ordinal() + 6];
|
||||
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.writer;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorABGR;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.fallback.VertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
|
||||
public class GlyphVertexWriterFallback extends VertexWriterFallback implements GlyphVertexSink {
|
||||
|
||||
-27
@@ -3,35 +3,8 @@ package me.jellysquid.mods.sodium.client.model.vertex.formats.line;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
public interface LineVertexSink extends VertexSink {
|
||||
VertexFormat VERTEX_FORMAT = DefaultVertexFormat.POSITION_COLOR;
|
||||
|
||||
/**
|
||||
* Writes a line vertex to the sink.
|
||||
*
|
||||
* @param x The x-position of the vertex
|
||||
* @param y The y-position of the vertex
|
||||
* @param z The z-position of the vertex
|
||||
* @param color The ABGR-packed color of the vertex
|
||||
*/
|
||||
void vertexLine(float x, float y, float z, int color);
|
||||
|
||||
/**
|
||||
* Writes a line vertex to the sink using unpacked normalized colors. This is slower than
|
||||
* {@link LineVertexSink#vertexLine(float, float, float, int)} as it needs to pack the colors
|
||||
* each call.
|
||||
*
|
||||
* @param x The x-position of the vertex
|
||||
* @param y The y-position of the vertex
|
||||
* @param z The z-position of the vertex
|
||||
* @param r The normalized red component of the vertex's color
|
||||
* @param g The normalized green component of the vertex's color
|
||||
* @param b The normalized blue component of the vertex's color
|
||||
* @param a The normalized alpha component of the vertex's color
|
||||
*/
|
||||
default void vertexLine(float x, float y, float z, float r, float g, float b, float a) {
|
||||
this.vertexLine(x, y, z, ColorABGR.pack(r, g, b, a));
|
||||
}
|
||||
}
|
||||
-14
@@ -5,23 +5,9 @@ import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.line.LineVertexSink;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class LineVertexBufferWriterNio extends VertexBufferWriterNio implements LineVertexSink {
|
||||
public LineVertexBufferWriterNio(VertexBufferView backingBuffer) {
|
||||
super(backingBuffer, VanillaVertexTypes.LINES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vertexLine(float x, float y, float z, int color) {
|
||||
int i = this.writeOffset;
|
||||
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
buffer.putFloat(i, x);
|
||||
buffer.putFloat(i + 4, y);
|
||||
buffer.putFloat(i + 8, z);
|
||||
buffer.putInt(i + 12, color);
|
||||
|
||||
this.advance();
|
||||
}
|
||||
}
|
||||
-13
@@ -1,7 +1,5 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.line.writer;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VanillaVertexTypes;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
|
||||
@@ -12,15 +10,4 @@ public class LineVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe imple
|
||||
super(backingBuffer, VanillaVertexTypes.LINES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vertexLine(float x, float y, float z, int color) {
|
||||
long i = this.writePointer;
|
||||
|
||||
memPutFloat(i, x);
|
||||
memPutFloat(i + 4, y);
|
||||
memPutFloat(i + 8, z);
|
||||
memPutInt(i + 12, color);
|
||||
|
||||
this.advance();
|
||||
}
|
||||
}
|
||||
-8
@@ -3,7 +3,6 @@ package me.jellysquid.mods.sodium.client.model.vertex.formats.line.writer;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.fallback.VertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.line.LineVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
|
||||
public class LineVertexWriterFallback extends VertexWriterFallback implements LineVertexSink {
|
||||
@@ -11,11 +10,4 @@ public class LineVertexWriterFallback extends VertexWriterFallback implements Li
|
||||
super(consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vertexLine(float x, float y, float z, int color) {
|
||||
VertexConsumer consumer = this.consumer;
|
||||
consumer.vertex(x, y, z);
|
||||
consumer.color(ColorABGR.unpackRed(color), ColorABGR.unpackGreen(color), ColorABGR.unpackBlue(color), ColorABGR.unpackAlpha(color));
|
||||
consumer.next();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.particle.writer;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorABGR;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.fallback.VertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.particle.ParticleVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
|
||||
public class ParticleVertexWriterFallback extends VertexWriterFallback implements ParticleVertexSink {
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.quad.writer;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorABGR;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.fallback.VertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.Norm3b;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
|
||||
public class QuadVertexWriterFallback extends VertexWriterFallback implements QuadVertexSink {
|
||||
@@ -20,7 +20,7 @@ public class QuadVertexWriterFallback extends VertexWriterFallback implements Qu
|
||||
consumer.texture(u, v);
|
||||
consumer.overlay(overlay);
|
||||
consumer.light(light);
|
||||
consumer.normal(Norm3b.unpackX(normal), Norm3b.unpackY(normal), Norm3b.unpackZ(normal));
|
||||
consumer.normal(NormI8.unpackX(normal), NormI8.unpackY(normal), NormI8.unpackZ(normal));
|
||||
consumer.next();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad.writer;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorABGR;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.fallback.VertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad.BasicScreenQuadVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
|
||||
public class BasicScreenQuadVertexWriterFallback extends VertexWriterFallback implements BasicScreenQuadVertexSink {
|
||||
|
||||
@@ -259,6 +259,7 @@ public class SodiumWorldRenderer {
|
||||
if(AngelicaConfig.enableIris) {
|
||||
if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) {
|
||||
ShadowRenderer.visibleTileEntities.addAll(this.chunkRenderManager.getVisibleTileEntities());
|
||||
ShadowRenderer.globalTileEntities.addAll(this.globalTileEntities);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,7 +377,7 @@ public class SodiumWorldRenderer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void renderTileEntities(EntityLivingBase entity, ICamera camera, float partialTicks) {
|
||||
final int pass = MinecraftForgeClient.getRenderPass();
|
||||
for (TileEntity tileEntity : this.chunkRenderManager.getVisibleTileEntities()) {
|
||||
@@ -390,7 +391,7 @@ public class SodiumWorldRenderer {
|
||||
|
||||
public void onChunkRenderUpdated(int x, int y, int z, ChunkRenderData meshBefore, ChunkRenderData meshAfter) {
|
||||
ListUtil.updateList(this.globalTileEntities, meshBefore.getGlobalTileEntities(), meshAfter.getGlobalTileEntities());
|
||||
|
||||
|
||||
this.chunkRenderManager.onChunkRenderUpdates(x, y, z, meshAfter);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.DirectionUtil;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.HORIZONTAL_DIRECTIONS;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.NEG_X;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.NEG_Z;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.POS_X;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.POS_Z;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class ChunkRenderColumn<T extends ChunkGraphicsState> {
|
||||
@@ -48,7 +53,7 @@ public class ChunkRenderColumn<T extends ChunkGraphicsState> {
|
||||
}
|
||||
|
||||
public boolean areNeighborsPresent() {
|
||||
for (ForgeDirection dir : DirectionUtil.HORIZONTAL_DIRECTIONS) {
|
||||
for (var dir : HORIZONTAL_DIRECTIONS) {
|
||||
ChunkRenderColumn<T> adj = this.adjacent[dir.ordinal()];
|
||||
|
||||
if (adj == null) {
|
||||
@@ -58,13 +63,13 @@ public class ChunkRenderColumn<T extends ChunkGraphicsState> {
|
||||
ForgeDirection corner;
|
||||
|
||||
// Access the adjacent corner chunk from the neighbor in this direction
|
||||
if (dir == ForgeDirection.NORTH) {
|
||||
if (dir == NEG_Z) {
|
||||
corner = ForgeDirection.EAST;
|
||||
} else if (dir == ForgeDirection.SOUTH) {
|
||||
} else if (dir == POS_Z) {
|
||||
corner = ForgeDirection.WEST;
|
||||
} else if (dir == ForgeDirection.WEST) {
|
||||
} else if (dir == NEG_X) {
|
||||
corner = ForgeDirection.NORTH;
|
||||
} else if (dir == ForgeDirection.EAST) {
|
||||
} else if (dir == POS_X) {
|
||||
corner = ForgeDirection.SOUTH;
|
||||
} else {
|
||||
continue;
|
||||
|
||||
@@ -352,12 +352,9 @@ public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkSt
|
||||
|
||||
private void addEntitiesToRenderLists(ChunkRenderContainer<T> render) {
|
||||
Collection<TileEntity> tileEntities = render.getData().getTileEntities();
|
||||
|
||||
if (!tileEntities.isEmpty()) {
|
||||
this.visibleTileEntities.addAll(tileEntities);
|
||||
}
|
||||
this.visibleTileEntities.addAll(tileEntities);
|
||||
}
|
||||
|
||||
|
||||
public ChunkRenderContainer<T> getRender(int x, int y, int z) {
|
||||
ChunkRenderColumn<T> column = this.columns.get(ChunkPos.toLong(x, z));
|
||||
|
||||
|
||||
+9
-10
@@ -1,9 +1,17 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayFIFOQueue;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Setter;
|
||||
import me.jellysquid.mods.sodium.client.gl.arena.GlBufferArena;
|
||||
import me.jellysquid.mods.sodium.client.gl.arena.GlBufferSegment;
|
||||
@@ -42,15 +50,6 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.Util;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Shader-based chunk renderer which makes use of a custom memory allocator on top of large buffer objects to allow
|
||||
* for draw call batching without buffer switching.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.gl.arena.GlBufferSegment;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.CommandList;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.oneshot;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexAttributeBinding;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexFormat;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.oneshot;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.CommandList;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.DrawCommandList;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.RenderDevice;
|
||||
|
||||
+3
-4
@@ -1,8 +1,10 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.compile;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import me.jellysquid.mods.sodium.client.gl.buffer.VertexData;
|
||||
@@ -24,9 +26,6 @@ import net.coderbot.iris.sodium.block_context.ContextAwareVertexWriter;
|
||||
import net.minecraft.block.Block;
|
||||
import org.lwjgl.BufferUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A collection of temporary buffers for each worker thread which will be used to build chunk meshes for given render
|
||||
* passes. This makes a best-effort attempt to pick a suitable size for each scratch buffer, but will never try to
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.compile.buffers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.compile.buffers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.compile.buffers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
|
||||
|
||||
+7
-7
@@ -1,14 +1,14 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.cull;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
|
||||
public class ChunkFaceFlags {
|
||||
public static final int UP = of(ModelQuadFacing.UP);
|
||||
public static final int DOWN = of(ModelQuadFacing.DOWN);
|
||||
public static final int WEST = of(ModelQuadFacing.WEST);
|
||||
public static final int EAST = of(ModelQuadFacing.EAST);
|
||||
public static final int NORTH = of(ModelQuadFacing.NORTH);
|
||||
public static final int SOUTH = of(ModelQuadFacing.SOUTH);
|
||||
public static final int UP = of(ModelQuadFacing.POS_Y);
|
||||
public static final int DOWN = of(ModelQuadFacing.NEG_Y);
|
||||
public static final int WEST = of(ModelQuadFacing.NEG_X);
|
||||
public static final int EAST = of(ModelQuadFacing.POS_X);
|
||||
public static final int NORTH = of(ModelQuadFacing.NEG_Z);
|
||||
public static final int SOUTH = of(ModelQuadFacing.POS_Z);
|
||||
public static final int UNASSIGNED = of(ModelQuadFacing.UNASSIGNED);
|
||||
|
||||
public static final int ALL = all();
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.data;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.gl.buffer.VertexData;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import me.jellysquid.mods.sodium.client.gl.buffer.VertexData;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
|
||||
public class ChunkMeshData {
|
||||
public static final ChunkMeshData EMPTY = new ChunkMeshData();
|
||||
|
||||
+7
-8
@@ -1,17 +1,10 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.data;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkOcclusionData;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ISpriteExt;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
@@ -19,6 +12,12 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* The render data for a chunk render container containing all the information about which meshes are attached, the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.region;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import me.jellysquid.mods.sodium.client.gl.arena.GlBufferArena;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.CommandList;
|
||||
|
||||
+5
-6
@@ -1,7 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.tasks;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.WorldUtil;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkOcclusionDataBuilder;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
@@ -11,6 +10,9 @@ import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue;
|
||||
import com.gtnewhorizons.angelica.utils.AnimationsRenderUtils;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderContainer;
|
||||
@@ -21,6 +23,7 @@ import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkMeshData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderBounds;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import me.jellysquid.mods.sodium.client.render.pipeline.WorldUtil;
|
||||
import me.jellysquid.mods.sodium.client.render.pipeline.context.ChunkRenderCacheLocal;
|
||||
import me.jellysquid.mods.sodium.client.util.MathUtil;
|
||||
import me.jellysquid.mods.sodium.client.util.task.CancellationSource;
|
||||
@@ -40,10 +43,6 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* Rebuilds all the meshes of a chunk for each given render pass with non-occluded blocks. The result is then uploaded
|
||||
* to graphics memory on the main thread.
|
||||
@@ -186,7 +185,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
ChunkRenderManager.setWorldRenderPass(pass);
|
||||
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(fluid.getBlock(), ExtendedDataHelper.FLUID_RENDER_TYPE);
|
||||
|
||||
cache.getBlockRenderer().renderFluidLogged(fluid, renderBlocks, pos, buffers.get(pass), seed);
|
||||
cache.getBlockRenderer().renderFluidLogged(cache.getWorldSlice(), fluid, renderBlocks, pos, buffers.get(pass), seed);
|
||||
}
|
||||
}
|
||||
if (canRenderInPass(block, pass) && !shouldUseSodiumFluidRendering(block)) {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.tasks;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.gl.buffer.VertexData;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
|
||||
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
package me.jellysquid.mods.sodium.client.render.occlusion;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ByteLinkedOpenHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockOcclusionCache {
|
||||
private static final byte UNCACHED_VALUE = (byte) 127;
|
||||
@@ -25,12 +25,12 @@ public class BlockOcclusionCache {
|
||||
* @param facing The facing direction of the side to check
|
||||
* @return True if the block side facing {@param dir} is not occluded, otherwise false
|
||||
*/
|
||||
public boolean shouldDrawSide(Block block, int meta, IBlockAccess view, BlockPos pos, ForgeDirection facing) {
|
||||
if (facing == ForgeDirection.UNKNOWN)
|
||||
public boolean shouldDrawSide(Block block, int meta, IBlockAccess view, BlockPos pos, ModelQuadFacing facing) {
|
||||
if (facing == ModelQuadFacing.UNASSIGNED)
|
||||
return true;
|
||||
|
||||
final BlockPos adjPos = this.cpos;
|
||||
adjPos.set(pos.getX() + facing.offsetX, pos.getY() + facing.offsetY, pos.getZ() + facing.offsetZ);
|
||||
adjPos.set(pos.getX() + facing.getStepX(), pos.getY() + facing.getStepY(), pos.getZ() + facing.getStepZ());
|
||||
|
||||
final Block adjState = view.getBlock(adjPos.x, adjPos.y, adjPos.z);
|
||||
|
||||
|
||||
+39
-114
@@ -3,27 +3,23 @@ package me.jellysquid.mods.sodium.client.render.pipeline;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadProvider;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadOrientation;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.DirectionUtil;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorMixer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadViewMutable;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadOrientation;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.util.ModelQuadUtil;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ModeledBlock;
|
||||
import com.gtnewhorizons.angelica.utils.ObjectPooler;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightMode;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipelineProvider;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.Quad;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuffers;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.render.occlusion.BlockOcclusionCache;
|
||||
import me.jellysquid.mods.sodium.client.util.ModelQuadUtil;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
import me.jellysquid.mods.sodium.client.util.rand.XoRoShiRoRandom;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -31,12 +27,8 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockRenderer {
|
||||
private static final BlockPos POS_ZERO = new BlockPos(0, 0, 0);
|
||||
|
||||
@@ -49,10 +41,6 @@ public class BlockRenderer {
|
||||
private boolean useSeparateAo;
|
||||
|
||||
private final LightPipelineProvider lighters;
|
||||
private final BlockOcclusionCache occlusionCache;
|
||||
|
||||
private final ObjectPooler<QuadView> quadPool = new ObjectPooler<>(Quad::new);
|
||||
// TODO: Use modern model API, and store them here
|
||||
|
||||
|
||||
public BlockRenderer(LightPipelineProvider lighters) {
|
||||
@@ -60,10 +48,9 @@ public class BlockRenderer {
|
||||
// TODO: Sodium - AO Setting
|
||||
this.useAmbientOcclusion = Minecraft.getMinecraft().gameSettings.ambientOcclusion > 0;
|
||||
this.useSodiumAO = SodiumClientMod.options().quality.useSodiumAO;
|
||||
this.occlusionCache = new BlockOcclusionCache();
|
||||
}
|
||||
|
||||
public boolean renderFluidLogged(Fluid fluid, RenderBlocks renderBlocks, BlockPos pos, ChunkModelBuffers buffers, long seed) {
|
||||
public boolean renderFluidLogged(IBlockAccess world, Fluid fluid, RenderBlocks renderBlocks, BlockPos pos, ChunkModelBuffers buffers, long seed) {
|
||||
if (fluid == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -73,6 +60,7 @@ public class BlockRenderer {
|
||||
}
|
||||
|
||||
boolean rendered = false;
|
||||
final int emitted = block.getLightValue(world, pos.x, pos.y, pos.z);
|
||||
|
||||
try {
|
||||
final LightMode mode = LightMode.SMOOTH; // TODO: this.getLightingMode(block); is what was previously used. The flat pipeline is busted and was only an optimization for very few blocks.
|
||||
@@ -86,12 +74,12 @@ public class BlockRenderer {
|
||||
tess.setOffset(POS_ZERO);
|
||||
tess.setTranslation(-pos.x, -pos.y, -pos.z);
|
||||
renderBlocks.renderBlockByRenderType(block, pos.x, pos.y, pos.z);
|
||||
final List<QuadView> quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
final var quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
tess.resetOffset();
|
||||
|
||||
for (ModelQuadFacing facing : ModelQuadFacing.VALUES) {
|
||||
this.random.setSeed(seed);
|
||||
this.renderQuadList(pos, lighter, buffers, quads, facing, (this.useAmbientOcclusion && this.useSodiumAO));
|
||||
this.renderQuadList(pos, lighter, emitted, buffers, quads, facing, (this.useAmbientOcclusion && this.useSodiumAO));
|
||||
}
|
||||
|
||||
if (!quads.isEmpty()) rendered = true;
|
||||
@@ -110,60 +98,34 @@ public class BlockRenderer {
|
||||
boolean rendered = false;
|
||||
|
||||
this.useSeparateAo = AngelicaConfig.enableIris && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo();
|
||||
final int emitted = block.getLightValue(world, pos.x, pos.y, pos.z);
|
||||
|
||||
final QuadProvider model = ((ModeledBlock) block).getModel();
|
||||
|
||||
if (model != null) {
|
||||
|
||||
final int color = model.getColor(world, pos, block, meta, random);
|
||||
|
||||
for (ForgeDirection dir : DirectionUtil.ALL_DIRECTIONS) {
|
||||
try {
|
||||
TessellatorManager.startCapturing();
|
||||
final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
tess.startDrawingQuads();
|
||||
// Use setTranslation rather than setOffset so that the float data written to the internal buffer
|
||||
// is done in subchunk-relative coordinates
|
||||
tess.setOffset(POS_ZERO);
|
||||
tess.setTranslation(-pos.x, -pos.y, -pos.z);
|
||||
renderBlocks.renderBlockByRenderType(block, pos.x, pos.y, pos.z);
|
||||
final var quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
tess.resetOffset();
|
||||
|
||||
for (ModelQuadFacing facing : ModelQuadFacing.VALUES) {
|
||||
this.random.setSeed(seed);
|
||||
List<QuadView> quads;
|
||||
|
||||
if (!cull || this.occlusionCache.shouldDrawSide(block, meta, world, pos, dir)) {
|
||||
quads = model.getQuads(world, pos, block, meta, dir, random, color, this.quadPool::getInstance);
|
||||
if (quads.isEmpty()) continue;
|
||||
|
||||
this.renderQuadList(pos, lighter, buffers, quads, ModelQuadFacing.fromDirection(dir), true);
|
||||
rendered = true;
|
||||
|
||||
if (model.isDynamic())
|
||||
for (QuadView q : quads) this.quadPool.releaseInstance(q);
|
||||
}
|
||||
this.renderQuadList(pos, lighter, emitted, buffers, quads, facing, (this.useAmbientOcclusion && this.useSodiumAO));
|
||||
}
|
||||
} else {
|
||||
|
||||
try {
|
||||
TessellatorManager.startCapturing();
|
||||
final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
tess.startDrawingQuads();
|
||||
// Use setTranslation rather than setOffset so that the float data written to the internal buffer
|
||||
// is done in subchunk-relative coordinates
|
||||
tess.setOffset(POS_ZERO);
|
||||
tess.setTranslation(-pos.x, -pos.y, -pos.z);
|
||||
renderBlocks.renderBlockByRenderType(block, pos.x, pos.y, pos.z);
|
||||
final List<QuadView> quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
tess.resetOffset();
|
||||
|
||||
for (ModelQuadFacing facing : ModelQuadFacing.VALUES) {
|
||||
this.random.setSeed(seed);
|
||||
this.renderQuadList(pos, lighter, buffers, quads, facing, (this.useAmbientOcclusion && this.useSodiumAO));
|
||||
}
|
||||
|
||||
if (!quads.isEmpty()) rendered = true;
|
||||
} finally {
|
||||
TessellatorManager.cleanup();
|
||||
}
|
||||
if (!quads.isEmpty()) rendered = true;
|
||||
} finally {
|
||||
TessellatorManager.cleanup();
|
||||
}
|
||||
|
||||
return rendered;
|
||||
}
|
||||
|
||||
private void renderQuadList(BlockPos pos, LightPipeline lighter, ChunkModelBuffers buffers, List<QuadView> quads, ModelQuadFacing facing, boolean useSodiumLight) {
|
||||
final ForgeDirection cullFace = ModelQuadFacing.toDirection(facing);
|
||||
|
||||
private void renderQuadList(BlockPos pos, LightPipeline lighter, int emitted, ChunkModelBuffers buffers, List<ModelQuadViewMutable> quads, ModelQuadFacing facing, boolean useSodiumLight) {
|
||||
final ModelVertexSink sink = buffers.getSink(facing);
|
||||
sink.ensureCapacity(quads.size() * 4);
|
||||
|
||||
@@ -172,25 +134,25 @@ public class BlockRenderer {
|
||||
// This is a very hot allocation, iterate over it manually
|
||||
// noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0, quadsSize = quads.size(); i < quadsSize; i++) {
|
||||
final QuadView quad = quads.get(i);
|
||||
final var quad = quads.get(i);
|
||||
|
||||
final QuadLightData light = this.cachedQuadLightData;
|
||||
|
||||
if (quad.getFace() != cullFace)
|
||||
if (quad.getNormalFace() != facing)
|
||||
continue;
|
||||
|
||||
if (useSodiumLight || this.useSeparateAo)
|
||||
lighter.calculate(quad, pos, light, cullFace, quad.getLightFace(), quad.isShade());
|
||||
lighter.calculate(quad, pos, light, facing, quad.getLightFace(), quad.hasAmbientOcclusion());
|
||||
|
||||
this.renderQuad(sink, quad, light, renderData, useSodiumLight);
|
||||
this.renderQuad(sink, quad, emitted, light, renderData, useSodiumLight);
|
||||
}
|
||||
|
||||
sink.flush();
|
||||
}
|
||||
|
||||
private void renderQuad(ModelVertexSink sink, QuadView quad, QuadLightData light, ChunkRenderData.Builder renderData, boolean useSodiumLight) {
|
||||
private void renderQuad(ModelVertexSink sink, ModelQuadView quad, int emitted, QuadLightData light, ChunkRenderData.Builder renderData, boolean useSodiumLight) {
|
||||
|
||||
final ModelQuadOrientation order = (useSodiumLight || this.useSeparateAo) ? ModelQuadOrientation.orient(light.br) : ModelQuadOrientation.NORMAL;
|
||||
final ModelQuadOrientation order = (useSodiumLight || this.useSeparateAo) ? ModelQuadOrientation.orientByBrightness(light.br, light.lm) : ModelQuadOrientation.NORMAL;
|
||||
|
||||
int shaderBlockId = quad.getShaderBlockId();
|
||||
for (int dstIndex = 0; dstIndex < 4; dstIndex++) {
|
||||
@@ -207,60 +169,23 @@ public class BlockRenderer {
|
||||
color |= ((int) (ao * 255.0f)) << 24;
|
||||
} else {
|
||||
|
||||
color = (useSodiumLight) ? ColorABGR.mul(quad.getColor(srcIndex), light.br[srcIndex]) : quad.getColor(srcIndex);
|
||||
color = (useSodiumLight) ? ColorMixer.mulSingleWithoutAlpha(quad.getColor(srcIndex), (int)(light.br[srcIndex] * 255)) : quad.getColor(srcIndex);
|
||||
}
|
||||
|
||||
final float u = quad.getTexU(srcIndex);
|
||||
final float v = quad.getTexV(srcIndex);
|
||||
|
||||
final int lm = (useSeparateAo) ? ModelQuadUtil.mergeBakedLight(quad.getLight(srcIndex), light.lm[srcIndex]) :
|
||||
final int lm = (useSeparateAo) ? ModelQuadUtil.mergeBakedLight(quad.getLight(srcIndex), emitted, light.lm[srcIndex]) :
|
||||
(useSodiumLight) ? light.lm[srcIndex] : quad.getLight(srcIndex);
|
||||
|
||||
sink.writeQuad(x, y, z, color, u, v, lm, shaderBlockId);
|
||||
}
|
||||
|
||||
final TextureAtlasSprite sprite = quad.rubidium$getSprite();
|
||||
final TextureAtlasSprite sprite = (TextureAtlasSprite) quad.celeritas$getSprite();
|
||||
|
||||
if (sprite != null) {
|
||||
renderData.addSprite(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Flags {
|
||||
boolean hasTexture;
|
||||
public boolean hasBrightness;
|
||||
public boolean hasColor;
|
||||
public boolean hasNormals;
|
||||
|
||||
public Flags(byte flags) {
|
||||
hasTexture = (flags & 1) != 0;
|
||||
hasBrightness = (flags & 2) != 0;
|
||||
hasColor = (flags & 4) != 0;
|
||||
hasNormals = (flags & 8) != 0;
|
||||
}
|
||||
|
||||
public Flags(boolean hasTexture, boolean hasBrightness, boolean hasColor, boolean hasNormals) {
|
||||
this.hasTexture = hasTexture;
|
||||
this.hasBrightness = hasBrightness;
|
||||
this.hasColor = hasColor;
|
||||
this.hasNormals = hasNormals;
|
||||
}
|
||||
|
||||
public byte toByte() {
|
||||
byte flags = 0;
|
||||
if(hasTexture) {
|
||||
flags |= 1;
|
||||
}
|
||||
if(hasBrightness) {
|
||||
flags |= 2;
|
||||
}
|
||||
if(hasColor) {
|
||||
flags |= 4;
|
||||
}
|
||||
if(hasNormals) {
|
||||
flags |= 8;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,27 @@
|
||||
package me.jellysquid.mods.sodium.client.render.pipeline;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.HORIZONTAL_DIRECTIONS;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.NEG_Y;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.POS_Y;
|
||||
import static org.joml.Math.lerp;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuad;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadViewMutable;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.DirectionUtil;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.WorldUtil;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorARGB;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorMixer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuad;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadViewMutable;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import java.util.Arrays;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightMode;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipelineProvider;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuffers;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.Norm3b;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorARGB;
|
||||
import me.jellysquid.mods.sodium.client.world.WorldSlice;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -29,10 +33,6 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.joml.Math.lerp;
|
||||
|
||||
public class FluidRenderer {
|
||||
private static final float EPSILON = 0.001f;
|
||||
private final LightPipelineProvider lpp;
|
||||
@@ -48,10 +48,10 @@ public class FluidRenderer {
|
||||
private final TextureAtlasSprite missingTex = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:missing");
|
||||
|
||||
public FluidRenderer(LightPipelineProvider lpp) {
|
||||
int normal = Norm3b.pack(0.0f, 1.0f, 0.0f);
|
||||
int normal = NormI8.pack(0.0f, 1.0f, 0.0f);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
this.quad.setNormal(i, normal);
|
||||
this.quad.setForgeNormal(i, normal);
|
||||
}
|
||||
|
||||
this.lpp = lpp;
|
||||
@@ -69,8 +69,8 @@ public class FluidRenderer {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private boolean isSideExposed(IBlockAccess world, int x, int y, int z, ForgeDirection dir, float height) {
|
||||
BlockPos pos = this.scratchPos.set(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
||||
private boolean isSideExposed(IBlockAccess world, int x, int y, int z, ModelQuadFacing dir, float height) {
|
||||
BlockPos pos = this.scratchPos.set(x + dir.getStepX(), y + dir.getStepY(), z + dir.getStepZ());
|
||||
Block block = world.getBlock(pos.x, pos.y, pos.z);
|
||||
|
||||
if (block.getMaterial().isOpaque()) {
|
||||
@@ -79,7 +79,7 @@ public class FluidRenderer {
|
||||
// Hoist these checks to avoid allocating the shape below
|
||||
if (renderAsFullCube) {
|
||||
// The top face always be inset, so if the shape above is a full cube it can't possibly occlude
|
||||
return dir == ForgeDirection.UP;
|
||||
return dir == POS_Y;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class FluidRenderer {
|
||||
// Check for occluded sides; if everything is occluded, don't render
|
||||
boolean sfUp = this.isFluidOccluded(world, posX, posY, posZ, ForgeDirection.UP, fluid);
|
||||
boolean sfDown = this.isFluidOccluded(world, posX, posY, posZ, ForgeDirection.DOWN, fluid) ||
|
||||
!this.isSideExposed(world, posX, posY, posZ, ForgeDirection.DOWN, 0.8888889F);
|
||||
!this.isSideExposed(world, posX, posY, posZ, NEG_Y, 0.8888889F);
|
||||
boolean sfNorth = this.isFluidOccluded(world, posX, posY, posZ, ForgeDirection.NORTH, fluid);
|
||||
boolean sfSouth = this.isFluidOccluded(world, posX, posY, posZ, ForgeDirection.SOUTH, fluid);
|
||||
boolean sfWest = this.isFluidOccluded(world, posX, posY, posZ, ForgeDirection.WEST, fluid);
|
||||
@@ -142,7 +142,7 @@ public class FluidRenderer {
|
||||
|
||||
quad.setFlags(0);
|
||||
|
||||
if (!sfUp && this.isSideExposed(world, posX, posY, posZ, ForgeDirection.UP, Math.min(Math.min(h1, h2), Math.min(h3, h4)))) {
|
||||
if (!sfUp && this.isSideExposed(world, posX, posY, posZ, POS_Y, Math.min(Math.min(h1, h2), Math.min(h3, h4)))) {
|
||||
h1 -= 0.001F;
|
||||
h2 -= 0.001F;
|
||||
h3 -= 0.001F;
|
||||
@@ -157,7 +157,7 @@ public class FluidRenderer {
|
||||
|
||||
if (velocity.x == 0.0D && velocity.z == 0.0D) {
|
||||
sprite = sprites[0];
|
||||
facing = ModelQuadFacing.UP;
|
||||
facing = ModelQuadFacing.POS_Y;
|
||||
u1 = sprite.getInterpolatedU(0.0D);
|
||||
v1 = sprite.getInterpolatedV(0.0D);
|
||||
u2 = u1;
|
||||
@@ -204,7 +204,7 @@ public class FluidRenderer {
|
||||
this.setVertex(quad, 2, 1.0F, h3, 1.0F, u3, v3);
|
||||
this.setVertex(quad, 3, 1.0F, h4, 0.0f, u4, v4);
|
||||
|
||||
this.calculateQuadColors(quad, pos, lighter, ForgeDirection.UP, 1.0F, hc, slice);
|
||||
this.calculateQuadColors(quad, pos, lighter, POS_Y, 1.0F, hc, slice);
|
||||
this.flushQuad(buffers, quad, facing, false);
|
||||
|
||||
if (WorldUtil.method_15756(slice, this.scratchPos.set(posX, posY + 1, posZ), fluid)) {
|
||||
@@ -213,7 +213,7 @@ public class FluidRenderer {
|
||||
this.setVertex(quad, 1, 1.0F, h3, 1.0F, u3, v3);
|
||||
this.setVertex(quad, 0, 1.0F, h4, 0.0f, u4, v4);
|
||||
|
||||
this.flushQuad(buffers, quad, ModelQuadFacing.DOWN, true);
|
||||
this.flushQuad(buffers, quad, ModelQuadFacing.NEG_Y, true);
|
||||
}
|
||||
|
||||
rendered = true;
|
||||
@@ -233,15 +233,15 @@ public class FluidRenderer {
|
||||
this.setVertex(quad, 2, 1.0F, yOffset, 0.0f, maxU, minV);
|
||||
this.setVertex(quad, 3, 1.0F, yOffset, 1.0F, maxU, maxV);
|
||||
|
||||
this.calculateQuadColors(quad, pos, lighter, ForgeDirection.DOWN, 1.0F, hc, slice);
|
||||
this.flushQuad(buffers, quad, ModelQuadFacing.DOWN, false);
|
||||
this.calculateQuadColors(quad, pos, lighter, NEG_Y, 1.0F, hc, slice);
|
||||
this.flushQuad(buffers, quad, ModelQuadFacing.NEG_Y, false);
|
||||
|
||||
rendered = true;
|
||||
}
|
||||
|
||||
quad.setFlags(ModelQuadFlags.IS_ALIGNED);
|
||||
|
||||
for (ForgeDirection dir : DirectionUtil.HORIZONTAL_DIRECTIONS) {
|
||||
for (var facing : HORIZONTAL_DIRECTIONS) {
|
||||
float c1;
|
||||
float c2;
|
||||
float x1;
|
||||
@@ -249,8 +249,8 @@ public class FluidRenderer {
|
||||
float x2;
|
||||
float z2;
|
||||
|
||||
switch (dir) {
|
||||
case NORTH:
|
||||
switch (facing) {
|
||||
case NEG_Z:
|
||||
if (sfNorth) {
|
||||
continue;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ public class FluidRenderer {
|
||||
z1 = 0.001f;
|
||||
z2 = z1;
|
||||
break;
|
||||
case SOUTH:
|
||||
case POS_Z:
|
||||
if (sfSouth) {
|
||||
continue;
|
||||
}
|
||||
@@ -274,7 +274,7 @@ public class FluidRenderer {
|
||||
z1 = 0.999f;
|
||||
z2 = z1;
|
||||
break;
|
||||
case WEST:
|
||||
case NEG_X:
|
||||
if (sfWest) {
|
||||
continue;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ public class FluidRenderer {
|
||||
z1 = 1.0F;
|
||||
z2 = 0.0f;
|
||||
break;
|
||||
case EAST:
|
||||
case POS_X:
|
||||
if (sfEast) {
|
||||
continue;
|
||||
}
|
||||
@@ -302,10 +302,10 @@ public class FluidRenderer {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.isSideExposed(world, posX, posY, posZ, dir, Math.max(c1, c2))) {
|
||||
int adjX = posX + dir.offsetX;
|
||||
int adjY = posY + dir.offsetY;
|
||||
int adjZ = posZ + dir.offsetZ;
|
||||
if (this.isSideExposed(world, posX, posY, posZ, facing, Math.max(c1, c2))) {
|
||||
int adjX = posX + facing.getStepX();
|
||||
int adjY = posY + facing.getStepY();
|
||||
int adjZ = posZ + facing.getStepZ();
|
||||
|
||||
TextureAtlasSprite sprite = sprites[1];
|
||||
TextureAtlasSprite oSprite = sprites[2];
|
||||
@@ -333,11 +333,9 @@ public class FluidRenderer {
|
||||
this.setVertex(quad, 2, x1, yOffset, z1, u1, v3);
|
||||
this.setVertex(quad, 3, x1, c1, z1, u1, v1);
|
||||
|
||||
float br = dir.offsetZ != 0 ? 0.8F : 0.6F;
|
||||
float br = facing.getStepZ() != 0 ? 0.8F : 0.6F;
|
||||
|
||||
ModelQuadFacing facing = ModelQuadFacing.fromDirection(dir);
|
||||
|
||||
this.calculateQuadColors(quad, pos, lighter, dir, br, hc, slice);
|
||||
this.calculateQuadColors(quad, pos, lighter, facing, br, hc, slice);
|
||||
this.flushQuad(buffers, quad, facing, false);
|
||||
|
||||
if (sprite != oSprite) {
|
||||
@@ -356,7 +354,7 @@ public class FluidRenderer {
|
||||
return rendered;
|
||||
}
|
||||
|
||||
private void calculateQuadColors(ModelQuadView quad, BlockPos pos, LightPipeline lighter, ForgeDirection dir, float brightness, boolean colorized, WorldSlice slice) {
|
||||
private void calculateQuadColors(ModelQuadView quad, BlockPos pos, LightPipeline lighter, ModelQuadFacing dir, float brightness, boolean colorized, WorldSlice slice) {
|
||||
QuadLightData light = this.quadLightData;
|
||||
lighter.calculate(quad, pos, light, null, dir, false);
|
||||
|
||||
@@ -372,7 +370,7 @@ public class FluidRenderer {
|
||||
color &= 0x00FFFFFF;
|
||||
color |= ((int) (ao * 255.0f)) << 24;
|
||||
} else {
|
||||
color = ColorABGR.mul(color, ao);
|
||||
color = ColorMixer.mulSingleWithoutAlpha(color, (int)(ao * 255));
|
||||
}
|
||||
this.quadColors[i] = color;
|
||||
}
|
||||
@@ -410,7 +408,7 @@ public class FluidRenderer {
|
||||
vertexIdx += lightOrder;
|
||||
}
|
||||
|
||||
TextureAtlasSprite sprite = quad.rubidium$getSprite();
|
||||
TextureAtlasSprite sprite = (TextureAtlasSprite) quad.celeritas$getSprite();
|
||||
|
||||
if (sprite != null) {
|
||||
buffers.getRenderData().addSprite(sprite);
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package me.jellysquid.mods.sodium.client.render.pipeline;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
/**
|
||||
* Contains methods stripped from BlockState or FluidState that didn't actually need to be there. Technically these
|
||||
* could be a mixin to Block or Fluid, but that's annoying while not actually providing any benefit.
|
||||
*/
|
||||
public class WorldUtil {
|
||||
|
||||
public static Vector3d getVelocity(IBlockAccess world, int x, int y, int z, Block thizz) {
|
||||
|
||||
Vector3d velocity = new Vector3d();
|
||||
int decay = getEffectiveFlowDecay(world, x, y, z, thizz);
|
||||
|
||||
for (var dire : ModelQuadFacing.HORIZONTAL_DIRECTIONS) {
|
||||
|
||||
int adjX = x + dire.getStepX();
|
||||
int adjZ = z + dire.getStepZ();
|
||||
|
||||
int adjDecay = getEffectiveFlowDecay(world, adjX, y, adjZ, thizz);
|
||||
|
||||
if (adjDecay < 0) {
|
||||
|
||||
if (!world.getBlock(adjX, y, adjZ).getMaterial().blocksMovement()) {
|
||||
|
||||
adjDecay = getEffectiveFlowDecay(world, adjX, y - 1, adjZ, thizz);
|
||||
|
||||
if (adjDecay >= 0) {
|
||||
|
||||
adjDecay -= (decay - 8);
|
||||
velocity = velocity.add((adjX - x) * adjDecay, 0, (adjZ - z) * adjDecay);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
adjDecay -= decay;
|
||||
velocity = velocity.add((adjX - x) * adjDecay, 0, (adjZ - z) * adjDecay);
|
||||
}
|
||||
}
|
||||
|
||||
if (world.getBlockMetadata(x, y, z) >= 8) {
|
||||
|
||||
if (thizz.isBlockSolid(world, x, y, z - 1, 2) || thizz.isBlockSolid(world, x, y, z + 1, 3)
|
||||
|| thizz.isBlockSolid(world, x - 1, y, z, 4)
|
||||
|| thizz.isBlockSolid(world, x + 1, y, z, 5)
|
||||
|| thizz.isBlockSolid(world, x, y + 1, z - 1, 2)
|
||||
|| thizz.isBlockSolid(world, x, y + 1, z + 1, 3)
|
||||
|| thizz.isBlockSolid(world, x - 1, y + 1, z, 4)
|
||||
|| thizz.isBlockSolid(world, x + 1, y + 1, z, 5)) {
|
||||
velocity = velocity.normalize().add(0.0D, -6.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
if (velocity.x == 0 && velocity.y == 0 && velocity.z == 0) return velocity.zero();
|
||||
return velocity.normalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if any block in a 3x3x3 cube is not the same fluid and not an opaque full cube. Equivalent to
|
||||
* FluidState::method_15756 in modern.
|
||||
*/
|
||||
public static boolean method_15756(IBlockAccess world, BlockPos pos, Fluid fluid) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
Block block = world.getBlock(pos.x, pos.y, pos.z);
|
||||
if (!block.isOpaqueCube() && getFluid(block) != fluid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns fluid height as a percentage of the block; 0 is none and 1 is full.
|
||||
*/
|
||||
public static float getFluidHeight(Fluid fluid, int meta) {
|
||||
return fluid == null ? 0 : 1 - BlockLiquid.getLiquidHeightPercent(meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the flow decay but converts values indicating falling liquid (values >=8) to their effective source block
|
||||
* value of zero
|
||||
*/
|
||||
public static int getEffectiveFlowDecay(IBlockAccess world, int x, int y, int z, Block thiz) {
|
||||
|
||||
if (world.getBlock(x, y, z).getMaterial() != thiz.getMaterial()) {
|
||||
|
||||
return -1;
|
||||
} else {
|
||||
|
||||
int decay = world.getBlockMetadata(x, y, z);
|
||||
return decay >= 8 ? 0 : decay;
|
||||
}
|
||||
}
|
||||
|
||||
// I believe forge mappings in modern say BreakableBlock, while yarn says TransparentBlock.
|
||||
// I have a sneaking suspicion isOpaque is neither, but it works for now
|
||||
public static boolean shouldDisplayFluidOverlay(Block block) {
|
||||
return !block.getMaterial().isOpaque() || block.getMaterial() == Material.leaves;
|
||||
}
|
||||
|
||||
public static boolean isFluidBlock(Block block) {
|
||||
return block instanceof IFluidBlock || block instanceof BlockLiquid;
|
||||
}
|
||||
|
||||
public static Fluid getFluid(Block b) {
|
||||
if (b instanceof IFluidBlock fluidBlock) return fluidBlock.getFluid();
|
||||
if (b instanceof BlockLiquid) {
|
||||
if (b.getMaterial() == Material.water) return FluidRegistry.WATER;
|
||||
if (b.getMaterial() == Material.lava) return FluidRegistry.LAVA;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to method_15748 in 1.16.5
|
||||
*/
|
||||
public static boolean isEmptyOrSame(Fluid fluid, Fluid otherFluid) {
|
||||
return otherFluid == null || fluid == otherFluid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to method_15749 in 1.16.5
|
||||
*/
|
||||
public static boolean method_15749(IBlockAccess world, Fluid thiz, BlockPos pos, ForgeDirection dir) {
|
||||
Block b = world.getBlock(pos.x, pos.y, pos.z);
|
||||
Fluid f = getFluid(b);
|
||||
if (f == thiz) {
|
||||
return false;
|
||||
}
|
||||
if (dir == ForgeDirection.UP) {
|
||||
return true;
|
||||
}
|
||||
return b.getMaterial() != Material.ice && b.isSideSolid(world, pos.x, pos.y, pos.z, dir);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,4 @@ public class MathUtil {
|
||||
return (a + b + 1) * (a + b) / 2 + b;
|
||||
}
|
||||
|
||||
public static boolean fuzzy_eq(float a, float b) {
|
||||
return Math.abs(a - b) < 1e-5;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.util;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Provides some utilities and constants for interacting with vanilla's model quad vertex format.
|
||||
*
|
||||
* This is the current vertex format used by Minecraft for chunk meshes and model quads. Internally, it uses integer
|
||||
* arrays for store baked quad data, and as such the following table provides both the byte and int indices.
|
||||
*
|
||||
* Byte Index Integer Index Name Format Fields
|
||||
* 0 ..11 0..2 Position 3 floats x, y, z
|
||||
* 12..15 3 Color 4 unsigned bytes a, r, g, b
|
||||
* 16..23 4..5 Block Texture 2 floats u, v
|
||||
* 24..27 6 Light Texture 2 shorts u, v
|
||||
* 28..30 7 Normal 3 unsigned bytes x, y, z
|
||||
* 31 Padding 1 byte
|
||||
*/
|
||||
public class ModelQuadUtil {
|
||||
// Integer indices for vertex attributes, useful for accessing baked quad data
|
||||
public static final int POSITION_INDEX = 0,
|
||||
COLOR_INDEX = 3,
|
||||
TEXTURE_INDEX = 4,
|
||||
LIGHT_INDEX = 6,
|
||||
NORMAL_INDEX = 7;
|
||||
|
||||
// Size of vertex format in 4-byte integers
|
||||
public static final int VERTEX_SIZE = 8;
|
||||
public static final int VERTEX_SIZE_BYTES = VERTEX_SIZE * 4;
|
||||
|
||||
// Cached array of normals for every facing to avoid expensive computation
|
||||
static final int[] NORMALS = new int[ForgeDirection.VALID_DIRECTIONS.length];
|
||||
|
||||
static {
|
||||
for (int i = 0; i < NORMALS.length; i++) {
|
||||
final ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i];
|
||||
NORMALS[i] = Norm3b.pack(dir.offsetX, dir.offsetY, dir.offsetZ);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the normal vector for a model quad with the given {@param facing}.
|
||||
*/
|
||||
public static int getFacingNormal(ForgeDirection facing) {
|
||||
return NORMALS[facing.ordinal()];
|
||||
}
|
||||
|
||||
public static int getFacingNormal(ForgeDirection facing, int bakedNormal) {
|
||||
if(!hasNormal(bakedNormal))
|
||||
return NORMALS[facing.ordinal()];
|
||||
return bakedNormal;
|
||||
}
|
||||
|
||||
public static boolean hasNormal(int n) {
|
||||
return (n & 0xFFFFFF) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vertexIndex The index of the vertex to access
|
||||
* @return The starting offset of the vertex's attributes
|
||||
*/
|
||||
public static int vertexOffset(int vertexIndex) {
|
||||
return vertexIndex * VERTEX_SIZE;
|
||||
}
|
||||
|
||||
public static int mergeBakedLight(int packedLight, int calcLight) {
|
||||
// bail early in most cases
|
||||
if (packedLight == 0)
|
||||
return calcLight;
|
||||
|
||||
final int psl = (packedLight >> 16) & 0xFF;
|
||||
final int csl = (calcLight >> 16) & 0xFF;
|
||||
final int pbl = (packedLight) & 0xFF;
|
||||
final int cbl = (calcLight) & 0xFF;
|
||||
final int bl = Math.max(pbl, cbl);
|
||||
final int sl = Math.max(psl, csl);
|
||||
return (sl << 16) | bl;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.util;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3i;
|
||||
|
||||
/**
|
||||
* Provides some utilities for working with packed normal vectors. Each getNormal component provides 8 bits of
|
||||
* precision in the range of [-1.0,1.0].
|
||||
*
|
||||
* | 32 | 24 | 16 | 8 |
|
||||
* | 0000 0000 | 0110 1100 | 0110 1100 | 0110 1100 |
|
||||
* | Padding | X | Y | Z |
|
||||
*/
|
||||
public class Norm3b {
|
||||
/**
|
||||
* The maximum value of a getNormal's vector component.
|
||||
*/
|
||||
private static final float COMPONENT_RANGE = 127.0f;
|
||||
|
||||
/**
|
||||
* Constant value which can be multiplied with a floating-point vector component to get the normalized value. The
|
||||
* multiplication is slightly faster than a floating point division, and this code is a hot path which justifies it.
|
||||
*/
|
||||
private static final float NORM = 1.0f / COMPONENT_RANGE;
|
||||
|
||||
static int pack(Vector3i norm) {
|
||||
return pack(norm.x, norm.y, norm.z);
|
||||
}
|
||||
|
||||
public static int pack(Vector3f dir) {
|
||||
return pack(dir.x, dir.y, dir.z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Packs the specified vector components into a 32-bit integer in XYZ ordering with the 8 bits of padding at the
|
||||
* end.
|
||||
* @param x The x component of the getNormal's vector
|
||||
* @param y The y component of the getNormal's vector
|
||||
* @param z The z component of the getNormal's vector
|
||||
*/
|
||||
public static int pack(float x, float y, float z) {
|
||||
int normX = encode(x);
|
||||
int normY = encode(y);
|
||||
int normZ = encode(z);
|
||||
|
||||
return (normZ << 16) | (normY << 8) | normX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a float in the range of -1.0..1.0 to a normalized unsigned integer in the range of 0..255 which can then
|
||||
* be passed to graphics memory.
|
||||
*/
|
||||
private static int encode(float comp) {
|
||||
// TODO: is the clamp necessary here? our inputs should always be normalized vector components
|
||||
return ((int) (MathHelper.clamp_float(comp, -1.0F, 1.0F) * COMPONENT_RANGE) & 255);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpacks the x-component of the packed getNormal, denormalizing it to a float in the range of -1.0..1.0.
|
||||
* @param norm The packed getNormal
|
||||
*/
|
||||
public static float unpackX(int norm) {
|
||||
return ((byte) (norm & 0xFF)) * NORM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpacks the y-component of the packed getNormal, denormalizing it to a float in the range of -1.0..1.0.
|
||||
* @param norm The packed getNormal
|
||||
*/
|
||||
public static float unpackY(int norm) {
|
||||
return ((byte) ((norm >> 8) & 0xFF)) * NORM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpacks the z-component of the packed getNormal, denormalizing it to a float in the range of -1.0..1.0.
|
||||
* @param norm The packed getNormal
|
||||
*/
|
||||
public static float unpackZ(int norm) {
|
||||
return ((byte) ((norm >> 16) & 0xFF)) * NORM;
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.util.color;
|
||||
|
||||
/**
|
||||
* Provides some utilities for packing and unpacking color components from packed integer colors in ABGR format, which
|
||||
* is used by OpenGL for color vectors.
|
||||
*
|
||||
* | 32 | 24 | 16 | 8 |
|
||||
* | 0110 1100 | 0110 1100 | 0110 1100 | 0110 1100 |
|
||||
* | Alpha | Blue | Green | Red |
|
||||
*/
|
||||
public class ColorABGR implements ColorU8 {
|
||||
/**
|
||||
* Packs the specified color components into ABGR format.
|
||||
* @param r The red component of the color
|
||||
* @param g The green component of the color
|
||||
* @param b The blue component of the color
|
||||
* @param a The alpha component of the color
|
||||
*/
|
||||
public static int pack(int r, int g, int b, int a) {
|
||||
return (a & 0xFF) << 24 | (b & 0xFF) << 16 | (g & 0xFF) << 8 | (r & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ColorABGR#pack(int, int, int, int)
|
||||
*/
|
||||
public static int pack(float r, float g, float b, float a) {
|
||||
return pack((int) (r * COMPONENT_RANGE), (int) (g * COMPONENT_RANGE), (int) (b * COMPONENT_RANGE), (int) (a * COMPONENT_RANGE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiplies the RGB components of the packed ABGR color using the given scale factors.
|
||||
* @param color The ABGR packed color to be multiplied
|
||||
* @param rw The red component scale factor
|
||||
* @param gw The green component scale factor
|
||||
* @param bw The blue component scale factor
|
||||
*/
|
||||
public static int mul(int color, float rw, float gw, float bw) {
|
||||
float r = unpackRed(color) * rw;
|
||||
float g = unpackGreen(color) * gw;
|
||||
float b = unpackBlue(color) * bw;
|
||||
|
||||
return pack((int) r, (int) g, (int) b, 0xFF);
|
||||
}
|
||||
|
||||
public static int mul(int color, float w) {
|
||||
return mul(color, w, w, w);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ABGR color to unpack
|
||||
* @return The red color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackRed(int color) {
|
||||
return color & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ABGR color to unpack
|
||||
* @return The green color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackGreen(int color) {
|
||||
return color >> 8 & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ABGR color to unpack
|
||||
* @return The blue color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackBlue(int color) {
|
||||
return color >> 16 & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ABGR color to unpack
|
||||
* @return The red color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackAlpha(int color) {
|
||||
return color >> 24 & 0xFF;
|
||||
}
|
||||
|
||||
public static int pack(float r, float g, float b) {
|
||||
return pack(r, g, b, 255);
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.util.color;
|
||||
|
||||
/**
|
||||
* Provides some utilities for packing and unpacking color components from packed integer colors in ARGB format. This
|
||||
* packed format is used by most of Minecraft, but special care must be taken to pack it into ABGR format before passing
|
||||
* it to OpenGL attributes.
|
||||
*
|
||||
* | 32 | 24 | 16 | 8 |
|
||||
* | 0110 1100 | 0110 1100 | 0110 1100 | 0110 1100 |
|
||||
* | Alpha | Red | Green | Blue |
|
||||
*/
|
||||
public class ColorARGB implements ColorU8 {
|
||||
/**
|
||||
* Packs the specified color components into big-endian format for consumption by OpenGL.
|
||||
* @param r The red component of the color
|
||||
* @param g The green component of the color
|
||||
* @param b The blue component of the color
|
||||
* @param a The alpha component of the color
|
||||
*/
|
||||
public static int pack(int r, int g, int b, int a) {
|
||||
return (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ARGB color to unpack
|
||||
* @return The red color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackAlpha(int color) {
|
||||
return color >> 24 & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ARGB color to unpack
|
||||
* @return The red color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackRed(int color) {
|
||||
return color >> 16 & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ARGB color to unpack
|
||||
* @return The green color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackGreen(int color) {
|
||||
return color >> 8 & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ARGB color to unpack
|
||||
* @return The blue color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackBlue(int color) {
|
||||
return color & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-packs the ARGB color into a aBGR color with the specified alpha component.
|
||||
*/
|
||||
public static int toABGR(int color, int alpha) {
|
||||
return Integer.reverseBytes(color << 8 | alpha);
|
||||
}
|
||||
|
||||
public static int toABGR(int color) {
|
||||
return Integer.reverseBytes(color << 8);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.util.color;
|
||||
|
||||
public class ColorMixer {
|
||||
private static final long MASK1 = 0x00FF00FF;
|
||||
private static final long MASK2 = 0xFF00FF00;
|
||||
|
||||
/**
|
||||
* Mixes two ARGB colors using the given ratios. Use {@link ColorMixer#getStartRatio(float)} and
|
||||
* {@link ColorMixer#getEndRatio(float)} to convert a floating-point ratio into a integer ratio.
|
||||
*
|
||||
* This method takes 64-bit inputs to avoid overflows when mixing the alpha channel. The helper method
|
||||
* {@link ColorMixer#mixARGB(int, int, int, int)} can be used with 32-bit inputs.
|
||||
*
|
||||
* @param c1 The first (starting) color to blend with in ARGB format
|
||||
* @param c2 The second (ending) color to blend with in ARGB format
|
||||
* @param f1 The ratio of the color {@param c1} as calculated by {@link ColorMixer#getStartRatio(float)}
|
||||
* @param f2 The ratio of the color {@param c2} as calculated by {@link ColorMixer#getEndRatio(float)}
|
||||
* @return The result of ((c1 * f1) + (c2 * f2) as an ARGB-encoded color
|
||||
*/
|
||||
public static long mixARGB(long c1, long c2, int f1, int f2) {
|
||||
return ((((((c1 & MASK1) * f1) + ((c2 & MASK1) * f2)) >> 8) & MASK1) |
|
||||
(((((c1 & MASK2) * f1) + ((c2 & MASK2) * f2)) >> 8) & MASK2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to convert 32-bit integers to 64-bit integers and back.
|
||||
* @see ColorMixer#mixARGB(long, long, int, int)
|
||||
*/
|
||||
public static int mixARGB(int c1, int c2, int f1, int f2) {
|
||||
return (int) mixARGB(Integer.toUnsignedLong(c1), Integer.toUnsignedLong(c2), f1, f2);
|
||||
}
|
||||
|
||||
public static int getStartRatio(float frac) {
|
||||
return (int) (256 * frac);
|
||||
}
|
||||
|
||||
public static int getEndRatio(float frac) {
|
||||
return 256 - getStartRatio(frac);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.util.color;
|
||||
|
||||
public interface ColorU8 {
|
||||
/**
|
||||
* The maximum value of a color component.
|
||||
*/
|
||||
float COMPONENT_RANGE = 255.0f;
|
||||
|
||||
/**
|
||||
* Constant value which can be multiplied with a floating-point color component to get the normalized value. The
|
||||
* multiplication is slightly faster than a floating point division, and this code is a hot path which justifies it.
|
||||
*/
|
||||
float NORM = 1.0f / COMPONENT_RANGE;
|
||||
|
||||
/**
|
||||
* Normalizes a color component to the range of 0..1.
|
||||
*/
|
||||
static float normalize(float v) {
|
||||
return v * NORM;
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.util.color;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.joml.Math.lerp;
|
||||
|
||||
public class FastCubicSampler {
|
||||
private static final double[] DENSITY_CURVE = new double[] { 0.0D, 1.0D, 4.0D, 6.0D, 4.0D, 1.0D, 0.0D };
|
||||
private static final int DIAMETER = 6;
|
||||
|
||||
private static Vector3d unpackRgb(int rgb) {
|
||||
return new Vector3d((rgb >> 16 & 255) / 255.0, (rgb >> 8 & 255) / 255.0, (rgb & 255) / 255.0);
|
||||
}
|
||||
|
||||
public static Vector3d sampleColor(Vector3d pos, ColorFetcher colorFetcher, Function<Vector3d, Vector3d> transformer) {
|
||||
int intX = MathHelper.floor_double(pos.x);
|
||||
int intY = MathHelper.floor_double(pos.y);
|
||||
int intZ = MathHelper.floor_double(pos.z);
|
||||
|
||||
int[] values = new int[DIAMETER * DIAMETER * DIAMETER];
|
||||
|
||||
for(int x = 0; x < DIAMETER; ++x) {
|
||||
int blockX = (intX - 2) + x;
|
||||
|
||||
for(int y = 0; y < DIAMETER; ++y) {
|
||||
int blockY = (intY - 2) + y;
|
||||
|
||||
for(int z = 0; z < DIAMETER; ++z) {
|
||||
int blockZ = (intZ - 2) + z;
|
||||
|
||||
values[index(x, y, z)] = colorFetcher.fetch(blockX, blockY, blockZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fast path! Skip blending the colors if all inputs are the same
|
||||
if (isHomogenousArray(values)) {
|
||||
// Take the first color if it's homogenous (all elements are the same...)
|
||||
return transformer.apply(unpackRgb(values[0]));
|
||||
}
|
||||
|
||||
double deltaX = pos.x - (double)intX;
|
||||
double deltaY = pos.y - (double)intY;
|
||||
double deltaZ = pos.z - (double)intZ;
|
||||
|
||||
Vector3d sum = new Vector3d();
|
||||
double totalFactor = 0.0D;
|
||||
|
||||
for(int x = 0; x < DIAMETER; ++x) {
|
||||
double densityX = lerp(DENSITY_CURVE[x + 1], DENSITY_CURVE[x], deltaX);
|
||||
|
||||
for(int y = 0; y < DIAMETER; ++y) {
|
||||
double densityY = lerp(DENSITY_CURVE[y + 1], DENSITY_CURVE[y], deltaY);
|
||||
|
||||
for(int z = 0; z < DIAMETER; ++z) {
|
||||
double densityZ = lerp(DENSITY_CURVE[z + 1], DENSITY_CURVE[z], deltaZ);
|
||||
|
||||
double factor = densityX * densityY * densityZ;
|
||||
totalFactor += factor;
|
||||
|
||||
Vector3d color = transformer.apply(unpackRgb(values[index(x, y, z)]));
|
||||
sum.add(color.mul(factor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sum.mul(1.0D / totalFactor);
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
private static int index(int x, int y, int z) {
|
||||
return (DIAMETER * DIAMETER * z) + (DIAMETER * y) + x;
|
||||
}
|
||||
|
||||
public interface ColorFetcher {
|
||||
int fetch(int x, int y, int z);
|
||||
}
|
||||
|
||||
private static boolean isHomogenousArray(int[] arr) {
|
||||
int val = arr[0];
|
||||
|
||||
for (int i = 1; i < arr.length; i++) {
|
||||
if (arr[i] != val) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.util.math;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.util.Norm3b;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
@@ -21,14 +21,14 @@ public class MatrixUtil {
|
||||
public static int transformPackedNormal(int norm, Matrix3f matrix) {
|
||||
Matrix3fExtended mat = MatrixUtil.getExtendedMatrix(matrix);
|
||||
|
||||
float normX1 = Norm3b.unpackX(norm);
|
||||
float normY1 = Norm3b.unpackY(norm);
|
||||
float normZ1 = Norm3b.unpackZ(norm);
|
||||
float normX1 = NormI8.unpackX(norm);
|
||||
float normY1 = NormI8.unpackY(norm);
|
||||
float normZ1 = NormI8.unpackZ(norm);
|
||||
|
||||
float normX2 = mat.transformVecX(normX1, normY1, normZ1);
|
||||
float normY2 = mat.transformVecY(normX1, normY1, normZ1);
|
||||
float normZ2 = mat.transformVecZ(normX1, normY1, normZ1);
|
||||
|
||||
return Norm3b.pack(normX2, normY2, normZ2);
|
||||
return NormI8.pack(normX2, normY2, normZ2);
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class XoRoShiRoRandom extends Random {
|
||||
return (int) this.nextLong(n);
|
||||
}
|
||||
|
||||
private long nextLong(final long n) {
|
||||
public long nextLong(final long n) {
|
||||
if (n <= 0) {
|
||||
throw new IllegalArgumentException("illegal bound " + n + " (must be positive)");
|
||||
}
|
||||
@@ -147,4 +147,4 @@ public class XoRoShiRoRandom extends Random {
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package me.jellysquid.mods.sodium.client.world;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.api.IBlockAccessExtended;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.CompatMathHelper;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import java.util.Arrays;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ChunkRenderContext;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ClonedChunkSection;
|
||||
@@ -19,7 +19,6 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -464,17 +463,17 @@ public class WorldSlice implements IBlockAccessExtended, FLBlockAccess {
|
||||
return z << TABLE_BITS | x;
|
||||
}
|
||||
|
||||
// Modern checks if the sky is darkened, which only happens in the nether. However, I think 1.7.10's hasNoSky is
|
||||
// close enough.
|
||||
public float getBrightness(ForgeDirection direction, boolean shaded) {
|
||||
/// Modern checks if the sky is darkened, which only happens in the nether. However, I think 1.7.10's hasNoSky is
|
||||
/// close enough.
|
||||
public float getBrightness(ModelQuadFacing direction, boolean shaded) {
|
||||
|
||||
if (!shaded) {
|
||||
return world.provider.hasNoSky ? 0.9f : 1.0f;
|
||||
}
|
||||
return switch (direction) {
|
||||
case DOWN -> 0.5f;
|
||||
case UP -> 1.0f;
|
||||
case NORTH, SOUTH -> 0.8f;
|
||||
case NEG_Y -> 0.5f;
|
||||
case POS_Y -> 1.0f;
|
||||
case NEG_Z, POS_Z -> 0.8f;
|
||||
default -> 0.6f;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -35,6 +35,24 @@ public class StandardMacros {
|
||||
defines.add(new StringPair(key, value));
|
||||
}
|
||||
|
||||
private static String makeAngelicaVersion()
|
||||
{
|
||||
String[] parts = Tags.VERSION.split("[.-]");
|
||||
int major = Integer.parseInt(parts[0]);
|
||||
int minor = Integer.parseInt(parts[1]);
|
||||
int patch = Integer.parseInt(parts[2]);
|
||||
int sub = 0;
|
||||
|
||||
// Handle optional prerelease (like beta62)
|
||||
if (parts.length > 3) {
|
||||
String pre = parts[3];
|
||||
String num = pre.replaceAll("\\D+", ""); // remove all non-digits
|
||||
if (!num.isEmpty())
|
||||
sub = Integer.parseInt(num);
|
||||
}
|
||||
return String.format("%d%02d%02d%03d", major, minor, patch, sub);
|
||||
}
|
||||
|
||||
public static Iterable<StringPair> createStandardEnvironmentDefines() {
|
||||
ArrayList<StringPair> standardDefines = new ArrayList<>();
|
||||
|
||||
@@ -54,7 +72,7 @@ public class StandardMacros {
|
||||
define(standardDefines, "MC_RENDER_QUALITY", "1.0");
|
||||
define(standardDefines, "MC_SHADOW_QUALITY", "1.0");
|
||||
define(standardDefines, "IS_ANGELICA");
|
||||
define(standardDefines, "ANGELICA_VERSION", Tags.VERSION);
|
||||
define(standardDefines, "ANGELICA_VERSION", makeAngelicaVersion());
|
||||
define(standardDefines, "MC_HAND_DEPTH", Float.toString(HandRenderer.DEPTH));
|
||||
|
||||
TextureFormat textureFormat = TextureFormatLoader.getFormat();
|
||||
|
||||
@@ -175,7 +175,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
|
||||
final Framebuffer main = Minecraft.getMinecraft().getFramebuffer();
|
||||
|
||||
final int depthTextureId = ((IRenderTargetExt)main).getIris$depthTextureId();
|
||||
final int depthTextureId = ((IRenderTargetExt)main).iris$getDepthTextureId();
|
||||
final int internalFormat = TextureInfoCache.INSTANCE.getInfo(depthTextureId).getInternalFormat();
|
||||
final DepthBufferFormat depthBufferFormat = DepthBufferFormat.fromGlEnumOrDefault(internalFormat);
|
||||
|
||||
@@ -911,7 +911,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
|
||||
final Framebuffer main = Minecraft.getMinecraft().getFramebuffer();
|
||||
|
||||
final int depthTextureId = ((IRenderTargetExt)main).getIris$depthTextureId();
|
||||
final int depthTextureId = ((IRenderTargetExt)main).iris$getDepthTextureId();
|
||||
final int internalFormat = TextureInfoCache.INSTANCE.getInfo(depthTextureId).getInternalFormat();
|
||||
final DepthBufferFormat depthBufferFormat = DepthBufferFormat.fromGlEnumOrDefault(internalFormat);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.profiler.Profiler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3dc;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
import org.lwjgl.BufferUtils;
|
||||
@@ -59,6 +59,7 @@ public class ShadowRenderer {
|
||||
public static final FloatBuffer MODELVIEW_BUFFER = BufferUtils.createFloatBuffer(16);
|
||||
public static final Matrix4f PROJECTION = new Matrix4f();
|
||||
public static List<TileEntity> visibleTileEntities;
|
||||
public static List<TileEntity> globalTileEntities;
|
||||
public static boolean ACTIVE = false;
|
||||
private final float halfPlaneLength;
|
||||
private final float renderDistanceMultiplier;
|
||||
@@ -140,11 +141,11 @@ public class ShadowRenderer {
|
||||
|
||||
public static MatrixStack createShadowModelView(float sunPathRotation, float intervalSize) {
|
||||
// Determine the camera position
|
||||
final Vector3d cameraPos = CameraUniforms.getUnshiftedCameraPosition();
|
||||
final Vector3dc cameraPos = CameraUniforms.getUnshiftedCameraPosition();
|
||||
|
||||
final double cameraX = cameraPos.x;
|
||||
final double cameraY = cameraPos.y;
|
||||
final double cameraZ = cameraPos.z;
|
||||
final double cameraX = cameraPos.x();
|
||||
final double cameraY = cameraPos.y();
|
||||
final double cameraZ = cameraPos.z();
|
||||
|
||||
// Set up our modelview matrix stack
|
||||
final MatrixStack modelView = new MatrixStack();
|
||||
@@ -460,6 +461,7 @@ public class ShadowRenderer {
|
||||
MODELVIEW_BUFFER.clear().rewind();
|
||||
modelView.peek().getModel().get(MODELVIEW_BUFFER);
|
||||
GL11.glLoadMatrix(MODELVIEW_BUFFER);
|
||||
|
||||
for (TileEntity tileEntity : visibleTileEntities) {
|
||||
if (hasEntityFrustum && (culler.isCulled(tileEntity.xCoord - 1, tileEntity.yCoord - 1, tileEntity.zCoord - 1, tileEntity.xCoord + 1, tileEntity.yCoord + 1, tileEntity.zCoord + 1))) {
|
||||
continue;
|
||||
@@ -468,6 +470,15 @@ public class ShadowRenderer {
|
||||
|
||||
shadowTileEntities++;
|
||||
}
|
||||
for (TileEntity tileEntity : globalTileEntities) {
|
||||
if (hasEntityFrustum && (culler.isCulled(tileEntity.xCoord - 1, tileEntity.yCoord - 1, tileEntity.zCoord - 1, tileEntity.xCoord + 1, tileEntity.yCoord + 1, tileEntity.zCoord + 1))) {
|
||||
continue;
|
||||
}
|
||||
renderTileEntity(tileEntity, cameraX, cameraY, cameraZ, partialTicks);
|
||||
|
||||
shadowTileEntities++;
|
||||
}
|
||||
|
||||
GLStateManager.glPopMatrix();
|
||||
|
||||
renderedShadowTileEntities = shadowTileEntities;
|
||||
@@ -492,6 +503,7 @@ public class ShadowRenderer {
|
||||
// levelRenderer.setRenderBuffers(buffers);
|
||||
|
||||
visibleTileEntities = new ArrayList<>();
|
||||
globalTileEntities = new ArrayList<>();
|
||||
|
||||
// Create our camera
|
||||
final MatrixStack modelView = createShadowModelView(this.sunPathRotation, this.intervalSize);
|
||||
@@ -518,7 +530,7 @@ public class ShadowRenderer {
|
||||
terrainFrustumHolder = createShadowFrustum(renderDistanceMultiplier, terrainFrustumHolder);
|
||||
|
||||
// Determine the player camera position
|
||||
final Vector3d cameraPos = CameraUniforms.getUnshiftedCameraPosition();
|
||||
final Vector3dc cameraPos = CameraUniforms.getUnshiftedCameraPosition();
|
||||
|
||||
final double cameraX = cameraPos.x();
|
||||
final double cameraY = cameraPos.y();
|
||||
|
||||
@@ -222,6 +222,10 @@ public class ShaderTransformer {
|
||||
for (var entry : types.entrySet()) {
|
||||
String formattedShader = getFormattedShader(entry.getValue(), prepatched.get(entry.getKey()));
|
||||
|
||||
// Restore identifiers that were temporarily renamed to dodge GLSL reserved keywords.
|
||||
formattedShader = formattedShader.replace("iris_renamed_texture", "texture");
|
||||
formattedShader = formattedShader.replace("iris_renamed_sample", "sample");
|
||||
|
||||
// Please don't mind the entire rest of this loop basically, we're doing awful fragile regex on the transformed
|
||||
// shader output to do things that I can't figure out with AST because I'm bad at it
|
||||
|
||||
|
||||
@@ -101,23 +101,23 @@ public class FinalPassRenderer {
|
||||
// TODO: We don't actually fully swap the content, we merely copy it from alt to main
|
||||
// This works for the most part, but it's not perfect. A better approach would be creating secondary
|
||||
// framebuffers for every other frame, but that would be a lot more complex...
|
||||
ImmutableList.Builder<SwapPass> swapPasses = ImmutableList.builder();
|
||||
|
||||
flippedBuffers.forEach(i -> {
|
||||
int target = i;
|
||||
final ImmutableList.Builder<SwapPass> swapPasses = ImmutableList.builder();
|
||||
|
||||
flippedBuffers.forEach((i) -> {
|
||||
final int target = i;
|
||||
|
||||
if (buffersToBeCleared.contains(target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SwapPass swap = new SwapPass();
|
||||
RenderTarget target1 = renderTargets.get(target);
|
||||
final SwapPass swap = new SwapPass();
|
||||
final RenderTarget target1 = renderTargets.get(target);
|
||||
swap.target = target;
|
||||
swap.width = target1.getWidth();
|
||||
swap.height = target1.getHeight();
|
||||
// Non-flipped buffers write to ALT, copy ALT→MAIN to preserve data
|
||||
swap.from = renderTargets.createColorFramebuffer(ImmutableSet.of(), new int[] {target});
|
||||
// NB: This is handled in RenderTargets now.
|
||||
//swap.from.readBuffer(target);
|
||||
swap.targetTexture = renderTargets.get(target).getMainTexture();
|
||||
|
||||
swapPasses.add(swap);
|
||||
@@ -264,8 +264,10 @@ public class FinalPassRenderer {
|
||||
|
||||
public void recalculateSwapPassSize() {
|
||||
for (SwapPass swapPass : swapPasses) {
|
||||
RenderTarget target = renderTargets.get(swapPass.target);
|
||||
final RenderTarget target = renderTargets.get(swapPass.target);
|
||||
renderTargets.destroyFramebuffer(swapPass.from);
|
||||
// Match constructor logic - swap passes are only for non-flipped buffers
|
||||
// Copy ALT→MAIN to preserve data written to ALT
|
||||
swapPass.from = renderTargets.createColorFramebuffer(ImmutableSet.of(), new int[] {swapPass.target});
|
||||
swapPass.width = target.getWidth();
|
||||
swapPass.height = target.getHeight();
|
||||
@@ -274,7 +276,7 @@ public class FinalPassRenderer {
|
||||
}
|
||||
|
||||
private static void setupMipmapping(RenderTarget target, boolean readFromAlt) {
|
||||
int texture = readFromAlt ? target.getAltTexture() : target.getMainTexture();
|
||||
final int texture = readFromAlt ? target.getAltTexture() : target.getMainTexture();
|
||||
|
||||
// TODO: Only generate the mipmap if a valid mipmap hasn't been generated or if we've written to the buffer
|
||||
// (since the last mipmap was generated)
|
||||
@@ -319,13 +321,13 @@ public class FinalPassRenderer {
|
||||
source.getVertexSource().orElseThrow(NullPointerException::new),
|
||||
source.getGeometrySource().orElse(null),
|
||||
source.getFragmentSource().orElseThrow(NullPointerException::new));
|
||||
String vertex = transformed.get(PatchShaderType.VERTEX);
|
||||
String geometry = transformed.get(PatchShaderType.GEOMETRY);
|
||||
String fragment = transformed.get(PatchShaderType.FRAGMENT);
|
||||
final String vertex = transformed.get(PatchShaderType.VERTEX);
|
||||
final String geometry = transformed.get(PatchShaderType.GEOMETRY);
|
||||
final String fragment = transformed.get(PatchShaderType.FRAGMENT);
|
||||
PatchedShaderPrinter.debugPatchedShaders(source.getName(), vertex, geometry, fragment);
|
||||
|
||||
Objects.requireNonNull(flipped);
|
||||
ProgramBuilder builder;
|
||||
final ProgramBuilder builder;
|
||||
|
||||
try {
|
||||
builder = ProgramBuilder.begin(source.getName(), vertex, geometry, fragment,
|
||||
@@ -337,7 +339,7 @@ public class FinalPassRenderer {
|
||||
|
||||
this.customUniforms.assignTo(builder);
|
||||
|
||||
ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureIds, flippedAtLeastOnceSnapshot);
|
||||
final ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureIds, flippedAtLeastOnceSnapshot);
|
||||
|
||||
CommonUniforms.addDynamicUniforms(builder);
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flipped, renderTargets, true);
|
||||
@@ -361,15 +363,15 @@ public class FinalPassRenderer {
|
||||
}
|
||||
|
||||
private ComputeProgram[] createComputes(ComputeSource[] compute, ImmutableSet<Integer> flipped, ImmutableSet<Integer> flippedAtLeastOnceSnapshot, Supplier<ShadowRenderTargets> shadowTargetsSupplier) {
|
||||
ComputeProgram[] programs = new ComputeProgram[compute.length];
|
||||
final ComputeProgram[] programs = new ComputeProgram[compute.length];
|
||||
for (int i = 0; i < programs.length; i++) {
|
||||
ComputeSource source = compute[i];
|
||||
final ComputeSource source = compute[i];
|
||||
if (source == null || !source.getSource().isPresent()) {
|
||||
continue;
|
||||
} else {
|
||||
// TODO: Properly handle empty shaders
|
||||
Objects.requireNonNull(flipped);
|
||||
ProgramBuilder builder;
|
||||
final ProgramBuilder builder;
|
||||
|
||||
try {
|
||||
builder = ProgramBuilder.beginCompute(source.getName(), source.getSource().orElse(null), IrisSamplers.COMPOSITE_RESERVED_TEXTURE_UNITS);
|
||||
|
||||
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user