mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-17 19:15:06 +00:00
Compare commits
39
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad63d2d62c | ||
|
|
d2730ccca8 | ||
|
|
e9257b8739 | ||
|
|
3984225faa | ||
|
|
52db6b56d6 | ||
|
|
34bfe513f1 | ||
|
|
42d7ed58aa | ||
|
|
9a4f0f9b99 | ||
|
|
be90a01725 | ||
|
|
e5e8250d44 | ||
|
|
062a03ffc2 | ||
|
|
9f5afaaec3 | ||
|
|
b05f17a477 | ||
|
|
57caf08212 | ||
|
|
085ec79c21 | ||
|
|
38641268ae | ||
|
|
fe8e723638 | ||
|
|
16debfd518 | ||
|
|
8cfc3e1f4a | ||
|
|
2c808fae43 | ||
|
|
1649c3c0c6 | ||
|
|
b84286ba3b | ||
|
|
ee6c79802a | ||
|
|
d3366ad31a | ||
|
|
92b6dcc010 | ||
|
|
89132f3ef9 | ||
|
|
f0d45b0d62 | ||
|
|
173d986a5b | ||
|
|
473a690054 | ||
|
|
2515b3520f | ||
|
|
a32f9ca244 | ||
|
|
941fc88484 | ||
|
|
4106dd3865 | ||
|
|
61f6aa19a8 | ||
|
|
77875f7f91 | ||
|
|
241c32def1 | ||
|
|
a8107f97e8 | ||
|
|
8bec433699 | ||
|
|
2d39fb2397 |
No files matched your search
@@ -39,6 +39,7 @@ body:
|
||||
- Java 19
|
||||
- Java 20
|
||||
- Java 21
|
||||
- Java 25
|
||||
- Other (Please Specify)
|
||||
validations:
|
||||
required: true
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
## **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
|
||||
* Complementary + Euphoria Patches is the primary compatibility target
|
||||
* Sildurs, Seus, and any other shaders might work
|
||||
|
||||
|
||||
# Required Dependencies
|
||||
* [UniMixins](https://github.com/LegacyModdingMC/UniMixins/releases) >= 0.1.23
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.8.21
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.9.0
|
||||
* NOTE: Some mods are not required, but a specific version is required if present - see: `Permanent Incompatibilities` below.
|
||||
|
||||
# Known (temporary) Incompatibilities
|
||||
@@ -38,7 +38,7 @@
|
||||
* [Amazing Trophies 1.2.1 and below](https://github.com/GTNewHorizons/Amazing-Trophies/releases) - Use 1.2.2+
|
||||
* [LWJGL3ify 1.5.4 and below](https://github.com/GTNewHorizons/lwjgl3ify/releases/) - Use the latest version available, 1.5.7+
|
||||
* [ArchaicFix 0.6.2 and below](https://www.curseforge.com/minecraft/mc-mods/archaicfix/files/all?page=1&pageSize=20) - Use 0.7.0 or above
|
||||
* [Hodgepodge 2.4.3 and below](https://github.com/GTNewHorizons/Hodgepodge/releases) - Use 0.4.5 or above
|
||||
* [Hodgepodge 2.4.3 and below](https://github.com/GTNewHorizons/Hodgepodge/releases) - Use 2.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
|
||||
@@ -83,3 +83,5 @@
|
||||
* Code from both glsl-transformation-lib and Monocle taken under their respective LGPL 3.0 licenses
|
||||
* FalseTweaks
|
||||
* FalsePattern for [FalseTweaks](https://github.com/falsepattern/falsetweaks) - Item Rendering Optimizations taken from FalseTweaks under the LGPL 3.0 license
|
||||
* Beddium
|
||||
* Venn and Falsepattern for [Beddium](https://github.com/vfx-dev/Beddium) - MinimapRenderer, SafeChunkTracker, and some debug commands adapted under the LGPL 3.0 License
|
||||
+14
-7
@@ -5,11 +5,8 @@ plugins {
|
||||
minecraft {
|
||||
extraRunJvmArguments.add("-Dangelica.enableTestBlocks=true")
|
||||
extraRunJvmArguments.add("-Dangelica.dumpClass=true")
|
||||
/* extraRunJvmArguments.addAll(
|
||||
"-Dlegacy.debugClassLoading=true",
|
||||
"-Dlegacy.debugClassLoadingFiner=true",
|
||||
"-Dlegacy.debugClassLoadingSave=true")*/
|
||||
|
||||
// extraRunJvmArguments.addAll("-Dlegacy.debugClassLoadingSave=true")
|
||||
// extraRunJvmArguments.addAll("-Drfb.dumpLoadedClasses=true", "-Drfb.dumpLoadedClassesPerTransformer=true")
|
||||
//extraRunJvmArguments.add("-Dangelica.redirectorLogspam=true")
|
||||
}
|
||||
|
||||
@@ -32,9 +29,10 @@ tasks.test {
|
||||
}
|
||||
|
||||
tasks.processResources {
|
||||
inputs.property("version", project.version.toString())
|
||||
val projectVersion = project.version.toString()
|
||||
inputs.property("version", projectVersion)
|
||||
filesMatching("META-INF/rfb-plugin/*") {
|
||||
expand("version" to project.version.toString())
|
||||
expand("version" to projectVersion)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,3 +42,12 @@ tasks.register<Copy>("copyDependencies") {
|
||||
from(configurations.default)
|
||||
into("testDependencies")
|
||||
}
|
||||
|
||||
val embedOnly: Configuration by configurations
|
||||
|
||||
tasks.shadowJar {
|
||||
from(embedOnly.map(::zipTree))
|
||||
relocate("com.mitchej123", "com.mitchej123")
|
||||
relocate("org.embeddedt", "org.embeddedt")
|
||||
}
|
||||
|
||||
+35
-12
@@ -46,26 +46,43 @@ configurations {
|
||||
// Can be enabled for testing if desired
|
||||
// runtimeClasspath.extendsFrom(transformedMod)
|
||||
// testRuntimeClasspath.extendsFrom(transformedMod)
|
||||
|
||||
// Embed in JAR without relocation (compile only, shadowed into JAR)
|
||||
embedOnly
|
||||
embedOnly.canBeConsumed = false
|
||||
embedOnly.canBeResolved = true
|
||||
compileClasspath.extendsFrom(embedOnly)
|
||||
testCompileClasspath.extendsFrom(embedOnly)
|
||||
}
|
||||
|
||||
|
||||
// Exclude self-reference from all configurations - prevents transitive Angelica deps from resolving against this project
|
||||
configurations.all {
|
||||
exclude group: "com.github.GTNewHorizons", module: "Angelica"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.14")
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.14:dev")
|
||||
|
||||
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")
|
||||
compileOnly("org.projectlombok:lombok:1.18.42") { transitive = false }
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.42")
|
||||
|
||||
// Iris Shaders
|
||||
compileOnly('org.jetbrains:annotations:26.0.2')
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.8.21:dev")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.9.0:dev")
|
||||
shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0
|
||||
shadowImplementation("org.taumc:glsl-transformation-lib:0.2.0-4.g6b42bca") {
|
||||
shadowImplementation("org.taumc:glsl-transformation-lib:0.2.0-25.g3a943bb") {
|
||||
exclude module: "antlr4" // we only want to shadow the runtime module
|
||||
}
|
||||
shadowImplementation("org.antlr:antlr4-runtime:4.13.2")
|
||||
compileOnly "org.apache.ant:ant:1.8.2"
|
||||
|
||||
// Celeritas (transitive=false: deps provided by GTNHLib/runtime)
|
||||
embedOnly("org.embeddedt.celeritas:celeritas-common:2.5.1-GTNH") { transitive = false }
|
||||
embedOnly("org.embeddedt.celeritas:celeritas-lwjgl2-service:2.5.1-GTNH") { transitive = false }
|
||||
|
||||
// Because who doesn't want NEI
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.35-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:CodeChickenCore:1.4.7:dev')
|
||||
@@ -99,7 +116,7 @@ dependencies {
|
||||
compileOnly(rfg.deobf("curse.maven:xaeros-minimap-263420:5060684"))
|
||||
compileOnly(rfg.deobf("curse.maven:security-craft-64760:2818228"))
|
||||
|
||||
runtimeOnlyNonPublishable(rfg.deobf("CoreTweaks:CoreTweaks:0.3.3.2"))
|
||||
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:CoreTweaks:0.3.3.6-GTNH")
|
||||
// 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")))
|
||||
|
||||
@@ -109,12 +126,18 @@ dependencies {
|
||||
// Better Crashes
|
||||
compileOnly("com.github.GTNewHorizons:BetterCrashes:1.4.0-GTNH:dev")
|
||||
|
||||
// Tests
|
||||
testImplementation(platform('org.junit:junit-bom:5.11.4'))
|
||||
testImplementation('org.junit.jupiter:junit-jupiter')
|
||||
testImplementation("org.mockito:mockito-core:3.+")
|
||||
testImplementation("org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209")
|
||||
testAnnotationProcessor("com.github.bsideup.jabel:jabel-javac-plugin:1.0.1")
|
||||
afterEvaluate {
|
||||
dependencies {
|
||||
testImplementation(platform('org.junit:junit-bom:5.14.1'))
|
||||
testImplementation('org.junit.jupiter:junit-jupiter')
|
||||
testImplementation("org.mockito:mockito-core:3.+")
|
||||
testImplementation("org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209")
|
||||
|
||||
testImplementation('org.junit.platform:junit-platform-engine')
|
||||
testImplementation('org.junit.platform:junit-platform-reporting')
|
||||
testImplementation('org.junit.platform:junit-platform-launcher')
|
||||
}
|
||||
}
|
||||
|
||||
compileOnly("mega:fluidlogged-mc1.7.10:0.1.2")
|
||||
}
|
||||
+32
-13
@@ -39,9 +39,33 @@ remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/co
|
||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||
developmentEnvironmentUserName = Developer
|
||||
|
||||
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# See https://github.com/bsideup/jabel for details on how this works.
|
||||
enableModernJavaSyntax = true
|
||||
# Enables modern Java syntax support. Valid values:
|
||||
# - false: No modern syntax, Java 8 only
|
||||
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
|
||||
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
|
||||
# - modern: Native modern Java bytecode, no downgrading
|
||||
enableModernJavaSyntax = jvmDowngrader
|
||||
|
||||
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
|
||||
# and should *not* be used in most situations. -1 disables this.
|
||||
# forceToolchainVersion = -1
|
||||
|
||||
# Target JVM version for JVM Downgrader bytecode downgrading.
|
||||
# Only used when enableModernJavaSyntax = jvmDowngrader
|
||||
# downgradeTargetVersion = 8
|
||||
|
||||
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
|
||||
# Classes will be available in META-INF/versions/N/ for each version N in this list.
|
||||
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
|
||||
jvmDowngraderMultiReleaseVersions = 17, 21, 25
|
||||
|
||||
# Specifies how JVM Downgrader API stubs are provided. Options:
|
||||
# - shade: Shade minimized stubs into the jar
|
||||
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
|
||||
# - external: Another dependency provides stubs (no constraint, no warning)
|
||||
# - (empty): Warning reminding you to configure stubs
|
||||
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
|
||||
jvmDowngraderStubsProvider = gtnhlib
|
||||
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||
@@ -55,22 +79,13 @@ generateGradleTokenClass = com.gtnewhorizons.angelica.Tags
|
||||
# Name of the token containing the project's current version to generate/replace.
|
||||
gradleTokenVersion = VERSION
|
||||
|
||||
# [DEPRECATED] Mod ID replacement token.
|
||||
gradleTokenModId =
|
||||
|
||||
# [DEPRECATED] Mod name replacement token.
|
||||
gradleTokenModName =
|
||||
|
||||
# [DEPRECATED] Mod Group replacement token.
|
||||
gradleTokenGroupName =
|
||||
|
||||
# [DEPRECATED]
|
||||
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
|
||||
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
|
||||
# version in @Mod([...], version = VERSION, [...]).
|
||||
# Leave these properties empty to skip individual token replacements.
|
||||
replaceGradleTokenInFile =
|
||||
# replaceGradleTokenInFile =
|
||||
|
||||
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
|
||||
# leave this property empty.
|
||||
@@ -209,3 +224,7 @@ disableSpotless = true
|
||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||
# ideaCheckSpotlessOnBuild = true
|
||||
|
||||
# Non-GTNH properties
|
||||
org.gradle.configuration-cache = true
|
||||
org.gradle.jvmargs = -Xmx2g
|
||||
org.gradle.parallel = true
|
||||
@@ -0,0 +1,12 @@
|
||||
#This file is generated by updateDaemonJvm
|
||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c5ee947fbfb70bc347d8d531e3a578c4/redirect
|
||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/5ee463876563a46fff651cce1bc53a4c/redirect
|
||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c5ee947fbfb70bc347d8d531e3a578c4/redirect
|
||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/5ee463876563a46fff651cce1bc53a4c/redirect
|
||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/e1118b4c7c2858d28154d086dbff010e/redirect
|
||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/59a9771cad43219260d9aac9a8ec4d6a/redirect
|
||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c5ee947fbfb70bc347d8d531e3a578c4/redirect
|
||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/5ee463876563a46fff651cce1bc53a4c/redirect
|
||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/832229f0f6f0be60ed817c5a5e5848eb/redirect
|
||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/b96cb7670c095245220e7d01d5927b58/redirect
|
||||
toolchainVersion=25
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -114,7 +114,6 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -172,7 +171,6 @@ fi
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -212,8 +210,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+1
-2
@@ -70,11 +70,10 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
@@ -15,23 +15,6 @@ repositories {
|
||||
includeGroup 'mega'
|
||||
}
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
ivy {
|
||||
name = 'CoreTweaks releases'
|
||||
url = 'https://github.com/makamys/CoreTweaks/releases/download/'
|
||||
patternLayout {
|
||||
artifact '[revision]/[module]-1.7.10-[revision]+nomixin(-[classifier])(.[ext])'
|
||||
}
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroup('CoreTweaks')
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = 'taumc'
|
||||
url = 'https://maven.taumc.org/releases'
|
||||
|
||||
@@ -2,8 +2,8 @@ pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
// RetroFuturaGradle
|
||||
name "GTNH Maven"
|
||||
url "https://nexus.gtnewhorizons.com/repository/public/"
|
||||
name = "GTNH Maven"
|
||||
url = uri("https://nexus.gtnewhorizons.com/repository/public/")
|
||||
mavenContent {
|
||||
includeGroup("com.gtnewhorizons")
|
||||
includeGroupByRegex("com\\.gtnewhorizons\\..+")
|
||||
@@ -16,5 +16,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.48'
|
||||
id("com.gtnewhorizons.gtnhsettingsconvention") version("2.0.13")
|
||||
}
|
||||
@@ -9,10 +9,14 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@LateMixin
|
||||
@SuppressWarnings("unused")
|
||||
public class AngelicaLateMixins implements ILateMixinLoader {
|
||||
|
||||
@Override
|
||||
public String getMixinConfig() {
|
||||
int v = Runtime.version().feature();
|
||||
if (v >= 21) return "mixins.angelica.late.j21.json";
|
||||
if (v >= 17) return "mixins.angelica.late.j17.json";
|
||||
return "mixins.angelica.late.json";
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.gtnewhorizons.angelica.utils.AnimationMode;
|
||||
import com.gtnewhorizons.angelica.utils.ManagedEnum;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
@@ -29,6 +31,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
guiFactory = "com.gtnewhorizons.angelica.config.AngelicaGuiConfigFactory")
|
||||
public class AngelicaMod {
|
||||
public static final String MOD_ID = "angelica";
|
||||
public static final Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
|
||||
@SidedProxy(clientSide = "com.gtnewhorizons.angelica.proxy.ClientProxy", serverSide = "com.gtnewhorizons.angelica.proxy.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.api;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IPatchedTextureAtlasSprite;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.SpriteExtension;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
@@ -20,8 +20,8 @@ public class TextureServices {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static void updateTextureAnimation(IIcon icon) {
|
||||
if(icon instanceof IPatchedTextureAtlasSprite patchedSprite) {
|
||||
patchedSprite.markNeedsAnimationUpdate();
|
||||
if (icon instanceof SpriteExtension ext) {
|
||||
ext.celeritas$markActive();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizon.gtnhlib.util.font.GlyphReplacements;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.FontRendererAccessor;
|
||||
@@ -380,11 +381,11 @@ public class BatchingFontRenderer {
|
||||
}
|
||||
|
||||
public float getGlyphScaleX() {
|
||||
return forceDefaults() ? 1 : (float) (FontConfig.glyphScale * Math.pow(2, FontConfig.glyphAspect)) * (FontStrategist.customFontInUse ? 1.5f : 1);
|
||||
return forceDefaults() ? 1 : (float) (FontConfig.glyphScale * Math.pow(2, FontConfig.glyphAspect));
|
||||
}
|
||||
|
||||
public float getGlyphScaleY() {
|
||||
return forceDefaults() ? 1 : (float) (FontConfig.glyphScale / Math.pow(2, FontConfig.glyphAspect)) * (FontStrategist.customFontInUse ? 1.5f : 1);
|
||||
return forceDefaults() ? 1 : (float) (FontConfig.glyphScale / Math.pow(2, FontConfig.glyphAspect));
|
||||
}
|
||||
|
||||
public float getGlyphSpacing() {
|
||||
@@ -431,13 +432,13 @@ public class BatchingFontRenderer {
|
||||
boolean curStrikethrough = false;
|
||||
boolean curUnderline = false;
|
||||
|
||||
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;
|
||||
float glyphScaleY = getGlyphScaleY();
|
||||
float heightNorth = anchorY + (underlying.FONT_HEIGHT - 1.0f) * (0.5f - glyphScaleY / 2);
|
||||
|
||||
final float underlineY = heightNorth + (underlying.FONT_HEIGHT - 1.0f) * glyphScaleY;
|
||||
float underlineStartX = 0.0f;
|
||||
float underlineEndX = 0.0f;
|
||||
|
||||
final float strikethroughY = heightNorth + ((float) (underlying.FONT_HEIGHT / 2) - 1.0f) * glyphScaleY;
|
||||
float strikethroughStartX = 0.0f;
|
||||
float strikethroughEndX = 0.0f;
|
||||
@@ -507,12 +508,22 @@ public class BatchingFontRenderer {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (FontConfig.enableCustomFont) {
|
||||
String chrReplacement = GlyphReplacements.customGlyphs.get(String.valueOf(chr));
|
||||
if (chrReplacement != null) {
|
||||
chr = chrReplacement.charAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (curRandom) {
|
||||
chr = FontProviderMC.get(this.isSGA).getRandomReplacement(chr);
|
||||
}
|
||||
|
||||
FontProvider fontProvider = FontStrategist.getFontProvider(this, chr, FontConfig.enableCustomFont, unicodeFlag);
|
||||
|
||||
heightNorth = anchorY + (underlying.FONT_HEIGHT - 1.0f) * (0.5f - glyphScaleY * fontProvider.getYScaleMultiplier() / 2);
|
||||
float heightSouth = (underlying.FONT_HEIGHT - 1.0f) * glyphScaleY * fontProvider.getYScaleMultiplier();
|
||||
|
||||
// Check ASCII space, NBSP, NNBSP
|
||||
if (chr == ' ' || chr == '\u00A0' || chr == '\u202F') {
|
||||
curX += 4 * this.getWhitespaceScale();
|
||||
|
||||
@@ -17,4 +17,5 @@ public interface FontProvider {
|
||||
float getVSize(char chr);
|
||||
float getShadowOffset();
|
||||
ResourceLocation getTexture(char chr);
|
||||
float getYScaleMultiplier();
|
||||
}
|
||||
@@ -40,12 +40,6 @@ public final class FontProviderCustom implements FontProvider {
|
||||
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;
|
||||
@@ -270,12 +264,12 @@ public final class FontProviderCustom implements FontProvider {
|
||||
|
||||
@Override
|
||||
public float getXAdvance(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].xAdvance;
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].xAdvance * FontConfig.customFontScale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGlyphW(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].glyphW;
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].glyphW * FontConfig.customFontScale;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -297,4 +291,9 @@ public final class FontProviderCustom implements FontProvider {
|
||||
public ResourceLocation getTexture(char chr) {
|
||||
return getAtlas(chr).texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getYScaleMultiplier() {
|
||||
return FontConfig.customFontScale;
|
||||
}
|
||||
}
|
||||
@@ -103,4 +103,9 @@ public final class FontProviderMC implements FontProvider {
|
||||
public ResourceLocation getTexture(char chr) {
|
||||
return locationFontTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getYScaleMultiplier() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public final class FontProviderUnicode implements FontProvider {
|
||||
|
||||
@Override
|
||||
public float getUStart(char chr) {
|
||||
final float startColumnF = (float)(this.glyphWidth[chr] >>> 4);
|
||||
final float startColumnF = (float)((this.glyphWidth[chr] >>> 4) & 15);
|
||||
return ((float) (chr % 16 * 16) + startColumnF + 0.21f) / 256.0f;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class FontProviderUnicode implements FontProvider {
|
||||
|
||||
@Override
|
||||
public float getXAdvance(char chr) {
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
final int startColumn = (this.glyphWidth[chr] >>> 4) & 15;
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
@@ -57,7 +57,7 @@ public final class FontProviderUnicode implements FontProvider {
|
||||
|
||||
@Override
|
||||
public float getGlyphW(char chr) {
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
final int startColumn = (this.glyphWidth[chr] >>> 4) & 15;
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
@@ -67,7 +67,7 @@ public final class FontProviderUnicode implements FontProvider {
|
||||
|
||||
@Override
|
||||
public float getUSize(char chr) {
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
final int startColumn = (this.glyphWidth[chr] >>> 4) & 15;
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
@@ -90,4 +90,9 @@ public final class FontProviderUnicode implements FontProvider {
|
||||
final int uniPage = chr / 256;
|
||||
return getUnicodePageLocation(uniPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getYScaleMultiplier() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -25,37 +25,42 @@ 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
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
LOGGER.warn("GraphicsEnvironment.isHeadless() returned true! Custom fonts will be unavailable. This is likely a MacOS issue.");
|
||||
availableFonts = new Font[0];
|
||||
} else {
|
||||
// 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(", ");
|
||||
for (Font font : availableFontsDirty) {
|
||||
String fontName = font.getFontName();
|
||||
if (fontSet.containsKey(fontName)) {
|
||||
duplicates.add(fontName);
|
||||
} else {
|
||||
fontSet.put(fontName, font);
|
||||
}
|
||||
}
|
||||
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);
|
||||
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);
|
||||
|
||||
LOGGER.info("Got {} fonts from GraphicsEnvironment ({} after deduplication)", availableFontsDirty.length, availableFonts.length);
|
||||
}
|
||||
|
||||
// create and add the resource pack that provides fonts
|
||||
HashMap<String, File> packMap = new HashMap<>();
|
||||
@@ -68,21 +73,6 @@ public class FontStrategist {
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,20 +102,14 @@ public class FontStrategist {
|
||||
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) {
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.gtnewhorizons.angelica.client.gui;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.config.EntityLightConfig;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.config.EntityLightConfigStorage;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.config.EntityTypeEntry;
|
||||
import jss.notfine.core.Settings;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.Option;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionGroup;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpl;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpact;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionPage;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DynamicLightsOptionPages {
|
||||
|
||||
public static OptionPage dynamicLights() {
|
||||
if (!DynamicLights.configEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<OptionGroup> groups = new ArrayList<>();
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.DYNAMIC_LIGHTS.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS_SHADER_FORCE.option)
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.DYNAMIC_LIGHTS_FRUSTUM_CULLING.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS_ADAPTIVE_TICKING.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS_CULL_TIMEOUT.option)
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.DYNAMIC_LIGHTS_SLOW_DIST.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS_SLOWER_DIST.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS_BACKGROUND_DIST.option)
|
||||
.build());
|
||||
|
||||
// Entity type toggles - grouped by mod ID
|
||||
List<EntityTypeEntry> allEntities = EntityLightConfig.getAllEntityTypes();
|
||||
Map<String, List<EntityTypeEntry>> byMod = new LinkedHashMap<>();
|
||||
|
||||
for (EntityTypeEntry entry : allEntities) {
|
||||
byMod.computeIfAbsent(entry.getModId(), _ -> new ArrayList<>()).add(entry);
|
||||
}
|
||||
|
||||
// Create a group for each mod's entities
|
||||
for (Map.Entry<String, List<EntityTypeEntry>> modEntry : byMod.entrySet()) {
|
||||
String modId = modEntry.getKey();
|
||||
List<EntityTypeEntry> entities = modEntry.getValue();
|
||||
|
||||
OptionGroup.Builder groupBuilder = OptionGroup.createBuilder();
|
||||
|
||||
for (EntityTypeEntry entity : entities) {
|
||||
Option<Boolean> option = createEntityOption(entity);
|
||||
if (option != null) {
|
||||
groupBuilder.add(option);
|
||||
}
|
||||
}
|
||||
|
||||
// Only add group if it has options
|
||||
OptionGroup group = groupBuilder.build();
|
||||
if (!group.getOptions().isEmpty()) {
|
||||
groups.add(group);
|
||||
}
|
||||
}
|
||||
|
||||
return new OptionPage(I18n.format("options.dynamiclights.page"), ImmutableList.copyOf(groups));
|
||||
}
|
||||
|
||||
private static Option<Boolean> createEntityOption(EntityTypeEntry entry) {
|
||||
final String className = entry.getClassName();
|
||||
|
||||
// Resolve class once during option creation, not on every get/set
|
||||
Class<?> resolvedClass;
|
||||
try {
|
||||
resolvedClass = Class.forName(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Class not loaded, skip this option
|
||||
return null;
|
||||
}
|
||||
|
||||
final Class<?> entityClass = resolvedClass;
|
||||
|
||||
return OptionImpl.createBuilder(Boolean.class, EntityLightConfigStorage.INSTANCE)
|
||||
.setName(entry.getDisplayName() + " (" + entry.getModId() + ")")
|
||||
.setTooltip(I18n.format("options.dynamiclights.entity.tooltip", entry.getDisplayName()))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding(
|
||||
(_, value) -> EntityLightConfig.setEntityTypeEnabled(entityClass, value),
|
||||
storage -> EntityLightConfig.isEntityTypeEnabled(entityClass)
|
||||
)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ public class FontConfigScreen extends GuiScreen {
|
||||
private final String searchPrompt;
|
||||
private final String testAreaPrompt;
|
||||
private List<String> testAreaInfo;
|
||||
private List<String> noFontsWarning;
|
||||
private String currentPrimaryFontName;
|
||||
private String currentFallbackFontName;
|
||||
private FontList fontList;
|
||||
@@ -56,6 +57,7 @@ public class FontConfigScreen extends GuiScreen {
|
||||
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);
|
||||
SliderClone.Option optCustomFontScale = new SliderClone.Option(0.1f, 3, 0.05f);
|
||||
|
||||
public FontConfigScreen(GuiScreen parent) {
|
||||
this.title = I18n.format("options.angelica.fontconfig.title");
|
||||
@@ -214,6 +216,16 @@ public class FontConfigScreen extends GuiScreen {
|
||||
.formatString("%.0f")
|
||||
.build()
|
||||
);
|
||||
sliders.add(new SliderClone.SliderCloneBuilder()
|
||||
.width(sliderWidth)
|
||||
.height(sliderHeight)
|
||||
.option(optCustomFontScale)
|
||||
.initialValue(FontConfig.customFontScale)
|
||||
.setter(value -> FontConfig.customFontScale = value)
|
||||
.langKey("options.angelica.fontconfig.custom_font_scale")
|
||||
.formatString("x%3.2f")
|
||||
.build()
|
||||
);
|
||||
|
||||
final int halfWidth = this.width / 2;
|
||||
final int sliderSpacing = 4;
|
||||
@@ -279,7 +291,6 @@ public class FontConfigScreen extends GuiScreen {
|
||||
currentFallbackFontName = null;
|
||||
selectedPrimaryFontListPos = -1;
|
||||
selectedFallbackFontListPos = -1;
|
||||
FontStrategist.customFontInUse = false;
|
||||
super.buttonList.clear();
|
||||
this.initButtons();
|
||||
}
|
||||
@@ -322,9 +333,22 @@ public class FontConfigScreen extends GuiScreen {
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float delta) {
|
||||
drawBackground(0);
|
||||
fontList.drawScreen(mouseX, mouseY, delta);
|
||||
searchBox.drawTextBox();
|
||||
// I bet you thought this was drawn inside the search box, not on top of it.
|
||||
|
||||
this.fontList.drawScreen(mouseX, mouseY, delta);
|
||||
if (availableFonts.length == 0) {
|
||||
if (this.noFontsWarning == null) {
|
||||
this.noFontsWarning = this.fontRendererObj.listFormattedStringToWidth(
|
||||
I18n.format("options.angelica.fontconfig.no_fonts_warning"), this.width / 2
|
||||
);
|
||||
}
|
||||
int y = 80;
|
||||
for (String s : this.noFontsWarning) {
|
||||
drawCenteredString(this.fontRendererObj, s, this.width / 3, y, 0xFFFFFF);
|
||||
y += this.fontRendererObj.FONT_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
this.searchBox.drawTextBox();
|
||||
if (!this.searchBox.isFocused() && this.searchBox.getText().isEmpty()) {
|
||||
this.drawCenteredString(this.fontRendererObj, this.searchPrompt,
|
||||
this.searchBox.xPosition + this.fontRendererObj.getStringWidth(this.searchPrompt) / 2 + 4,
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.gtnewhorizons.angelica.commands;
|
||||
|
||||
// Debug commands adapted from Beddium by Ven and FalsePattern
|
||||
|
||||
import com.gtnewhorizons.angelica.debug.ChunkDebugMinimap;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasDebugScreenHandler;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasWorldRenderer;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class AngelicaCommand extends CommandBase {
|
||||
|
||||
private static final List<String> SUBCOMMANDS = Arrays.asList("wireframe", "fog", "minimap", "help");
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "angelica";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "/angelica <wireframe|fog|minimap|help>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 0; // Available to all players (client-side only)
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return getListOfStringsMatchingLastWord(args, SUBCOMMANDS.toArray(new String[0]));
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sendHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "wireframe" -> handleWireframe(sender);
|
||||
case "fog" -> handleFog(sender);
|
||||
case "minimap" -> handleMinimap(sender);
|
||||
default -> sendHelp(sender);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleWireframe(ICommandSender sender) {
|
||||
CeleritasWorldRenderer.DEBUG_WIREFRAME_MODE = !CeleritasWorldRenderer.DEBUG_WIREFRAME_MODE;
|
||||
final String state = CeleritasWorldRenderer.DEBUG_WIREFRAME_MODE ? "ON" : "OFF";
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "[Angelica] " + EnumChatFormatting.WHITE + "Wireframe mode: " + state));
|
||||
}
|
||||
|
||||
private void handleFog(ICommandSender sender) {
|
||||
CeleritasDebugScreenHandler.showFogDebug = !CeleritasDebugScreenHandler.showFogDebug;
|
||||
final String f3State = CeleritasDebugScreenHandler.showFogDebug ? "ON" : "OFF";
|
||||
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "[Angelica] " + EnumChatFormatting.WHITE + "Fog debug (F3): " + f3State));
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + " " + CeleritasDebugScreenHandler.getFogDebugString()));
|
||||
}
|
||||
|
||||
private void handleMinimap(ICommandSender sender) {
|
||||
ChunkDebugMinimap.toggle();
|
||||
final String state = ChunkDebugMinimap.isEnabled() ? "ON" : "OFF";
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "[Angelica] " + EnumChatFormatting.WHITE + "Chunk debug minimap: " + state));
|
||||
}
|
||||
|
||||
private void sendHelp(ICommandSender sender) {
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "[Angelica] Debug Commands:"));
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + " /angelica wireframe" + EnumChatFormatting.WHITE + " - Toggle wireframe rendering"));
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + " /angelica fog" + EnumChatFormatting.WHITE + " - Toggle fog debug on F3"));
|
||||
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + " /angelica minimap" + EnumChatFormatting.WHITE + " - Toggle chunk debug overlay"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if (o instanceof ICommand cmd) {
|
||||
return this.getCommandName().compareTo(cmd.getCommandName());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+8
-4
@@ -55,8 +55,10 @@ public class BackhandReflectionCompat {
|
||||
if (isLoaded && renderOffhandReturn != null) {
|
||||
try {
|
||||
renderOffhandReturn.invokeExact(partialTicks);
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("Failed to invoke Backhand renderOffhandReturn", e);
|
||||
} catch (Error e) {
|
||||
throw e;
|
||||
} catch (Throwable t) {
|
||||
LOGGER.error("Failed to invoke HoloInventory renderEvent", t);
|
||||
isLoaded = false;
|
||||
}
|
||||
}
|
||||
@@ -66,8 +68,10 @@ public class BackhandReflectionCompat {
|
||||
if (isLoaded && getOffhandItem != null) {
|
||||
try {
|
||||
return (ItemStack) getOffhandItem.invokeExact(player);
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("Failed to invoke Backhand getOffhandItem", e);
|
||||
} catch (Error e) {
|
||||
throw e;
|
||||
} catch (Throwable t) {
|
||||
LOGGER.error("Failed to invoke HoloInventory renderEvent", t);
|
||||
isLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public class BetterCrashesCompat implements StateManager.IResettable {
|
||||
@Override
|
||||
public void resetState() {
|
||||
LOGGER.info("Reloading SodiumRenderer");
|
||||
((IRenderGlobalExt) Minecraft.getMinecraft().renderGlobal).reload();
|
||||
((IRenderGlobalExt) Minecraft.getMinecraft().renderGlobal).angelica$reload();
|
||||
LOGGER.info("Resetting GLStateManager");
|
||||
GLStateManager.reset();
|
||||
}
|
||||
|
||||
+8
-4
@@ -75,8 +75,10 @@ public class HoloInventoryReflectionCompat {
|
||||
} else {
|
||||
renderEventMethod.invokeExact(event);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("Failed to invoke HoloInventory renderEvent", e);
|
||||
} catch (Error e) {
|
||||
throw e;
|
||||
} catch (Throwable t) {
|
||||
LOGGER.error("Failed to invoke HoloInventory renderEvent", t);
|
||||
isLoaded = false;
|
||||
}
|
||||
}
|
||||
@@ -85,8 +87,10 @@ public class HoloInventoryReflectionCompat {
|
||||
if (!isLoaded) return;
|
||||
try {
|
||||
angelicaOverrideSetter.invokeExact(value);
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("Failed to set HoloInventory angelicaOverride", e);
|
||||
} catch (Error e) {
|
||||
throw e;
|
||||
} catch (Throwable t) {
|
||||
LOGGER.error("Failed to invoke HoloInventory renderEvent", t);
|
||||
isLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,17 @@ public class MatrixStack {
|
||||
public void pop() {
|
||||
this.matrixStack.removeLast();
|
||||
}
|
||||
public boolean clear() {
|
||||
public boolean isEmpty() {
|
||||
return this.matrixStack.size() == 1;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
while (this.matrixStack.size() > 1) {
|
||||
this.matrixStack.removeLast();
|
||||
}
|
||||
loadIdentity();
|
||||
}
|
||||
|
||||
public void translate(double d, double e, double f) {
|
||||
final Entry lv = (Entry)this.matrixStack.getLast();
|
||||
lv.model.translate((float)d, (float)e, (float)f);
|
||||
|
||||
@@ -4,10 +4,21 @@ import com.gtnewhorizon.gtnhlib.config.Config;
|
||||
|
||||
@Config(modid = "angelica", filename = "angelica-modules")
|
||||
public class AngelicaConfig {
|
||||
@Config.Comment("Enable Sodium rendering")
|
||||
@Config.Comment("Enable Celeritas terrain rendering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableSodium;
|
||||
public static boolean enableCeleritas;
|
||||
|
||||
@Config.Comment("Enable multi-threaded chunk building for improved performance [Requires Celeritas]")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresWorldRestart
|
||||
public static boolean enableThreadedChunkBuilding;
|
||||
|
||||
@Config.Comment("Number of chunk builder threads. 0 = auto-detect, -1 = use single-threaded fallback")
|
||||
@Config.DefaultInt(0)
|
||||
@Config.RangeInt(min = -1, max = 16)
|
||||
@Config.RequiresWorldRestart
|
||||
public static int chunkBuilderThreadCount;
|
||||
|
||||
@Config.Comment("Enable NotFine Options")
|
||||
@Config.DefaultBoolean(false)
|
||||
@@ -17,11 +28,6 @@ public class AngelicaConfig {
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean enableReesesSodiumOptions;
|
||||
|
||||
@Config.Comment("Enable Sodium fluid rendering [Experimental]")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableSodiumFluidRendering;
|
||||
|
||||
@Config.Comment("Inject BakedModel rendering into some vanilla blocks")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
@@ -32,7 +38,7 @@ public class AngelicaConfig {
|
||||
@Config.Ignore()
|
||||
public static boolean enableTestBlocks;
|
||||
|
||||
@Config.Comment("Enable Iris Shaders [Requires Sodium]")
|
||||
@Config.Comment("Enable Iris Shaders [Requires Celeritas]")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableIris;
|
||||
@@ -47,6 +53,11 @@ public class AngelicaConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableVBOClouds;
|
||||
|
||||
@Config.Comment("Uses cached attributes for VBO rendering, resulting in less CPU overhead. Disable if you notice any graphical issues.")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableVAO;
|
||||
|
||||
@Config.Comment("Enable NotFine features")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
@@ -194,14 +205,20 @@ public class AngelicaConfig {
|
||||
"Add a block class here if you see flickering (z-fighting) with fixBlockCrack enabled"
|
||||
})
|
||||
@Config.DefaultStringList({
|
||||
"gregtech.common.blocks.BlockOres",
|
||||
"gregtech.common.blocks.GTBlockOre",
|
||||
"shukaro.artifice.block.world.BlockOre",
|
||||
"bartworks.system.material.BWMetaGeneratedOres",
|
||||
"gtPlusPlus.core.block.base.BlockBaseOre",
|
||||
})
|
||||
public static String[] blockCrackFixRenderPassWhitelist_;
|
||||
public static String[] blockCrackFixRenderPassWhitelist__;
|
||||
|
||||
@Config.Comment("Register HardcodedCustomUniforms in Iris Shaders. May help with compatibility in certain shader packs")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean enableHardcodedCustomUniforms;
|
||||
|
||||
@Config.Comment("Renders chunks before neighbors are ready. Improves loading at render distance edges, useful for low render distance servers.")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean useVanillaChunkTracking;
|
||||
|
||||
}
|
||||
@@ -65,4 +65,9 @@ public class FontConfig {
|
||||
@Config.DefaultInt(7)
|
||||
@Config.RangeInt(min = 1, max = 24)
|
||||
public static int fontAAStrength;
|
||||
|
||||
@Config.Comment("Custom font scale multiplier, for bugfixes.")
|
||||
@Config.DefaultFloat(1.5F)
|
||||
@Config.RangeFloat(min = 0.1F, max = 3F)
|
||||
public static float customFontScale;
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Adapated from: Beddium for usage in Angelica
|
||||
*
|
||||
* Copyright (C) 2025 Ven, FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.gtnewhorizons.angelica.debug;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.AngelicaRenderSectionManager;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasWorldRenderer;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ChunkProviderClient;
|
||||
import net.minecraft.world.chunk.EmptyChunk;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Debug overlay that renders a minimap showing chunk loading and rendering state. Toggle via /angelica minimap
|
||||
*/
|
||||
public class ChunkDebugMinimap {
|
||||
private static final ChunkDebugMinimap INSTANCE = new ChunkDebugMinimap();
|
||||
@Getter
|
||||
private static volatile boolean enabled = false;
|
||||
|
||||
private static final int RANGE = 32; // Chunks in each direction from player
|
||||
|
||||
public static synchronized void toggle() {
|
||||
if (enabled) disable();
|
||||
else enable();
|
||||
}
|
||||
|
||||
public static synchronized void enable() {
|
||||
if (enabled) return;
|
||||
enabled = true;
|
||||
MinecraftForge.EVENT_BUS.register(INSTANCE);
|
||||
}
|
||||
|
||||
public static synchronized void disable() {
|
||||
if (!enabled) return;
|
||||
enabled = false;
|
||||
MinecraftForge.EVENT_BUS.unregister(INSTANCE);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderOverlay(RenderGameOverlayEvent.Text event) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.theWorld == null || mc.thePlayer == null) return;
|
||||
|
||||
final CeleritasWorldRenderer renderer;
|
||||
try {
|
||||
renderer = CeleritasWorldRenderer.getInstance();
|
||||
} catch (IllegalStateException e) {
|
||||
return; // Renderer not initialized
|
||||
}
|
||||
|
||||
final AngelicaRenderSectionManager manager = renderer.getRenderSectionManager();
|
||||
if (manager == null) return;
|
||||
|
||||
final float partialTicks = event.partialTicks;
|
||||
final double pX = mc.thePlayer.prevPosX + (mc.thePlayer.posX - mc.thePlayer.prevPosX) * partialTicks;
|
||||
final double pZ = mc.thePlayer.prevPosZ + (mc.thePlayer.posZ - mc.thePlayer.prevPosZ) * partialTicks;
|
||||
|
||||
final int playerChunkX = ((int) Math.floor(pX)) >> 4;
|
||||
final int playerChunkZ = ((int) Math.floor(pZ)) >> 4;
|
||||
|
||||
// Save GL state
|
||||
GLStateManager.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GLStateManager.glPushMatrix();
|
||||
|
||||
// Setup rendering
|
||||
GLStateManager.glScaled(2, 2, 1);
|
||||
GLStateManager.glTranslated(32, 32, 0);
|
||||
|
||||
GLStateManager.disableLighting();
|
||||
GLStateManager.disableTexture();
|
||||
GLStateManager.disableDepthTest();
|
||||
GLStateManager.enableBlend();
|
||||
GLStateManager.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GLStateManager.glBegin(GL11.GL_QUADS);
|
||||
|
||||
final ChunkProviderClient chunkProvider = (ChunkProviderClient) mc.theWorld.getChunkProvider();
|
||||
|
||||
for (int x = playerChunkX - RANGE; x < playerChunkX + RANGE; x++) {
|
||||
for (int z = playerChunkZ - RANGE; z < playerChunkZ + RANGE; z++) {
|
||||
drawChunk(x, z, playerChunkX, playerChunkZ, manager, chunkProvider);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnd();
|
||||
|
||||
// Restore GL state
|
||||
GLStateManager.enableLighting();
|
||||
GLStateManager.enableDepthTest();
|
||||
GLStateManager.disableBlend();
|
||||
GLStateManager.glPopMatrix();
|
||||
GLStateManager.glPopAttrib();
|
||||
}
|
||||
|
||||
private void drawChunk(int chunkX, int chunkZ, int playerChunkX, int playerChunkZ, AngelicaRenderSectionManager manager, ChunkProviderClient chunkProvider) {
|
||||
boolean initialized = false;
|
||||
float r = 0, g = 0, b = 0;
|
||||
|
||||
// Check all 16 sections in the chunk column
|
||||
for (int y = 0; y < 16; y++) {
|
||||
if (manager.isSectionBuilt(chunkX, y, chunkZ) && !manager.isSectionVisuallyEmpty(chunkX, y, chunkZ)) {
|
||||
initialized = true;
|
||||
g = 1; // Green = built
|
||||
if (manager.isSectionVisible(chunkX, y, chunkZ)) {
|
||||
b = 1; // Cyan = visible
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!initialized) {
|
||||
// Check if chunk is loaded
|
||||
final var chunk = chunkProvider.provideChunk(chunkX, chunkZ);
|
||||
if (chunk instanceof EmptyChunk) {
|
||||
r = 1; // Red = unloaded
|
||||
} else {
|
||||
b = 1; // Blue = loaded but not built
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glColor4f(r, g, b, 0.8f);
|
||||
|
||||
final int xStart = chunkX - playerChunkX;
|
||||
final int zStart = chunkZ - playerChunkZ;
|
||||
final int xEnd = xStart + 1;
|
||||
final int zEnd = zStart + 1;
|
||||
|
||||
GLStateManager.glVertex3d(xStart, zStart, 0);
|
||||
GLStateManager.glVertex3d(xStart, zEnd, 0);
|
||||
GLStateManager.glVertex3d(xEnd, zEnd, 0);
|
||||
GLStateManager.glVertex3d(xEnd, zStart, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Calculates the appropriate tick mode for a dynamic light source based on distance from camera and position relative to camera direction.
|
||||
*/
|
||||
public final class AdaptiveTickCalculator {
|
||||
|
||||
// Distance thresholds in blocks (configurable via settings)
|
||||
private static int slowDistance = 32; // ~2 chunks
|
||||
private static int slowerDistance = 64; // ~4 chunks
|
||||
private static int backgroundDistance = 128; // ~8 chunks
|
||||
|
||||
// Squared thresholds for efficient distance comparison
|
||||
private static int slowDistanceSq = slowDistance * slowDistance;
|
||||
private static int slowerDistanceSq = slowerDistance * slowerDistance;
|
||||
private static int backgroundDistanceSq = backgroundDistance * backgroundDistance;
|
||||
|
||||
private AdaptiveTickCalculator() {}
|
||||
|
||||
/**
|
||||
* Calculate the appropriate tick mode for a light source.
|
||||
*/
|
||||
public static AdaptiveTickMode calculate(@NotNull IDynamicLightSource source, double cameraX, double cameraY, double cameraZ, double lookDirX, double lookDirZ) {
|
||||
double dx = source.angelica$getDynamicLightX() - cameraX;
|
||||
double dy = source.angelica$getDynamicLightY() - cameraY;
|
||||
double dz = source.angelica$getDynamicLightZ() - cameraZ;
|
||||
|
||||
double distSq = dx * dx + dy * dy + dz * dz;
|
||||
|
||||
// Check if behind camera (dot product of direction to source with look direction)
|
||||
// Only use X and Z for horizontal check (more stable as player looks up/down)
|
||||
double dot = dx * lookDirX + dz * lookDirZ;
|
||||
boolean behindCamera = dot < 0;
|
||||
|
||||
// Behind camera always gets BACKGROUND mode
|
||||
if (behindCamera) {
|
||||
return AdaptiveTickMode.BACKGROUND;
|
||||
}
|
||||
|
||||
// Distance-based mode selection
|
||||
if (distSq > backgroundDistanceSq) {
|
||||
return AdaptiveTickMode.BACKGROUND;
|
||||
}
|
||||
if (distSq > slowerDistanceSq) {
|
||||
return AdaptiveTickMode.SLOWER;
|
||||
}
|
||||
if (distSq > slowDistanceSq) {
|
||||
return AdaptiveTickMode.SLOW;
|
||||
}
|
||||
|
||||
return AdaptiveTickMode.REAL_TIME;
|
||||
}
|
||||
|
||||
public static void setSlowDistance(int distance) {
|
||||
slowDistance = distance;
|
||||
slowDistanceSq = distance * distance;
|
||||
}
|
||||
|
||||
public static void setSlowerDistance(int distance) {
|
||||
slowerDistance = distance;
|
||||
slowerDistanceSq = distance * distance;
|
||||
}
|
||||
|
||||
public static void setBackgroundDistance(int distance) {
|
||||
backgroundDistance = distance;
|
||||
backgroundDistanceSq = distance * distance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights;
|
||||
|
||||
/**
|
||||
* Defines tick modes for adaptive dynamic light updates. Distant or off-screen light sources update less frequently to save CPU.
|
||||
*/
|
||||
public enum AdaptiveTickMode {
|
||||
/** Updates every tick - for nearby, visible light sources */
|
||||
REAL_TIME(1),
|
||||
/** Updates every 5 ticks - for light sources at moderate distance */
|
||||
SLOW(5),
|
||||
/** Updates every 10 ticks - for light sources at far distance */
|
||||
SLOWER(10),
|
||||
/** Updates every 20 ticks - for light sources behind the camera or very far */
|
||||
BACKGROUND(20);
|
||||
|
||||
private final int delay;
|
||||
|
||||
AdaptiveTickMode(int delay) {
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
public int getDelay() {
|
||||
return delay;
|
||||
}
|
||||
|
||||
public boolean shouldTickThisFrame(int worldTick, int sourceHash) {
|
||||
if (delay <= 1) {
|
||||
return true;
|
||||
}
|
||||
return (worldTick % delay) == Math.abs(sourceHash % delay);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.util.CoordinatePacker;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
import it.unimi.dsi.fastutil.longs.LongIterator;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
/**
|
||||
* Manages deferred chunk rebuilds for dynamic lights with optional frustum culling. Instead of scheduling chunk rebuilds immediately
|
||||
* when light sources move, this tracks pending rebuilds and only schedules visible chunks.
|
||||
*/
|
||||
public class ChunkRebuildManager {
|
||||
|
||||
/** Maps packed chunk position to ticks waiting */
|
||||
private final Long2IntOpenHashMap pendingRebuilds = new Long2IntOpenHashMap();
|
||||
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
/** Maximum ticks a pending rebuild can wait before being forced through */
|
||||
private static int maxTicksWaiting = 100;
|
||||
|
||||
/** Reusable lists for processVisible - only used from render thread */
|
||||
private final LongArrayList candidates = new LongArrayList();
|
||||
private final LongArrayList toRebuild = new LongArrayList();
|
||||
private final LongArrayList toIncrement = new LongArrayList();
|
||||
|
||||
public static void setMaxTicksWaiting(int ticks) {
|
||||
maxTicksWaiting = Math.max(20, Math.min(ticks, 600)); // Clamp 1-30 seconds (20-600 ticks)
|
||||
}
|
||||
|
||||
public void requestRebuild(int x, int y, int z) {
|
||||
final long packed = CoordinatePacker.pack(x, y, z);
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
// Reset wait counter if already pending, otherwise add new entry
|
||||
pendingRebuilds.put(packed, 0);
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void processVisible(Viewport viewport, @NotNull IDynamicLightWorldRenderer renderer) {
|
||||
candidates.clear();
|
||||
toRebuild.clear();
|
||||
toIncrement.clear();
|
||||
|
||||
// Phase 1: Collect all pending chunks with read lock (fast)
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
if (pendingRebuilds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// Collect candidates that might need processing
|
||||
final var iterator = pendingRebuilds.long2IntEntrySet().fastIterator();
|
||||
while (iterator.hasNext()) {
|
||||
final var entry = iterator.next();
|
||||
final long packed = entry.getLongKey();
|
||||
final int ticksWaiting = entry.getIntValue();
|
||||
|
||||
// Force process if no viewport or waited too long
|
||||
if (viewport == null || ticksWaiting >= maxTicksWaiting) {
|
||||
toRebuild.add(packed);
|
||||
} else {
|
||||
candidates.add(packed);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
|
||||
// Phase 2: Check visibility
|
||||
for (int i = 0; i < candidates.size(); i++) {
|
||||
long packed = candidates.getLong(i);
|
||||
int x = CoordinatePacker.unpackX(packed);
|
||||
int y = CoordinatePacker.unpackY(packed);
|
||||
int z = CoordinatePacker.unpackZ(packed);
|
||||
|
||||
if (isChunkVisible(viewport, x, y, z)) {
|
||||
toRebuild.add(packed);
|
||||
} else {
|
||||
toIncrement.add(packed);
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 3: Update map with write lock (brief)
|
||||
if (!toRebuild.isEmpty() || !toIncrement.isEmpty()) {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
// Remove chunks we're going to rebuild
|
||||
LongIterator rebuildIter = toRebuild.iterator();
|
||||
while (rebuildIter.hasNext()) {
|
||||
pendingRebuilds.remove(rebuildIter.nextLong());
|
||||
}
|
||||
LongIterator incIter = toIncrement.iterator();
|
||||
while (incIter.hasNext()) {
|
||||
long packed = incIter.nextLong();
|
||||
int current = pendingRebuilds.get(packed);
|
||||
if (pendingRebuilds.containsKey(packed)) {
|
||||
pendingRebuilds.put(packed, current + 1);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 4: Schedule rebuilds outside of lock
|
||||
for (int i = 0; i < toRebuild.size(); i++) {
|
||||
final long packed = toRebuild.getLong(i);
|
||||
renderer.scheduleRebuildForChunk(
|
||||
CoordinatePacker.unpackX(packed),
|
||||
CoordinatePacker.unpackY(packed),
|
||||
CoordinatePacker.unpackZ(packed),
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isChunkVisible(Viewport viewport, int chunkX, int chunkY, int chunkZ) {
|
||||
// Convert chunk section coords to block coords
|
||||
int blockX = chunkX << 4;
|
||||
int blockY = chunkY << 4;
|
||||
int blockZ = chunkZ << 4;
|
||||
|
||||
// Check if the 16x16x16 chunk section box is visible
|
||||
return viewport.isBoxVisible(
|
||||
blockX, blockY, blockZ,
|
||||
blockX + 16, blockY + 16, blockZ + 16
|
||||
);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
pendingRebuilds.clear();
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public int getPendingCount() {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
return pendingRebuilds.size();
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,10 @@ import com.gtnewhorizons.angelica.api.IDynamicLightProducer;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.battlegear2.Battlegear2Compat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.config.EntityLightConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.PrimedEntityAccessor;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
|
||||
import mods.battlegear2.api.core.IBattlePlayer;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -22,20 +23,28 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class DynamicLights {
|
||||
private static DynamicLights instance;
|
||||
private static IDynamicLightWorldRenderer activeRenderer;
|
||||
public static DynamicLightsMode Mode = DynamicLightsMode.OFF;
|
||||
public static boolean ShaderForce = false;
|
||||
public static boolean FrustumCullingEnabled = true;
|
||||
public static boolean AdaptiveTickingEnabled = true;
|
||||
|
||||
public static final boolean configEnabled = AngelicaConfig.enableDynamicLights;
|
||||
|
||||
@@ -43,6 +52,7 @@ public class DynamicLights {
|
||||
private static final double MAX_RADIUS_SQUARED = MAX_RADIUS * MAX_RADIUS;
|
||||
private final Set<IDynamicLightSource> dynamicLightSources = new ObjectOpenHashSet<>();
|
||||
private final ReentrantReadWriteLock lightSourcesLock = new ReentrantReadWriteLock();
|
||||
private final ChunkRebuildManager chunkRebuildManager = new ChunkRebuildManager();
|
||||
private long lastUpdate = System.currentTimeMillis();
|
||||
private int lastUpdateCount = 0;
|
||||
|
||||
@@ -60,12 +70,20 @@ public class DynamicLights {
|
||||
(ShaderForce || !IrisApi.getInstance().isShaderPackInUse());
|
||||
}
|
||||
|
||||
public static IDynamicLightWorldRenderer getActiveRenderer() {
|
||||
return activeRenderer;
|
||||
}
|
||||
|
||||
public static void setActiveRenderer(IDynamicLightWorldRenderer renderer) {
|
||||
activeRenderer = renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates all light sources.
|
||||
*
|
||||
* @param renderer the renderer
|
||||
*/
|
||||
public void updateAll(@NotNull SodiumWorldRenderer renderer) {
|
||||
public void updateAll(@NotNull IDynamicLightWorldRenderer renderer) {
|
||||
if (!isEnabled())
|
||||
return;
|
||||
|
||||
@@ -74,8 +92,43 @@ public class DynamicLights {
|
||||
this.lastUpdate = now;
|
||||
this.lastUpdateCount = 0;
|
||||
|
||||
// Get camera info for adaptive ticking
|
||||
double cameraX = 0, cameraY = 0, cameraZ = 0;
|
||||
double lookDirX = 0, lookDirZ = 1;
|
||||
int worldTick = 0;
|
||||
|
||||
if (AdaptiveTickingEnabled) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.theWorld != null && mc.renderViewEntity != null) {
|
||||
cameraX = mc.renderViewEntity.posX;
|
||||
cameraY = mc.renderViewEntity.posY + mc.renderViewEntity.getEyeHeight();
|
||||
cameraZ = mc.renderViewEntity.posZ;
|
||||
worldTick = (int) (mc.theWorld.getTotalWorldTime() & 0x7FFFFFFF);
|
||||
|
||||
// Calculate look direction from yaw (normalized horizontal direction)
|
||||
float yaw = mc.renderViewEntity.rotationYaw;
|
||||
double yawRad = Math.toRadians(yaw);
|
||||
lookDirX = -Math.sin(yawRad);
|
||||
lookDirZ = Math.cos(yawRad);
|
||||
}
|
||||
}
|
||||
|
||||
this.lightSourcesLock.readLock().lock();
|
||||
for (var lightSource : this.dynamicLightSources) {
|
||||
// Entity type filter
|
||||
if (!EntityLightConfig.isEntityTypeEnabled(lightSource)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Adaptive ticking filter
|
||||
if (AdaptiveTickingEnabled) {
|
||||
AdaptiveTickMode mode = AdaptiveTickCalculator.calculate(
|
||||
lightSource, cameraX, cameraY, cameraZ, lookDirX, lookDirZ);
|
||||
if (!mode.shouldTickThisFrame(worldTick, lightSource.hashCode())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (lightSource.angelica$updateDynamicLight(renderer))
|
||||
this.lastUpdateCount++;
|
||||
}
|
||||
@@ -107,8 +160,8 @@ public class DynamicLights {
|
||||
it = dynamicLightSources.next();
|
||||
if (it.equals(lightSource)) {
|
||||
dynamicLightSources.remove();
|
||||
if (SodiumWorldRenderer.getInstance() != null)
|
||||
lightSource.angelica$scheduleTrackedChunksRebuild(SodiumWorldRenderer.getInstance());
|
||||
if (activeRenderer != null)
|
||||
lightSource.angelica$scheduleTrackedChunksRebuild(activeRenderer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -130,10 +183,10 @@ public class DynamicLights {
|
||||
it = dynamicLightSources.next();
|
||||
if (filter.test(it)) {
|
||||
dynamicLightSources.remove();
|
||||
if (SodiumWorldRenderer.getInstance() != null) {
|
||||
if (activeRenderer != null) {
|
||||
if (it.angelica$getLuminance() > 0)
|
||||
it.angelica$resetDynamicLight();
|
||||
it.angelica$scheduleTrackedChunksRebuild(SodiumWorldRenderer.getInstance());
|
||||
it.angelica$scheduleTrackedChunksRebuild(activeRenderer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -153,10 +206,10 @@ public class DynamicLights {
|
||||
while (dynamicLightSources.hasNext()) {
|
||||
it = dynamicLightSources.next();
|
||||
dynamicLightSources.remove();
|
||||
if (SodiumWorldRenderer.getInstance() != null) {
|
||||
if (activeRenderer != null) {
|
||||
if (it.angelica$getLuminance() > 0)
|
||||
it.angelica$resetDynamicLight();
|
||||
it.angelica$scheduleTrackedChunksRebuild(SodiumWorldRenderer.getInstance());
|
||||
it.angelica$scheduleTrackedChunksRebuild(activeRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,6 +256,20 @@ public class DynamicLights {
|
||||
return MathHelper.clamp_double(result, 0, 15);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets dynamic light level at an exact world position (for smooth per-vertex lighting).
|
||||
*/
|
||||
public double getDynamicLightLevel(double x, double y, double z) {
|
||||
double result = 0;
|
||||
this.lightSourcesLock.readLock().lock();
|
||||
for (var lightSource : this.dynamicLightSources) {
|
||||
result = maxDynamicLightLevelExact(x, y, z, lightSource, result);
|
||||
}
|
||||
this.lightSourcesLock.readLock().unlock();
|
||||
|
||||
return MathHelper.clamp_double(result, 0, 15);
|
||||
}
|
||||
|
||||
public double getDynamicLightLevel(@NotNull BlockPos pos) {
|
||||
return this.getDynamicLightLevel(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
@@ -229,6 +296,29 @@ public class DynamicLights {
|
||||
return currentLightLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates dynamic light level at an exact position (no block center offset).
|
||||
* Used for smooth per-vertex lighting.
|
||||
*/
|
||||
public static double maxDynamicLightLevelExact(double x, double y, double z, @NotNull IDynamicLightSource lightSource, double currentLightLevel) {
|
||||
int luminance = lightSource.angelica$getLuminance();
|
||||
if (luminance > 0) {
|
||||
double dx = x - lightSource.angelica$getDynamicLightX();
|
||||
double dy = y - lightSource.angelica$getDynamicLightY();
|
||||
double dz = z - lightSource.angelica$getDynamicLightZ();
|
||||
|
||||
double distanceSquared = dx * dx + dy * dy + dz * dz;
|
||||
if (distanceSquared <= MAX_RADIUS_SQUARED) {
|
||||
double multiplier = 1.0 - Math.sqrt(distanceSquared) / MAX_RADIUS;
|
||||
double lightLevel = multiplier * (double) luminance;
|
||||
if (lightLevel > currentLightLevel) {
|
||||
return lightLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
return currentLightLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the dynamic light level generated by the light source at the specified position.
|
||||
*
|
||||
@@ -245,6 +335,51 @@ public class DynamicLights {
|
||||
return this.getLightmapWithDynamicLight(this.getDynamicLightLevel(x, y, z), lightmap);
|
||||
}
|
||||
|
||||
public List<IDynamicLightSource> getSourcesForChunk(int chunkMinX, int chunkMinY, int chunkMinZ) {
|
||||
// Chunk center
|
||||
final double centerX = chunkMinX + 8.0;
|
||||
final double centerY = chunkMinY + 8.0;
|
||||
final double centerZ = chunkMinZ + 8.0;
|
||||
|
||||
// Max distance from chunk center to any corner is sqrt(3) * 8 ≈ 13.86
|
||||
// Add MAX_RADIUS to get the search radius (13.86 + 7.75)^2 ≈ 467
|
||||
final double searchRadiusSq = 470.0; // Slightly padded for safety
|
||||
|
||||
List<IDynamicLightSource> result = null;
|
||||
|
||||
this.lightSourcesLock.readLock().lock();
|
||||
try {
|
||||
for (IDynamicLightSource source : this.dynamicLightSources) {
|
||||
double dx = source.angelica$getDynamicLightX() - centerX;
|
||||
double dy = source.angelica$getDynamicLightY() - centerY;
|
||||
double dz = source.angelica$getDynamicLightZ() - centerZ;
|
||||
double distSq = dx * dx + dy * dy + dz * dz;
|
||||
|
||||
if (distSq <= searchRadiusSq) {
|
||||
if (result == null) {
|
||||
result = new ArrayList<>();
|
||||
}
|
||||
result.add(source);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
this.lightSourcesLock.readLock().unlock();
|
||||
}
|
||||
|
||||
return result != null ? result : Collections.emptyList();
|
||||
}
|
||||
|
||||
public double getDynamicLightLevelFromSources(double x, double y, double z, List<IDynamicLightSource> sources) {
|
||||
if (sources == null || sources.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
double result = 0;
|
||||
for (int i = 0, size = sources.size(); i < size; i++) {
|
||||
result = maxDynamicLightLevelExact(x, y, z, sources.get(i), result);
|
||||
}
|
||||
return MathHelper.clamp_double(result, 0, 15);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lightmap with combined light levels.
|
||||
*
|
||||
@@ -275,7 +410,7 @@ public class DynamicLights {
|
||||
* @param renderer the renderer
|
||||
* @param chunkPos the chunk position
|
||||
*/
|
||||
public static void scheduleChunkRebuild(@NotNull SodiumWorldRenderer renderer, @NotNull IBlockPos chunkPos) {
|
||||
public static void scheduleChunkRebuild(@NotNull IDynamicLightWorldRenderer renderer, @NotNull IBlockPos chunkPos) {
|
||||
scheduleChunkRebuild(renderer, chunkPos.getX(), chunkPos.getY(), chunkPos.getZ());
|
||||
}
|
||||
|
||||
@@ -285,14 +420,37 @@ public class DynamicLights {
|
||||
* @param renderer the renderer
|
||||
* @param chunkPos the packed chunk position
|
||||
*/
|
||||
public static void scheduleChunkRebuild(@NotNull SodiumWorldRenderer renderer, long chunkPos) {
|
||||
public static void scheduleChunkRebuild(@NotNull IDynamicLightWorldRenderer renderer, long chunkPos) {
|
||||
scheduleChunkRebuild(renderer, CoordinatePacker.unpackX(chunkPos), CoordinatePacker.unpackY(chunkPos), CoordinatePacker.unpackZ(chunkPos));
|
||||
}
|
||||
|
||||
public static void scheduleChunkRebuild(@NotNull SodiumWorldRenderer renderer, int x, int y, int z) {
|
||||
public static void scheduleChunkRebuild(@NotNull IDynamicLightWorldRenderer renderer, int x, int y, int z) {
|
||||
if (FrustumCullingEnabled && instance != null) {
|
||||
instance.chunkRebuildManager.requestRebuild(x, y, z);
|
||||
} else {
|
||||
renderer.scheduleRebuildForChunk(x, y, z, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void scheduleChunkRebuildForRemoval(@NotNull IDynamicLightWorldRenderer renderer, int x, int y, int z) {
|
||||
renderer.scheduleRebuildForChunk(x, y, z, false);
|
||||
}
|
||||
|
||||
public static void scheduleChunkRebuildForRemoval(@NotNull IDynamicLightWorldRenderer renderer, long chunkPos) {
|
||||
scheduleChunkRebuildForRemoval(renderer, CoordinatePacker.unpackX(chunkPos), CoordinatePacker.unpackY(chunkPos), CoordinatePacker.unpackZ(chunkPos));
|
||||
}
|
||||
|
||||
public void processChunkRebuilds(@Nullable Viewport viewport) {
|
||||
if (activeRenderer == null) {
|
||||
return;
|
||||
}
|
||||
chunkRebuildManager.processVisible(viewport, activeRenderer);
|
||||
}
|
||||
|
||||
public ChunkRebuildManager getChunkRebuildManager() {
|
||||
return chunkRebuildManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the tracked chunk sets.
|
||||
*
|
||||
@@ -333,10 +491,7 @@ public class DynamicLights {
|
||||
* @param submergedInWater {@code true} if the stack is submerged in water, else {@code false}
|
||||
* @return the luminance of the item
|
||||
*/
|
||||
public static int getLuminanceFromItemStack(@NotNull ItemStack stack, boolean submergedInWater) {
|
||||
// TODO only have certain items not glow in water?
|
||||
if (submergedInWater) return 0;
|
||||
|
||||
public static int getLuminanceFromItemStack(@NotNull ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof ItemBlock itemBlock) {
|
||||
Block block = itemBlock.field_150939_a;
|
||||
@@ -354,49 +509,53 @@ public class DynamicLights {
|
||||
|
||||
public static int getLuminanceFromEntity(@NotNull Entity entity) {
|
||||
|
||||
if (entity.fire > 0) return 15;
|
||||
if (entity.isBurning()) return 15;
|
||||
|
||||
boolean inWater = entity.isInsideOfMaterial(Material.water);
|
||||
|
||||
// TODO only have certain items not glow in water?
|
||||
if (inWater) return 0;
|
||||
|
||||
if (entity instanceof EntityItem item) {
|
||||
return getLuminanceFromItemStack(item.getEntityItem(), item.isInsideOfMaterial(Material.water));
|
||||
return getLuminanceFromItemStack(item.getEntityItem());
|
||||
}
|
||||
|
||||
int luminance = 0;
|
||||
if (entity instanceof EntityLivingBase living) {
|
||||
int luminance = 0;
|
||||
|
||||
boolean inWater = living.isInsideOfMaterial(Material.water);
|
||||
|
||||
// check equipment + hand for light (should work for all entities)
|
||||
ItemStack itemStack;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if ((itemStack = living.getEquipmentInSlot(i)) != null) {
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(itemStack, inWater));
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(itemStack));
|
||||
}
|
||||
}
|
||||
|
||||
if (ModStatus.isBattlegearLoaded &&
|
||||
living instanceof EntityPlayer player &&
|
||||
player instanceof IBattlePlayer battlePlayer &&
|
||||
battlePlayer.battlegear2$isBattlemode()
|
||||
) {
|
||||
ItemStack offhand = Battlegear2Compat.getBattlegear2Offhand(player);
|
||||
if (offhand != null) {
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand, inWater));
|
||||
if (living instanceof EntityPlayer player) {
|
||||
if (ModStatus.isBattlegearLoaded &&
|
||||
player instanceof IBattlePlayer battlePlayer &&
|
||||
battlePlayer.battlegear2$isBattlemode()
|
||||
) {
|
||||
ItemStack offhand = Battlegear2Compat.getBattlegear2Offhand(player);
|
||||
if (offhand != null) {
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ModStatus.isBackhandLoaded && living instanceof EntityPlayer player){
|
||||
ItemStack offhand = ModStatus.backhandCompat.getOffhandItem(player);
|
||||
if (offhand != null) {
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand, inWater));
|
||||
else if (ModStatus.isBackhandLoaded){
|
||||
ItemStack offhand = ModStatus.backhandCompat.getOffhandItem(player);
|
||||
if (offhand != null) {
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ModStatus.isBaublesLoaded && living instanceof EntityPlayer player){
|
||||
var playerBaubles = PlayerHandler.getPlayerBaubles(player);
|
||||
if (playerBaubles != null){
|
||||
for (int i = 0; i < playerBaubles.getSizeInventory(); i++){
|
||||
var stack = playerBaubles.getStackInSlot(i);
|
||||
if (stack != null){
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(stack, inWater));
|
||||
if (ModStatus.isBaublesLoaded){
|
||||
var playerBaubles = PlayerHandler.getPlayerBaubles(player);
|
||||
if (playerBaubles != null){
|
||||
for (int i = 0; i < playerBaubles.getSizeInventory(); i++){
|
||||
var stack = playerBaubles.getStackInSlot(i);
|
||||
if (stack != null){
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -406,7 +565,10 @@ public class DynamicLights {
|
||||
}
|
||||
|
||||
// TODO: Creepers? TNT? Dusts?
|
||||
if (entity instanceof PrimedEntityAccessor primedEntity) {
|
||||
luminance = Math.max(luminance, primedEntity.angelica$getLuminance());
|
||||
}
|
||||
|
||||
return 0;
|
||||
return luminance;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -27,11 +26,13 @@ public interface IDynamicLightSource {
|
||||
double angelica$getDynamicLightZ();
|
||||
|
||||
/**
|
||||
* Returns the dynamic light source world.
|
||||
* Returns the dynamic light source world renderer.
|
||||
*
|
||||
* @return the world instance
|
||||
* @return the world renderer instance
|
||||
*/
|
||||
SodiumWorldRenderer angelica$getDynamicLightWorld();
|
||||
default IDynamicLightWorldRenderer angelica$getDynamicLightWorld() {
|
||||
return DynamicLights.getActiveRenderer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the dynamic light is enabled or not.
|
||||
@@ -72,8 +73,9 @@ public interface IDynamicLightSource {
|
||||
* Executed at each tick.
|
||||
*/
|
||||
void angelica$dynamicLightTick();
|
||||
default void angelica$updateLights() {}
|
||||
|
||||
boolean angelica$updateDynamicLight(@NotNull SodiumWorldRenderer renderer);
|
||||
boolean angelica$updateDynamicLight(@NotNull IDynamicLightWorldRenderer renderer);
|
||||
|
||||
void angelica$scheduleTrackedChunksRebuild(@NotNull SodiumWorldRenderer renderer);
|
||||
void angelica$scheduleTrackedChunksRebuild(@NotNull IDynamicLightWorldRenderer renderer);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights;
|
||||
|
||||
/**
|
||||
* Common interface for world renderers that support dynamic lights chunk rebuilds.
|
||||
* Implemented by CeleritasWorldRenderer.
|
||||
*/
|
||||
public interface IDynamicLightWorldRenderer {
|
||||
/**
|
||||
* Schedules a chunk rebuild for the render section at the given chunk coordinates.
|
||||
*/
|
||||
void scheduleRebuildForChunk(int x, int y, int z, boolean important);
|
||||
|
||||
/**
|
||||
* Returns whether this renderer is currently active (has a world loaded).
|
||||
*/
|
||||
boolean isActive();
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights.config;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.concurrent.cas.CasMap;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.IDynamicLightSource;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public final class EntityLightConfig {
|
||||
private static final Logger LOGGER = LogManager.getLogger("Angelica/DynamicLights");
|
||||
|
||||
private static final Set<String> disabledClassNames = ConcurrentHashMap.newKeySet();
|
||||
private static final CasMap<Class<?>, Boolean> enabledCache = new CasMap<>();
|
||||
|
||||
private static File configFile;
|
||||
private static boolean initialized = false;
|
||||
|
||||
private EntityLightConfig() {}
|
||||
|
||||
public static void init(@NotNull File configDir) {
|
||||
if (initialized) return;
|
||||
|
||||
configFile = new File(configDir, "angelica-dynamiclights-entities.txt");
|
||||
load();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public static boolean isEntityTypeEnabled(@NotNull IDynamicLightSource source) {
|
||||
if (!initialized) return true;
|
||||
return isEntityTypeEnabled(source.getClass());
|
||||
}
|
||||
|
||||
public static boolean isEntityTypeEnabled(@NotNull Class<?> entityClass) {
|
||||
if (!initialized) return true;
|
||||
|
||||
Boolean cached = enabledCache.get(entityClass);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
final boolean enabled = !disabledClassNames.contains(entityClass.getName());
|
||||
Boolean existing = enabledCache.putIfAbsent(entityClass, enabled);
|
||||
return existing != null ? existing : enabled;
|
||||
}
|
||||
|
||||
public static void setEntityTypeEnabled(@NotNull Class<?> entityClass, boolean enabled) {
|
||||
enabledCache.put(entityClass, enabled);
|
||||
|
||||
final String className = entityClass.getName();
|
||||
if (enabled) {
|
||||
disabledClassNames.remove(className);
|
||||
} else {
|
||||
disabledClassNames.add(className);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<EntityTypeEntry> getAllEntityTypes() {
|
||||
List<EntityTypeEntry> entries = new ArrayList<>();
|
||||
Set<String> seenClasses = new HashSet<>();
|
||||
|
||||
Map<String, Class<? extends Entity>> stringToClass = EntityList.stringToClassMapping;
|
||||
|
||||
for (Map.Entry<String, Class<? extends Entity>> entry : stringToClass.entrySet()) {
|
||||
String entityId = entry.getKey();
|
||||
Class<?> entityClass = entry.getValue();
|
||||
String className = entityClass.getName();
|
||||
|
||||
if (seenClasses.contains(className)) continue;
|
||||
seenClasses.add(className);
|
||||
|
||||
String modId = getModIdForEntity(entityClass, entityId);
|
||||
String displayName = getDisplayName(entityId, entityClass);
|
||||
boolean enabled = !disabledClassNames.contains(className);
|
||||
|
||||
entries.add(new EntityTypeEntry(displayName, className, modId, enabled));
|
||||
}
|
||||
|
||||
// Sort by mod ID, then by display name
|
||||
entries.sort((a, b) -> {
|
||||
int modCompare = a.getModId().compareToIgnoreCase(b.getModId());
|
||||
if (modCompare != 0) return modCompare;
|
||||
return a.getDisplayName().compareToIgnoreCase(b.getDisplayName());
|
||||
});
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static String getModIdForEntity(Class<?> entityClass, String entityId) {
|
||||
// Check EntityRegistry for mod entity entries
|
||||
if (Entity.class.isAssignableFrom(entityClass)) {
|
||||
EntityRegistry.EntityRegistration registration = EntityRegistry.instance()
|
||||
.lookupModSpawn((Class<? extends Entity>) entityClass, false);
|
||||
if (registration != null && registration.getContainer() != null) {
|
||||
return registration.getContainer().getModId();
|
||||
}
|
||||
}
|
||||
|
||||
// Check if it's a vanilla entity (no dot in entity ID)
|
||||
if (!entityId.contains(".")) {
|
||||
return "minecraft";
|
||||
}
|
||||
|
||||
// Extract mod ID from entity ID (format: modid.EntityName)
|
||||
int dotIndex = entityId.indexOf('.');
|
||||
if (dotIndex > 0) {
|
||||
return entityId.substring(0, dotIndex);
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
private static String getDisplayName(String entityId, Class<?> entityClass) {
|
||||
// Use the simple class name, removing package
|
||||
String simpleName = entityClass.getSimpleName();
|
||||
if (simpleName.isEmpty()) {
|
||||
// Anonymous class, use entity ID
|
||||
return entityId;
|
||||
}
|
||||
return simpleName;
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
if (configFile == null || !configFile.exists()) return;
|
||||
|
||||
disabledClassNames.clear();
|
||||
enabledCache.clear();
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(configFile))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
line = line.trim();
|
||||
if (line.isEmpty() || line.startsWith("#")) continue;
|
||||
|
||||
// Lines are entity class names that are DISABLED
|
||||
disabledClassNames.add(line);
|
||||
}
|
||||
LOGGER.info("Loaded {} disabled entity types from config", disabledClassNames.size());
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("Failed to load entity light config: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
if (configFile == null) return;
|
||||
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(configFile))) {
|
||||
writer.write("# Angelica Dynamic Lights - Disabled Entity Types");
|
||||
writer.newLine();
|
||||
writer.write("# Each line is a fully qualified class name of an entity type that is DISABLED.");
|
||||
writer.newLine();
|
||||
writer.write("# Remove a line to re-enable dynamic lighting for that entity type.");
|
||||
writer.newLine();
|
||||
writer.newLine();
|
||||
|
||||
List<String> sorted = new ArrayList<>(disabledClassNames);
|
||||
Collections.sort(sorted);
|
||||
|
||||
for (String className : sorted) {
|
||||
writer.write(className);
|
||||
writer.newLine();
|
||||
}
|
||||
|
||||
LOGGER.info("Saved {} disabled entity types to config", disabledClassNames.size());
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("Failed to save entity light config: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights.config;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage;
|
||||
|
||||
public class EntityLightConfigStorage implements OptionStorage<EntityLightConfigStorage> {
|
||||
|
||||
public static final EntityLightConfigStorage INSTANCE = new EntityLightConfigStorage();
|
||||
|
||||
private EntityLightConfigStorage() {}
|
||||
|
||||
@Override
|
||||
public EntityLightConfigStorage getData() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
EntityLightConfig.save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights.config;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityTypeEntry {
|
||||
private final String displayName;
|
||||
private final String className;
|
||||
private final String modId;
|
||||
private boolean enabled;
|
||||
|
||||
public EntityTypeEntry(@NotNull String displayName, @NotNull String className, @NotNull String modId, boolean enabled) {
|
||||
this.displayName = displayName;
|
||||
this.className = className;
|
||||
this.modId = modId;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public String getModId() {
|
||||
return modId;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayName + " (" + modId + ") [" + (enabled ? "ON" : "OFF") + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import org.embeddedt.embeddium.impl.render.chunk.fog.FogService;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkFogMode;
|
||||
|
||||
public class AngelicaFogService implements FogService {
|
||||
private final float[] fogColorArray = new float[4];
|
||||
|
||||
@Override
|
||||
public float getFogEnd() {
|
||||
return GLStateManager.getFogState().getEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFogStart() {
|
||||
return GLStateManager.getFogState().getStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFogDensity() {
|
||||
return GLStateManager.getFogState().getDensity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFogShapeIndex() {
|
||||
return 0; // 1.7.10 only has one fog shape
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFogCutoff() {
|
||||
return getFogEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getFogColor() {
|
||||
final var fogState = GLStateManager.getFogState();
|
||||
final var color = fogState.getFogColor();
|
||||
fogColorArray[0] = (float) color.x;
|
||||
fogColorArray[1] = (float) color.y;
|
||||
fogColorArray[2] = (float) color.z;
|
||||
fogColorArray[3] = fogState.getFogAlpha();
|
||||
return fogColorArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkFogMode getFogMode() {
|
||||
if (!GLStateManager.getFogMode().isEnabled()) {
|
||||
return ChunkFogMode.NONE;
|
||||
}
|
||||
return ChunkFogMode.fromGLMode(GLStateManager.getFogState().getFogMode());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,369 @@
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import com.mitchej123.glsm.GLStateManagerService;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
public class AngelicaGLStateManagerService implements GLStateManagerService {
|
||||
|
||||
private IntBuffer intArrayBuffer = BufferUtils.createIntBuffer(16);
|
||||
|
||||
private IntBuffer getIntArrayBuffer(int size) {
|
||||
if (intArrayBuffer.capacity() < size) {
|
||||
intArrayBuffer = BufferUtils.createIntBuffer(size);
|
||||
}
|
||||
intArrayBuffer.clear();
|
||||
return intArrayBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
// ===================== QUERY OPERATIONS =====================
|
||||
|
||||
@Override
|
||||
public int glGetInteger(int pname) {
|
||||
return GLStateManager.glGetInteger(pname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String glGetString(int pname) {
|
||||
return GL11.glGetString(pname);
|
||||
}
|
||||
|
||||
// ===================== FRAMEBUFFER OPERATIONS =====================
|
||||
|
||||
@Override
|
||||
public int glGenFramebuffers() {
|
||||
return GL30.glGenFramebuffers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteFramebuffers(int framebuffer) {
|
||||
GL30.glDeleteFramebuffers(framebuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBindFramebuffer(int target, int framebuffer) {
|
||||
GL30.glBindFramebuffer(target, framebuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glCheckFramebufferStatus(int target) {
|
||||
return GL30.glCheckFramebufferStatus(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glFramebufferTexture2D(int target, int attachment, int textarget, int texture, int level) {
|
||||
GL30.glFramebufferTexture2D(target, attachment, textarget, texture, level);
|
||||
}
|
||||
|
||||
// ===================== SHADER OPERATIONS =====================
|
||||
|
||||
@Override
|
||||
public int glCreateShader(int type) {
|
||||
return GL20.glCreateShader(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glCompileShader(int shader) {
|
||||
GL20.glCompileShader(shader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glGetShaderi(int shader, int pname) {
|
||||
return GL20.glGetShaderi(shader, pname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String glGetShaderInfoLog(int shader, int maxLength) {
|
||||
return GL20.glGetShaderInfoLog(shader, maxLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteShader(int shader) {
|
||||
GL20.glDeleteShader(shader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glCreateProgram() {
|
||||
return GL20.glCreateProgram();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glAttachShader(int program, int shader) {
|
||||
GL20.glAttachShader(program, shader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glLinkProgram(int program) {
|
||||
GL20.glLinkProgram(program);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glGetProgrami(int program, int pname) {
|
||||
return GL20.glGetProgrami(program, pname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUseProgram(int program) {
|
||||
GLStateManager.glUseProgram(program);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteProgram(int program) {
|
||||
GL20.glDeleteProgram(program);
|
||||
}
|
||||
|
||||
// ===================== UNIFORM/ATTRIBUTE OPERATIONS =====================
|
||||
|
||||
@Override
|
||||
public int glGetUniformLocation(int program, CharSequence name) {
|
||||
return GL20.glGetUniformLocation(program, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform1i(int location, int value) {
|
||||
GL20.glUniform1i(location, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glGetAttribLocation(int program, CharSequence name) {
|
||||
return GL20.glGetAttribLocation(program, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBindAttribLocation(int program, int index, CharSequence name) {
|
||||
GL20.glBindAttribLocation(program, index, name);
|
||||
}
|
||||
|
||||
// ===================== VAO OPERATIONS =====================
|
||||
|
||||
@Override
|
||||
public int glGenVertexArrays() {
|
||||
return GL30.glGenVertexArrays();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBindVertexArray(int array) {
|
||||
GL30.glBindVertexArray(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteVertexArrays(int array) {
|
||||
GL30.glDeleteVertexArrays(array);
|
||||
}
|
||||
|
||||
// ===================== BUFFER OPERATIONS =====================
|
||||
|
||||
@Override
|
||||
public int glGenBuffers() {
|
||||
return GL15.glGenBuffers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBindBuffer(int target, int buffer) {
|
||||
GL15.glBindBuffer(target, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteBuffers(int buffer) {
|
||||
GL15.glDeleteBuffers(buffer);
|
||||
}
|
||||
|
||||
// ===================== TEXTURE OPERATIONS =====================
|
||||
|
||||
@Override
|
||||
public int glGenTextures() {
|
||||
return GL11.glGenTextures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGenTextures(int[] textures) {
|
||||
IntBuffer buffer = getIntArrayBuffer(textures.length);
|
||||
GL11.glGenTextures(buffer);
|
||||
buffer.get(textures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteTextures(int texture) {
|
||||
GLStateManager.glDeleteTextures(texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteTextures(int[] textures) {
|
||||
IntBuffer buffer = getIntArrayBuffer(textures.length);
|
||||
buffer.put(textures);
|
||||
buffer.flip();
|
||||
GLStateManager.glDeleteTextures(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glActiveTexture(int texture) {
|
||||
GLStateManager.glActiveTexture(texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glGetTexLevelParameteri(int target, int level, int pname) {
|
||||
return GLStateManager.glGetTexLevelParameteri(target, level, pname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glGetTexLevelParameter(int target, int level, int pname) {
|
||||
return GLStateManager.glGetTexLevelParameteri(target, level, pname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y, int width, int height) {
|
||||
GL11.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glPixelStorei(int pname, int param) {
|
||||
GLStateManager.glPixelStorei(pname, param);
|
||||
}
|
||||
|
||||
// ===================== STATE OPERATIONS =====================
|
||||
|
||||
@Override
|
||||
public void enableCullFace() {
|
||||
GLStateManager.enableCull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableCullFace() {
|
||||
GLStateManager.disableCull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableBlend() {
|
||||
GLStateManager.enableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableBlend() {
|
||||
GLStateManager.disableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBlendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
|
||||
GLStateManager.tryBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableDepthTest() {
|
||||
GLStateManager.enableDepthTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableDepthTest() {
|
||||
GLStateManager.disableDepthTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDepthFunc(int func) {
|
||||
GLStateManager.glDepthFunc(func);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDepthMask(boolean flag) {
|
||||
GLStateManager.glDepthMask(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glViewport(int x, int y, int width, int height) {
|
||||
GLStateManager.glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glColorMask(boolean red, boolean green, boolean blue, boolean alpha) {
|
||||
GLStateManager.glColorMask(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glClearColor(float red, float green, float blue, float alpha) {
|
||||
GLStateManager.glClearColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glClear(int mask) {
|
||||
GLStateManager.glClear(mask);
|
||||
}
|
||||
|
||||
// ===================== MOJANG ADDITIONS =====================
|
||||
|
||||
@Override
|
||||
public void clear(int mask, boolean checkError) {
|
||||
GLStateManager.glClear(mask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTexture(int texture) {
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveTexture() {
|
||||
return GLStateManager.getActiveTextureUnit() + GL13.GL_TEXTURE0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveTextureAccessor() {
|
||||
return GLStateManager.getActiveTextureUnit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBoundTexture(int internalUnit) {
|
||||
return GLStateManager.getBoundTextureForServerState(internalUnit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveBoundTexture() {
|
||||
return GLStateManager.getBoundTextureForServerState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewportWidth() {
|
||||
return GLStateManager.getViewportState().width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewportHeight() {
|
||||
return GLStateManager.getViewportState().height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDepthStateMask() {
|
||||
return GLStateManager.getDepthState().isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlendEnabled() {
|
||||
return GLStateManager.getBlendMode().isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoundTexture(int unit, int texture) {
|
||||
int currentUnit = GLStateManager.getActiveTextureUnit();
|
||||
if (currentUnit != unit) {
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0 + unit);
|
||||
}
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, texture);
|
||||
if (currentUnit != unit) {
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0 + currentUnit);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextureBinding(int unit) {
|
||||
return GLStateManager.getBoundTextureForServerState(unit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import com.mitchej123.glsm.RenderSystemService;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
public class AngelicaRenderSystemService implements RenderSystemService {
|
||||
|
||||
// Shader state (Mojang-specific, tracked here)
|
||||
private final int[] shaderTextures = new int[16];
|
||||
private final float[] shaderColor = {1f, 1f, 1f, 1f};
|
||||
private final float[] shaderFogColor = {0f, 0f, 0f, 1f};
|
||||
private float shaderFogStart = 0f;
|
||||
private float shaderFogEnd = 0f;
|
||||
private int fogShape = 0;
|
||||
private float shaderLineWidth = 1f;
|
||||
private final Matrix4f projectionMatrix = new Matrix4f();
|
||||
private final FloatBuffer projectionMatrixBuffer = BufferUtils.createFloatBuffer(16);
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
// ===================== TEXTURE OPERATIONS =====================
|
||||
|
||||
@Override
|
||||
public void glActiveTexture(int texture) {
|
||||
GLStateManager.glActiveTexture(texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTexture(int texture) {
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, texture);
|
||||
}
|
||||
|
||||
// ===================== STATE OPERATIONS =====================
|
||||
|
||||
@Override
|
||||
public void enableCullFace() {
|
||||
GLStateManager.enableCull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableCullFace() {
|
||||
GLStateManager.disableCull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableBlend() {
|
||||
GLStateManager.enableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableBlend() {
|
||||
GLStateManager.disableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultBlendFunc() {
|
||||
GLStateManager.defaultBlendFunc();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
|
||||
GLStateManager.tryBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnknownBlendState() {
|
||||
// No-op: Angelica tracks blend state accurately
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableDepthTest() {
|
||||
GLStateManager.enableDepthTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableDepthTest() {
|
||||
GLStateManager.disableDepthTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void depthFunc(int depthFunc) {
|
||||
GLStateManager.glDepthFunc(depthFunc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void depthMask(boolean flag) {
|
||||
GLStateManager.glDepthMask(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glViewport(int x, int y, int width, int height) {
|
||||
GLStateManager.glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glClearColor(float red, float green, float blue, float alpha) {
|
||||
GLStateManager.glClearColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(int mask, boolean checkError) {
|
||||
GLStateManager.glClear(mask);
|
||||
}
|
||||
|
||||
// ===================== UNIFORM OPERATIONS =====================
|
||||
|
||||
@Override
|
||||
public void glUniform1i(int location, int value) {
|
||||
GL20.glUniform1i(location, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniformMatrix3(int location, boolean transpose, FloatBuffer value) {
|
||||
GL20.glUniformMatrix3(location, transpose, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniformMatrix4(int location, boolean transpose, FloatBuffer value) {
|
||||
GL20.glUniformMatrix4(location, transpose, value);
|
||||
}
|
||||
|
||||
// ===================== THREAD ASSERTIONS =====================
|
||||
|
||||
@Override
|
||||
public void assertOnRenderThread() {
|
||||
// No-op: 1.7.10 is single-threaded for rendering
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertOnRenderThreadOrInit() {
|
||||
// No-op: 1.7.10 is single-threaded for rendering
|
||||
}
|
||||
|
||||
// ===================== SHADER STATE =====================
|
||||
|
||||
@Override
|
||||
public void setShaderTexture(int shaderTexture, int textureId) {
|
||||
if (shaderTexture >= 0 && shaderTexture < 16) {
|
||||
shaderTextures[shaderTexture] = textureId;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getShaderTexture(int shaderTexture) {
|
||||
return (shaderTexture >= 0 && shaderTexture < 16) ? shaderTextures[shaderTexture] : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShaderColor(float red, float green, float blue, float alpha) {
|
||||
shaderColor[0] = red;
|
||||
shaderColor[1] = green;
|
||||
shaderColor[2] = blue;
|
||||
shaderColor[3] = alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getShaderColor() {
|
||||
return shaderColor.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShaderLineWidth(float lineWidth) {
|
||||
shaderLineWidth = lineWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShaderLineWidth() {
|
||||
return shaderLineWidth;
|
||||
}
|
||||
|
||||
// ===================== FOG STATE =====================
|
||||
|
||||
@Override
|
||||
public void setShaderFogColor(float red, float green, float blue, float alpha) {
|
||||
shaderFogColor[0] = red;
|
||||
shaderFogColor[1] = green;
|
||||
shaderFogColor[2] = blue;
|
||||
shaderFogColor[3] = alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getShaderFogColor() {
|
||||
return shaderFogColor.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShaderFogStart(float start) {
|
||||
shaderFogStart = start;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShaderFogStart() {
|
||||
return shaderFogStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShaderFogEnd(float end) {
|
||||
shaderFogEnd = end;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShaderFogEnd() {
|
||||
return shaderFogEnd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFogShape(int shape) {
|
||||
fogShape = shape;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFogShape() {
|
||||
return fogShape;
|
||||
}
|
||||
|
||||
// ===================== PROJECTION MATRIX =====================
|
||||
|
||||
@Override
|
||||
public Matrix4f getProjectionMatrix() {
|
||||
return new Matrix4f(projectionMatrix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectionMatrixOrth(Matrix4f m) {
|
||||
projectionMatrix.set(m);
|
||||
GLStateManager.glMatrixMode(GL11.GL_PROJECTION);
|
||||
projectionMatrix.get(projectionMatrixBuffer);
|
||||
projectionMatrixBuffer.rewind();
|
||||
GLStateManager.glLoadMatrix(projectionMatrixBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectionMatrixOrigin(Matrix4f m) {
|
||||
setProjectionMatrixOrth(m);
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,13 @@ package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer;
|
||||
import com.gtnewhorizons.angelica.glsm.recording.AccumulatedDraw;
|
||||
import com.gtnewhorizons.angelica.glsm.recording.CommandBuffer;
|
||||
import com.gtnewhorizons.angelica.glsm.recording.CommandBufferProcessor;
|
||||
import com.gtnewhorizons.angelica.glsm.recording.CommandBufferProcessor.BufferTransformOptimizer;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
@@ -16,17 +17,16 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* Builds final command buffers from raw command buffers and compiled VBO data.
|
||||
* Bridges the gap between VBO compilation (glsm types) and buffer processing (recording types).
|
||||
* Transforms are already collapsed to MultMatrix during recording; the optimizer
|
||||
* tracks transform state to emit deltas when draws need a different transform.
|
||||
*/
|
||||
public final class CommandBufferBuilder {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger("CommandBufferBuilder");
|
||||
|
||||
private CommandBufferBuilder() {}
|
||||
|
||||
/**
|
||||
* Build commands with transform collapsing optimization.
|
||||
* Accumulates MODELVIEW transforms and emits MultMatrix at barriers (draws, CallList).
|
||||
* Uses mergedRanges where consecutive same-transform draws are combined.
|
||||
*/
|
||||
/** Build with transform delta optimization and merged draw ranges. */
|
||||
public static void buildOptimizedFromRawBuffer(
|
||||
CommandBuffer rawBuffer,
|
||||
Map<CapturingTessellator.Flags, CompiledFormatBuffer> compiledQuadBuffers,
|
||||
@@ -76,11 +76,7 @@ public final class CommandBufferBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build commands without transform collapsing.
|
||||
* Copies state commands directly (no transform optimization), but still uses
|
||||
* merged draw ranges (draws already collapsed by format + transform in VBO compilation).
|
||||
*/
|
||||
/** Debug build: no optimizations, 1:1 draw commands. */
|
||||
public static void buildUnoptimizedFromRawBuffer(
|
||||
CommandBuffer rawBuffer,
|
||||
Map<CapturingTessellator.Flags, CompiledFormatBuffer> compiledQuadBuffers,
|
||||
@@ -96,8 +92,8 @@ public final class CommandBufferBuilder {
|
||||
vboIndexMap.put(ownedVbos[i], i);
|
||||
}
|
||||
|
||||
// Collect all merged draw ranges sorted by command index
|
||||
final List<DrawRangeWithBuffer> allRanges = collectDrawRanges(compiledQuadBuffers, compiledLineBuffer, compiledPrimitiveBuffers);
|
||||
// Collect per-draw ranges (no merging) sorted by command index
|
||||
final List<DrawRangeWithBuffer> allRanges = collectDrawRangesUnoptimized(compiledQuadBuffers, compiledLineBuffer, compiledPrimitiveBuffers);
|
||||
|
||||
rawBuffer.resetRead();
|
||||
int cmdIndex = 0;
|
||||
@@ -110,6 +106,7 @@ public final class CommandBufferBuilder {
|
||||
final int vboIdx = vboIndexMap.getInt(drb.vbo());
|
||||
if (vboIdx >= 0) {
|
||||
finalBuffer.writeDrawRange(vboIdx, drb.range().startVertex(), drb.range().vertexCount(), drb.hasBrightness());
|
||||
DisplayListManager.trackDrawRangeSource(drb.source().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,17 +121,32 @@ public final class CommandBufferBuilder {
|
||||
final int vboIdx = vboIndexMap.getInt(drb.vbo());
|
||||
if (vboIdx >= 0) {
|
||||
finalBuffer.writeDrawRange(vboIdx, drb.range().startVertex(), drb.range().vertexCount(), drb.hasBrightness());
|
||||
DisplayListManager.trackDrawRangeSource(drb.source().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect all draw ranges from compiled buffers, sorted by command index.
|
||||
*/
|
||||
/** Collect merged draw ranges, sorted by command index. */
|
||||
static List<DrawRangeWithBuffer> collectDrawRanges(
|
||||
Map<CapturingTessellator.Flags, CompiledFormatBuffer> compiledQuadBuffers,
|
||||
CompiledLineBuffer compiledLineBuffer,
|
||||
Map<CapturingTessellator.Flags, CompiledPrimitiveBuffers> compiledPrimitiveBuffers) {
|
||||
return collectDrawRangesInternal(compiledQuadBuffers, compiledLineBuffer, compiledPrimitiveBuffers, true);
|
||||
}
|
||||
|
||||
/** Collect unmerged draw ranges for debug mode. */
|
||||
static List<DrawRangeWithBuffer> collectDrawRangesUnoptimized(
|
||||
Map<CapturingTessellator.Flags, CompiledFormatBuffer> compiledQuadBuffers,
|
||||
CompiledLineBuffer compiledLineBuffer,
|
||||
Map<CapturingTessellator.Flags, CompiledPrimitiveBuffers> compiledPrimitiveBuffers) {
|
||||
return collectDrawRangesInternal(compiledQuadBuffers, compiledLineBuffer, compiledPrimitiveBuffers, false);
|
||||
}
|
||||
|
||||
private static List<DrawRangeWithBuffer> collectDrawRangesInternal(
|
||||
Map<CapturingTessellator.Flags, CompiledFormatBuffer> compiledQuadBuffers,
|
||||
CompiledLineBuffer compiledLineBuffer,
|
||||
Map<CapturingTessellator.Flags, CompiledPrimitiveBuffers> compiledPrimitiveBuffers,
|
||||
boolean useMerged) {
|
||||
|
||||
final List<DrawRangeWithBuffer> allRanges = new ArrayList<>();
|
||||
|
||||
@@ -142,17 +154,21 @@ public final class CommandBufferBuilder {
|
||||
final CompiledFormatBuffer[] quadBufferArray = compiledQuadBuffers.values().toArray(new CompiledFormatBuffer[0]);
|
||||
for (int b = 0; b < quadBufferArray.length; b++) {
|
||||
final CompiledFormatBuffer compiledBuffer = quadBufferArray[b];
|
||||
final DrawRange[] ranges = compiledBuffer.mergedRanges();
|
||||
final DrawRange[] ranges = useMerged ? compiledBuffer.mergedRanges() : compiledBuffer.perDrawRanges();
|
||||
for (int i = 0; i < ranges.length; i++) {
|
||||
allRanges.add(new DrawRangeWithBuffer(ranges[i], compiledBuffer.vbo(), compiledBuffer.flags().hasBrightness));
|
||||
allRanges.add(new DrawRangeWithBuffer(ranges[i], compiledBuffer.vbo(), compiledBuffer.flags(),
|
||||
DrawRangeWithBuffer.DrawSource.TESSELLATOR_QUADS));
|
||||
}
|
||||
}
|
||||
|
||||
// Add immediate mode line ranges
|
||||
// Lines use a minimal flags (color only, no texture/brightness/normals)
|
||||
if (compiledLineBuffer != null) {
|
||||
final DrawRange[] ranges = compiledLineBuffer.mergedRanges();
|
||||
final CapturingTessellator.Flags lineFlags = new CapturingTessellator.Flags(false, false, true, false);
|
||||
final DrawRange[] ranges = useMerged ? compiledLineBuffer.mergedRanges() : compiledLineBuffer.perDrawRanges();
|
||||
for (int i = 0; i < ranges.length; i++) {
|
||||
allRanges.add(new DrawRangeWithBuffer(ranges[i], compiledLineBuffer.vbo(), false));
|
||||
allRanges.add(new DrawRangeWithBuffer(ranges[i], compiledLineBuffer.vbo(), lineFlags,
|
||||
DrawRangeWithBuffer.DrawSource.IMMEDIATE_MODE_LINES));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,21 +177,23 @@ public final class CommandBufferBuilder {
|
||||
final CompiledPrimitiveBuffers[] primBufferArray = compiledPrimitiveBuffers.values().toArray(new CompiledPrimitiveBuffers[0]);
|
||||
for (int p = 0; p < primBufferArray.length; p++) {
|
||||
final CompiledPrimitiveBuffers primBuffers = primBufferArray[p];
|
||||
final boolean hasBrightness = primBuffers.flags().hasBrightness;
|
||||
final CapturingTessellator.Flags primFlags = primBuffers.flags();
|
||||
// Tessellator lines
|
||||
if (primBuffers.hasLines()) {
|
||||
final DrawRange[] ranges = primBuffers.lineMergedRanges();
|
||||
final DrawRange[] ranges = useMerged ? primBuffers.lineMergedRanges() : primBuffers.linePerDrawRanges();
|
||||
final VertexBuffer vbo = primBuffers.lineVbo();
|
||||
for (int i = 0; i < ranges.length; i++) {
|
||||
allRanges.add(new DrawRangeWithBuffer(ranges[i], vbo, hasBrightness));
|
||||
allRanges.add(new DrawRangeWithBuffer(ranges[i], vbo, primFlags,
|
||||
DrawRangeWithBuffer.DrawSource.TESSELLATOR_LINES));
|
||||
}
|
||||
}
|
||||
// Tessellator triangles
|
||||
if (primBuffers.hasTriangles()) {
|
||||
final DrawRange[] ranges = primBuffers.triangleMergedRanges();
|
||||
final DrawRange[] ranges = useMerged ? primBuffers.triangleMergedRanges() : primBuffers.trianglePerDrawRanges();
|
||||
final VertexBuffer vbo = primBuffers.triangleVbo();
|
||||
for (int i = 0; i < ranges.length; i++) {
|
||||
allRanges.add(new DrawRangeWithBuffer(ranges[i], vbo, hasBrightness));
|
||||
allRanges.add(new DrawRangeWithBuffer(ranges[i], vbo, primFlags,
|
||||
DrawRangeWithBuffer.DrawSource.TESSELLATOR_TRIANGLES));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,21 +203,36 @@ public final class CommandBufferBuilder {
|
||||
return allRanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit a draw range to the output buffer, with transform if needed.
|
||||
*/
|
||||
/** Emit draw range with delta transform. Uses writeDrawRangeRestore for immediate mode. */
|
||||
private static void emitDrawRangeToBuffer(
|
||||
DrawRangeWithBuffer drb,
|
||||
BufferTransformOptimizer opt,
|
||||
CommandBuffer out,
|
||||
Object2IntMap<VertexBuffer> vboIndexMap) {
|
||||
|
||||
// Emit transform to reach the draw's expected transform
|
||||
opt.emitTransformTo(out, drb.range().transform());
|
||||
|
||||
// Write the draw range command
|
||||
final int vboIdx = vboIndexMap.getInt(drb.vbo());
|
||||
if (vboIdx >= 0) {
|
||||
out.writeDrawRange(vboIdx, drb.range().startVertex(), drb.range().vertexCount(), drb.hasBrightness());
|
||||
final var restoreData = drb.range().restoreData();
|
||||
if (restoreData != null) {
|
||||
// Immediate mode draw with attribute restoration
|
||||
final var flags = drb.flags();
|
||||
out.writeDrawRangeRestore(
|
||||
vboIdx, drb.range().startVertex(), drb.range().vertexCount(),
|
||||
drb.hasBrightness(), flags.hasColor, flags.hasNormals, flags.hasTexture,
|
||||
restoreData.lastColorR(), restoreData.lastColorG(),
|
||||
restoreData.lastColorB(), restoreData.lastColorA(),
|
||||
restoreData.lastNormalX(), restoreData.lastNormalY(), restoreData.lastNormalZ(),
|
||||
restoreData.lastTexCoordS(), restoreData.lastTexCoordT()
|
||||
);
|
||||
} else {
|
||||
// Regular tessellator draw (no restoration needed)
|
||||
out.writeDrawRange(vboIdx, drb.range().startVertex(), drb.range().vertexCount(), drb.hasBrightness());
|
||||
}
|
||||
DisplayListManager.trackDrawRangeSource(drb.source().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer;
|
||||
* </ul>
|
||||
*/
|
||||
@Desugar
|
||||
record CompiledLineBuffer(
|
||||
public record CompiledLineBuffer(
|
||||
VertexBuffer vbo,
|
||||
DrawRange[] mergedRanges,
|
||||
DrawRange[] perDrawRanges
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer;
|
||||
* Similar to CompiledFormatBuffer but handles primitives instead of quads.
|
||||
*/
|
||||
@Desugar
|
||||
record CompiledPrimitiveBuffers(
|
||||
public record CompiledPrimitiveBuffers(
|
||||
CapturingTessellator.Flags flags,
|
||||
VertexBuffer lineVbo,
|
||||
DrawRange[] lineMergedRanges,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,11 +1,25 @@
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizons.angelica.glsm.recording.AccumulatedDraw;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
/**
|
||||
* Represents a vertex range within a shared VBO, along with its transform.
|
||||
* Used during format-based batching to track where each draw's vertices are stored.
|
||||
*
|
||||
* <p>The restoreData field holds last vertex attributes for GL state restoration
|
||||
* after VBO rendering (immediate mode draws only). Null for tessellator draws.
|
||||
*/
|
||||
@Desugar
|
||||
record DrawRange(int startVertex, int vertexCount, Matrix4f transform, int commandIndex) {}
|
||||
public record DrawRange(
|
||||
int startVertex,
|
||||
int vertexCount,
|
||||
Matrix4f transform,
|
||||
int commandIndex,
|
||||
AccumulatedDraw.RestoreData restoreData
|
||||
) {
|
||||
DrawRange(int startVertex, int vertexCount, Matrix4f transform, int commandIndex) {
|
||||
this(startVertex, vertexCount, transform, commandIndex, null);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,43 @@
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer;
|
||||
|
||||
/**
|
||||
* Helper record pairing a DrawRange with its VBO and brightness flag.
|
||||
* Helper record pairing a DrawRange with its VBO and vertex format flags.
|
||||
* Used for sorting ranges by command index while retaining VBO reference.
|
||||
* Works for both quad ranges (from CompiledFormatBuffer) and line ranges (from CompiledLineBuffer).
|
||||
*/
|
||||
@Desugar
|
||||
record DrawRangeWithBuffer(DrawRange range, VertexBuffer vbo, boolean hasBrightness) {}
|
||||
record DrawRangeWithBuffer(
|
||||
DrawRange range,
|
||||
VertexBuffer vbo,
|
||||
CapturingTessellator.Flags flags,
|
||||
DrawSource source
|
||||
) {
|
||||
boolean hasBrightness() {
|
||||
return flags != null && flags.hasBrightness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Source of a draw command for debug logging.
|
||||
*/
|
||||
enum DrawSource {
|
||||
TESSELLATOR_QUADS("tessellator quads"),
|
||||
TESSELLATOR_LINES("tessellator lines"),
|
||||
TESSELLATOR_TRIANGLES("tessellator triangles"),
|
||||
IMMEDIATE_MODE_LINES("immediate mode lines");
|
||||
|
||||
private final String description;
|
||||
|
||||
DrawSource(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Accumulates geometry for a single vertex format during display list compilation.
|
||||
* All draws with the same format are collected here, then compiled into a single VBO.
|
||||
* <p>
|
||||
* Tracks two types of ranges:
|
||||
* <ul>
|
||||
* <li><b>mergedRanges</b>: Consecutive same-transform draws merged for optimized path</li>
|
||||
* <li><b>perDrawRanges</b>: One range per input draw for unoptimized path (1:1 with addDraw calls)</li>
|
||||
* </ul>
|
||||
* Tracks merged ranges (same-transform draws combined) and per-draw ranges (1:1).
|
||||
*/
|
||||
class FormatBuffer {
|
||||
final CapturingTessellator.Flags flags;
|
||||
@@ -36,25 +30,36 @@ class FormatBuffer {
|
||||
private int pendingVertexCount = 0;
|
||||
private Matrix4f pendingTransform = null;
|
||||
private int pendingCommandIndex = -1;
|
||||
private int pendingGeneration = -1;
|
||||
private int pendingStateGen = -1;
|
||||
// Track last restore data for merged draws (uses the LAST draw's data)
|
||||
private AccumulatedDraw.RestoreData pendingRestoreData = null;
|
||||
|
||||
FormatBuffer(CapturingTessellator.Flags flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a draw to this format buffer.
|
||||
* Tracks both merged (for optimized) and per-draw (for unoptimized) ranges.
|
||||
*/
|
||||
/** Add a draw, tracking both merged and per-draw ranges. */
|
||||
void addDraw(AccumulatedDraw draw) {
|
||||
int vertexCount = draw.quads.size() * 4; // 4 vertices per quad
|
||||
final int vertexCount = draw.quads.size() * 4; // 4 vertices per quad
|
||||
|
||||
// Always track per-draw range for unoptimized path
|
||||
perDrawRanges.add(new DrawRange(currentVertexOffset, vertexCount, draw.transform, draw.commandIndex));
|
||||
// Always track per-draw range for unoptimized path (includes restoreData)
|
||||
perDrawRanges.add(new DrawRange(
|
||||
currentVertexOffset, vertexCount, draw.transform, draw.commandIndex, draw.restoreData
|
||||
));
|
||||
|
||||
// Merge logic for optimized path
|
||||
if (pendingTransform != null && pendingTransform.equals(draw.transform)) {
|
||||
// Merge logic for optimized path:
|
||||
// - same matrixGeneration = same matrix transform context
|
||||
// - same stateGeneration = no state commands (draw barriers) between draws
|
||||
boolean canMerge = pendingGeneration != -1
|
||||
&& pendingGeneration == draw.matrixGeneration
|
||||
&& pendingStateGen == draw.stateGeneration;
|
||||
|
||||
if (canMerge) {
|
||||
// Extend the pending range
|
||||
pendingVertexCount += vertexCount;
|
||||
// Update restoreData to the LAST draw's data (used after merged draw completes)
|
||||
pendingRestoreData = draw.restoreData;
|
||||
} else {
|
||||
// Flush pending range if any
|
||||
flushPendingRange();
|
||||
@@ -64,6 +69,9 @@ class FormatBuffer {
|
||||
pendingVertexCount = vertexCount;
|
||||
pendingTransform = new Matrix4f(draw.transform);
|
||||
pendingCommandIndex = draw.commandIndex;
|
||||
pendingGeneration = draw.matrixGeneration;
|
||||
pendingStateGen = draw.stateGeneration;
|
||||
pendingRestoreData = draw.restoreData;
|
||||
}
|
||||
|
||||
allQuads.addAll(draw.quads);
|
||||
@@ -71,16 +79,18 @@ class FormatBuffer {
|
||||
}
|
||||
|
||||
private void flushPendingRange() {
|
||||
if (pendingTransform != null) {
|
||||
mergedRanges.add(new DrawRange(pendingStartVertex, pendingVertexCount, pendingTransform, pendingCommandIndex));
|
||||
if (pendingGeneration != -1) {
|
||||
mergedRanges.add(new DrawRange(
|
||||
pendingStartVertex, pendingVertexCount, pendingTransform, pendingCommandIndex, pendingRestoreData
|
||||
));
|
||||
pendingTransform = null;
|
||||
pendingGeneration = -1;
|
||||
pendingStateGen = -1;
|
||||
pendingRestoreData = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile all accumulated quads into a single VBO.
|
||||
* @return The compiled buffer with VBO and both range types
|
||||
*/
|
||||
/** Compile accumulated quads into a VBO. */
|
||||
CompiledFormatBuffer finish() {
|
||||
// Flush any remaining pending range
|
||||
flushPendingRange();
|
||||
|
||||
@@ -103,6 +103,9 @@ public final class GLDebug {
|
||||
GL43.glDebugMessageControl(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_NOTIFICATION, null, false);
|
||||
GL43.glDebugMessageCallback(proc);
|
||||
|
||||
// Enable synchronous debug output so errors are reported immediately with accurate stack traces
|
||||
GL11.glEnable(GL43.GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
|
||||
if ((GL11.glGetInteger(GL30.GL_CONTEXT_FLAGS) & GL43.GL_CONTEXT_FLAG_DEBUG_BIT) == 0) {
|
||||
LOGGER.warn("[GL] Warning: A non-debug context may not produce any debug output.");
|
||||
GL11.glEnable(GL43.GL_DEBUG_OUTPUT);
|
||||
@@ -125,6 +128,9 @@ public final class GLDebug {
|
||||
ARBDebugOutput.glDebugMessageControlARB(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_LOW, null, false);
|
||||
ARBDebugOutput.glDebugMessageControlARB(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_NOTIFICATION, null, false);
|
||||
ARBDebugOutput.glDebugMessageCallbackARB(proc);
|
||||
|
||||
// Enable synchronous debug output so errors are reported immediately with accurate stack traces
|
||||
GL11.glEnable(ARBDebugOutput.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
return 1;
|
||||
} else if (GLStateManager.capabilities.GL_AMD_debug_output) {
|
||||
LOGGER.info("[GL] Using AMD_debug_output for error logging.");
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -41,6 +41,7 @@ class LineBuffer {
|
||||
private int pendingVertexCount = 0;
|
||||
private Matrix4f pendingTransform = null;
|
||||
private int pendingCommandIndex = -1;
|
||||
private int pendingStateGen = -1;
|
||||
|
||||
/**
|
||||
* Add a line draw to this buffer.
|
||||
@@ -52,8 +53,14 @@ class LineBuffer {
|
||||
// Always track per-draw range for unoptimized path
|
||||
perDrawRanges.add(new DrawRange(currentVertexOffset, vertexCount, draw.transform, draw.commandIndex));
|
||||
|
||||
// Merge logic for optimized path
|
||||
if (pendingTransform != null && pendingTransform.equals(draw.transform)) {
|
||||
// Merge logic for optimized path:
|
||||
// - same transform
|
||||
// - same stateGeneration = no state commands (draw barriers) between draws
|
||||
boolean canMerge = pendingTransform != null
|
||||
&& pendingTransform.equals(draw.transform)
|
||||
&& pendingStateGen == draw.stateGeneration;
|
||||
|
||||
if (canMerge) {
|
||||
// Extend the pending range
|
||||
pendingVertexCount += vertexCount;
|
||||
} else {
|
||||
@@ -65,6 +72,7 @@ class LineBuffer {
|
||||
pendingVertexCount = vertexCount;
|
||||
pendingTransform = new Matrix4f(draw.transform);
|
||||
pendingCommandIndex = draw.commandIndex;
|
||||
pendingStateGen = draw.stateGeneration;
|
||||
}
|
||||
|
||||
allVertices.addAll(draw.lines);
|
||||
@@ -75,6 +83,7 @@ class LineBuffer {
|
||||
if (pendingTransform != null) {
|
||||
mergedRanges.add(new DrawRange(pendingStartVertex, pendingVertexCount, pendingTransform, pendingCommandIndex));
|
||||
pendingTransform = null;
|
||||
pendingStateGen = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class RenderSystem {
|
||||
}
|
||||
|
||||
public static void copyTexImage2D(int target, int level, int internalFormat, int x, int y, int width, int height, int border) {
|
||||
GL11.glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
|
||||
GLStateManager.glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
|
||||
}
|
||||
|
||||
public static void uniform1f(int location, float v0) {
|
||||
@@ -195,6 +195,10 @@ public class RenderSystem {
|
||||
return dsaState.getTexParameteri(texture, target, pname);
|
||||
}
|
||||
|
||||
public static int getTexLevelParameteri(int texture, int level, int pname) {
|
||||
return dsaState.getTexLevelParameteri(texture, level, pname);
|
||||
}
|
||||
|
||||
public static void bindImageTexture(int unit, int texture, int level, boolean layered, int layer, int access, int format) {
|
||||
if (GLStateManager.capabilities.OpenGL42) {
|
||||
GL42.glBindImageTexture(unit, texture, level, layered, layer, access, format);
|
||||
@@ -253,17 +257,17 @@ public class RenderSystem {
|
||||
|
||||
public static final FloatBuffer PROJECTION_MATRIX_BUFFER = BufferUtils.createFloatBuffer(16);
|
||||
public static void setupProjectionMatrix(Matrix4f matrix) {
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glPushMatrix();
|
||||
GLStateManager.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GLStateManager.glPushMatrix();
|
||||
matrix.get(0, PROJECTION_MATRIX_BUFFER);
|
||||
GL11.glLoadMatrix(PROJECTION_MATRIX_BUFFER);
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GLStateManager.glLoadMatrix(PROJECTION_MATRIX_BUFFER);
|
||||
GLStateManager.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
}
|
||||
|
||||
public static void restoreProjectionMatrix() {
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GLStateManager.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GLStateManager.glPopMatrix();
|
||||
GLStateManager.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
}
|
||||
|
||||
public static void blitFramebuffer(int source, int dest, int offsetX, int offsetY, int width, int height, int offsetX2, int offsetY2, int width2, int height2, int bufferChoice, int filter) {
|
||||
|
||||
@@ -40,6 +40,7 @@ class TessellatorPrimitiveBuffer {
|
||||
private int pendingLineVertexCount = 0;
|
||||
private Matrix4f pendingLineTransform = null;
|
||||
private int pendingLineCommandIndex = -1;
|
||||
private int pendingLineStateGen = -1;
|
||||
|
||||
// Ranges for triangles
|
||||
final List<DrawRange> triangleMergedRanges = new ArrayList<>();
|
||||
@@ -49,6 +50,7 @@ class TessellatorPrimitiveBuffer {
|
||||
private int pendingTriangleVertexCount = 0;
|
||||
private Matrix4f pendingTriangleTransform = null;
|
||||
private int pendingTriangleCommandIndex = -1;
|
||||
private int pendingTriangleStateGen = -1;
|
||||
|
||||
TessellatorPrimitiveBuffer(CapturingTessellator.Flags flags) {
|
||||
this.flags = flags;
|
||||
@@ -81,8 +83,14 @@ class TessellatorPrimitiveBuffer {
|
||||
final int lineVertexCount = lineCount * 2; // 2 vertices per line
|
||||
linePerDrawRanges.add(new DrawRange(currentLineVertexOffset, lineVertexCount, draw.transform, draw.commandIndex));
|
||||
|
||||
// Merge logic for optimized path
|
||||
if (pendingLineTransform != null && pendingLineTransform.equals(draw.transform)) {
|
||||
// Merge logic for optimized path:
|
||||
// - same transform
|
||||
// - same stateGeneration = no state commands (draw barriers) between draws
|
||||
boolean canMerge = pendingLineTransform != null
|
||||
&& pendingLineTransform.equals(draw.transform)
|
||||
&& pendingLineStateGen == draw.stateGeneration;
|
||||
|
||||
if (canMerge) {
|
||||
pendingLineVertexCount += lineVertexCount;
|
||||
} else {
|
||||
flushPendingLineRange();
|
||||
@@ -90,6 +98,7 @@ class TessellatorPrimitiveBuffer {
|
||||
pendingLineVertexCount = lineVertexCount;
|
||||
pendingLineTransform = new Matrix4f(draw.transform);
|
||||
pendingLineCommandIndex = draw.commandIndex;
|
||||
pendingLineStateGen = draw.stateGeneration;
|
||||
}
|
||||
currentLineVertexOffset += lineVertexCount;
|
||||
}
|
||||
@@ -99,8 +108,14 @@ class TessellatorPrimitiveBuffer {
|
||||
final int triangleVertexCount = triangleCount * 3; // 3 vertices per triangle
|
||||
trianglePerDrawRanges.add(new DrawRange(currentTriangleVertexOffset, triangleVertexCount, draw.transform, draw.commandIndex));
|
||||
|
||||
// Merge logic for optimized path
|
||||
if (pendingTriangleTransform != null && pendingTriangleTransform.equals(draw.transform)) {
|
||||
// Merge logic for optimized path:
|
||||
// - same transform
|
||||
// - same stateGeneration = no state commands (draw barriers) between draws
|
||||
boolean canMerge = pendingTriangleTransform != null
|
||||
&& pendingTriangleTransform.equals(draw.transform)
|
||||
&& pendingTriangleStateGen == draw.stateGeneration;
|
||||
|
||||
if (canMerge) {
|
||||
pendingTriangleVertexCount += triangleVertexCount;
|
||||
} else {
|
||||
flushPendingTriangleRange();
|
||||
@@ -108,6 +123,7 @@ class TessellatorPrimitiveBuffer {
|
||||
pendingTriangleVertexCount = triangleVertexCount;
|
||||
pendingTriangleTransform = new Matrix4f(draw.transform);
|
||||
pendingTriangleCommandIndex = draw.commandIndex;
|
||||
pendingTriangleStateGen = draw.stateGeneration;
|
||||
}
|
||||
currentTriangleVertexOffset += triangleVertexCount;
|
||||
}
|
||||
@@ -117,6 +133,7 @@ class TessellatorPrimitiveBuffer {
|
||||
if (pendingLineTransform != null) {
|
||||
lineMergedRanges.add(new DrawRange(pendingLineStartVertex, pendingLineVertexCount, pendingLineTransform, pendingLineCommandIndex));
|
||||
pendingLineTransform = null;
|
||||
pendingLineStateGen = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +141,7 @@ class TessellatorPrimitiveBuffer {
|
||||
if (pendingTriangleTransform != null) {
|
||||
triangleMergedRanges.add(new DrawRange(pendingTriangleStartVertex, pendingTriangleVertexCount, pendingTriangleTransform, pendingTriangleCommandIndex));
|
||||
pendingTriangleTransform = null;
|
||||
pendingTriangleStateGen = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,14 +5,13 @@ import com.gtnewhorizons.angelica.glsm.recording.commands.MultMatrixCmd;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Helper class for tracking and collapsing MODELVIEW transforms during optimization.
|
||||
* Helper class for tracking and collapsing matrix transforms during optimization.
|
||||
* Implements the transform accumulation and emission strategy:
|
||||
* <ul>
|
||||
* <li>accumulated: total relative transform (what GL matrix should be)</li>
|
||||
@@ -100,11 +99,11 @@ class TransformOptimizer {
|
||||
// But for simplicity, if lastEmitted is identity, just emit target
|
||||
if (DisplayListManager.isIdentity(lastEmitted)) {
|
||||
// Simple case: just emit target
|
||||
output.add(MultMatrixCmd.create(target, GL11.GL_MODELVIEW));
|
||||
output.add(MultMatrixCmd.create(target));
|
||||
} else {
|
||||
// Need to emit delta: inv(lastEmitted) * target
|
||||
final Matrix4f delta = new Matrix4f(lastEmitted).invert().mul(target);
|
||||
output.add(MultMatrixCmd.create(delta, GL11.GL_MODELVIEW));
|
||||
output.add(MultMatrixCmd.create(delta));
|
||||
}
|
||||
lastEmitted.set(target);
|
||||
}
|
||||
@@ -126,7 +125,7 @@ class TransformOptimizer {
|
||||
|
||||
/**
|
||||
* Check if the GL matrix is at an absolute value and clear the flag.
|
||||
* Used by LoadIdentityCmd to determine if it needs to emit.
|
||||
* Used to determine if LoadIdentity needs to emit.
|
||||
* @return true if LoadMatrix was called and not yet reset by LoadIdentity
|
||||
*/
|
||||
boolean checkAndClearAbsoluteMatrix() {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.gtnewhorizons.angelica.glsm.compat;
|
||||
|
||||
/**
|
||||
* Simple holder for fog color values captured from vanilla rendering.
|
||||
* Used by terrain renderers to access fog state.
|
||||
*/
|
||||
public class FogHelper {
|
||||
public static float red;
|
||||
public static float green;
|
||||
public static float blue;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.glsm.debug;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.states.TextureUnitArray;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -23,7 +24,9 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
// Adapted from https://github.com/makamys/CoreTweaks/blob/master/src/main/java/makamys/coretweaks/util/OpenGLDebugging.java;
|
||||
@@ -34,6 +37,7 @@ public class OpenGLDebugging {
|
||||
public static final Logger LOGGER = LogManager.getLogger("gldumper");
|
||||
|
||||
private static final Consumer<String> LINE_LOGGER = LOGGER::debug;
|
||||
private static final Set<String> seenErrors = new HashSet<>();
|
||||
public static final String GL_IS_ENABLED = "glIsEnabled()";
|
||||
public static final String GL_GET_BOOLEANV = "glGetBooleanv()";
|
||||
public static final String GL_GET_INTEGERV = "glGetIntegerv()";
|
||||
@@ -455,49 +459,195 @@ public class OpenGLDebugging {
|
||||
}
|
||||
|
||||
public static String getGLSMErrorLog() {
|
||||
StringBuilder error = new StringBuilder();
|
||||
return getGLSMErrorLog(null, false, false);
|
||||
}
|
||||
|
||||
// Re-entrancy guard - getGLSMErrorLog calls glActiveTexture which could trigger checkGLSMOnce
|
||||
private static boolean inCheck = false;
|
||||
|
||||
/**
|
||||
* Enhanced GLSM error logging with context, stack trace, and first-occurrence filtering.
|
||||
*
|
||||
* @param context Optional context string to include in error messages (e.g., "During rendering")
|
||||
* @param logStacktrace If true, includes the current stack trace in the error output
|
||||
* @param onlyFirstOccurrence If true, only logs each unique error once
|
||||
* @return Error log string if mismatches found, null otherwise
|
||||
*/
|
||||
public static String getGLSMErrorLog(String context, boolean logStacktrace, boolean onlyFirstOccurrence) {
|
||||
if (inCheck) return null;
|
||||
if (!GLStateManager.isCachingEnabled() || GLStateManager.isRecordingDisplayList()) {
|
||||
return null;
|
||||
}
|
||||
inCheck = true;
|
||||
try {
|
||||
String group = "checkGLSM" + (context == null ? "" : " " + context);
|
||||
GLDebug.pushGroup(group);
|
||||
final StringBuilder error = new StringBuilder();
|
||||
boolean mismatch = false;
|
||||
|
||||
if (context != null && !context.isEmpty()) {
|
||||
error.append("[").append(context).append("] ");
|
||||
}
|
||||
|
||||
for (int i = 0; i < instance.propertyList.length; ++i) {
|
||||
final GLproperty gLProperty = instance.propertyList[i];
|
||||
if (gLProperty.fetchCommand.equals(GL_GET_FLOATV) && gLProperty.name.endsWith("_MATRIX")) {
|
||||
final Matrix4f cached = gLProperty.getAsMatrix4f(true);
|
||||
final Matrix4f uncached = gLProperty.getAsMatrix4f(false);
|
||||
// Some precision issues due to RAD vs degrees, and translated (vs f)
|
||||
if (!cached.equals(uncached, 0.001f)) {
|
||||
LOGGER.error("GLSM mismatch: " + gLProperty.name + "\ncached:\n" + cached + "uncached:\n" + uncached);
|
||||
mismatch = true;
|
||||
|
||||
// Skip comparison if either matrix is degenerate (contains NaN/Infinity) these represent invalid GL state from bad parameters, not cache bugs
|
||||
if (isMatrixDegenerate(cached) || isMatrixDegenerate(uncached)) continue;
|
||||
|
||||
if (!matricesEquivalent(cached, uncached, 0.001f)) {
|
||||
final String errorKey = "MATRIX:" + gLProperty.name;
|
||||
if (!onlyFirstOccurrence || seenErrors.add(errorKey)) {
|
||||
final String errorMsg = "GLSM mismatch: " + gLProperty.name + "\ncached:\n" + cached + "uncached:\n" + uncached;
|
||||
LOGGER.error(errorMsg);
|
||||
error.append(errorMsg).append('\n');
|
||||
mismatch = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final String cached = gLProperty.getAsString(true);
|
||||
final String uncached = gLProperty.getAsString(false);
|
||||
if (!cached.equals(uncached)) {
|
||||
error.append("GLSM mismatch: " + gLProperty.name + " cached: " + cached + " uncached: " + uncached);
|
||||
error.append('\n');
|
||||
final String errorKey = "PROPERTY:" + gLProperty.name + ":" + cached + ":" + uncached;
|
||||
if (!onlyFirstOccurrence || seenErrors.add(errorKey)) {
|
||||
error.append("GLSM mismatch: ").append(gLProperty.name).append(" cached: ").append(cached).append(" uncached: ").append(uncached);
|
||||
error.append('\n');
|
||||
mismatch = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final TextureUnitArray textureUnits = GLStateManager.getTextures();
|
||||
final int currentActiveTexture = GLStateManager.getActiveTextureUnit();
|
||||
|
||||
// Check GL_ACTIVE_TEXTURE
|
||||
final int glActiveUnit = GL11.glGetInteger(GL13.GL_ACTIVE_TEXTURE) - GL13.GL_TEXTURE0;
|
||||
if (glActiveUnit != currentActiveTexture) {
|
||||
final String errorKey = "ACTIVE_TEXTURE:" + currentActiveTexture + ":" + glActiveUnit;
|
||||
if (!onlyFirstOccurrence || seenErrors.add(errorKey)) {
|
||||
error.append("GLSM mismatch: GL_ACTIVE_TEXTURE cached: ").append(currentActiveTexture)
|
||||
.append(" uncached: ").append(glActiveUnit).append('\n');
|
||||
mismatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check per-unit texture state
|
||||
for (int i = 0; i < textureUnits.textureMatricies.length; i++) {
|
||||
GL13.glActiveTexture(GL13.GL_TEXTURE0 + i);
|
||||
|
||||
// Check GL_TEXTURE_2D enabled
|
||||
final boolean cachedEnabled = textureUnits.getTextureUnitStates(i).isEnabled();
|
||||
final boolean uncachedEnabled = GL11.glIsEnabled(GL11.GL_TEXTURE_2D);
|
||||
if (cachedEnabled != uncachedEnabled) {
|
||||
final String errorKey = "TEXTURE_2D:" + i + ":" + cachedEnabled + ":" + uncachedEnabled;
|
||||
if (!onlyFirstOccurrence || seenErrors.add(errorKey)) {
|
||||
error.append("GLSM mismatch: GL_TEXTURE_2D cached: ").append(cachedEnabled)
|
||||
.append(" uncached: ").append(uncachedEnabled)
|
||||
.append(", texture unit: GL_TEXTURE").append(i).append('\n');
|
||||
mismatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check GL_TEXTURE_BINDING_2D
|
||||
final int cachedBinding = textureUnits.getTextureUnitBindings(i).getBinding();
|
||||
final int uncachedBinding = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
if (cachedBinding != uncachedBinding) {
|
||||
final String errorKey = "TEXTURE_BINDING_2D:" + i + ":" + cachedBinding + ":" + uncachedBinding;
|
||||
if (!onlyFirstOccurrence || seenErrors.add(errorKey)) {
|
||||
error.append("GLSM mismatch: GL_TEXTURE_BINDING_2D cached: ").append(cachedBinding)
|
||||
.append(" uncached: ").append(uncachedBinding)
|
||||
.append(", texture unit: GL_TEXTURE").append(i).append('\n');
|
||||
mismatch = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
final TextureUnitArray textureUnits = GLStateManager.getTextures();
|
||||
int currentActiveTexture = GLStateManager.getActiveTextureUnit();
|
||||
for (int i = 0; i < textureUnits.textureMatricies.length; i++) {
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0 + i);
|
||||
final boolean cached = GLStateManager.glIsEnabled(GL11.GL_TEXTURE_2D);
|
||||
final boolean uncached = GL11.glIsEnabled(GL11.GL_TEXTURE_2D);
|
||||
if (cached != uncached) {
|
||||
error.append("GLSM mismatch: " + "GL_TEXTURE_2D" + " cached: " + cached + " uncached: " + uncached + ", texture unit: GL_TEXTURE" + i);
|
||||
error.append('\n');
|
||||
mismatch = true;
|
||||
GL13.glActiveTexture(GL13.GL_TEXTURE0 + currentActiveTexture);
|
||||
|
||||
// Add stack trace if requested
|
||||
if (mismatch && logStacktrace) {
|
||||
error.append("\nStack trace:\n");
|
||||
final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||
for (int i = 2; i < stackTrace.length; i++) {
|
||||
error.append(" at ").append(stackTrace[i].toString()).append('\n');
|
||||
}
|
||||
}
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0 + currentActiveTexture);
|
||||
if (!mismatch) {
|
||||
return null;
|
||||
GLDebug.popGroup();
|
||||
|
||||
return mismatch ? error.toString() : null;
|
||||
} finally {
|
||||
inCheck = false;
|
||||
}
|
||||
return error.toString();
|
||||
}
|
||||
|
||||
public static boolean checkGLSMOnce(String context) {
|
||||
final String output = getGLSMErrorLog(context, true, true);
|
||||
|
||||
if (output != null) {
|
||||
// Only log on actual mismatch
|
||||
LOGGER.error("[{}] MISMATCH thread={}\n{}", context, Thread.currentThread().getName(), output);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a matrix contains any non-finite values (NaN or Infinity).
|
||||
* Such matrices represent invalid/degenerate GL state (e.g., zero near/far in projection).
|
||||
*/
|
||||
private static boolean isMatrixDegenerate(Matrix4f matrix) {
|
||||
for (int col = 0; col < 4; col++) {
|
||||
for (int row = 0; row < 4; row++) {
|
||||
if (!Float.isFinite(matrix.get(col, row))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two matrices with tolerance for NaN/Infinity.
|
||||
* Treats NaN == NaN and Infinity == Infinity as equal (both are degenerate states).
|
||||
* For finite values, uses epsilon comparison.
|
||||
*/
|
||||
private static boolean matricesEquivalent(Matrix4f a, Matrix4f b, float epsilon) {
|
||||
// Compare all 16 elements
|
||||
for (int col = 0; col < 4; col++) {
|
||||
for (int row = 0; row < 4; row++) {
|
||||
final float aVal = a.get(col, row);
|
||||
final float bVal = b.get(col, row);
|
||||
|
||||
// If both are non-finite (NaN or Infinity), consider them equal
|
||||
if (!Float.isFinite(aVal) && !Float.isFinite(bVal)) {
|
||||
// Both non-finite: check if both NaN or both same Infinity
|
||||
if (Float.isNaN(aVal) && Float.isNaN(bVal)) continue;
|
||||
if (Float.isInfinite(aVal) && Float.isInfinite(bVal)) {
|
||||
// Check same sign of infinity
|
||||
if ((aVal > 0) == (bVal > 0)) continue;
|
||||
}
|
||||
return false; // Different non-finite values
|
||||
}
|
||||
|
||||
// If one is finite and other is not, they differ
|
||||
if (Float.isFinite(aVal) != Float.isFinite(bVal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Both finite: use epsilon comparison
|
||||
if (Math.abs(aVal - bVal) > epsilon) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void checkGLSM() {
|
||||
String output = getGLSMErrorLog();
|
||||
final String output = getGLSMErrorLog();
|
||||
|
||||
if (output == null) {
|
||||
LOGGER.info("GLSM state matches!");
|
||||
@@ -507,7 +657,7 @@ public class OpenGLDebugging {
|
||||
}
|
||||
|
||||
public static void copyTexture(ResourceLocation resource, File output) {
|
||||
Object object = Minecraft.getMinecraft().renderEngine.mapTextureObjects.get(resource);
|
||||
final Object object = Minecraft.getMinecraft().renderEngine.mapTextureObjects.get(resource);
|
||||
|
||||
if (object != null) {
|
||||
copyTexture(((ITextureObject) object).getGlTextureId(), output);
|
||||
|
||||
@@ -72,6 +72,11 @@ public class DSAARB extends DSAUnsupported {
|
||||
return GLStateManager.getTexParameterOrDefault(texture, pname, () -> ARBDirectStateAccess.glGetTextureParameteri(texture, pname));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTexLevelParameteri(int texture, int level, int pname) {
|
||||
return ARBDirectStateAccess.glGetTextureLevelParameteri(texture, level, pname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTexSubImage2D(int destTexture, int target, int i, int i1, int i2, int i3, int i4, int width, int height) {
|
||||
ARBDirectStateAccess.glCopyTextureSubImage2D(destTexture, i, i1, i2, i3, i4, width, height);
|
||||
@@ -79,7 +84,7 @@ public class DSAARB extends DSAUnsupported {
|
||||
|
||||
@Override
|
||||
public void bindTextureToUnit(int unit, int texture) {
|
||||
if(GLStateManager.getBoundTexture(unit) == texture) return;
|
||||
if(GLStateManager.getBoundTextureForServerState(unit) == texture) return;
|
||||
|
||||
if (texture == 0) {
|
||||
super.bindTextureToUnit(unit, texture);
|
||||
|
||||
@@ -23,6 +23,8 @@ public interface DSAAccess {
|
||||
|
||||
int getTexParameteri(int texture, int target, int pname);
|
||||
|
||||
int getTexLevelParameteri(int texture, int level, int pname);
|
||||
|
||||
void copyTexSubImage2D(int destTexture, int target, int i, int i1, int i2, int i3, int i4, int width, int height);
|
||||
|
||||
void bindTextureToUnit(int unit, int texture);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DSAUnsupported implements DSAAccess {
|
||||
@Override
|
||||
public void textureImage2D(int texture, int target, int level, int internalformat, int width, int height, int border, int format, int type, ByteBuffer pixels) {
|
||||
// Get what cache thinks is bound - we'll restore to this to keep cache/GL in sync
|
||||
final int cachedBinding = GLStateManager.getBoundTexture();
|
||||
final int cachedBinding = GLStateManager.getBoundTextureForServerState();
|
||||
GL11.glBindTexture(target, texture);
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
GL11.glBindTexture(target, cachedBinding); // Restore to cache value
|
||||
@@ -32,7 +32,7 @@ public class DSAUnsupported implements DSAAccess {
|
||||
|
||||
@Override
|
||||
public void textureImage2D(int texture, int target, int level, int internalformat, int width, int height, int border, int format, int type, IntBuffer pixels) {
|
||||
final int cachedBinding = GLStateManager.getBoundTexture();
|
||||
final int cachedBinding = GLStateManager.getBoundTextureForServerState();
|
||||
GL11.glBindTexture(target, texture);
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
GL11.glBindTexture(target, cachedBinding);
|
||||
@@ -40,7 +40,7 @@ public class DSAUnsupported implements DSAAccess {
|
||||
|
||||
@Override
|
||||
public void textureSubImage2D(int texture, int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, ByteBuffer pixels) {
|
||||
final int cachedBinding = GLStateManager.getBoundTexture();
|
||||
final int cachedBinding = GLStateManager.getBoundTextureForServerState();
|
||||
GL11.glBindTexture(target, texture);
|
||||
GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
||||
GL11.glBindTexture(target, cachedBinding);
|
||||
@@ -48,7 +48,7 @@ public class DSAUnsupported implements DSAAccess {
|
||||
|
||||
@Override
|
||||
public void textureSubImage2D(int texture, int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, IntBuffer pixels) {
|
||||
final int cachedBinding = GLStateManager.getBoundTexture();
|
||||
final int cachedBinding = GLStateManager.getBoundTextureForServerState();
|
||||
GL11.glBindTexture(target, texture);
|
||||
GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
||||
GL11.glBindTexture(target, cachedBinding);
|
||||
@@ -90,9 +90,18 @@ public class DSAUnsupported implements DSAAccess {
|
||||
return GLStateManager.glGetTexParameteri(target, pname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTexLevelParameteri(int texture, int level, int pname) {
|
||||
final int previous = GLStateManager.getBoundTextureForServerState();
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
|
||||
final int result = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, pname);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, previous);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTexSubImage2D(int destTexture, int target, int i, int i1, int i2, int i3, int i4, int width, int height) {
|
||||
final int previous = GLStateManager.getBoundTexture();
|
||||
final int previous = GLStateManager.getBoundTextureForServerState();
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, destTexture);
|
||||
GL11.glCopyTexSubImage2D(target, i, i1, i2, i3, i4, width, height);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, previous);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadViewMutable;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.util.ModelQuadUtil;
|
||||
@@ -17,19 +18,49 @@ public class AccumulatedDraw {
|
||||
public final Matrix4f transform;
|
||||
public final CapturingTessellator.Flags flags;
|
||||
public final int commandIndex; // Position in command list for state tracking
|
||||
public final int matrixGeneration; // For batching: same generation = same transform context
|
||||
public final int stateGeneration; // Same value = no state commands between draws, can merge
|
||||
|
||||
public AccumulatedDraw(List<ModelQuadViewMutable> quads, Matrix4f transform, CapturingTessellator.Flags flags, int commandIndex) {
|
||||
/**
|
||||
* Last vertex restoration data for immediate mode draws.
|
||||
* Null for tessellator draws (no restoration needed).
|
||||
*/
|
||||
public final RestoreData restoreData;
|
||||
|
||||
/**
|
||||
* Holds last vertex attribute values for GL state restoration after VBO draw.
|
||||
* Used to sync GLSM cache with actual GL state after VBO rendering.
|
||||
*/
|
||||
@Desugar
|
||||
public record RestoreData(
|
||||
float lastColorR, float lastColorG, float lastColorB, float lastColorA,
|
||||
float lastNormalX, float lastNormalY, float lastNormalZ,
|
||||
float lastTexCoordS, float lastTexCoordT) {}
|
||||
|
||||
public AccumulatedDraw(List<ModelQuadViewMutable> quads, Matrix4f transform, CapturingTessellator.Flags flags, int commandIndex, int matrixGeneration) {
|
||||
this(quads, transform, flags, commandIndex, matrixGeneration, 0, null);
|
||||
}
|
||||
|
||||
public AccumulatedDraw(List<ModelQuadViewMutable> quads, Matrix4f transform, CapturingTessellator.Flags flags, int commandIndex, int matrixGeneration, int stateGeneration) {
|
||||
this(quads, transform, flags, commandIndex, matrixGeneration, stateGeneration, null);
|
||||
}
|
||||
|
||||
public AccumulatedDraw(List<ModelQuadViewMutable> quads, Matrix4f transform, CapturingTessellator.Flags flags, int commandIndex, int matrixGeneration, int stateGeneration, RestoreData restoreData) {
|
||||
// Deep copy quads - pooled quads are reused after callback
|
||||
this.quads = ModelQuadUtil.deepCopyQuads(quads);
|
||||
|
||||
this.transform = new Matrix4f(transform); // Snapshot for runtime application
|
||||
this.flags = flags;
|
||||
this.commandIndex = commandIndex;
|
||||
this.matrixGeneration = matrixGeneration;
|
||||
this.stateGeneration = stateGeneration;
|
||||
this.restoreData = restoreData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("AccumulatedDraw[quads=%d, cmdIdx=%d, flags=C%dT%dL%dN%d]",
|
||||
quads.size(), commandIndex, flags.hasColor ? 1 : 0, flags.hasTexture ? 1 : 0, flags.hasBrightness ? 1 : 0, flags.hasNormals ? 1 : 0);
|
||||
return String.format("AccumulatedDraw[quads=%d, cmdIdx=%d, matrixGen=%d, stateGen=%d, flags=C%dT%dL%dN%d, restore=%s]",
|
||||
quads.size(), commandIndex, matrixGeneration, stateGeneration, flags.hasColor ? 1 : 0, flags.hasTexture ? 1 : 0, flags.hasBrightness ? 1 : 0, flags.hasNormals ? 1 : 0,
|
||||
restoreData != null ? "yes" : "no");
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,19 @@ public class AccumulatedLineDraw {
|
||||
public final Matrix4f transform;
|
||||
public final CapturingTessellator.Flags flags;
|
||||
public final int commandIndex; // Position in command list for state tracking
|
||||
public final int stateGeneration; // Same value = no state commands between draws, can merge
|
||||
|
||||
public AccumulatedLineDraw(List<ImmediateModeRecorder.LineVertex> lines, Matrix4f transform, CapturingTessellator.Flags flags, int commandIndex) {
|
||||
this(lines, transform, flags, commandIndex, 0);
|
||||
}
|
||||
|
||||
public AccumulatedLineDraw(List<ImmediateModeRecorder.LineVertex> lines, Matrix4f transform, CapturingTessellator.Flags flags, int commandIndex, int stateGeneration) {
|
||||
// Copy lines - the source list may be cleared
|
||||
this.lines = new ArrayList<>(lines);
|
||||
this.transform = new Matrix4f(transform); // Snapshot for runtime application
|
||||
this.flags = flags;
|
||||
this.commandIndex = commandIndex;
|
||||
this.stateGeneration = stateGeneration;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+11
-3
@@ -21,13 +21,21 @@ public class AccumulatedPrimitiveDraw {
|
||||
public final Matrix4f transform;
|
||||
public final CapturingTessellator.Flags flags;
|
||||
public final int commandIndex;
|
||||
public final int matrixGeneration; // For batching: same generation = same transform context
|
||||
public final int stateGeneration; // Same value = no state commands between draws, can merge
|
||||
|
||||
public AccumulatedPrimitiveDraw(List<ModelPrimitiveView> primitives, Matrix4f transform, CapturingTessellator.Flags flags, int commandIndex) {
|
||||
public AccumulatedPrimitiveDraw(List<ModelPrimitiveView> primitives, Matrix4f transform, CapturingTessellator.Flags flags, int commandIndex, int matrixGeneration) {
|
||||
this(primitives, transform, flags, commandIndex, matrixGeneration, 0);
|
||||
}
|
||||
|
||||
public AccumulatedPrimitiveDraw(List<ModelPrimitiveView> primitives, Matrix4f transform, CapturingTessellator.Flags flags, int commandIndex, int matrixGeneration, int stateGeneration) {
|
||||
// Deep copy primitives - pooled primitives are reused after callback
|
||||
this.primitives = deepCopyPrimitives(primitives);
|
||||
this.transform = new Matrix4f(transform);
|
||||
this.flags = flags;
|
||||
this.commandIndex = commandIndex;
|
||||
this.matrixGeneration = matrixGeneration;
|
||||
this.stateGeneration = stateGeneration;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,8 +58,8 @@ public class AccumulatedPrimitiveDraw {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("AccumulatedPrimitiveDraw[primitives=%d, cmdIdx=%d, mode=%d, flags=C%dT%dL%dN%d]",
|
||||
primitives.size(), commandIndex, flags.drawMode,
|
||||
return String.format("AccumulatedPrimitiveDraw[primitives=%d, cmdIdx=%d, matrixGen=%d, stateGen=%d, mode=%d, flags=C%dT%dL%dN%d]",
|
||||
primitives.size(), commandIndex, matrixGeneration, stateGeneration, flags.drawMode,
|
||||
flags.hasColor ? 1 : 0, flags.hasTexture ? 1 : 0,
|
||||
flags.hasBrightness ? 1 : 0, flags.hasNormals ? 1 : 0);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.joml.Matrix4f;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,6 +14,12 @@ import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
public final class CommandBuffer {
|
||||
private static final int DEFAULT_CAPACITY = 4096; // Guess at typical display list size
|
||||
|
||||
// Flag bits for DRAW_RANGE_RESTORE command
|
||||
public static final int FLAG_HAS_BRIGHTNESS = 1 << 0;
|
||||
public static final int FLAG_HAS_COLOR = 1 << 1;
|
||||
public static final int FLAG_HAS_NORMALS = 1 << 2;
|
||||
public static final int FLAG_HAS_TEXTURE = 1 << 3;
|
||||
|
||||
private ByteBuffer buffer;
|
||||
private long basePointer;
|
||||
private long writePointer;
|
||||
@@ -136,22 +143,19 @@ public final class CommandBuffer {
|
||||
writeInt(0); // unused padding
|
||||
}
|
||||
|
||||
public void writeLoadIdentity(int matrixMode) {
|
||||
ensureCapacity(8);
|
||||
public void writeLoadIdentity() {
|
||||
ensureCapacity(4);
|
||||
writeInt(GLCommand.LOAD_IDENTITY);
|
||||
writeInt(matrixMode);
|
||||
}
|
||||
|
||||
public void writePushMatrix(int matrixMode) {
|
||||
ensureCapacity(8);
|
||||
public void writePushMatrix() {
|
||||
ensureCapacity(4);
|
||||
writeInt(GLCommand.PUSH_MATRIX);
|
||||
writeInt(matrixMode);
|
||||
}
|
||||
|
||||
public void writePopMatrix(int matrixMode) {
|
||||
ensureCapacity(8);
|
||||
public void writePopMatrix() {
|
||||
ensureCapacity(4);
|
||||
writeInt(GLCommand.POP_MATRIX);
|
||||
writeInt(matrixMode);
|
||||
}
|
||||
|
||||
public void writeStencilMask(int mask) {
|
||||
@@ -317,14 +321,6 @@ public final class CommandBuffer {
|
||||
writeFloat(units);
|
||||
}
|
||||
|
||||
public void writeNormal(float x, float y, float z) {
|
||||
ensureCapacity(16);
|
||||
writeInt(GLCommand.NORMAL);
|
||||
writeFloat(x);
|
||||
writeFloat(y);
|
||||
writeFloat(z);
|
||||
}
|
||||
|
||||
public void writeColor(float r, float g, float b, float a) {
|
||||
ensureCapacity(20);
|
||||
writeInt(GLCommand.COLOR);
|
||||
@@ -422,29 +418,26 @@ public final class CommandBuffer {
|
||||
|
||||
// === Double commands ===
|
||||
|
||||
public void writeTranslate(int matrixMode, double x, double y, double z) {
|
||||
ensureCapacity(32);
|
||||
public void writeTranslate(double x, double y, double z) {
|
||||
ensureCapacity(28);
|
||||
writeInt(GLCommand.TRANSLATE);
|
||||
writeInt(matrixMode);
|
||||
writeDouble(x);
|
||||
writeDouble(y);
|
||||
writeDouble(z);
|
||||
}
|
||||
|
||||
public void writeRotate(int matrixMode, double angle, double x, double y, double z) {
|
||||
ensureCapacity(40);
|
||||
public void writeRotate(double angle, double x, double y, double z) {
|
||||
ensureCapacity(36);
|
||||
writeInt(GLCommand.ROTATE);
|
||||
writeInt(matrixMode);
|
||||
writeDouble(angle);
|
||||
writeDouble(x);
|
||||
writeDouble(y);
|
||||
writeDouble(z);
|
||||
}
|
||||
|
||||
public void writeScale(int matrixMode, double x, double y, double z) {
|
||||
ensureCapacity(32);
|
||||
public void writeScale(double x, double y, double z) {
|
||||
ensureCapacity(28);
|
||||
writeInt(GLCommand.SCALE);
|
||||
writeInt(matrixMode);
|
||||
writeDouble(x);
|
||||
writeDouble(y);
|
||||
writeDouble(z);
|
||||
@@ -474,17 +467,15 @@ public final class CommandBuffer {
|
||||
|
||||
// === Matrix commands ===
|
||||
|
||||
public void writeMultMatrix(int matrixMode, Matrix4f matrix) {
|
||||
ensureCapacity(72);
|
||||
public void writeMultMatrix(Matrix4f matrix) {
|
||||
ensureCapacity(68);
|
||||
writeInt(GLCommand.MULT_MATRIX);
|
||||
writeInt(matrixMode);
|
||||
writeMatrix4f(matrix);
|
||||
}
|
||||
|
||||
public void writeLoadMatrix(int matrixMode, Matrix4f matrix) {
|
||||
ensureCapacity(72);
|
||||
public void writeLoadMatrix(Matrix4f matrix) {
|
||||
ensureCapacity(68);
|
||||
writeInt(GLCommand.LOAD_MATRIX);
|
||||
writeInt(matrixMode);
|
||||
writeMatrix4f(matrix);
|
||||
}
|
||||
|
||||
@@ -566,12 +557,97 @@ public final class CommandBuffer {
|
||||
writeInt(hasBrightness ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a DRAW_RANGE_RESTORE command that draws a VBO range and restores GL current state after.
|
||||
* Used for immediate mode VBOs to restore GL_CURRENT_COLOR, GL_CURRENT_NORMAL, GL_CURRENT_TEXTURE_COORDS.
|
||||
*
|
||||
* @param vboIndex Index into ownedVbos array
|
||||
* @param startVertex First vertex to draw
|
||||
* @param vertexCount Number of vertices to draw
|
||||
* @param hasBrightness True if VBO has brightness/lightmap data
|
||||
* @param hasColor True if color should be restored after draw
|
||||
* @param hasNormals True if normal should be restored after draw
|
||||
* @param hasTexture True if texcoord should be restored after draw
|
||||
* @param lastColorR Last vertex's red color component
|
||||
* @param lastColorG Last vertex's green color component
|
||||
* @param lastColorB Last vertex's blue color component
|
||||
* @param lastColorA Last vertex's alpha color component
|
||||
* @param lastNormalX Last vertex's normal X
|
||||
* @param lastNormalY Last vertex's normal Y
|
||||
* @param lastNormalZ Last vertex's normal Z
|
||||
* @param lastTexS Last vertex's texture S coordinate
|
||||
* @param lastTexT Last vertex's texture T coordinate
|
||||
*/
|
||||
public void writeDrawRangeRestore(
|
||||
int vboIndex, int startVertex, int vertexCount,
|
||||
boolean hasBrightness, boolean hasColor, boolean hasNormals, boolean hasTexture,
|
||||
float lastColorR, float lastColorG, float lastColorB, float lastColorA,
|
||||
float lastNormalX, float lastNormalY, float lastNormalZ,
|
||||
float lastTexS, float lastTexT
|
||||
) {
|
||||
ensureCapacity(56);
|
||||
writeInt(GLCommand.DRAW_RANGE_RESTORE);
|
||||
writeInt(vboIndex);
|
||||
writeInt(startVertex);
|
||||
writeInt(vertexCount);
|
||||
int flags = (hasBrightness ? FLAG_HAS_BRIGHTNESS : 0)
|
||||
| (hasColor ? FLAG_HAS_COLOR : 0)
|
||||
| (hasNormals ? FLAG_HAS_NORMALS : 0)
|
||||
| (hasTexture ? FLAG_HAS_TEXTURE : 0);
|
||||
writeInt(flags);
|
||||
// Last color (4 floats = 16 bytes)
|
||||
writeFloat(lastColorR);
|
||||
writeFloat(lastColorG);
|
||||
writeFloat(lastColorB);
|
||||
writeFloat(lastColorA);
|
||||
// Last normal (3 floats = 12 bytes)
|
||||
writeFloat(lastNormalX);
|
||||
writeFloat(lastNormalY);
|
||||
writeFloat(lastNormalZ);
|
||||
// Last texcoord (2 floats = 8 bytes)
|
||||
writeFloat(lastTexS);
|
||||
writeFloat(lastTexT);
|
||||
}
|
||||
|
||||
public void writeCallList(int listId) {
|
||||
ensureCapacity(8);
|
||||
writeInt(GLCommand.CALL_LIST);
|
||||
writeInt(listId);
|
||||
}
|
||||
|
||||
public void writeDrawBuffer(int mode) {
|
||||
ensureCapacity(8);
|
||||
writeInt(GLCommand.DRAW_BUFFER);
|
||||
writeInt(mode);
|
||||
}
|
||||
|
||||
private static final int MAX_DRAW_BUFFERS = 8;
|
||||
// cmd (4) + count (4) + buffers (4 * MAX_DRAW_BUFFERS)
|
||||
private static final int DRAW_BUFFERS_SIZE = 4 + 4 + 4 * MAX_DRAW_BUFFERS;
|
||||
|
||||
public void writeDrawBuffers(int count, int buffer) {
|
||||
ensureCapacity(DRAW_BUFFERS_SIZE);
|
||||
writeInt(GLCommand.DRAW_BUFFERS);
|
||||
writeInt(count);
|
||||
writeInt(buffer);
|
||||
for (int i = 1; i < MAX_DRAW_BUFFERS; i++) {
|
||||
writeInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeDrawBuffers(int count, IntBuffer bufs) {
|
||||
ensureCapacity(DRAW_BUFFERS_SIZE);
|
||||
writeInt(GLCommand.DRAW_BUFFERS);
|
||||
writeInt(count);
|
||||
final int pos = bufs.position();
|
||||
for (int i = 0; i < count && i < MAX_DRAW_BUFFERS; i++) {
|
||||
writeInt(bufs.get(pos + i));
|
||||
}
|
||||
for (int i = count; i < MAX_DRAW_BUFFERS; i++) {
|
||||
writeInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
// === Complex object reference ===
|
||||
|
||||
public void writeComplexRef(DisplayListCommand cmd) {
|
||||
|
||||
+68
-57
@@ -8,8 +8,10 @@ import org.lwjgl.BufferUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
import static com.gtnewhorizons.angelica.glsm.recording.CommandBuffer.*;
|
||||
|
||||
/**
|
||||
* Executes commands from a CommandBuffer
|
||||
@@ -21,6 +23,9 @@ public final class CommandBufferExecutor {
|
||||
private static final FloatBuffer MATRIX_BUFFER = BufferUtils.createFloatBuffer(16);
|
||||
// Static reusable buffer for fog/light/material params
|
||||
private static final FloatBuffer PARAMS_BUFFER = BufferUtils.createFloatBuffer(4);
|
||||
// Static reusable buffer for draw buffers
|
||||
private static final int MAX_DRAW_BUFFERS = 8;
|
||||
private static final IntBuffer DRAW_BUFFERS_BUFFER = BufferUtils.createIntBuffer(MAX_DRAW_BUFFERS);
|
||||
|
||||
/**
|
||||
* Execute all commands in the buffer.
|
||||
@@ -92,28 +97,13 @@ public final class CommandBufferExecutor {
|
||||
ptr += 4; // Skip unused padding
|
||||
}
|
||||
case GLCommand.LOAD_IDENTITY -> {
|
||||
final int mode = memGetInt(ptr);
|
||||
ptr += 4;
|
||||
final int savedMode = GLStateManager.getMatrixMode().getMode();
|
||||
GLStateManager.glMatrixMode(mode);
|
||||
GLStateManager.glLoadIdentity();
|
||||
GLStateManager.glMatrixMode(savedMode);
|
||||
}
|
||||
case GLCommand.PUSH_MATRIX -> {
|
||||
final int mode = memGetInt(ptr);
|
||||
ptr += 4;
|
||||
final int savedMode = GLStateManager.getMatrixMode().getMode();
|
||||
GLStateManager.glMatrixMode(mode);
|
||||
GLStateManager.glPushMatrix();
|
||||
GLStateManager.glMatrixMode(savedMode);
|
||||
}
|
||||
case GLCommand.POP_MATRIX -> {
|
||||
final int mode = memGetInt(ptr);
|
||||
ptr += 4;
|
||||
final int savedMode = GLStateManager.getMatrixMode().getMode();
|
||||
GLStateManager.glMatrixMode(mode);
|
||||
GLStateManager.glPopMatrix();
|
||||
GLStateManager.glMatrixMode(savedMode);
|
||||
}
|
||||
case GLCommand.STENCIL_MASK -> {
|
||||
GLStateManager.glStencilMask(memGetInt(ptr));
|
||||
@@ -256,13 +246,6 @@ public final class CommandBufferExecutor {
|
||||
ptr += 8;
|
||||
GLStateManager.glPolygonOffset(factor, units);
|
||||
}
|
||||
case GLCommand.NORMAL -> {
|
||||
final float x = memGetFloat(ptr);
|
||||
final float y = memGetFloat(ptr + 4);
|
||||
final float z = memGetFloat(ptr + 8);
|
||||
ptr += 12;
|
||||
GLStateManager.glNormal3f(x, y, z);
|
||||
}
|
||||
case GLCommand.COLOR -> {
|
||||
final float r = memGetFloat(ptr);
|
||||
final float g = memGetFloat(ptr + 4);
|
||||
@@ -349,38 +332,26 @@ public final class CommandBufferExecutor {
|
||||
|
||||
// === Double commands ===
|
||||
case GLCommand.TRANSLATE -> {
|
||||
final int mode = memGetInt(ptr);
|
||||
final double x = memGetDouble(ptr + 4);
|
||||
final double y = memGetDouble(ptr + 12);
|
||||
final double z = memGetDouble(ptr + 20);
|
||||
ptr += 28;
|
||||
final int savedMode = GLStateManager.getMatrixMode().getMode();
|
||||
GLStateManager.glMatrixMode(mode);
|
||||
final double x = memGetDouble(ptr);
|
||||
final double y = memGetDouble(ptr + 8);
|
||||
final double z = memGetDouble(ptr + 16);
|
||||
ptr += 24;
|
||||
GLStateManager.glTranslated(x, y, z);
|
||||
GLStateManager.glMatrixMode(savedMode);
|
||||
}
|
||||
case GLCommand.ROTATE -> {
|
||||
final int mode = memGetInt(ptr);
|
||||
final double angle = memGetDouble(ptr + 4);
|
||||
final double x = memGetDouble(ptr + 12);
|
||||
final double y = memGetDouble(ptr + 20);
|
||||
final double z = memGetDouble(ptr + 28);
|
||||
ptr += 36;
|
||||
final int savedMode = GLStateManager.getMatrixMode().getMode();
|
||||
GLStateManager.glMatrixMode(mode);
|
||||
final double angle = memGetDouble(ptr);
|
||||
final double x = memGetDouble(ptr + 8);
|
||||
final double y = memGetDouble(ptr + 16);
|
||||
final double z = memGetDouble(ptr + 24);
|
||||
ptr += 32;
|
||||
GLStateManager.glRotated(angle, x, y, z);
|
||||
GLStateManager.glMatrixMode(savedMode);
|
||||
}
|
||||
case GLCommand.SCALE -> {
|
||||
final int mode = memGetInt(ptr);
|
||||
final double x = memGetDouble(ptr + 4);
|
||||
final double y = memGetDouble(ptr + 12);
|
||||
final double z = memGetDouble(ptr + 20);
|
||||
ptr += 28;
|
||||
final int savedMode = GLStateManager.getMatrixMode().getMode();
|
||||
GLStateManager.glMatrixMode(mode);
|
||||
final double x = memGetDouble(ptr);
|
||||
final double y = memGetDouble(ptr + 8);
|
||||
final double z = memGetDouble(ptr + 16);
|
||||
ptr += 24;
|
||||
GLStateManager.glScaled(x, y, z);
|
||||
GLStateManager.glMatrixMode(savedMode);
|
||||
}
|
||||
case GLCommand.ORTHO -> {
|
||||
final double left = memGetDouble(ptr);
|
||||
@@ -405,32 +376,23 @@ public final class CommandBufferExecutor {
|
||||
|
||||
// === Matrix commands ===
|
||||
case GLCommand.MULT_MATRIX -> {
|
||||
final int mode = memGetInt(ptr);
|
||||
ptr += 4;
|
||||
// Mode-agnostic: just multiply current matrix
|
||||
MATRIX_BUFFER.clear();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
MATRIX_BUFFER.put(memGetFloat(ptr));
|
||||
ptr += 4;
|
||||
}
|
||||
MATRIX_BUFFER.flip();
|
||||
final int savedMode = GLStateManager.getMatrixMode().getMode();
|
||||
GLStateManager.glMatrixMode(mode);
|
||||
GLStateManager.glMultMatrix(MATRIX_BUFFER);
|
||||
GLStateManager.glMatrixMode(savedMode);
|
||||
}
|
||||
case GLCommand.LOAD_MATRIX -> {
|
||||
final int mode = memGetInt(ptr);
|
||||
ptr += 4;
|
||||
MATRIX_BUFFER.clear();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
MATRIX_BUFFER.put(memGetFloat(ptr));
|
||||
ptr += 4;
|
||||
}
|
||||
MATRIX_BUFFER.flip();
|
||||
final int savedMode = GLStateManager.getMatrixMode().getMode();
|
||||
GLStateManager.glMatrixMode(mode);
|
||||
GLStateManager.glLoadMatrix(MATRIX_BUFFER);
|
||||
GLStateManager.glMatrixMode(savedMode);
|
||||
}
|
||||
|
||||
// === Buffer commands ===
|
||||
@@ -497,11 +459,60 @@ public final class CommandBufferExecutor {
|
||||
vbo.draw(start, count);
|
||||
vbo.cleanupState();
|
||||
}
|
||||
case GLCommand.DRAW_RANGE_RESTORE -> {
|
||||
// Draw VBO range then restore GL current state from last vertex attributes
|
||||
final int vboIndex = memGetInt(ptr);
|
||||
final int start = memGetInt(ptr + 4);
|
||||
final int count = memGetInt(ptr + 8);
|
||||
final int flags = memGetInt(ptr + 12);
|
||||
|
||||
// Draw the VBO
|
||||
final VertexBuffer vbo = ownedVbos[vboIndex];
|
||||
vbo.setupState();
|
||||
vbo.draw(start, count);
|
||||
vbo.cleanupState();
|
||||
|
||||
// Restore attributes based on flags
|
||||
if ((flags & FLAG_HAS_COLOR) != 0) {
|
||||
final float r = memGetFloat(ptr + 16);
|
||||
final float g = memGetFloat(ptr + 20);
|
||||
final float b = memGetFloat(ptr + 24);
|
||||
final float a = memGetFloat(ptr + 28);
|
||||
GLStateManager.glColor4f(r, g, b, a);
|
||||
}
|
||||
if ((flags & FLAG_HAS_NORMALS) != 0) {
|
||||
final float nx = memGetFloat(ptr + 32);
|
||||
final float ny = memGetFloat(ptr + 36);
|
||||
final float nz = memGetFloat(ptr + 40);
|
||||
GLStateManager.glNormal3f(nx, ny, nz);
|
||||
}
|
||||
if ((flags & FLAG_HAS_TEXTURE) != 0) {
|
||||
final float s = memGetFloat(ptr + 44);
|
||||
final float t = memGetFloat(ptr + 48);
|
||||
GLStateManager.glTexCoord2f(s, t);
|
||||
}
|
||||
ptr += 52; // Skip full command size (56 - 4 for cmd already read)
|
||||
}
|
||||
case GLCommand.CALL_LIST -> {
|
||||
final int listId = memGetInt(ptr);
|
||||
ptr += 4;
|
||||
DisplayListManager.glCallList(listId);
|
||||
}
|
||||
case GLCommand.DRAW_BUFFER -> {
|
||||
GLStateManager.glDrawBuffer(memGetInt(ptr));
|
||||
ptr += 4;
|
||||
}
|
||||
case GLCommand.DRAW_BUFFERS -> {
|
||||
final int count = memGetInt(ptr);
|
||||
ptr += 4;
|
||||
DRAW_BUFFERS_BUFFER.clear();
|
||||
for (int i = 0; i < count; i++) {
|
||||
DRAW_BUFFERS_BUFFER.put(memGetInt(ptr + i * 4));
|
||||
}
|
||||
DRAW_BUFFERS_BUFFER.flip();
|
||||
ptr += 4 * MAX_DRAW_BUFFERS;
|
||||
GLStateManager.glDrawBuffers(DRAW_BUFFERS_BUFFER);
|
||||
}
|
||||
|
||||
// === Complex object reference ===
|
||||
case GLCommand.COMPLEX_REF -> {
|
||||
|
||||
+67
-101
@@ -19,92 +19,53 @@ public final class CommandBufferProcessor {
|
||||
|
||||
public static void processCommandForOptimization(int opcode, CommandBuffer raw, BufferTransformOptimizer opt, CommandBuffer out) {
|
||||
switch (opcode) {
|
||||
// === MODELVIEW matrix commands - accumulate instead of copying ===
|
||||
case GLCommand.TRANSLATE -> {
|
||||
final int mode = raw.readInt();
|
||||
final double x = raw.readDouble();
|
||||
final double y = raw.readDouble();
|
||||
final double z = raw.readDouble();
|
||||
if (mode == GL11.GL_MODELVIEW) {
|
||||
opt.translate(x, y, z);
|
||||
} else {
|
||||
out.writeTranslate(mode, x, y, z);
|
||||
}
|
||||
}
|
||||
case GLCommand.ROTATE -> {
|
||||
final int mode = raw.readInt();
|
||||
final double angle = raw.readDouble();
|
||||
final double x = raw.readDouble();
|
||||
final double y = raw.readDouble();
|
||||
final double z = raw.readDouble();
|
||||
if (mode == GL11.GL_MODELVIEW) {
|
||||
opt.rotate(angle, x, y, z);
|
||||
} else {
|
||||
out.writeRotate(mode, angle, x, y, z);
|
||||
}
|
||||
}
|
||||
case GLCommand.SCALE -> {
|
||||
final int mode = raw.readInt();
|
||||
final double x = raw.readDouble();
|
||||
final double y = raw.readDouble();
|
||||
final double z = raw.readDouble();
|
||||
if (mode == GL11.GL_MODELVIEW) {
|
||||
opt.scale(x, y, z);
|
||||
} else {
|
||||
out.writeScale(mode, x, y, z);
|
||||
}
|
||||
}
|
||||
// === MultMatrix - already collapsed transforms from flushMatrix() ===
|
||||
case GLCommand.MULT_MATRIX -> {
|
||||
final int mode = raw.readInt();
|
||||
raw.readMatrix4f(tempMatrix);
|
||||
if (mode == GL11.GL_MODELVIEW) {
|
||||
opt.multMatrix(tempMatrix);
|
||||
} else {
|
||||
out.writeMultMatrix(mode, tempMatrix);
|
||||
}
|
||||
}
|
||||
case GLCommand.LOAD_IDENTITY -> {
|
||||
final int mode = raw.readInt();
|
||||
if (mode == GL11.GL_MODELVIEW) {
|
||||
if (opt.checkAndClearAbsoluteMatrix()) {
|
||||
out.writeLoadIdentity(mode);
|
||||
}
|
||||
opt.loadIdentity();
|
||||
} else {
|
||||
out.writeLoadIdentity(mode);
|
||||
}
|
||||
}
|
||||
case GLCommand.LOAD_MATRIX -> {
|
||||
final int mode = raw.readInt();
|
||||
raw.readMatrix4f(tempMatrix);
|
||||
if (mode == GL11.GL_MODELVIEW) {
|
||||
opt.emitPendingTransform(out);
|
||||
out.writeLoadMatrix(mode, tempMatrix);
|
||||
opt.loadIdentity();
|
||||
opt.markAbsoluteMatrix();
|
||||
} else {
|
||||
out.writeLoadMatrix(mode, tempMatrix);
|
||||
}
|
||||
opt.multMatrix(tempMatrix); // accumulated = accumulated * tempMatrix
|
||||
out.writeMultMatrix(tempMatrix); // Copy to output
|
||||
opt.markLastEmittedAsAccumulated(); // lastEmitted = accumulated (what GL now has)
|
||||
}
|
||||
|
||||
// === Stack operations - update optimizer state and copy ===
|
||||
// === Load commands - flush pending, emit, reset accumulator ===
|
||||
case GLCommand.LOAD_IDENTITY -> {
|
||||
opt.emitPendingTransform(out); // Emit any pending transforms first
|
||||
out.writeLoadIdentity(); // Always emit LoadIdentity
|
||||
opt.loadIdentity(); // Reset accumulated to identity
|
||||
opt.resetLastEmitted(); // Reset lastEmitted to identity
|
||||
opt.checkAndClearAbsoluteMatrix(); // Clear the flag if set
|
||||
}
|
||||
case GLCommand.LOAD_MATRIX -> {
|
||||
raw.readMatrix4f(tempMatrix);
|
||||
opt.emitPendingTransform(out);
|
||||
out.writeLoadMatrix(tempMatrix);
|
||||
opt.loadIdentity();
|
||||
opt.resetLastEmitted(); // Reset lastEmitted to identity
|
||||
opt.markAbsoluteMatrix();
|
||||
}
|
||||
|
||||
// === Stack operations - flush/update optimizer state and copy ===
|
||||
case GLCommand.PUSH_MATRIX -> {
|
||||
final int mode = raw.readInt();
|
||||
if (mode == GL11.GL_MODELVIEW) {
|
||||
opt.emitPendingTransform(out);
|
||||
opt.push();
|
||||
}
|
||||
out.writePushMatrix(mode);
|
||||
opt.emitPendingTransform(out);
|
||||
opt.push();
|
||||
// Reset accumulated/lastEmitted to identity after push.
|
||||
opt.loadIdentity();
|
||||
opt.resetLastEmitted();
|
||||
out.writePushMatrix();
|
||||
}
|
||||
case GLCommand.POP_MATRIX -> {
|
||||
final int mode = raw.readInt();
|
||||
if (mode == GL11.GL_MODELVIEW) {
|
||||
opt.pop();
|
||||
}
|
||||
out.writePopMatrix(mode);
|
||||
opt.pop();
|
||||
out.writePopMatrix();
|
||||
}
|
||||
|
||||
// === Barriers - emit pending transform before copying ===
|
||||
case GLCommand.MATRIX_MODE -> {
|
||||
final int mode = raw.readInt();
|
||||
opt.emitPendingTransform(out); // Pending transforms apply to OLD mode
|
||||
out.writeMatrixMode(mode);
|
||||
opt.loadIdentity(); // Reset accumulated for new mode
|
||||
opt.resetLastEmitted(); // Reset lastEmitted for new mode
|
||||
}
|
||||
case GLCommand.CALL_LIST -> {
|
||||
final int listId = raw.readInt();
|
||||
opt.emitPendingTransform(out);
|
||||
@@ -150,9 +111,9 @@ public final class CommandBufferProcessor {
|
||||
case GLCommand.USE_PROGRAM -> out.writeUseProgram(raw.readInt());
|
||||
case GLCommand.PUSH_ATTRIB -> out.writePushAttrib(raw.readInt());
|
||||
case GLCommand.POP_ATTRIB -> { raw.readInt(); out.writePopAttrib(); }
|
||||
case GLCommand.LOAD_IDENTITY -> out.writeLoadIdentity(raw.readInt());
|
||||
case GLCommand.PUSH_MATRIX -> out.writePushMatrix(raw.readInt());
|
||||
case GLCommand.POP_MATRIX -> out.writePopMatrix(raw.readInt());
|
||||
case GLCommand.LOAD_IDENTITY -> out.writeLoadIdentity();
|
||||
case GLCommand.PUSH_MATRIX -> out.writePushMatrix();
|
||||
case GLCommand.POP_MATRIX -> out.writePopMatrix();
|
||||
case GLCommand.STENCIL_MASK -> out.writeStencilMask(raw.readInt());
|
||||
case GLCommand.DEPTH_MASK -> out.writeDepthMask(raw.readInt() != 0);
|
||||
case GLCommand.FRONT_FACE -> out.writeFrontFace(raw.readInt());
|
||||
@@ -182,7 +143,6 @@ public final class CommandBufferProcessor {
|
||||
case GLCommand.POINT_SIZE -> out.writePointSize(raw.readFloat());
|
||||
case GLCommand.LINE_WIDTH -> out.writeLineWidth(raw.readFloat());
|
||||
case GLCommand.POLYGON_OFFSET -> out.writePolygonOffset(raw.readFloat(), raw.readFloat());
|
||||
case GLCommand.NORMAL -> out.writeNormal(raw.readFloat(), raw.readFloat(), raw.readFloat());
|
||||
case GLCommand.COLOR -> out.writeColor(raw.readFloat(), raw.readFloat(), raw.readFloat(), raw.readFloat());
|
||||
case GLCommand.CLEAR_COLOR -> out.writeClearColor(raw.readFloat(), raw.readFloat(), raw.readFloat(), raw.readFloat());
|
||||
|
||||
@@ -203,15 +163,15 @@ public final class CommandBufferProcessor {
|
||||
case GLCommand.TEX_PARAMETERF -> out.writeTexParameterf(raw.readInt(), raw.readInt(), raw.readFloat());
|
||||
|
||||
// Double commands
|
||||
case GLCommand.TRANSLATE -> out.writeTranslate(raw.readInt(), raw.readDouble(), raw.readDouble(), raw.readDouble());
|
||||
case GLCommand.ROTATE -> out.writeRotate(raw.readInt(), raw.readDouble(), raw.readDouble(), raw.readDouble(), raw.readDouble());
|
||||
case GLCommand.SCALE -> out.writeScale(raw.readInt(), raw.readDouble(), raw.readDouble(), raw.readDouble());
|
||||
case GLCommand.TRANSLATE -> out.writeTranslate(raw.readDouble(), raw.readDouble(), raw.readDouble());
|
||||
case GLCommand.ROTATE -> out.writeRotate(raw.readDouble(), raw.readDouble(), raw.readDouble(), raw.readDouble());
|
||||
case GLCommand.SCALE -> out.writeScale(raw.readDouble(), raw.readDouble(), raw.readDouble());
|
||||
case GLCommand.ORTHO -> out.writeOrtho(raw.readDouble(), raw.readDouble(), raw.readDouble(), raw.readDouble(), raw.readDouble(), raw.readDouble());
|
||||
case GLCommand.FRUSTUM -> out.writeFrustum(raw.readDouble(), raw.readDouble(), raw.readDouble(), raw.readDouble(), raw.readDouble(), raw.readDouble());
|
||||
|
||||
// Matrix commands
|
||||
case GLCommand.MULT_MATRIX -> { int mode = raw.readInt(); out.writeMultMatrix(mode, raw.readMatrix4f(tempMatrix)); }
|
||||
case GLCommand.LOAD_MATRIX -> { int mode = raw.readInt(); out.writeLoadMatrix(mode, raw.readMatrix4f(tempMatrix)); }
|
||||
case GLCommand.MULT_MATRIX -> { out.writeMultMatrix(raw.readMatrix4f(tempMatrix)); }
|
||||
case GLCommand.LOAD_MATRIX -> { out.writeLoadMatrix(raw.readMatrix4f(tempMatrix)); }
|
||||
|
||||
// FloatBuffer commands (inline 4 floats max)
|
||||
case GLCommand.FOG -> {
|
||||
@@ -266,11 +226,17 @@ public final class CommandBufferProcessor {
|
||||
|
||||
/**
|
||||
* Lightweight transform optimizer for buffer-to-buffer processing.
|
||||
* Tracks accumulated MODELVIEW transform and emits MultMatrix commands when needed.
|
||||
* Tracks accumulated transform (mode-agnostic) and emits MultMatrix commands when needed.
|
||||
*
|
||||
* <p>This optimizer processes raw transform commands (TRANSLATE, ROTATE, SCALE) and
|
||||
* collapses them into single MultMatrix commands at barriers. It must stay synchronized
|
||||
* with the relativeTransform tracking in DisplayListManager - both systems must reset
|
||||
* at the same barriers (MatrixMode, LoadIdentity, LoadMatrix, Push/Pop).</p>
|
||||
*/
|
||||
public static class BufferTransformOptimizer {
|
||||
private final Matrix4f accumulated = new Matrix4f();
|
||||
private final Matrix4f lastEmitted = new Matrix4f();
|
||||
private final Matrix4f delta = new Matrix4f(); // Reused for delta computation
|
||||
private final Deque<Matrix4f> stack = new ArrayDeque<>();
|
||||
private boolean absoluteMatrixFlag = false;
|
||||
|
||||
@@ -279,18 +245,6 @@ public final class CommandBufferProcessor {
|
||||
lastEmitted.identity();
|
||||
}
|
||||
|
||||
public void translate(double x, double y, double z) {
|
||||
accumulated.translate((float) x, (float) y, (float) z);
|
||||
}
|
||||
|
||||
public void rotate(double angle, double x, double y, double z) {
|
||||
accumulated.rotate((float) Math.toRadians(angle), (float) x, (float) y, (float) z);
|
||||
}
|
||||
|
||||
public void scale(double x, double y, double z) {
|
||||
accumulated.scale((float) x, (float) y, (float) z);
|
||||
}
|
||||
|
||||
public void multMatrix(Matrix4f m) {
|
||||
accumulated.mul(m);
|
||||
}
|
||||
@@ -327,6 +281,18 @@ public final class CommandBufferProcessor {
|
||||
return was;
|
||||
}
|
||||
|
||||
public void resetLastEmitted() {
|
||||
lastEmitted.identity();
|
||||
}
|
||||
|
||||
public void setLastEmitted(Matrix4f m) {
|
||||
lastEmitted.set(m);
|
||||
}
|
||||
|
||||
public void markLastEmittedAsAccumulated() {
|
||||
lastEmitted.set(accumulated);
|
||||
}
|
||||
|
||||
public void emitPendingTransform(CommandBuffer out) {
|
||||
if (!accumulated.equals(lastEmitted)) {
|
||||
emitTransformTo(out, accumulated);
|
||||
@@ -339,10 +305,10 @@ public final class CommandBufferProcessor {
|
||||
}
|
||||
|
||||
if (DisplayListManager.isIdentity(lastEmitted)) {
|
||||
out.writeMultMatrix(GL11.GL_MODELVIEW, target);
|
||||
out.writeMultMatrix(target);
|
||||
} else {
|
||||
final Matrix4f delta = new Matrix4f(lastEmitted).invert().mul(target);
|
||||
out.writeMultMatrix(GL11.GL_MODELVIEW, delta);
|
||||
delta.set(lastEmitted).invert().mul(target);
|
||||
out.writeMultMatrix(delta);
|
||||
}
|
||||
lastEmitted.set(target);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.gtnewhorizons.angelica.glsm.recording.commands.DisplayListCommand;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
/**
|
||||
* Records GL commands to a CommandBuffer during display list compilation.
|
||||
@@ -131,43 +132,28 @@ public class CommandRecorder {
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordLoadIdentity(int matrixMode) {
|
||||
buffer.writeLoadIdentity(matrixMode);
|
||||
public void recordLoadIdentity() {
|
||||
buffer.writeLoadIdentity();
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordPushMatrix(int matrixMode) {
|
||||
buffer.writePushMatrix(matrixMode);
|
||||
public void recordPushMatrix() {
|
||||
buffer.writePushMatrix();
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordPopMatrix(int matrixMode) {
|
||||
buffer.writePopMatrix(matrixMode);
|
||||
public void recordPopMatrix() {
|
||||
buffer.writePopMatrix();
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordTranslate(int matrixMode, double x, double y, double z) {
|
||||
buffer.writeTranslate(matrixMode, x, y, z);
|
||||
public void recordMultMatrix(Matrix4f matrix) {
|
||||
buffer.writeMultMatrix(matrix);
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordRotate(int matrixMode, double angle, double x, double y, double z) {
|
||||
buffer.writeRotate(matrixMode, angle, x, y, z);
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordScale(int matrixMode, double x, double y, double z) {
|
||||
buffer.writeScale(matrixMode, x, y, z);
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordMultMatrix(int matrixMode, Matrix4f matrix) {
|
||||
buffer.writeMultMatrix(matrixMode, matrix);
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordLoadMatrix(int matrixMode, Matrix4f matrix) {
|
||||
buffer.writeLoadMatrix(matrixMode, matrix);
|
||||
public void recordLoadMatrix(Matrix4f matrix) {
|
||||
buffer.writeLoadMatrix(matrix);
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
@@ -186,11 +172,6 @@ public class CommandRecorder {
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordNormal(float nx, float ny, float nz) {
|
||||
buffer.writeNormal(nx, ny, nz);
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordPointSize(float size) {
|
||||
buffer.writePointSize(size);
|
||||
commandCount++;
|
||||
@@ -341,6 +322,21 @@ public class CommandRecorder {
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordDrawBuffer(int mode) {
|
||||
buffer.writeDrawBuffer(mode);
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordDrawBuffers(int count, int buf) {
|
||||
buffer.writeDrawBuffers(count, buf);
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordDrawBuffers(int count, IntBuffer bufs) {
|
||||
buffer.writeDrawBuffers(count, bufs);
|
||||
commandCount++;
|
||||
}
|
||||
|
||||
public void recordComplexCommand(DisplayListCommand cmd) {
|
||||
buffer.writeComplexRef(cmd);
|
||||
commandCount++;
|
||||
|
||||
@@ -22,6 +22,12 @@ import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.memGetInt;
|
||||
* <p>The ownedVbos array contains VBOs that are referenced by DrawRange commands.
|
||||
*/
|
||||
public final class CompiledDisplayList {
|
||||
/**
|
||||
* Empty display list singleton. Per OpenGL spec, an empty list is still valid.
|
||||
* This instance does nothing when rendered and is never deleted (shared singleton).
|
||||
*/
|
||||
public static final CompiledDisplayList EMPTY = new CompiledDisplayList(null, null, null);
|
||||
|
||||
private final ByteBuffer commandBuffer; // Off-heap command storage, must be freed
|
||||
private final Object[] complexObjects; // Complex commands (TexImage2D, etc.)
|
||||
private final VertexBuffer[] ownedVbos; // GPU resources referenced by index
|
||||
@@ -97,14 +103,14 @@ public final class CompiledDisplayList {
|
||||
* Used for testing to verify optimization results.
|
||||
*/
|
||||
public Int2IntMap getCommandCounts() {
|
||||
Int2IntMap counts = new Int2IntOpenHashMap();
|
||||
final Int2IntMap counts = new Int2IntOpenHashMap();
|
||||
if (commandBuffer == null || commandBuffer.limit() == 0) {
|
||||
return counts;
|
||||
}
|
||||
long ptr = memAddress(commandBuffer);
|
||||
long end = ptr + commandBuffer.limit();
|
||||
final long end = ptr + commandBuffer.limit();
|
||||
while (ptr < end) {
|
||||
int cmd = memGetInt(ptr);
|
||||
final int cmd = memGetInt(ptr);
|
||||
counts.mergeInt(cmd, 1, Integer::sum);
|
||||
ptr += getCommandSize(cmd, ptr);
|
||||
}
|
||||
@@ -116,14 +122,14 @@ public final class CompiledDisplayList {
|
||||
* Used for testing to verify command ordering.
|
||||
*/
|
||||
public IntList getCommandOpcodes() {
|
||||
IntList opcodes = new IntArrayList();
|
||||
final IntList opcodes = new IntArrayList();
|
||||
if (commandBuffer == null || commandBuffer.limit() == 0) {
|
||||
return opcodes;
|
||||
}
|
||||
long ptr = memAddress(commandBuffer);
|
||||
long end = ptr + commandBuffer.limit();
|
||||
final long end = ptr + commandBuffer.limit();
|
||||
while (ptr < end) {
|
||||
int cmd = memGetInt(ptr);
|
||||
final int cmd = memGetInt(ptr);
|
||||
opcodes.add(cmd);
|
||||
ptr += getCommandSize(cmd, ptr);
|
||||
}
|
||||
@@ -135,12 +141,14 @@ public final class CompiledDisplayList {
|
||||
*/
|
||||
private static int getCommandSize(int cmd, long ptr) {
|
||||
return switch (cmd) {
|
||||
// Opcode-only commands (4 bytes)
|
||||
case GLCommand.LOAD_IDENTITY, GLCommand.PUSH_MATRIX, GLCommand.POP_MATRIX -> 4;
|
||||
|
||||
// Single int commands (8 bytes)
|
||||
case GLCommand.ENABLE, GLCommand.DISABLE, GLCommand.CLEAR, GLCommand.CLEAR_STENCIL,
|
||||
GLCommand.CULL_FACE, GLCommand.DEPTH_FUNC, GLCommand.SHADE_MODEL, GLCommand.LOGIC_OP,
|
||||
GLCommand.MATRIX_MODE, GLCommand.ACTIVE_TEXTURE, GLCommand.USE_PROGRAM,
|
||||
GLCommand.PUSH_ATTRIB, GLCommand.POP_ATTRIB, GLCommand.LOAD_IDENTITY,
|
||||
GLCommand.PUSH_MATRIX, GLCommand.POP_MATRIX, GLCommand.STENCIL_MASK,
|
||||
GLCommand.PUSH_ATTRIB, GLCommand.POP_ATTRIB, GLCommand.STENCIL_MASK,
|
||||
GLCommand.DEPTH_MASK, GLCommand.FRONT_FACE, GLCommand.POINT_SIZE, GLCommand.LINE_WIDTH,
|
||||
GLCommand.CALL_LIST, GLCommand.COMPLEX_REF -> 8;
|
||||
|
||||
@@ -152,7 +160,7 @@ public final class CompiledDisplayList {
|
||||
|
||||
// Three int commands (16 bytes)
|
||||
case GLCommand.STENCIL_FUNC, GLCommand.STENCIL_OP, GLCommand.TEX_PARAMETERI,
|
||||
GLCommand.NORMAL, GLCommand.LIGHTF, GLCommand.LIGHTI,
|
||||
GLCommand.LIGHTF, GLCommand.LIGHTI,
|
||||
GLCommand.MATERIALF, GLCommand.TEX_PARAMETERF -> 16;
|
||||
|
||||
// Four int commands (20 bytes)
|
||||
@@ -161,22 +169,32 @@ public final class CompiledDisplayList {
|
||||
GLCommand.COLOR, GLCommand.CLEAR_COLOR, GLCommand.BLEND_COLOR,
|
||||
GLCommand.DRAW_RANGE -> 20;
|
||||
|
||||
// DRAW_RANGE_RESTORE: 56 bytes
|
||||
// [cmd:4][vboIndex:4][start:4][count:4][flags:4][color:16f][normal:12f][texcoord:8f]
|
||||
case GLCommand.DRAW_RANGE_RESTORE -> 56;
|
||||
|
||||
// DRAW_BUFFER: 8 bytes [cmd:4][mode:4]
|
||||
case GLCommand.DRAW_BUFFER -> 8;
|
||||
|
||||
// DRAW_BUFFERS: 40 bytes [cmd:4][count:4][bufs:4*8]
|
||||
case GLCommand.DRAW_BUFFERS -> 40;
|
||||
|
||||
// Double commands
|
||||
case GLCommand.TRANSLATE, GLCommand.SCALE -> 32; // cmd + mode + 3 doubles
|
||||
case GLCommand.TRANSLATE, GLCommand.SCALE -> 28; // cmd + 3 doubles
|
||||
case GLCommand.CLEAR_DEPTH -> 12; // cmd + 1 double
|
||||
case GLCommand.ROTATE -> 40; // cmd + mode + 4 doubles
|
||||
case GLCommand.ROTATE -> 36; // cmd + 4 doubles
|
||||
case GLCommand.ORTHO, GLCommand.FRUSTUM -> 52; // cmd + 6 doubles
|
||||
|
||||
// Matrix commands (72 bytes)
|
||||
case GLCommand.MULT_MATRIX, GLCommand.LOAD_MATRIX -> 72;
|
||||
// Matrix commands
|
||||
case GLCommand.MULT_MATRIX, GLCommand.LOAD_MATRIX -> 68; // cmd + 16 floats
|
||||
|
||||
// Buffer commands (variable, read count)
|
||||
case GLCommand.FOG, GLCommand.LIGHT_MODEL -> {
|
||||
int count = memGetInt(ptr + 8); // pname at +4, count at +8
|
||||
final int count = memGetInt(ptr + 8); // pname at +4, count at +8
|
||||
yield 12 + count * 4;
|
||||
}
|
||||
case GLCommand.LIGHT, GLCommand.MATERIAL -> {
|
||||
int count = memGetInt(ptr + 12); // light/face at +4, pname at +8, count at +12
|
||||
final int count = memGetInt(ptr + 12); // light/face at +4, pname at +8, count at +12
|
||||
yield 16 + count * 4;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,14 @@ public final class GLCommand {
|
||||
// === Draw commands ===
|
||||
public static final int DRAW_RANGE = 100; // [cmd:4][vboIndex:4][start:4][count:4][hasBrightness:4] = 20 bytes
|
||||
public static final int CALL_LIST = 101; // [cmd:4][listId:4] = 8 bytes
|
||||
public static final int DRAW_BUFFER = 102; // [cmd:4][mode:4] = 8 bytes
|
||||
public static final int DRAW_BUFFERS = 103; // [cmd:4][count:4][bufs:4*8] = 40 bytes (up to 8 buffers)
|
||||
/**
|
||||
* Draw VBO range with attribute restoration after draw.
|
||||
* Used for immediate mode VBOs to restore GL current state (color, normal, texcoord).
|
||||
*/
|
||||
public static final int DRAW_RANGE_RESTORE = 104; // [cmd:4][vboIndex:4][start:4][count:4][flags:4]
|
||||
// [lastColor:16f][lastNormal:12f][lastTexCoord:8f] = 56 bytes
|
||||
|
||||
// === Complex object reference ===
|
||||
public static final int COMPLEX_REF = 255; // [cmd:4][index:4] = 8 bytes
|
||||
@@ -136,7 +144,6 @@ public final class GLCommand {
|
||||
case POINT_SIZE -> "POINT_SIZE";
|
||||
case LINE_WIDTH -> "LINE_WIDTH";
|
||||
case POLYGON_OFFSET -> "POLYGON_OFFSET";
|
||||
case NORMAL -> "NORMAL";
|
||||
case COLOR -> "COLOR";
|
||||
case CLEAR_COLOR -> "CLEAR_COLOR";
|
||||
case BLEND_COLOR -> "BLEND_COLOR";
|
||||
@@ -162,6 +169,9 @@ public final class GLCommand {
|
||||
case MATERIAL -> "MATERIAL";
|
||||
case DRAW_RANGE -> "DRAW_RANGE";
|
||||
case CALL_LIST -> "CALL_LIST";
|
||||
case DRAW_BUFFER -> "DRAW_BUFFER";
|
||||
case DRAW_BUFFERS -> "DRAW_BUFFERS";
|
||||
case DRAW_RANGE_RESTORE -> "DRAW_RANGE_RESTORE";
|
||||
case COMPLEX_REF -> "COMPLEX_REF";
|
||||
default -> "UNKNOWN(" + opcode + ")";
|
||||
};
|
||||
|
||||
@@ -164,6 +164,31 @@ public class ImmediateModeRecorder {
|
||||
throw new IllegalStateException("glEnd called without glBegin");
|
||||
}
|
||||
|
||||
// Capture last vertex attributes BEFORE clearing currentVertices
|
||||
// These will be used to restore GL current state after VBO playback
|
||||
float lastColorR = 1.0f, lastColorG = 1.0f, lastColorB = 1.0f, lastColorA = 1.0f;
|
||||
float lastNormalX = 0.0f, lastNormalY = 0.0f, lastNormalZ = 1.0f;
|
||||
float lastTexS = 0.0f, lastTexT = 0.0f;
|
||||
|
||||
if (!currentVertices.isEmpty()) {
|
||||
ImmediateVertex last = currentVertices.get(currentVertices.size() - 1);
|
||||
|
||||
// Unpack color from ABGR format
|
||||
lastColorR = (last.color & 0xFF) / 255.0f;
|
||||
lastColorG = ((last.color >> 8) & 0xFF) / 255.0f;
|
||||
lastColorB = ((last.color >> 16) & 0xFF) / 255.0f;
|
||||
lastColorA = ((last.color >> 24) & 0xFF) / 255.0f;
|
||||
|
||||
// Unpack normal from NormI8 format (signed bytes packed into int)
|
||||
lastNormalX = NormI8.unpackX(last.normal);
|
||||
lastNormalY = NormI8.unpackY(last.normal);
|
||||
lastNormalZ = NormI8.unpackZ(last.normal);
|
||||
|
||||
// Texture coords are stored directly as floats
|
||||
lastTexS = last.texU;
|
||||
lastTexT = last.texV;
|
||||
}
|
||||
|
||||
// Convert this primitive's vertices to quads or lines
|
||||
convertPrimitiveToQuads();
|
||||
this.currentVertices.clear();
|
||||
@@ -188,7 +213,10 @@ public class ImmediateModeRecorder {
|
||||
quads.clear();
|
||||
lineVertices.clear();
|
||||
|
||||
return new Result(resultQuads, resultLines, flags);
|
||||
return new Result(resultQuads, resultLines, flags,
|
||||
lastColorR, lastColorG, lastColorB, lastColorA,
|
||||
lastNormalX, lastNormalY, lastNormalZ,
|
||||
lastTexS, lastTexT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -520,14 +548,28 @@ public class ImmediateModeRecorder {
|
||||
hasNormal = false;
|
||||
// Note: current texcoord/normal values are NOT reset - they persist per OpenGL spec
|
||||
|
||||
return new Result(resultQuads, resultLines, flags);
|
||||
// For getQuadsAndClear, we don't have last vertex data (it was cleared in end())
|
||||
// Use default values - this method is for edge cases/cleanup anyway
|
||||
return new Result(resultQuads, resultLines, flags,
|
||||
1.0f, 1.0f, 1.0f, 1.0f, // Default white color
|
||||
0.0f, 0.0f, 1.0f, // Default +Z normal
|
||||
0.0f, 0.0f); // Default (0,0) texcoord
|
||||
}
|
||||
|
||||
/**
|
||||
* Result of immediate mode recording: quads, lines, and their attribute flags.
|
||||
* Result of immediate mode recording: quads, lines, attribute flags, and last vertex state.
|
||||
* The last vertex state is used to restore GL_CURRENT_COLOR etc. after VBO playback.
|
||||
*/
|
||||
@com.github.bsideup.jabel.Desugar
|
||||
public record Result(List<ModelQuadViewMutable> quads, List<LineVertex> lines, CapturingTessellator.Flags flags) {}
|
||||
public record Result(
|
||||
List<ModelQuadViewMutable> quads,
|
||||
List<LineVertex> lines,
|
||||
CapturingTessellator.Flags flags,
|
||||
// Last vertex attributes for restoration after VBO draw
|
||||
float lastColorR, float lastColorG, float lastColorB, float lastColorA,
|
||||
float lastNormalX, float lastNormalY, float lastNormalZ,
|
||||
float lastTexCoordS, float lastTexCoordT
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Reset all state including current texcoord/normal.
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizons.angelica.glsm.recording.commands.DrawCommand;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.BufferVertexFormat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents recorded geometry from a display list compilation.
|
||||
* Contains the vertex data buffer and metadata about draw commands.
|
||||
*/
|
||||
@Desugar
|
||||
public record RecordedGeometry(ByteBuffer buffer, BufferVertexFormat format, List<DrawCommand> drawCommands, int totalVertexCount) {
|
||||
public int getByteSize() {
|
||||
return buffer.remaining();
|
||||
}
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording.commands;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
/**
|
||||
* Interface for matrix commands that can be accumulated during transform optimization.
|
||||
* Implemented by TranslateCmd, RotateCmd, ScaleCmd, and MultMatrixCmd.
|
||||
*/
|
||||
public interface AccumulableMatrixCommand extends DisplayListCommand {
|
||||
boolean isModelView();
|
||||
void applyTo(Matrix4f matrix);
|
||||
|
||||
@Override
|
||||
default boolean handleOptimization(OptimizationContext ctx) {
|
||||
if (isModelView()) {
|
||||
applyTo(ctx.getAccumulatedTransform());
|
||||
return false; // Accumulated, don't emit
|
||||
}
|
||||
return true; // Non-MODELVIEW, emit as-is
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording.commands;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.recording.CompiledDisplayList;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Command: Call another display list (glCallList)
|
||||
* Records a reference to another display list to be executed during playback.
|
||||
* Per OpenGL spec: the referenced list is NOT executed during compilation,
|
||||
* only the reference is recorded.
|
||||
*
|
||||
*/
|
||||
@Desugar
|
||||
public record CallListCmd(int listId) implements DisplayListCommand {
|
||||
private static final Logger LOGGER = LogManager.getLogger("CallListCmd");
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
final CompiledDisplayList compiled = GLStateManager.getDisplayList(listId);
|
||||
|
||||
if (compiled != null) {
|
||||
GLDebug.pushGroup("CallList(" + listId + ")");
|
||||
try {
|
||||
compiled.render();
|
||||
} finally {
|
||||
GLDebug.popGroup();
|
||||
}
|
||||
} else {
|
||||
// Fallback if list not found (shouldn't happen in normal operation)
|
||||
LOGGER.warn("[CallListCmd] List {} not found in cache, using fallback glCallList", listId);
|
||||
GLStateManager.glCallList(listId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
// No resources to free - we just hold a reference
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsTransformSync() {
|
||||
return true; // Nested list uses current GL matrix state
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOptimization(OptimizationContext ctx) {
|
||||
// Nested list needs current GL matrix state
|
||||
ctx.emitPendingTransform();
|
||||
return true; // Emit this command
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return "CallList(" + listId + ")";
|
||||
}
|
||||
}
|
||||
-17
@@ -18,23 +18,6 @@ public interface DisplayListCommand {
|
||||
// Most commands don't hold resources
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this barrier command requires the MODELVIEW transform to be
|
||||
* synchronized with the accumulated state before execution.
|
||||
*
|
||||
* <p>This should return true for commands where the GL matrix state matters,
|
||||
* such as CallListCmd (nested lists use current GL state) or PushAttribCmd
|
||||
* with GL_TRANSFORM_BIT (saves the current matrix).</p>
|
||||
*
|
||||
* <p>Commands like PushAttribCmd with only GL_COLOR_BUFFER_BIT don't need
|
||||
* transform sync because they don't interact with the matrix stack.</p>
|
||||
*
|
||||
* @return true if transform must be synced to accumulated before this barrier
|
||||
*/
|
||||
default boolean needsTransformSync() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle this command during display list optimization.
|
||||
*
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording.commands;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Command: glLoadIdentity()
|
||||
* Replaces the current matrix with the identity matrix for the specified matrix mode.
|
||||
*/
|
||||
@Desugar
|
||||
public record LoadIdentityCmd(int matrixMode) implements DisplayListCommand {
|
||||
@Override
|
||||
public void execute() {
|
||||
GLStateManager.glLoadIdentity();
|
||||
}
|
||||
|
||||
public boolean isModelView() {
|
||||
return matrixMode == GL11.GL_MODELVIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOptimization(OptimizationContext ctx) {
|
||||
if (isModelView()) {
|
||||
// Check if we're at an absolute matrix (after LoadMatrix)
|
||||
// If so, we must emit LoadIdentity to actually reset GL state
|
||||
if (ctx.checkAndClearAbsoluteMatrix()) {
|
||||
ctx.emit(this);
|
||||
ctx.loadIdentity();
|
||||
return false; // Already emitted
|
||||
}
|
||||
ctx.loadIdentity();
|
||||
return false; // Accumulated, don't emit
|
||||
}
|
||||
return true; // Non-MODELVIEW, emit as-is
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return String.format("LoadIdentity(%s)", GLDebug.getMatrixModeName(matrixMode));
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording.commands;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
/**
|
||||
* Command: glLoadMatrix(matrix)
|
||||
* Replaces the current matrix with the specified matrix for the given matrix mode.
|
||||
*
|
||||
* <p>Unlike MultMatrixCmd which can be absorbed into the accumulated transform,
|
||||
* LoadMatrixCmd must always be emitted because it sets an absolute value, not a relative one.
|
||||
* After a LoadMatrix command, the accumulated transform is reset to identity since
|
||||
* subsequent transforms are relative to the newly loaded matrix.</p>
|
||||
*/
|
||||
@Desugar
|
||||
public record LoadMatrixCmd(Matrix4f matrix, int matrixMode, FloatBuffer buffer) implements DisplayListCommand {
|
||||
|
||||
/**
|
||||
* Create a LoadMatrixCmd with pre-allocated buffer.
|
||||
*/
|
||||
public static LoadMatrixCmd create(Matrix4f matrix, int matrixMode) {
|
||||
final FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
|
||||
matrix.get(buffer);
|
||||
buffer.rewind();
|
||||
return new LoadMatrixCmd(new Matrix4f(matrix), matrixMode, buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a LoadMatrixCmd from a FloatBuffer (copies the data).
|
||||
*/
|
||||
public static LoadMatrixCmd create(FloatBuffer src, int matrixMode) {
|
||||
final Matrix4f matrix = new Matrix4f().set(src);
|
||||
src.rewind();
|
||||
return create(matrix, matrixMode);
|
||||
}
|
||||
|
||||
public boolean isModelView() {
|
||||
return matrixMode == GL11.GL_MODELVIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
// Buffer already populated at construction, just rewind and use
|
||||
buffer.rewind();
|
||||
GLStateManager.glLoadMatrix(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOptimization(OptimizationContext ctx) {
|
||||
if (isModelView()) {
|
||||
// LoadMatrix sets an absolute value - emit any pending relative transform first
|
||||
ctx.emitPendingTransform();
|
||||
// Emit this command
|
||||
ctx.emit(this);
|
||||
// Reset accumulated to identity - subsequent transforms are relative to the loaded matrix
|
||||
ctx.loadIdentity();
|
||||
// Mark that GL is at an absolute value - LoadIdentity must emit to reset
|
||||
ctx.markAbsoluteMatrix();
|
||||
return false; // Already emitted
|
||||
}
|
||||
return true; // Non-MODELVIEW, emit as-is
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return String.format("LoadMatrix(%s, %s)", GLDebug.getMatrixModeName(matrixMode), matrix);
|
||||
}
|
||||
}
|
||||
+4
-15
@@ -11,34 +11,23 @@ import java.nio.FloatBuffer;
|
||||
|
||||
/**
|
||||
* Command: glMultMatrix(matrix)
|
||||
* Multiplies the specified matrix mode by the specified matrix.
|
||||
* Multiplies the current matrix by the specified matrix.
|
||||
*/
|
||||
@Desugar
|
||||
public record MultMatrixCmd(Matrix4f matrix, int matrixMode, FloatBuffer buffer) implements AccumulableMatrixCommand {
|
||||
public record MultMatrixCmd(Matrix4f matrix, FloatBuffer buffer) implements DisplayListCommand {
|
||||
|
||||
/**
|
||||
* Create a MultMatrixCmd with pre-allocated buffer.
|
||||
*/
|
||||
public static MultMatrixCmd create(Matrix4f matrix, int matrixMode) {
|
||||
public static MultMatrixCmd create(Matrix4f matrix) {
|
||||
final FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
|
||||
matrix.get(buffer);
|
||||
buffer.rewind();
|
||||
return new MultMatrixCmd(new Matrix4f(matrix), matrixMode, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModelView() {
|
||||
return matrixMode == GL11.GL_MODELVIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(Matrix4f target) {
|
||||
target.mul(matrix);
|
||||
return new MultMatrixCmd(new Matrix4f(matrix), buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
// Buffer already populated at construction, just rewind and use
|
||||
buffer.rewind();
|
||||
GLStateManager.glMultMatrix(buffer);
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording.commands;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Command: glPopAttrib()
|
||||
* Pops the server attribute stack.
|
||||
*/
|
||||
@Desugar
|
||||
public record PopAttribCmd() implements DisplayListCommand {
|
||||
@Override
|
||||
public void execute() {
|
||||
GLStateManager.glPopAttrib();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsTransformSync() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOptimization(OptimizationContext ctx) {
|
||||
ctx.emitPendingTransform();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return "PopAttrib()";
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording.commands;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Command: glPopMatrix()
|
||||
* Pops the current matrix from the matrix stack for the specified matrix mode.
|
||||
*/
|
||||
@Desugar
|
||||
public record PopMatrixCmd(int matrixMode) implements DisplayListCommand {
|
||||
@Override
|
||||
public void execute() {
|
||||
GLStateManager.glPopMatrix();
|
||||
}
|
||||
|
||||
public boolean isModelView() {
|
||||
return matrixMode == GL11.GL_MODELVIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOptimization(OptimizationContext ctx) {
|
||||
if (isModelView()) {
|
||||
ctx.popTransform();
|
||||
}
|
||||
return true; // Always emit Pop
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return String.format("PopMatrix(%s)", GLDebug.getMatrixModeName(matrixMode));
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording.commands;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Command: glPushAttrib(mask)
|
||||
* Pushes the server attribute stack.
|
||||
*/
|
||||
@Desugar
|
||||
public record PushAttribCmd(int mask) implements DisplayListCommand {
|
||||
@Override
|
||||
public void execute() {
|
||||
GLStateManager.glPushAttrib(mask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsTransformSync() {
|
||||
// Only need transform sync if we're pushing transform state.
|
||||
// GL_TRANSFORM_BIT includes the matrix mode and matrix stacks.
|
||||
return (mask & GL11.GL_TRANSFORM_BIT) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOptimization(OptimizationContext ctx) {
|
||||
if (needsTransformSync()) {
|
||||
ctx.emitPendingTransform();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return String.format("PushAttrib(0x%08X)", mask);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording.commands;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Command: glPushMatrix()
|
||||
* Pushes the current matrix onto the matrix stack for the specified matrix mode.
|
||||
*/
|
||||
@Desugar
|
||||
public record PushMatrixCmd(int matrixMode) implements DisplayListCommand {
|
||||
@Override
|
||||
public void execute() {
|
||||
GLStateManager.glPushMatrix();
|
||||
}
|
||||
|
||||
public boolean isModelView() {
|
||||
return matrixMode == GL11.GL_MODELVIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOptimization(OptimizationContext ctx) {
|
||||
if (isModelView()) {
|
||||
ctx.emitPendingTransform();
|
||||
ctx.pushTransform();
|
||||
}
|
||||
return true; // Always emit Push
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return String.format("PushMatrix(%s)", GLDebug.getMatrixModeName(matrixMode));
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording.commands;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Command: glRotatef() or glRotated()
|
||||
* Stores as doubles for precision.
|
||||
*/
|
||||
@Desugar
|
||||
public record RotateCmd(double angle, double x, double y, double z, int matrixMode) implements AccumulableMatrixCommand {
|
||||
@Override
|
||||
public void execute() {
|
||||
GLStateManager.glRotated(angle, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModelView() {
|
||||
return matrixMode == GL11.GL_MODELVIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(Matrix4f matrix) {
|
||||
matrix.rotate((float) Math.toRadians(angle), (float) x, (float) y, (float) z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return String.format("Rotate(%.2f deg, %.2f, %.2f, %.2f, %s)", angle, x, y, z, GLDebug.getMatrixModeName(matrixMode));
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording.commands;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Command: glScalef() or glScaled()
|
||||
* Stores as doubles for precision.
|
||||
*/
|
||||
@Desugar
|
||||
public record ScaleCmd(double x, double y, double z, int matrixMode) implements AccumulableMatrixCommand {
|
||||
@Override
|
||||
public void execute() {
|
||||
GLStateManager.glScaled(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModelView() {
|
||||
return matrixMode == GL11.GL_MODELVIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(Matrix4f matrix) {
|
||||
matrix.scale((float) x, (float) y, (float) z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return String.format("Scale(%.2f, %.2f, %.2f, %s)", x, y, z, GLDebug.getMatrixModeName(matrixMode));
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording.commands;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Command: glTranslatef() or glTranslated()
|
||||
* Stores as doubles for precision.
|
||||
*/
|
||||
@Desugar
|
||||
public record TranslateCmd(double x, double y, double z, int matrixMode) implements AccumulableMatrixCommand {
|
||||
@Override
|
||||
public void execute() {
|
||||
// Save current mode
|
||||
final int savedMode = GLStateManager.getMatrixMode().getMode();
|
||||
|
||||
// Switch to the mode this was recorded with
|
||||
GLStateManager.glMatrixMode(matrixMode);
|
||||
GLStateManager.glTranslated(x, y, z);
|
||||
|
||||
// Restore mode
|
||||
GLStateManager.glMatrixMode(savedMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModelView() {
|
||||
return matrixMode == GL11.GL_MODELVIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(Matrix4f matrix) {
|
||||
matrix.translate((float) x, (float) y, (float) z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return String.format("Translate(%.2f, %.2f, %.2f, %s)", x, y, z, GLDebug.getMatrixModeName(matrixMode));
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.gtnewhorizons.angelica.glsm.stacks;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
/**
|
||||
* BooleanStateStack for per-texture-unit state.
|
||||
* Switches to correct unit (raw GL) before enable/disable calls.
|
||||
*/
|
||||
public class TextureUnitBooleanStateStack extends BooleanStateStack {
|
||||
private final int unitIndex;
|
||||
|
||||
public TextureUnitBooleanStateStack(int glCap, int unitIndex) {
|
||||
super(glCap);
|
||||
this.unitIndex = unitIndex;
|
||||
}
|
||||
|
||||
public TextureUnitBooleanStateStack(int glCap, int unitIndex, boolean initialState) {
|
||||
super(glCap, initialState);
|
||||
this.unitIndex = unitIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
beforeModify();
|
||||
setEnabledWithUnitSwitch(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureUnitBooleanStateStack popDepth() {
|
||||
if (savedDepth > 0) {
|
||||
final boolean oldValue = stack[--savedDepth];
|
||||
setEnabledWithUnitSwitch(oldValue);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void setEnabledWithUnitSwitch(boolean enabled) {
|
||||
final boolean bypass = GLStateManager.shouldBypassCache();
|
||||
if (bypass || enabled != this.enabled) {
|
||||
if (!bypass) this.enabled = enabled;
|
||||
|
||||
int currentUnit = GLStateManager.getActiveTextureUnit();
|
||||
boolean needsSwitch = currentUnit != unitIndex;
|
||||
|
||||
if (needsSwitch) GL13.glActiveTexture(GL13.GL_TEXTURE0 + unitIndex);
|
||||
if (enabled) GL11.glEnable(glCap); else GL11.glDisable(glCap);
|
||||
if (needsSwitch) GL13.glActiveTexture(GL13.GL_TEXTURE0 + currentUnit);
|
||||
}
|
||||
}
|
||||
|
||||
public int getUnitIndex() {
|
||||
return unitIndex;
|
||||
}
|
||||
}
|
||||
@@ -27,13 +27,11 @@ public class BooleanState implements ISettableState<BooleanState> {
|
||||
if (!bypass) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
// Skip actual GL calls during display list recording (state tracking only)
|
||||
if (!GLStateManager.isRecordingDisplayList()) {
|
||||
if (enabled) {
|
||||
GL11.glEnable(this.glCap);
|
||||
} else {
|
||||
GL11.glDisable(this.glCap);
|
||||
}
|
||||
// Always call GL - the calling method controls whether we reach here based on recording mode
|
||||
if (enabled) {
|
||||
GL11.glEnable(this.glCap);
|
||||
} else {
|
||||
GL11.glDisable(this.glCap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.glsm.states;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.stacks.BooleanStateStack;
|
||||
import com.gtnewhorizons.angelica.glsm.stacks.TextureUnitBooleanStateStack;
|
||||
import com.gtnewhorizons.angelica.glsm.stacks.TextureBindingStack;
|
||||
import lombok.Getter;
|
||||
import org.joml.Matrix4fStack;
|
||||
@@ -10,36 +10,36 @@ 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;
|
||||
private final TextureUnitBooleanStateStack[] states;
|
||||
private final TextureUnitBooleanStateStack[] texture1DStates;
|
||||
private final TextureUnitBooleanStateStack[] texture3DStates;
|
||||
private final TextureUnitBooleanStateStack[] texGenSStates;
|
||||
private final TextureUnitBooleanStateStack[] texGenTStates;
|
||||
private final TextureUnitBooleanStateStack[] texGenRStates;
|
||||
private final TextureUnitBooleanStateStack[] 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];
|
||||
states = new TextureUnitBooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texture1DStates = new TextureUnitBooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texture3DStates = new TextureUnitBooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texGenSStates = new TextureUnitBooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texGenTStates = new TextureUnitBooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texGenRStates = new TextureUnitBooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texGenQStates = new TextureUnitBooleanStateStack[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);
|
||||
states[i] = new TextureUnitBooleanStateStack(GL11.GL_TEXTURE_2D, i);
|
||||
texture1DStates[i] = new TextureUnitBooleanStateStack(GL11.GL_TEXTURE_1D, i);
|
||||
texture3DStates[i] = new TextureUnitBooleanStateStack(GL12.GL_TEXTURE_3D, i);
|
||||
texGenSStates[i] = new TextureUnitBooleanStateStack(GL11.GL_TEXTURE_GEN_S, i);
|
||||
texGenTStates[i] = new TextureUnitBooleanStateStack(GL11.GL_TEXTURE_GEN_T, i);
|
||||
texGenRStates[i] = new TextureUnitBooleanStateStack(GL11.GL_TEXTURE_GEN_R, i);
|
||||
texGenQStates[i] = new TextureUnitBooleanStateStack(GL11.GL_TEXTURE_GEN_Q, i);
|
||||
textureMatricies[i] = new Matrix4fStack(GLStateManager.MAX_TEXTURE_STACK_DEPTH);
|
||||
}
|
||||
}
|
||||
@@ -48,31 +48,31 @@ public class TextureUnitArray {
|
||||
return bindings[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTextureUnitStates(int index) {
|
||||
public TextureUnitBooleanStateStack getTextureUnitStates(int index) {
|
||||
return states[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexture1DStates(int index) {
|
||||
public TextureUnitBooleanStateStack getTexture1DStates(int index) {
|
||||
return texture1DStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexture3DStates(int index) {
|
||||
public TextureUnitBooleanStateStack getTexture3DStates(int index) {
|
||||
return texture3DStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexGenSStates(int index) {
|
||||
public TextureUnitBooleanStateStack getTexGenSStates(int index) {
|
||||
return texGenSStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexGenTStates(int index) {
|
||||
public TextureUnitBooleanStateStack getTexGenTStates(int index) {
|
||||
return texGenTStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexGenRStates(int index) {
|
||||
public TextureUnitBooleanStateStack getTexGenRStates(int index) {
|
||||
return texGenRStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexGenQStates(int index) {
|
||||
public TextureUnitBooleanStateStack getTexGenQStates(int index) {
|
||||
return texGenQStates[index];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.glsm.texture;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -12,7 +12,7 @@ public class TextureInfo {
|
||||
protected int width = -1;
|
||||
protected int height = -1;
|
||||
|
||||
@Getter @Setter protected int minFilter = GL11.GL_LINEAR_MIPMAP_LINEAR;
|
||||
@Getter @Setter protected int minFilter = GL11.GL_NEAREST_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;
|
||||
@@ -29,36 +29,22 @@ public class TextureInfo {
|
||||
|
||||
public int getInternalFormat() {
|
||||
if (internalFormat == -1) {
|
||||
internalFormat = fetchLevelParameter(GL11.GL_TEXTURE_INTERNAL_FORMAT);
|
||||
internalFormat = RenderSystem.getTexLevelParameteri(id, 0, GL11.GL_TEXTURE_INTERNAL_FORMAT);
|
||||
}
|
||||
return internalFormat;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
if (width == -1) {
|
||||
width = fetchLevelParameter(GL11.GL_TEXTURE_WIDTH);
|
||||
width = RenderSystem.getTexLevelParameteri(id, 0, GL11.GL_TEXTURE_WIDTH);
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
if (height == -1) {
|
||||
height = fetchLevelParameter(GL11.GL_TEXTURE_HEIGHT);
|
||||
height = RenderSystem.getTexLevelParameteri(id, 0, GL11.GL_TEXTURE_HEIGHT);
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
private int fetchLevelParameter(int pname) {
|
||||
// Keep track of what texture was bound before
|
||||
final int previousTextureBinding = GLStateManager.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
|
||||
// Bind this texture and grab the parameter from it.
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, id);
|
||||
final int parameter = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, pname);
|
||||
|
||||
// Make sure to re-bind the previous texture to avoid issues.
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, previousTextureBinding);
|
||||
|
||||
return parameter;
|
||||
}
|
||||
}
|
||||
@@ -7,45 +7,73 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public class TextureInfoCache {
|
||||
/**
|
||||
* Adapted from Iris for use in GLSM
|
||||
* Adapted from Iris for use in GLSM.
|
||||
*
|
||||
* This cache stores server-side texture state (parameters, dimensions) that is shared across GL contexts.
|
||||
* Locking is only used during splash when multiple contexts exist.
|
||||
*/
|
||||
|
||||
public static final TextureInfoCache INSTANCE = new TextureInfoCache();
|
||||
public static final TextureInfoCache INSTANCE = new TextureInfoCache();
|
||||
|
||||
private final Int2ObjectMap<TextureInfo> cache = new Int2ObjectOpenHashMap<>();
|
||||
private final Int2ObjectMap<TextureInfo> cache = new Int2ObjectOpenHashMap<>();
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
private TextureInfoCache() {
|
||||
}
|
||||
private TextureInfoCache() {
|
||||
}
|
||||
|
||||
public TextureInfo getInfo(int id) {
|
||||
if(id < 0 || !GLStateManager.isCachingEnabled()) return null;
|
||||
return cache.computeIfAbsent(id, TextureInfo::new);
|
||||
}
|
||||
public TextureInfo getInfo(int id) {
|
||||
if (id < 0) return null;
|
||||
|
||||
if (GLStateManager.isSplashComplete()) {
|
||||
return cache.computeIfAbsent(id, TextureInfo::new);
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
try {
|
||||
return cache.computeIfAbsent(id, TextureInfo::new);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void onTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, @Nullable Buffer pixels) {
|
||||
if (target == GL11.GL_TEXTURE_2D && level == 0) {
|
||||
final TextureInfo info = getInfo(GLStateManager.getBoundTextureForServerState());
|
||||
if (info == null) return;
|
||||
info.internalFormat = internalformat;
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
public void onTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, @Nullable Buffer pixels) {
|
||||
if (target == GL11.GL_TEXTURE_2D && level == 0) {
|
||||
final TextureInfo info = getInfo(GLStateManager.getBoundTexture());
|
||||
if(info == null) return;
|
||||
info.internalFormat = internalformat;
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
}
|
||||
}
|
||||
public void onTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, long pixels_buffer_offset) {
|
||||
if (target == GL11.GL_TEXTURE_2D && level == 0) {
|
||||
final TextureInfo info = getInfo(GLStateManager.getBoundTexture());
|
||||
if(info == null) return;
|
||||
info.internalFormat = internalformat;
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
}
|
||||
}
|
||||
if (target == GL11.GL_TEXTURE_2D && level == 0) {
|
||||
final TextureInfo info = getInfo(GLStateManager.getBoundTextureForServerState());
|
||||
if (info == null) return;
|
||||
info.internalFormat = internalformat;
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
public void onDeleteTexture(int id) {
|
||||
if(id >= 0 && GLStateManager.isCachingEnabled()) cache.remove(id);
|
||||
}
|
||||
public void onDeleteTexture(int id) {
|
||||
if (id < 0) return;
|
||||
|
||||
if (GLStateManager.isSplashComplete()) {
|
||||
cache.remove(id);
|
||||
return;
|
||||
}
|
||||
|
||||
// During splash: lock for thread safety
|
||||
lock.lock();
|
||||
try {
|
||||
cache.remove(id);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gl.state.StateUpdateNotifiers;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -17,12 +16,6 @@ public class TextureTracker {
|
||||
|
||||
public static final TextureTracker INSTANCE = new TextureTracker();
|
||||
|
||||
private static Runnable bindTextureListener;
|
||||
|
||||
static {
|
||||
StateUpdateNotifiers.bindTextureNotifier = listener -> bindTextureListener = listener;
|
||||
}
|
||||
|
||||
private final Int2ObjectMap<AbstractTexture> textures = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private boolean lockBindCallback;
|
||||
@@ -45,9 +38,6 @@ public class TextureTracker {
|
||||
}
|
||||
if (GLStateManager.getActiveTextureUnit() == 0) {
|
||||
lockBindCallback = true;
|
||||
if (bindTextureListener != null) {
|
||||
bindTextureListener.run();
|
||||
}
|
||||
if(Iris.enabled) {
|
||||
final WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
||||
if (pipeline != null) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.postprocessing.CustomFramebuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.postprocessing.SharedDepthFramebuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vao.VertexArrayBuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
@@ -178,10 +179,7 @@ public class HUDCaching {
|
||||
if (quadWidth != width || quadHeight != height) {
|
||||
quadWidth = width;
|
||||
quadHeight = height;
|
||||
if (quadVAO != null) {
|
||||
quadVAO.close();
|
||||
}
|
||||
quadVAO = rebuildVAO(width, height);
|
||||
rebuildVAO(width, height);
|
||||
}
|
||||
GLStateManager.disableDepthTest();
|
||||
GLStateManager.enableTexture();
|
||||
@@ -190,7 +188,7 @@ public class HUDCaching {
|
||||
}
|
||||
|
||||
|
||||
private static VertexBuffer rebuildVAO(float width, float height) {
|
||||
private static void rebuildVAO(float width, float height) {
|
||||
final CapturingTessellator tessellator = TessellatorManager.startCapturingAndGet();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(0, height, 0.0, 0, 0);
|
||||
@@ -198,7 +196,7 @@ public class HUDCaching {
|
||||
tessellator.addVertexWithUV(width, 0, 0.0, 1, 1);
|
||||
tessellator.addVertexWithUV(0, 0, 0.0, 0, 1);
|
||||
tessellator.draw();
|
||||
return TessellatorManager.stopCapturingToVAO(DefaultVertexFormat.POSITION_TEXTURE);
|
||||
quadVAO = TessellatorManager.stopCapturingToVAO(quadVAO, DefaultVertexFormat.POSITION_TEXTURE);
|
||||
}
|
||||
|
||||
public static void disableHoloInventory() {
|
||||
|
||||
@@ -16,6 +16,7 @@ import jss.notfine.asm.AsmTransformers;
|
||||
import jss.notfine.asm.mappings.Namer;
|
||||
import jss.notfine.config.MCPatcherForgeConfig;
|
||||
import jss.notfine.config.NotFineConfig;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.SharedConfig;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -45,7 +46,8 @@ import java.util.Set;
|
||||
@IFMLLoadingPlugin.TransformerExclusions({
|
||||
"jss.notfine.asm",
|
||||
"com.gtnewhorizons.angelica.loading",
|
||||
"com.gtnewhorizons.angelica.glsm.GLStateManager"})
|
||||
"com.gtnewhorizons.angelica.glsm.GLStateManager"
|
||||
})
|
||||
public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
|
||||
private static Boolean OBF_ENV;
|
||||
@@ -54,6 +56,10 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
private String[] transformerClasses;
|
||||
|
||||
public AngelicaTweaker() {
|
||||
if (Launch.blackboard.getOrDefault("angelica.rfbPluginLoaded", Boolean.FALSE) == Boolean.TRUE) {
|
||||
addLwjgl3ifyExclusions();
|
||||
}
|
||||
|
||||
try {
|
||||
// Angelica Config
|
||||
ConfigurationManager.registerConfig(AngelicaConfig.class);
|
||||
@@ -78,8 +84,19 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
}
|
||||
|
||||
private static void verifyDependencies() {
|
||||
// Check for fastutil (bundled with GTNHLib since 0.2.1)
|
||||
if (AngelicaTweaker.class.getResource("/it/unimi/dsi/fastutil/ints/Int2ObjectMap.class") == null) {
|
||||
throw new RuntimeException("Missing dependency: Angelica requires GTNHLib 0.2.1 or newer! Download: https://modrinth.com/mod/gtnhlib");
|
||||
throw new RuntimeException("Missing dependency: Angelica requires GTNHLib! Download: https://modrinth.com/mod/gtnhlib");
|
||||
}
|
||||
|
||||
// Check for PrimitiveExtractor/cel.model classes (added in GTNHLib 0.8.21)
|
||||
if (AngelicaTweaker.class.getResource("/com/gtnewhorizon/gtnhlib/client/renderer/PrimitiveExtractor.class") == null) {
|
||||
throw new RuntimeException("GTNHLib is outdated: Angelica requires GTNHLib 0.8.21 or newer! Download: https://modrinth.com/mod/gtnhlib");
|
||||
}
|
||||
|
||||
// Check for jvmdowngrader stubs (bundled with GTNHLib since 0.9.0)
|
||||
if (AngelicaTweaker.class.getResource("/xyz/wagyourtail/jvmdg/exc/MissingStubError.class") == null) {
|
||||
throw new RuntimeException("GTNHLib is outdated: Angelica requires GTNHLib 0.9.0 or newer! Download: https://modrinth.com/mod/gtnhlib");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,9 +142,6 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
boolean rfbLoaded = Launch.blackboard.getOrDefault("angelica.rfbPluginLoaded", Boolean.FALSE) == Boolean.TRUE;
|
||||
if (!rfbLoaded) {
|
||||
tweaks.add("com.gtnewhorizons.angelica.loading.fml.tweakers.AngelicaLateTweaker");
|
||||
if (AngelicaConfig.enableSodium) {
|
||||
tweaks.add("com.gtnewhorizons.angelica.loading.fml.tweakers.SodiumLateTweaker");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,6 +154,9 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
|
||||
@Override
|
||||
public String getMixinConfig() {
|
||||
int v = Runtime.version().feature();
|
||||
if (v >= 21) return "mixins.angelica.early.j21.json";
|
||||
if (v >= 17) return "mixins.angelica.early.j17.json";
|
||||
return "mixins.angelica.early.json";
|
||||
}
|
||||
|
||||
@@ -153,6 +170,19 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
return IMixins.getEarlyMixins(Mixins.class, loadedCoreMods);
|
||||
}
|
||||
|
||||
private static void addLwjgl3ifyExclusions() {
|
||||
var handle = SharedConfig.getRfbTransformers().stream()
|
||||
.filter(transformer -> transformer.id().equals("lwjgl3ify:redirect"))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (handle != null) {
|
||||
handle.exclusions().add("org.embeddedt.embeddium");
|
||||
handle.exclusions().add("org.taumc.celeritas");
|
||||
handle.exclusions().add("com.mitchej123.lwjgl.lwjgl3");
|
||||
handle.exclusions().add("com.mitchej123.glsm");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if we are in an obfuscated environment, returns false in dev environment.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class SodiumBlockTransformer implements IClassTransformer {
|
||||
public SodiumBlockTransformer() {
|
||||
this.inner = new SodiumBlockTransform(AngelicaTweaker.isObfEnv());
|
||||
this.exclusions = inner.getTransformerExclusions();
|
||||
this.inner.setSodiumSetting();
|
||||
this.inner.setCeleritasSetting();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.loading.fml.tweakers;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class SodiumLateTweaker implements ITweaker {
|
||||
|
||||
@Override
|
||||
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLaunchTarget() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getLaunchArguments() {
|
||||
String transformer = "com.gtnewhorizons.angelica.loading.fml.transformers.SodiumBlockTransformer";
|
||||
FMLRelaunchLog.finer("Registering transformer %s", transformer);
|
||||
Launch.classLoader.registerTransformer(transformer);
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
+1
@@ -244,6 +244,7 @@ public final class AngelicaRedirector {
|
||||
"org.lwjgl",
|
||||
"com.gtnewhorizons.angelica.glsm.",
|
||||
"com.gtnewhorizons.angelica.transform",
|
||||
"com.gtnewhorizon.gtnhlib.asm.",
|
||||
"me.eigenraven.lwjgl3ify"
|
||||
};
|
||||
}
|
||||
|
||||
+11
-10
@@ -58,22 +58,22 @@ public class SodiumBlockTransform {
|
||||
// Block owners we *shouldn't* redirect because they shadow one of our fields
|
||||
private static final Set<String> blockOwnerExclusions = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
// Needed because the config is loaded in LaunchClassLoader, but we need to access it in the parent system loader.
|
||||
private static final MethodHandle angelicaConfigSodiumEnabledGetter;
|
||||
private static boolean isSodiumEnabled;
|
||||
private static final MethodHandle angelicaConfigCeleritasEnabledGetter;
|
||||
private static boolean isCeleritasEnabled;
|
||||
|
||||
static {
|
||||
try {
|
||||
final Class<?> angelicaConfig = Class.forName("com.gtnewhorizons.angelica.config.AngelicaConfig", true, Launch.classLoader);
|
||||
angelicaConfigSodiumEnabledGetter = MethodHandles.lookup().findStaticGetter(angelicaConfig, "enableSodium", boolean.class);
|
||||
angelicaConfigCeleritasEnabledGetter = MethodHandles.lookup().findStaticGetter(angelicaConfig, "enableCeleritas", boolean.class);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSodiumEnabled() {
|
||||
if (isSodiumEnabled) return true;
|
||||
private static boolean isCeleritasEnabled() {
|
||||
if (isCeleritasEnabled) return true;
|
||||
try {
|
||||
return (boolean) angelicaConfigSodiumEnabledGetter.invokeExact();
|
||||
return (boolean) angelicaConfigCeleritasEnabledGetter.invokeExact();
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -104,6 +104,7 @@ public class SodiumBlockTransform {
|
||||
"org.lwjgl",
|
||||
"com.gtnewhorizons.angelica.glsm.",
|
||||
"com.gtnewhorizons.angelica.transform",
|
||||
"com.gtnewhorizon.gtnhlib.asm.",
|
||||
"me.eigenraven.lwjgl3ify"
|
||||
};
|
||||
}
|
||||
@@ -118,7 +119,7 @@ public class SodiumBlockTransform {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("net.minecraft.block.Block".equals(transformedName) && isSodiumEnabled()) {
|
||||
if ("net.minecraft.block.Block".equals(transformedName) && isCeleritasEnabled()) {
|
||||
cn.fields.removeIf(field -> BlockBoundsFields.stream().anyMatch(pair -> field.name.equals(pair.getLeft()) || field.name.equals(pair.getRight())));
|
||||
}
|
||||
|
||||
@@ -163,7 +164,7 @@ public class SodiumBlockTransform {
|
||||
for (MethodNode mn : cn.methods) {
|
||||
for (AbstractInsnNode node : mn.instructions.toArray()) {
|
||||
if ((node.getOpcode() == Opcodes.GETFIELD || node.getOpcode() == Opcodes.PUTFIELD) && node instanceof FieldInsnNode fNode) {
|
||||
if (!blockOwnerExclusions.contains(fNode.owner) && isBlockSubclass(fNode.owner) && isSodiumEnabled()) {
|
||||
if (!blockOwnerExclusions.contains(fNode.owner) && isBlockSubclass(fNode.owner) && isCeleritasEnabled()) {
|
||||
Pair<String, String> fieldToRedirect = BlockBoundsFields.stream()
|
||||
.filter(pair -> fNode.name.equals(getFieldName(pair)))
|
||||
.findFirst()
|
||||
@@ -205,7 +206,7 @@ public class SodiumBlockTransform {
|
||||
return changed;
|
||||
}
|
||||
|
||||
public void setSodiumSetting() {
|
||||
isSodiumEnabled = true;
|
||||
public void setCeleritasSetting() {
|
||||
isCeleritasEnabled = true;
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ public enum Mixins implements IMixins {
|
||||
, "angelica.MixinFMLClientHandler"
|
||||
, "angelica.bugfixes.MixinRenderGlobal_DestroyBlock"
|
||||
, "angelica.glsm.MixinSplashProgressCaching"
|
||||
, "angelica.debug.MixinMinecraft_FPSCap"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -73,6 +74,8 @@ public enum Mixins implements IMixins {
|
||||
, "angelica.dynamiclights.MixinEntity"
|
||||
, "angelica.dynamiclights.MixinWorld"
|
||||
, "angelica.dynamiclights.MixinItemRenderer"
|
||||
, "angelica.dynamiclights.MixinEntityCreeper"
|
||||
, "angelica.dynamiclights.MixinEntityTNTPrimed"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -138,36 +141,53 @@ public enum Mixins implements IMixins {
|
||||
)
|
||||
),
|
||||
|
||||
SODIUM(new MixinBuilder()
|
||||
RENDERING_INFRASTRUCTURE(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableSodium)
|
||||
.setApplyIf(() -> AngelicaConfig.enableCeleritas)
|
||||
.addClientMixins(
|
||||
"sodium.MixinBlock"
|
||||
, "sodium.MixinBlockFluidBase"
|
||||
, "sodium.AccessorBiomeColorEvent"
|
||||
, "sodium.MixinBiomeGenBase"
|
||||
, "sodium.MixinChunk"
|
||||
, "sodium.MixinChunkProviderServer"
|
||||
, "sodium.MixinClientRegistry"
|
||||
, "sodium.MixinEntity_RenderDist"
|
||||
, "sodium.MixinEntityItem_RenderDist"
|
||||
, "sodium.MixinRenderManager"
|
||||
, "sodium.MixinEntityRenderer"
|
||||
, "sodium.MixinFMLClientHandler"
|
||||
, "sodium.MixinForgeHooksClient"
|
||||
, "sodium.MixinGameSettings"
|
||||
, "sodium.MixinFrustrum"
|
||||
, "sodium.MixinMinecraft"
|
||||
, "sodium.MixinRenderBlocks"
|
||||
, "sodium.MixinRenderGlobal"
|
||||
, "sodium.MixinWorldClient"
|
||||
, "sodium.MixinTileEntity"
|
||||
, "sodium.MixinTileEntityMobSpawner"
|
||||
, "sodium.MixinEffectRenderer"
|
||||
, "sodium.MixinTileEntityRendererDispatcher"
|
||||
, "sodium.MixinLongHashMap"
|
||||
, "sodium.MixinRenderingRegistry"
|
||||
, "sodium.MixinPlayerManager"
|
||||
"rendering.MixinBlock"
|
||||
, "rendering.MixinBlockFluidBase"
|
||||
, "rendering.AccessorBiomeColorEvent"
|
||||
, "rendering.MixinBiomeGenBase"
|
||||
, "rendering.MixinChunk"
|
||||
, "rendering.MixinChunkProviderServer"
|
||||
, "rendering.MixinClientRegistry"
|
||||
, "rendering.MixinEntity_RenderDist"
|
||||
, "rendering.MixinEntityItem_RenderDist"
|
||||
, "rendering.MixinEntityRenderer"
|
||||
, "rendering.MixinFMLClientHandler"
|
||||
, "rendering.MixinGameSettings"
|
||||
, "rendering.MixinLongHashMap"
|
||||
, "rendering.MixinMinecraft"
|
||||
, "rendering.MixinPlayerManager"
|
||||
, "rendering.MixinRenderBlocks"
|
||||
, "rendering.MixinRenderingRegistry"
|
||||
, "rendering.MixinTileEntity"
|
||||
, "rendering.MixinTileEntityMobSpawner"
|
||||
, "rendering.MixinTileEntityRendererDispatcher"
|
||||
)
|
||||
),
|
||||
|
||||
CELERITAS(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableCeleritas)
|
||||
.addClientMixins(
|
||||
"celeritas.terrain.ChunkTrackerAccessor"
|
||||
, "celeritas.terrain.MixinChunkProviderClient"
|
||||
, "celeritas.terrain.MixinMinecraft_ChunkUpdates"
|
||||
, "celeritas.terrain.MixinRenderGlobal"
|
||||
, "celeritas.terrain.MixinRenderSectionManager"
|
||||
, "celeritas.terrain.MixinWorldClient"
|
||||
, "celeritas.frustum.MixinFrustrum"
|
||||
, "celeritas.features.culling.MixinEffectRenderer"
|
||||
, "celeritas.features.mipmaps.MixinTextureAtlasSprite"
|
||||
, "celeritas.features.mipmaps.MixinTextureUtil"
|
||||
, "celeritas.features.textures.MixinTextureMap"
|
||||
, "celeritas.features.textures.MixinTextureAtlasSprite"
|
||||
, "celeritas.biome_blending.MixinBlockGrass"
|
||||
, "celeritas.biome_blending.MixinBlockLeaves"
|
||||
, "celeritas.biome_blending.MixinBlockLiquid"
|
||||
, "celeritas.threading.MixinForgeHooksClient"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -182,6 +202,7 @@ public enum Mixins implements IMixins {
|
||||
, "shaders.MixinLocale"
|
||||
, "shaders.MixinOpenGlHelper"
|
||||
, "shaders.MixinRender"
|
||||
, "shaders.MixinRenderEntityFlame"
|
||||
, "shaders.MixinRendererLivingEntity"
|
||||
, "shaders.MixinRenderGlobal"
|
||||
, "shaders.MixinTileEntityBeaconRenderer"
|
||||
@@ -208,7 +229,7 @@ public enum Mixins implements IMixins {
|
||||
|
||||
ANGELICA_TEXTURE(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableIris || AngelicaConfig.enableSodium)
|
||||
.setApplyIf(() -> AngelicaConfig.enableIris || AngelicaConfig.enableCeleritas)
|
||||
.addClientMixins(
|
||||
"angelica.textures.MixinTextureAtlasSprite"
|
||||
, "angelica.textures.MixinTextureUtil"
|
||||
@@ -249,13 +270,8 @@ public enum Mixins implements IMixins {
|
||||
.addClientMixins(
|
||||
"angelica.animation.MixinTextureAtlasSprite",
|
||||
"angelica.animation.MixinTextureMap",
|
||||
"angelica.animation.MixinBlockFire",
|
||||
"angelica.animation.MixinMinecraftForgeClient",
|
||||
"angelica.animation.MixinChunkCache",
|
||||
"angelica.animation.MixinRenderBlocks",
|
||||
"angelica.animation.MixinRenderBlockFluid",
|
||||
"angelica.animation.MixinWorldRenderer",
|
||||
"angelica.animation.MixinRenderItem")),
|
||||
"angelica.animation.MixinRenderBlocks")),
|
||||
|
||||
SCALED_RESOUTION_UNICODE_FIX(new MixinBuilder("Removes unicode languages gui scaling being forced to even values")
|
||||
.setPhase(Phase.EARLY)
|
||||
@@ -451,12 +467,12 @@ public enum Mixins implements IMixins {
|
||||
),
|
||||
MCPATCHER_FORGE_RENDERPASS_DISPLAYLIST(new MixinBuilder("RenderPass display list allocation increase")
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> NotFineConfig.renderPass && !AngelicaConfig.enableSodium)
|
||||
.setApplyIf(() -> NotFineConfig.renderPass && !AngelicaConfig.enableCeleritas)
|
||||
.addClientMixins("mcpatcherforge.renderpass.MixinRenderGlobal_DisplayLists")
|
||||
),
|
||||
MCPATCHER_FORGE_RENDERPASS_FEATURES(new MixinBuilder("RenderPass rendering features")
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> NotFineConfig.renderPass && !AngelicaConfig.enableSodium)
|
||||
.setApplyIf(() -> NotFineConfig.renderPass && !AngelicaConfig.enableCeleritas)
|
||||
.addClientMixins("mcpatcherforge.renderpass.MixinRenderGlobal_Features")
|
||||
),
|
||||
MCPATCHER_FORGE_CUSTOM_COLORS(new MixinBuilder()
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
|
||||
public interface ChunkTrackerAccessor {
|
||||
Long2IntOpenHashMap angelica$getChunkStatus();
|
||||
LongOpenHashSet angelica$getChunkReady();
|
||||
LongSet angelica$getUnloadQueue();
|
||||
LongSet angelica$getLoadQueue();
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public interface EntityRendererAccessor {
|
||||
float invokeGetNightVisionBrightness(EntityPlayer entityPlayer, float partialTicks);
|
||||
|
||||
/**
|
||||
* Get the lightmap texture for shader binding.
|
||||
*/
|
||||
DynamicTexture getLightmapTexture();
|
||||
}
|
||||
Loaded 100 of 501 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user