mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 04:42:17 +00:00
Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fabe45ae7 | ||
|
|
ab54359f03 | ||
|
|
0c9ec5b23a | ||
|
|
20ae68aa62 | ||
|
|
46164ebac7 | ||
|
|
de0a600163 | ||
|
|
956f9e344e | ||
|
|
acc1f58778 | ||
|
|
1a38bd1a00 | ||
|
|
cfc19bb35e | ||
|
|
446c8e74ee | ||
|
|
74cdc561e6 | ||
|
|
67fbcc8ff0 | ||
|
|
d19b8d5302 | ||
|
|
ae0e03bead | ||
|
|
7d7d73a48f | ||
|
|
6dcc4649db | ||
|
|
5db5c7f683 |
No files matched your search
@@ -18,8 +18,9 @@
|
||||
* Fastcraft [Disable, won't fix]
|
||||
* LWJGL3ify 1.5.4 and below - Use the latest version available, 1.5.7+
|
||||
* ArchaicFix 0.6.2 and below - Use 0.7.0 or above
|
||||
* Hodgepodge 2.4.2 and below - Use 2.4.3 or above
|
||||
* Hodgepodge 2.4.3 and below - Use 2.4.4 or above
|
||||
* CodeChickenCore/Lib <1.2.0 - Threading issues, use 1.2.0+
|
||||
* Neodymium - Untested, but unlikely to be compatible. (Chunk Meshing is definitely incompatible, other features might work depending on config)
|
||||
|
||||
# Credits
|
||||
* ShadersMod
|
||||
|
||||
+1
-1
@@ -798,7 +798,7 @@ dependencies {
|
||||
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
|
||||
}
|
||||
if (modId != 'hodgepodge') {
|
||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.4.3')
|
||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.4.4')
|
||||
}
|
||||
|
||||
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
|
||||
|
||||
+7
-3
@@ -39,11 +39,13 @@ configurations {
|
||||
transformedModCompileOnly
|
||||
transformedModCompileOnly.canBeConsumed = false
|
||||
|
||||
// Add the transformed mod dependencies to the compilation and runtime classpaths, but don't publish them in the Maven metadata
|
||||
// Add the transformed mod dependencies to the compilation classpaths, but don't publish them in the Maven metadata
|
||||
compileClasspath.extendsFrom(transformedMod, transformedModCompileOnly)
|
||||
runtimeClasspath.extendsFrom(transformedMod)
|
||||
testCompileClasspath.extendsFrom(transformedMod, transformedModCompileOnly)
|
||||
testRuntimeClasspath.extendsFrom(transformedMod)
|
||||
|
||||
// Can be enabled for testing if desired
|
||||
// runtimeClasspath.extendsFrom(transformedMod)
|
||||
// testRuntimeClasspath.extendsFrom(transformedMod)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -73,6 +75,8 @@ dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.5.1:dev") {transitive = false }
|
||||
compileOnly(rfg.deobf('curse.maven:witchery-69673:2234410'))
|
||||
|
||||
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.0:api")
|
||||
compileOnly("com.falsepattern:endlessids-mc1.7.10:1.5-beta0002:dev")
|
||||
|
||||
compileOnly(rfg.deobf("curse.maven:extrautils-225561:2264383"))
|
||||
compileOnly(rfg.deobf("curse.maven:dynamiclights-227874:2337326"))
|
||||
|
||||
+4
-5
@@ -2,11 +2,10 @@
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'covers1624 maven'
|
||||
url = 'https://nexus.covers1624.net/repository/maven-hosted/'
|
||||
metadataSources {
|
||||
mavenPom()
|
||||
artifact()
|
||||
name = 'mavenpattern'
|
||||
url = 'https://mvn.falsepattern.com/releases'
|
||||
content {
|
||||
includeGroup "com.falsepattern"
|
||||
}
|
||||
}
|
||||
mavenLocal()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.gtnewhorizons.angelica;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.proxy.CommonProxy;
|
||||
import com.gtnewhorizons.angelica.utils.AnimationMode;
|
||||
import com.gtnewhorizons.angelica.utils.ManagedEnum;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
@@ -20,18 +20,14 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
public class AngelicaMod {
|
||||
@SidedProxy(clientSide = "com.gtnewhorizons.angelica.proxy.ClientProxy", serverSide = "com.gtnewhorizons.angelica.proxy.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
/** Mixin Version */
|
||||
public static boolean isNEIDLoaded;
|
||||
/** ASM Version */
|
||||
public static boolean isOldNEIDLoaded;
|
||||
|
||||
public static final boolean lwjglDebug = Boolean.parseBoolean(System.getProperty("org.lwjgl.util.Debug", "false"));
|
||||
|
||||
public static final ManagedEnum<AnimationMode> animationsMode = new ManagedEnum<>(AnimationMode.VISIBLE_ONLY);
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
isNEIDLoaded = Loader.isModLoaded("neid");
|
||||
isOldNEIDLoaded = Loader.isModLoaded("notenoughIDs");
|
||||
ModStatus.preInit();
|
||||
proxy.preInit(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.gtnewhorizons.angelica.client.renderer;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPos;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
import com.gtnewhorizons.angelica.compat.nd.RecyclingList;
|
||||
import me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* To be used in conjunction with the TessellatorManager
|
||||
*
|
||||
* Used to capture the quads generated by the Tessellator across multiple draw calls and make the quad
|
||||
* list available for usage.
|
||||
*
|
||||
* NOTE: This will _not_ (currently) capture, integrate, or stop any GL calls made around the tessellator draw calls.
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class CapturingTessellator extends Tessellator {
|
||||
private final BlockRenderer.Flags FLAGS = new BlockRenderer.Flags(true, true, true, true);
|
||||
private final RecyclingList<Quad> quadBuf = new RecyclingList<>(Quad::new);
|
||||
|
||||
// Any offset we need to the Tesselator's offset!
|
||||
private final BlockPos offset = new BlockPos();
|
||||
|
||||
public void setOffset(BlockPos pos) {
|
||||
this.offset.set(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int draw() {
|
||||
// Adapted from Neodymium
|
||||
|
||||
FLAGS.hasBrightness = this.hasBrightness;
|
||||
FLAGS.hasColor = this.hasColor;
|
||||
FLAGS.hasNormals = this.hasNormals;
|
||||
|
||||
// TODO: Support GL_TRIANGLES
|
||||
if(this.drawMode != GL11.GL_QUADS) {
|
||||
throw new IllegalStateException("Currently only supports GL_QUADS");
|
||||
|
||||
}
|
||||
final int verticesPerPrimitive = this.drawMode == GL11.GL_QUADS ? 4 : 3;
|
||||
|
||||
|
||||
for(int quadI = 0; quadI < this.vertexCount / verticesPerPrimitive; quadI++) {
|
||||
final Quad quad = quadBuf.next();
|
||||
quad.setState(this.rawBuffer, quadI * (verticesPerPrimitive * 8), FLAGS, this.drawMode, -offset.x, -offset.y, -offset.z);
|
||||
|
||||
if(quad.deleted) {
|
||||
quadBuf.remove();
|
||||
}
|
||||
}
|
||||
|
||||
final int i = this.rawBufferIndex * 4;
|
||||
this.reset();
|
||||
this.isDrawing = false;
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
this.offset.zero();
|
||||
}
|
||||
|
||||
public List<Quad> getQuads() {
|
||||
return quadBuf.getAsList();
|
||||
}
|
||||
|
||||
public void clearQuads() {
|
||||
this.quadBuf.reset();
|
||||
}
|
||||
|
||||
public static ByteBuffer quadsToBuffer(List<Quad> quads, VertexFormat format) {
|
||||
if(!format.canWriteQuads()) {
|
||||
throw new IllegalStateException("Vertex format has no quad writer: " + format);
|
||||
}
|
||||
final ByteBuffer byteBuffer = BufferUtils.createByteBuffer(format.getVertexSize() * quads.size() * 4);
|
||||
// noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0, quadsSize = quads.size(); i < quadsSize; i++) {
|
||||
format.writeQuad(quads.get(i), byteBuffer);
|
||||
}
|
||||
byteBuffer.rewind();
|
||||
return byteBuffer;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.gtnewhorizons.angelica.compat;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.falsepattern.chunk.api.DataRegistry;
|
||||
import com.gtnewhorizons.angelica.mixins.early.sodium.MixinExtendedBlockStorage;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ExtendedNibbleArray;
|
||||
import com.gtnewhorizons.neid.mixins.interfaces.IExtendedBlockStorageMixin;
|
||||
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.NibbleArray;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import ru.fewizz.idextender.Hooks;
|
||||
@@ -16,44 +18,51 @@ public class ExtendedBlockStorageExt extends ExtendedBlockStorage {
|
||||
this.hasSky = hasSky;
|
||||
}
|
||||
|
||||
public ExtendedBlockStorageExt(ExtendedBlockStorage storage) {
|
||||
public ExtendedBlockStorageExt(Chunk chunk, ExtendedBlockStorage storage) {
|
||||
super(((MixinExtendedBlockStorage) storage).getYBase(), storage.getSkylightArray() != null);
|
||||
|
||||
int arrayLen;
|
||||
if (AngelicaMod.isNEIDLoaded){
|
||||
final short[] block16BArray = ((IExtendedBlockStorageMixin)(Object)this).getBlock16BArray();
|
||||
System.arraycopy(((IExtendedBlockStorageMixin)(Object)storage).getBlock16BArray(), 0, block16BArray, 0, block16BArray.length);
|
||||
if(storage.getBlockMSBArray() != null) {
|
||||
this.setBlockMSBArray(new NibbleArray(block16BArray.length, 4));
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlockMSBArray(), (ExtendedNibbleArray) this.getBlockMSBArray());
|
||||
if (ModStatus.isChunkAPILoaded) {
|
||||
if (storage.getSkylightArray() != null) {
|
||||
hasSky = true;
|
||||
}
|
||||
arrayLen = block16BArray.length;
|
||||
}
|
||||
else if (AngelicaMod.isOldNEIDLoaded){
|
||||
final short[] blockLSBArray = Hooks.get(this);
|
||||
System.arraycopy(Hooks.get(storage), 0, blockLSBArray, 0, blockLSBArray.length);
|
||||
// getBlockMSBArray is nuked in asm version
|
||||
arrayLen = blockLSBArray.length;
|
||||
}
|
||||
else {
|
||||
final byte[] blockLSBArray = this.getBlockLSBArray();
|
||||
System.arraycopy(storage.getBlockLSBArray(), 0, blockLSBArray, 0, blockLSBArray.length);
|
||||
if(storage.getBlockMSBArray() != null) {
|
||||
this.setBlockMSBArray(new NibbleArray(blockLSBArray.length, 4));
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlockMSBArray(), (ExtendedNibbleArray) this.getBlockMSBArray());
|
||||
DataRegistry.cloneSubChunk(chunk, storage, this);
|
||||
} else {
|
||||
int arrayLen;
|
||||
if (ModStatus.isNEIDLoaded){
|
||||
final short[] block16BArray = ((IExtendedBlockStorageMixin)(Object)this).getBlock16BArray();
|
||||
System.arraycopy(((IExtendedBlockStorageMixin)(Object)storage).getBlock16BArray(), 0, block16BArray, 0, block16BArray.length);
|
||||
if(storage.getBlockMSBArray() != null) {
|
||||
this.setBlockMSBArray(new NibbleArray(block16BArray.length, 4));
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlockMSBArray(), (ExtendedNibbleArray) this.getBlockMSBArray());
|
||||
}
|
||||
arrayLen = block16BArray.length;
|
||||
}
|
||||
else if (ModStatus.isOldNEIDLoaded){
|
||||
final short[] blockLSBArray = Hooks.get(this);
|
||||
System.arraycopy(Hooks.get(storage), 0, blockLSBArray, 0, blockLSBArray.length);
|
||||
// getBlockMSBArray is nuked in asm version
|
||||
arrayLen = blockLSBArray.length;
|
||||
}
|
||||
else {
|
||||
final byte[] blockLSBArray = this.getBlockLSBArray();
|
||||
System.arraycopy(storage.getBlockLSBArray(), 0, blockLSBArray, 0, blockLSBArray.length);
|
||||
if(storage.getBlockMSBArray() != null) {
|
||||
this.setBlockMSBArray(new NibbleArray(blockLSBArray.length, 4));
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlockMSBArray(), (ExtendedNibbleArray) this.getBlockMSBArray());
|
||||
}
|
||||
arrayLen = blockLSBArray.length;
|
||||
}
|
||||
arrayLen = blockLSBArray.length;
|
||||
}
|
||||
|
||||
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getMetadataArray(), (ExtendedNibbleArray)this.getMetadataArray());
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlocklightArray(), (ExtendedNibbleArray)this.getBlocklightArray());
|
||||
if(storage.getSkylightArray() != null) {
|
||||
hasSky = true;
|
||||
if(this.getSkylightArray() == null) {
|
||||
this.setSkylightArray(new NibbleArray(arrayLen, 4));
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getMetadataArray(), (ExtendedNibbleArray)this.getMetadataArray());
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlocklightArray(), (ExtendedNibbleArray)this.getBlocklightArray());
|
||||
if(storage.getSkylightArray() != null) {
|
||||
hasSky = true;
|
||||
if(this.getSkylightArray() == null) {
|
||||
this.setSkylightArray(new NibbleArray(arrayLen, 4));
|
||||
}
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getSkylightArray(), (ExtendedNibbleArray) this.getSkylightArray());
|
||||
}
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getSkylightArray(), (ExtendedNibbleArray) this.getSkylightArray());
|
||||
}
|
||||
((MixinExtendedBlockStorage) this).setBlockRefCount(((MixinExtendedBlockStorage) storage).getBlockRefCount());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.gtnewhorizons.angelica.compat;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class ModStatus {
|
||||
/**
|
||||
* Mixin Version
|
||||
*/
|
||||
public static boolean isNEIDLoaded;
|
||||
/**
|
||||
* ASM Version
|
||||
*/
|
||||
public static boolean isOldNEIDLoaded;
|
||||
public static boolean isLotrLoaded;
|
||||
public static boolean isChunkAPILoaded;
|
||||
public static boolean isEIDBiomeLoaded;
|
||||
|
||||
public static void preInit(){
|
||||
isNEIDLoaded = Loader.isModLoaded("neid");
|
||||
isOldNEIDLoaded = Loader.isModLoaded("notenoughIDs");
|
||||
isLotrLoaded = Loader.isModLoaded("lotr");
|
||||
isChunkAPILoaded = Loader.isModLoaded("chunkapi");
|
||||
isEIDBiomeLoaded = Loader.isModLoaded("endlessids_biome");
|
||||
}
|
||||
}
|
||||
+17
-13
@@ -1,32 +1,36 @@
|
||||
package com.gtnewhorizons.angelica.compat.toremove;
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormatElement;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormatElement.Type;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormatElement.Usage;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.nd.writers.ItemVBOQuadWriter;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
|
||||
public class DefaultVertexFormat {
|
||||
|
||||
public static final VertexFormatElement POSITION_ELEMENT = new VertexFormatElement(0, Type.FLOAT, Usage.POSITION, 3);
|
||||
public static final VertexFormatElement COLOR_ELEMENT = new VertexFormatElement(0, Type.UBYTE, Usage.COLOR, 4);
|
||||
public static final VertexFormatElement TEXTURE_0_ELEMENT = new VertexFormatElement(0, Type.FLOAT, Usage.UV, 2);
|
||||
public static final VertexFormatElement TEXTURE_ELEMENT = new VertexFormatElement(OpenGlHelper.defaultTexUnit, Type.FLOAT, Usage.UV, 2);
|
||||
public static final VertexFormatElement LIGHT_ELEMENT = new VertexFormatElement(OpenGlHelper.lightmapTexUnit, Type.SHORT, Usage.UV, 2);
|
||||
// TODO: The overlay element index is wrong, need to find a 1.7.10 equivalent
|
||||
public static final VertexFormatElement OVERLAY_ELEMENT = new VertexFormatElement(1, Type.SHORT, Usage.UV, 2);
|
||||
public static final VertexFormatElement LIGHT_ELEMENT = new VertexFormatElement(2, Type.SHORT, Usage.UV, 2);
|
||||
public static final VertexFormatElement NORMAL_ELEMENT = new VertexFormatElement(0, Type.BYTE, Usage.NORMAL, 3);
|
||||
public static final VertexFormatElement PADDING_ELEMENT = new VertexFormatElement(0, Type.BYTE, Usage.PADDING, 1);
|
||||
public static final VertexFormat POSITION_COLOR_TEXTURE_LIGHT_NORMAL = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_0_ELEMENT).add(LIGHT_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_0_ELEMENT).add(OVERLAY_ELEMENT).add(LIGHT_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE_COLOR_LIGHT = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_0_ELEMENT).add(COLOR_ELEMENT).add(LIGHT_ELEMENT).build());
|
||||
public static final VertexFormat ITEM_VBO = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build(), new ItemVBOQuadWriter());
|
||||
public static final VertexFormat POSITION_COLOR_TEXTURE_LIGHT_NORMAL = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_ELEMENT).add(LIGHT_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_ELEMENT).add(OVERLAY_ELEMENT).add(LIGHT_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE_COLOR_LIGHT = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).add(COLOR_ELEMENT).add(LIGHT_ELEMENT).build());
|
||||
public static final VertexFormat POSITION = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_COLOR = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_COLOR_LIGHT = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(LIGHT_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_0_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_COLOR_TEXTURE = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_0_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE_COLOR = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_0_ELEMENT).add(COLOR_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_COLOR_TEX_LIGHTMAP = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_0_ELEMENT).add(LIGHT_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE_LIGHT_COLOR = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_0_ELEMENT).add(LIGHT_ELEMENT).add(COLOR_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE_COLOR_NORMAL = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_0_ELEMENT).add(COLOR_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_COLOR_TEXTURE = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE_COLOR = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).add(COLOR_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_COLOR_TEX_LIGHTMAP = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_ELEMENT).add(LIGHT_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE_LIGHT_COLOR = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).add(LIGHT_ELEMENT).add(COLOR_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE_COLOR_NORMAL = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).add(COLOR_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build());
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITessellatorInstance;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
@@ -23,6 +26,47 @@ public class VertexBuffer implements AutoCloseable {
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
public void upload(Tessellator tessellator, VertexFormat format) {
|
||||
try {
|
||||
this.upload(tessellatorToBuffer(tessellator, format), tessellator.vertexCount);
|
||||
} catch(Exception e) {
|
||||
throw new RuntimeException("Failed to upload vertex buffer", e);
|
||||
} finally {
|
||||
((ITessellatorInstance) tessellator).discard();
|
||||
}
|
||||
}
|
||||
|
||||
public ByteBuffer tessellatorToBuffer(Tessellator tessellator, VertexFormat format) {
|
||||
|
||||
final int verticesPerPrimitive = tessellator.drawMode == GL11.GL_QUADS ? 4 : 3;
|
||||
|
||||
final int[] rawBuffer = tessellator.rawBuffer;
|
||||
final int byteSize = format.getVertexSize() * tessellator.vertexCount;
|
||||
final ByteBuffer byteBuffer = BufferUtils.createByteBuffer(byteSize);
|
||||
|
||||
|
||||
|
||||
for(int quadI = 0 ; quadI < tessellator.vertexCount / verticesPerPrimitive ; quadI++) {
|
||||
for(int vertexI = 0 ; vertexI < 4 ; vertexI++) {
|
||||
final int i = (quadI * 4 * 8 ) + (vertexI * 8);
|
||||
|
||||
// Position
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 0]));
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 1]));
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 2]));
|
||||
|
||||
// Texture
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 3]));
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 4]));
|
||||
|
||||
// Normals
|
||||
byteBuffer.putInt(rawBuffer[i + 6]);
|
||||
}
|
||||
}
|
||||
|
||||
return (ByteBuffer) byteBuffer.rewind();
|
||||
}
|
||||
|
||||
public void upload(ByteBuffer buffer, int vertexCount) {
|
||||
if (this.id == -1) return;
|
||||
this.vertexCount = vertexCount;
|
||||
@@ -42,7 +86,11 @@ public class VertexBuffer implements AutoCloseable {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMultMatrix(floatBuffer);
|
||||
GL11.glDrawArrays(mode, 0, this.vertexCount);
|
||||
draw(mode);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void draw(int mode) {
|
||||
GL11.glDrawArrays(mode, 0, this.vertexCount);
|
||||
}
|
||||
}
|
||||
+22
-5
@@ -1,7 +1,8 @@
|
||||
package com.gtnewhorizons.angelica.compat.toremove;
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormatElement;
|
||||
import com.gtnewhorizons.angelica.compat.nd.IWriteQuads;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import lombok.Getter;
|
||||
@@ -9,6 +10,7 @@ import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.vertices.ImmediateState;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
public class VertexFormat {
|
||||
@@ -18,7 +20,13 @@ public class VertexFormat {
|
||||
@Getter
|
||||
protected final int vertexSize;
|
||||
|
||||
protected IWriteQuads quadWriter;
|
||||
|
||||
public VertexFormat(ImmutableList<VertexFormatElement> elements) {
|
||||
this(elements, null);
|
||||
}
|
||||
|
||||
public VertexFormat(ImmutableList<VertexFormatElement> elements, IWriteQuads quadWriter) {
|
||||
this.elements = elements;
|
||||
int i = 0;
|
||||
for (VertexFormatElement element : elements) {
|
||||
@@ -26,9 +34,9 @@ public class VertexFormat {
|
||||
i += element.getByteSize();
|
||||
}
|
||||
vertexSize = i;
|
||||
this.quadWriter = quadWriter;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setupBufferState(long l) {
|
||||
if (BlockRenderingSettings.INSTANCE.shouldUseExtendedVertexFormat() && ImmediateState.renderWithExtendedVertexFormat) {
|
||||
if (this == DefaultVertexFormat.POSITION_COLOR_TEXTURE_LIGHT_NORMAL || this == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
|
||||
@@ -44,11 +52,10 @@ public class VertexFormat {
|
||||
final List<VertexFormatElement> list = this.getElements();
|
||||
|
||||
for(int j = 0; j < list.size(); ++j) {
|
||||
((VertexFormatElement)list.get(j)).setupBufferState(l + (long)this.offsets.getInt(j), i);
|
||||
list.get(j).setupBufferState(l + this.offsets.getInt(j), i);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void clearBufferState() {
|
||||
if (BlockRenderingSettings.INSTANCE.shouldUseExtendedVertexFormat() && ImmediateState.renderWithExtendedVertexFormat) {
|
||||
if (this == DefaultVertexFormat.POSITION_COLOR_TEXTURE_LIGHT_NORMAL || this == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
|
||||
@@ -64,4 +71,14 @@ public class VertexFormat {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canWriteQuads() {
|
||||
return quadWriter != null;
|
||||
}
|
||||
|
||||
public void writeQuad(Quad quad, ByteBuffer byteBuffer) {
|
||||
if(quadWriter == null) {
|
||||
throw new IllegalStateException("No quad writer set");
|
||||
}
|
||||
quadWriter.writeQuad(quad, byteBuffer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public interface IWriteQuads {
|
||||
void writeQuad(Quad quad, ByteBuffer buf);
|
||||
}
|
||||
@@ -31,7 +31,8 @@ public class Quad implements ModelQuadView {
|
||||
public float[] vs = new float[4];
|
||||
public int[] bs = new int[4];
|
||||
public int[] cs = new int[4];
|
||||
// TODO normals?
|
||||
public int[] ns = new int[4];
|
||||
|
||||
public boolean deleted;
|
||||
|
||||
public ModelQuadFacing normal;
|
||||
@@ -51,6 +52,7 @@ public class Quad implements ModelQuadView {
|
||||
|
||||
private boolean hasColor;
|
||||
private boolean hasShade;
|
||||
private boolean hasNormals;
|
||||
|
||||
public boolean hasColor() {
|
||||
return this.hasColor;
|
||||
@@ -64,6 +66,10 @@ public class Quad implements ModelQuadView {
|
||||
return this.hasShade;
|
||||
}
|
||||
|
||||
public boolean hasNormals() {
|
||||
return this.hasNormals;
|
||||
}
|
||||
|
||||
public ForgeDirection getFace() {
|
||||
// TODO: Sodium/Quad Facing
|
||||
return ForgeDirection.UP;
|
||||
@@ -111,7 +117,7 @@ public class Quad implements ModelQuadView {
|
||||
|
||||
@Override
|
||||
public int getNormal(int idx) {
|
||||
return 0;
|
||||
return ns[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,10 +142,14 @@ public class Quad implements ModelQuadView {
|
||||
us[vi] = Float.intBitsToFloat(rawBuffer[i + 3]);
|
||||
vs[vi] = Float.intBitsToFloat(rawBuffer[i + 4]);
|
||||
|
||||
bs[vi] = flags.hasBrightness ? rawBuffer[i + 7] : DEFAULT_BRIGHTNESS;
|
||||
cs[vi] = flags.hasColor ? rawBuffer[i + 5] : DEFAULT_COLOR;
|
||||
ns[vi] = flags.hasNormals ? rawBuffer[i + 6] : 0;
|
||||
bs[vi] = flags.hasBrightness ? rawBuffer[i + 7] : DEFAULT_BRIGHTNESS;
|
||||
|
||||
this.hasColor |= flags.hasColor;
|
||||
this.hasShade |= flags.hasBrightness;
|
||||
this.hasNormals |= flags.hasNormals;
|
||||
|
||||
|
||||
i += 8;
|
||||
}
|
||||
@@ -155,6 +165,7 @@ public class Quad implements ModelQuadView {
|
||||
|
||||
bs[3] = bs[2];
|
||||
cs[3] = cs[2];
|
||||
ns[3] = ns[2];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,39 +216,6 @@ public class Quad implements ModelQuadView {
|
||||
Arrays.fill(quadCountByDirection, 1);
|
||||
}
|
||||
|
||||
public void writeToBuffer(BufferWriter out) throws IOException {
|
||||
for(int vertexI = 0; vertexI < 4; vertexI++) {
|
||||
int vi = vertexI;
|
||||
int provokingI = 3;
|
||||
|
||||
float x = xs[vi];
|
||||
float y = ys[vi];
|
||||
float z = zs[vi];
|
||||
|
||||
out.writeFloat(x);
|
||||
out.writeFloat(y);
|
||||
out.writeFloat(z);
|
||||
|
||||
float u = us[vi];
|
||||
float v = vs[vi];
|
||||
|
||||
out.writeFloat(u);
|
||||
out.writeFloat(v);
|
||||
|
||||
int b = bs[vi];
|
||||
|
||||
out.writeInt(b);
|
||||
|
||||
int c = cs[vi];
|
||||
|
||||
out.writeInt(c);
|
||||
|
||||
assert out.position() % getStride() == 0;
|
||||
|
||||
//System.out.println("[" + vertexI + "] x: " + x + ", y: " + y + " z: " + z + ", u: " + u + ", v: " + v + ", b: " + b + ", c: " + c);
|
||||
}
|
||||
}
|
||||
|
||||
public int quadCountByUVDirection(boolean v) {
|
||||
if(v) {
|
||||
return quadCountByDirection[uDirectionIs01 ? 0 : 1];
|
||||
@@ -285,6 +263,7 @@ public class Quad implements ModelQuadView {
|
||||
vs[dest] = o.vs[src];
|
||||
bs[dest] = o.bs[src];
|
||||
cs[dest] = o.cs[src];
|
||||
ns[dest] = o.ns[src];
|
||||
|
||||
updateMinMaxXYZ(); // TODO isn't doing this a waste? I should get rid of the min/maxXYZ variables entirely.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.nd.IWriteQuads;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ItemVBOQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public ItemVBOQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(Quad quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(Quad quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(Quad quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
|
||||
// Normals + Padding
|
||||
buf.putInt(quad.getNormal(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.compat.toremove;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import lombok.Getter;
|
||||
|
||||
@Deprecated
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.gtnewhorizons.angelica.compat.toremove;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import it.unimi.dsi.fastutil.Hash;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -78,4 +78,14 @@ public class AngelicaConfig {
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean optimizeJabbaGetInteger;
|
||||
|
||||
@Config.Comment("Fix thread-safety in lotrs rendering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixLotrSodiumCompat;
|
||||
|
||||
@Config.Comment("Enable Debug Logging")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableDebugLogging;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import com.gtnewhorizons.angelica.glsm.states.Color4;
|
||||
import com.gtnewhorizons.angelica.glsm.states.TextureBinding;
|
||||
import com.gtnewhorizons.angelica.glsm.states.TextureUnitArray;
|
||||
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntStack;
|
||||
import lombok.Getter;
|
||||
@@ -35,6 +36,7 @@ import org.joml.Matrix4d;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Matrix4fStack;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.opengl.ARBMultitexture;
|
||||
@@ -159,6 +161,11 @@ public class GLStateManager {
|
||||
}
|
||||
|
||||
public static void glGetFloat(int pname, FloatBuffer params) {
|
||||
if(GLStateManager.BYPASS_CACHE) {
|
||||
GL11.glGetFloat(pname, params);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pname) {
|
||||
case GL11.GL_MODELVIEW_MATRIX -> modelViewMatrix.get(params);
|
||||
case GL11.GL_PROJECTION_MATRIX -> projectionMatrix.get(params);
|
||||
@@ -807,14 +814,17 @@ public class GLStateManager {
|
||||
getMatrixStack().mul(conersionMatrix4f);
|
||||
}
|
||||
|
||||
private static final Vector3f rotation = new Vector3f();
|
||||
public static void glRotatef(float angle, float x, float y, float z) {
|
||||
GL11.glRotatef(angle, x, y, z);
|
||||
getMatrixStack().rotate((float)Math.toRadians(angle), x, y, z);
|
||||
rotation.set(x, y, z).normalize();
|
||||
getMatrixStack().rotate((float)Math.toRadians(angle), rotation);
|
||||
}
|
||||
|
||||
public static void glRotated(double angle, double x, double y, double z) {
|
||||
GL11.glRotated(angle, x, y, z);
|
||||
getMatrixStack().rotate((float)Math.toRadians(angle), (float) x, (float) y, (float) z);
|
||||
rotation.set(x, y, z).normalize();
|
||||
getMatrixStack().rotate((float)Math.toRadians(angle), rotation);
|
||||
}
|
||||
|
||||
public static void glOrtho(double left, double right, double bottom, double top, double zNear, double zFar) {
|
||||
@@ -828,12 +838,24 @@ public class GLStateManager {
|
||||
}
|
||||
public static void glPushMatrix() {
|
||||
GL11.glPushMatrix();
|
||||
getMatrixStack().pushMatrix();
|
||||
try {
|
||||
getMatrixStack().pushMatrix();
|
||||
} catch(IllegalStateException ignored) {
|
||||
// Ignore
|
||||
if(AngelicaMod.lwjglDebug)
|
||||
AngelicaTweaker.LOGGER.warn("Matrix stack overflow ", new Throwable());
|
||||
}
|
||||
}
|
||||
|
||||
public static void glPopMatrix() {
|
||||
GL11.glPopMatrix();
|
||||
getMatrixStack().popMatrix();
|
||||
try {
|
||||
getMatrixStack().popMatrix();
|
||||
} catch(IllegalStateException ignored) {
|
||||
// Ignore
|
||||
if(AngelicaMod.lwjglDebug)
|
||||
AngelicaTweaker.LOGGER.warn("Matrix stack underflow ", new Throwable());
|
||||
}
|
||||
}
|
||||
|
||||
private static final Matrix4f perspectiveMatrix = new Matrix4f();
|
||||
|
||||
@@ -1,15 +1,29 @@
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import com.gtnewhorizons.angelica.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITessellatorInstance;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TessellatorManager {
|
||||
private static final ThreadLocal<Tessellator> theTessellator = ThreadLocal.withInitial(Tessellator::new);
|
||||
private static final ThreadLocal<CapturingTessellator> capturingTessellator = ThreadLocal.withInitial(CapturingTessellator::new);
|
||||
|
||||
private static final ThreadLocal<Boolean> currentlyCapturing = ThreadLocal.withInitial(() -> Boolean.FALSE);
|
||||
private static final Thread mainThread = Thread.currentThread();
|
||||
|
||||
public static Tessellator get() {
|
||||
if(isOnMainThread())
|
||||
if(currentlyCapturing.get()) {
|
||||
return capturingTessellator.get();
|
||||
} else if(isOnMainThread()) {
|
||||
return Tessellator.instance;
|
||||
return theTessellator.get();
|
||||
} else {
|
||||
// TODO: Verify this works correctly and nothing unexpected is grabbing a tessellator off the main thread
|
||||
// when not capturing
|
||||
throw new IllegalStateException("Tried to get the Tessellator off the main thread when not capturing!");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isOnMainThread() {
|
||||
@@ -17,10 +31,41 @@ public class TessellatorManager {
|
||||
}
|
||||
|
||||
public static boolean isMainInstance(Object instance) {
|
||||
return instance == Tessellator.instance;
|
||||
return instance == Tessellator.instance || isOnMainThread();
|
||||
}
|
||||
|
||||
public static void startCapturing() {
|
||||
if(currentlyCapturing.get()) throw new IllegalStateException("Tried to start capturing when already capturing!");
|
||||
currentlyCapturing.set(true);
|
||||
}
|
||||
|
||||
|
||||
public static List<Quad> stopCapturing() {
|
||||
if(!currentlyCapturing.get()) throw new IllegalStateException("Tried to stop capturing when not capturing!");
|
||||
currentlyCapturing.set(false);
|
||||
final CapturingTessellator tess = capturingTessellator.get();
|
||||
|
||||
// Be sure we got all the quads
|
||||
if(tess.isDrawing) tess.draw();
|
||||
|
||||
final List<Quad> quads = tess.getQuads();
|
||||
((ITessellatorInstance)tess).discard();
|
||||
|
||||
tess.clearQuads();
|
||||
return quads;
|
||||
}
|
||||
|
||||
static {
|
||||
System.out.println("[TessellatorManager] Initialized on thread " + mainThread.getName());
|
||||
}
|
||||
|
||||
public static void cleanup() {
|
||||
// Ensure we've cleaned everything up
|
||||
if(currentlyCapturing.get()) {
|
||||
currentlyCapturing.set(false);
|
||||
final CapturingTessellator tess = capturingTessellator.get();
|
||||
((ITessellatorInstance)tess).discard();
|
||||
tess.clearQuads();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,12 @@ public class MatrixMode implements ISettableState<MatrixMode> {
|
||||
protected int mode = GL11.GL_MODELVIEW;
|
||||
|
||||
public void setMode(int mode) {
|
||||
if(mode != GL11.GL_MODELVIEW && mode != GL11.GL_PROJECTION && mode != GL11.GL_TEXTURE && mode != GL11.GL_COLOR) {
|
||||
// Invalid mode, do nothing on the cache, but pass it along to OGL
|
||||
GL11.glMatrixMode(mode);
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.mode != mode || GLStateManager.BYPASS_CACHE) {
|
||||
this.mode = mode;
|
||||
GL11.glMatrixMode(mode);
|
||||
|
||||
@@ -43,7 +43,9 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||
Configuration config = ctx.getConfiguration();
|
||||
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
|
||||
loggerConfig.setLevel(Level.DEBUG);
|
||||
if (AngelicaConfig.enableDebugLogging) {
|
||||
loggerConfig.setLevel(Level.DEBUG);
|
||||
}
|
||||
ctx.updateLoggers();
|
||||
} catch (ConfigException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.loading;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.transform.BlockTransformer;
|
||||
import com.gtnewhorizons.angelica.transform.RedirectorTransformer;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
@@ -75,7 +76,9 @@ public class MixinCompatHackTweaker implements ITweaker {
|
||||
if (FMLLaunchHandler.side().isClient()) {
|
||||
// Run after Mixins, but before LWJGl3ify
|
||||
Launch.classLoader.registerTransformer(RedirectorTransformer.class.getName());
|
||||
Launch.classLoader.registerTransformer(BlockTransformer.class.getName());
|
||||
if(AngelicaConfig.enableSodium) {
|
||||
Launch.classLoader.registerTransformer(BlockTransformer.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return new String[0];
|
||||
|
||||
@@ -27,6 +27,7 @@ public enum Mixins {
|
||||
.setPhase(Phase.EARLY).addMixinClasses(
|
||||
"angelica.MixinActiveRenderInfo"
|
||||
,"angelica.MixinEntityRenderer"
|
||||
,"angelica.vbo.MixinWavefrontObject"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -42,6 +43,13 @@ public enum Mixins {
|
||||
"angelica.debug.MixinSplashProgress"
|
||||
)
|
||||
),
|
||||
|
||||
ANGELICA_THAUMCRAFT_COMPAT(new Builder("Angelica Thaumcraft Compat").addTargetedMod(TargetedMod.THAUMCRAFT).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).addMixinClasses(
|
||||
"angelica.thaumcraft.MixinClientTickEventsFML"
|
||||
)
|
||||
),
|
||||
|
||||
// Not compatible with the lwjgl debug callbacks, so disable if that's enabled
|
||||
ARCHAIC_SPLASH(new Builder("ArchaicFix Splash").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.showSplashMemoryBar && !AngelicaMod.lwjglDebug).addMixinClasses(
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.thaumcraft;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import thaumcraft.client.lib.ClientTickEventsFML;
|
||||
|
||||
@Mixin(ClientTickEventsFML.class)
|
||||
public class MixinClientTickEventsFML {
|
||||
|
||||
/**
|
||||
* Thaumcraft disables lighting and only re-enables it if actually drawing an aspect(hovering over an item that
|
||||
* you can see the aspect for and draws it). This shoves in a lighting re-enable at the end so that it is always
|
||||
* re-enabled regardless.
|
||||
*/
|
||||
@Inject(method = "renderAspectsInGui", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glPopAttrib()V"), remap = false)
|
||||
private void angelica$lightingFix(CallbackInfo ci) {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.vbo;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexBuffer;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IModelCustomExt;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraftforge.client.model.obj.GroupObject;
|
||||
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(value = WavefrontObject.class, remap = false)
|
||||
public abstract class MixinWavefrontObject implements IModelCustomExt {
|
||||
@Unique private VertexBuffer vertexBuffer;
|
||||
|
||||
@Shadow private GroupObject currentGroupObject;
|
||||
|
||||
@Shadow public abstract void tessellateAll(Tessellator tessellator);
|
||||
|
||||
@Unique VertexFormat format = DefaultVertexFormat.ITEM_VBO;
|
||||
|
||||
@Override
|
||||
public void rebuildVBO() {
|
||||
if(currentGroupObject == null) {
|
||||
throw new RuntimeException("No group object selected");
|
||||
}
|
||||
if (this.vertexBuffer != null) {
|
||||
this.vertexBuffer.close();
|
||||
}
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawing(currentGroupObject.glDrawingMode);
|
||||
tessellateAll(tessellator);
|
||||
|
||||
this.vertexBuffer = new VertexBuffer();
|
||||
this.vertexBuffer.bind();
|
||||
this.vertexBuffer.upload(tessellator, format);
|
||||
this.vertexBuffer.unbind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderAllVBO() {
|
||||
if(vertexBuffer == null) {
|
||||
rebuildVBO();
|
||||
}
|
||||
vertexBuffer.bind();
|
||||
format.setupBufferState(0L);
|
||||
vertexBuffer.draw(GL11.GL_QUADS);
|
||||
format.clearBufferState();
|
||||
vertexBuffer.unbind();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.sodium;
|
||||
|
||||
import com.gtnewhorizons.angelica.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizons.angelica.glsm.TessellatorManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITessellatorInstance;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -85,6 +86,4 @@ public abstract class MixinTessellator implements ITessellatorInstance {
|
||||
return angelica$midTextureV;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
|
||||
import static cpw.mods.fml.relauncher.Side.CLIENT;
|
||||
|
||||
public interface IModelCustomExt extends IModelCustom {
|
||||
@SideOnly(CLIENT)
|
||||
void rebuildVBO();
|
||||
|
||||
@SideOnly(CLIENT)
|
||||
void renderAllVBO();
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.proxy;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
@@ -11,6 +12,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import me.jellysquid.mods.sodium.client.SodiumDebugScreenHandler;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.client.IrisDebugScreenHandler;
|
||||
@@ -32,6 +34,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
@@ -62,7 +65,17 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
@Override
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
// Nothing to do here (yet)
|
||||
if (ModStatus.isLotrLoaded && AngelicaConfig.enableSodium && AngelicaConfig.fixLotrSodiumCompat) {
|
||||
try {
|
||||
Class<?> lotrRendering = Class.forName("lotr.common.coremod.LOTRReplacedMethods$BlockRendering");
|
||||
ReflectionHelper.setPrivateValue(lotrRendering,null,new ConcurrentHashMap<>(),"naturalBlockClassTable");
|
||||
ReflectionHelper.setPrivateValue(lotrRendering,null,new ConcurrentHashMap<>(),"naturalBlockTable");
|
||||
ReflectionHelper.setPrivateValue(lotrRendering,null,new ConcurrentHashMap<>(),"cachedNaturalBlocks");
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
AngelicaTweaker.LOGGER.error("Could net replace LOTR handle render code with thread safe version");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float lastIntegratedTickTime;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class AngelicaBlockSafetyRegistry {
|
||||
private static final StampedLock LOCK = new StampedLock();
|
||||
|
||||
public static boolean canBlockRenderOffThread(Block block) {
|
||||
long stamp = LOCK.readLock();
|
||||
final long stamp = LOCK.readLock();
|
||||
boolean isOffThread, shouldPopulate;
|
||||
try {
|
||||
isOffThread = SAFETY_MAP.getBoolean(block);
|
||||
@@ -32,9 +32,9 @@ public class AngelicaBlockSafetyRegistry {
|
||||
}
|
||||
|
||||
private static boolean populateCanRenderOffThread(Block block) {
|
||||
boolean canBeOffThread = !(block.getClass().getName().startsWith("gregtech."));
|
||||
final boolean canBeOffThread = !(block.getClass().getName().startsWith("gregtech."));
|
||||
|
||||
long stamp = LOCK.writeLock();
|
||||
final long stamp = LOCK.writeLock();
|
||||
|
||||
try {
|
||||
SAFETY_MAP.put(block, canBeOffThread);
|
||||
|
||||
@@ -91,15 +91,18 @@ public class ClassConstantPoolParser {
|
||||
case UTF8:
|
||||
final int strLen = readUnsignedShort(index + 1, basicClass);
|
||||
size = 3 + strLen;
|
||||
label:
|
||||
for (byte[] bytes : BYTES_TO_SEARCH) {
|
||||
if (strLen == bytes.length) {
|
||||
boolean found = true;
|
||||
for (int j = index + 3; j < index + 3 + strLen; j++) {
|
||||
if (basicClass[j] != bytes[j - (index + 3)]) {
|
||||
break label;
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (found) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.transform;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.coderbot.iris.IrisLogging;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
@@ -261,7 +261,7 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
}
|
||||
}
|
||||
else if ((node.getOpcode() == Opcodes.GETFIELD || node.getOpcode() == Opcodes.PUTFIELD) && node instanceof FieldInsnNode fNode) {
|
||||
if(!blockOwnerExclusions.contains(fNode.owner) && blockSubclasses.contains(fNode.owner)) {
|
||||
if(!blockOwnerExclusions.contains(fNode.owner) && blockSubclasses.contains(fNode.owner) && AngelicaConfig.enableSodium) {
|
||||
Pair<String, String> fieldToRedirect = null;
|
||||
for(Pair<String, String> blockPairs : BlockBoundsFields) {
|
||||
if(fNode.name.equals(blockPairs.getLeft()) || fNode.name.equals(blockPairs.getRight())) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.gl.attribute;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
|
||||
public interface BufferVertexFormat {
|
||||
static BufferVertexFormat from(VertexFormat format) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.gl.attribute;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ChunkMeshAttribute;
|
||||
|
||||
import java.util.EnumMap;
|
||||
@@ -18,6 +19,12 @@ public class GlVertexFormat<T extends Enum<T>> implements BufferVertexFormat {
|
||||
private final EnumMap<T, GlVertexAttribute> attributesKeyed;
|
||||
private final GlVertexAttribute[] attributesArray;
|
||||
|
||||
/**
|
||||
* -- GETTER --
|
||||
*
|
||||
* The stride (or the size of) the vertex format in bytes
|
||||
*/
|
||||
@Getter
|
||||
private final int stride;
|
||||
|
||||
public GlVertexFormat(Class<T> attributeEnum, EnumMap<T, GlVertexAttribute> attributesKeyed, int stride) {
|
||||
@@ -36,7 +43,7 @@ public class GlVertexFormat<T extends Enum<T>> implements BufferVertexFormat {
|
||||
* @throws NullPointerException If the attribute does not exist in this format
|
||||
*/
|
||||
public GlVertexAttribute getAttribute(T name) {
|
||||
GlVertexAttribute attr = this.attributesKeyed.get(name);
|
||||
final GlVertexAttribute attr = this.attributesKeyed.get(name);
|
||||
|
||||
if (attr == null) {
|
||||
throw new NullPointerException("No attribute exists for " + name.toString());
|
||||
@@ -45,13 +52,6 @@ public class GlVertexFormat<T extends Enum<T>> implements BufferVertexFormat {
|
||||
return attr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The stride (or the size of) the vertex format in bytes
|
||||
*/
|
||||
public int getStride() {
|
||||
return this.stride;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("GlVertexFormat<%s>{attributes=%d,stride=%d}", this.attributeEnum.getName(),
|
||||
|
||||
@@ -131,7 +131,7 @@ public class GLRenderDevice implements RenderDevice {
|
||||
|
||||
@Override
|
||||
public void deleteBuffer(GlBuffer buffer) {
|
||||
int handle = buffer.handle();
|
||||
final int handle = buffer.handle();
|
||||
buffer.invalidateHandle();
|
||||
|
||||
GL15.glDeleteBuffers(handle);
|
||||
@@ -139,7 +139,7 @@ public class GLRenderDevice implements RenderDevice {
|
||||
|
||||
@Override
|
||||
public void deleteVertexArray(GlVertexArray array) {
|
||||
int handle = array.handle();
|
||||
final int handle = array.handle();
|
||||
array.invalidateHandle();
|
||||
|
||||
GlFunctions.VERTEX_ARRAY.glDeleteVertexArrays(handle);
|
||||
@@ -176,7 +176,7 @@ public class GLRenderDevice implements RenderDevice {
|
||||
@Override
|
||||
public GlTessellation createTessellation(GlPrimitiveType primitiveType, TessellationBinding[] bindings) {
|
||||
if (GlVertexArrayTessellation.isSupported()) {
|
||||
GlVertexArrayTessellation tessellation = new GlVertexArrayTessellation(new GlVertexArray(GLRenderDevice.this), primitiveType, bindings);
|
||||
final GlVertexArrayTessellation tessellation = new GlVertexArrayTessellation(new GlVertexArray(GLRenderDevice.this), primitiveType, bindings);
|
||||
tessellation.init(this);
|
||||
|
||||
return tessellation;
|
||||
@@ -193,13 +193,13 @@ public class GLRenderDevice implements RenderDevice {
|
||||
|
||||
@Override
|
||||
public void multiDrawArrays(IntBuffer first, IntBuffer count) {
|
||||
GlPrimitiveType primitiveType = GLRenderDevice.this.activeTessellation.getPrimitiveType();
|
||||
final GlPrimitiveType primitiveType = GLRenderDevice.this.activeTessellation.getPrimitiveType();
|
||||
GL14.glMultiDrawArrays(primitiveType.getId(), first, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void multiDrawArraysIndirect(long pointer, int count, int stride) {
|
||||
GlPrimitiveType primitiveType = GLRenderDevice.this.activeTessellation.getPrimitiveType();
|
||||
final GlPrimitiveType primitiveType = GLRenderDevice.this.activeTessellation.getPrimitiveType();
|
||||
GlFunctions.INDIRECT_DRAW.glMultiDrawArraysIndirect(primitiveType.getId(), pointer, count, stride);
|
||||
}
|
||||
|
||||
|
||||
+3
-7
@@ -1,11 +1,14 @@
|
||||
package me.jellysquid.mods.sodium.client.gl.tessellation;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexAttributeBinding;
|
||||
import me.jellysquid.mods.sodium.client.gl.buffer.GlBuffer;
|
||||
|
||||
public class TessellationBinding {
|
||||
@Getter
|
||||
private final GlBuffer buffer;
|
||||
private final GlVertexAttributeBinding[] bindings;
|
||||
@Getter
|
||||
private final boolean instanced;
|
||||
|
||||
public TessellationBinding(GlBuffer buffer, GlVertexAttributeBinding[] bindings, boolean instanced) {
|
||||
@@ -14,15 +17,8 @@ public class TessellationBinding {
|
||||
this.instanced = instanced;
|
||||
}
|
||||
|
||||
public GlBuffer getBuffer() {
|
||||
return this.buffer;
|
||||
}
|
||||
|
||||
public GlVertexAttributeBinding[] getAttributeBindings() {
|
||||
return this.bindings;
|
||||
}
|
||||
|
||||
public boolean isInstanced() {
|
||||
return this.instanced;
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class SodiumGameOptions {
|
||||
|
||||
public static class PerformanceSettings {
|
||||
public int chunkBuilderThreads = 0;
|
||||
public boolean alwaysDeferChunkUpdates = false;
|
||||
public boolean alwaysDeferChunkUpdates = true;
|
||||
public boolean useNoErrorGLContext = true;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -22,10 +22,10 @@ public class VertexBufferBuilder implements VertexBufferView {
|
||||
|
||||
private void grow(int len) {
|
||||
// The new capacity will at least as large as the write it needs to service
|
||||
int cap = Math.max(this.capacity * 2, this.capacity + len);
|
||||
final int cap = Math.max(this.capacity * 2, this.capacity + len);
|
||||
|
||||
// Allocate a new buffer and copy the old buffer's contents into it
|
||||
ByteBuffer buffer = BufferUtils.createByteBuffer(cap);
|
||||
final ByteBuffer buffer = BufferUtils.createByteBuffer(cap);
|
||||
this.buffer.rewind();
|
||||
buffer.put(this.buffer);
|
||||
buffer.position(0);
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.glyph;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.math.Matrix4fExtended;
|
||||
import me.jellysquid.mods.sodium.client.util.math.MatrixUtil;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.glyph;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.writer.GlyphVertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.writer.GlyphVertexBufferWriterUnsafe;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.line;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.line;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.line.writer.LineVertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.line.writer.LineVertexBufferWriterUnsafe;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.particle;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.particle;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.particle.writer.ParticleVertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.particle.writer.ParticleVertexBufferWriterUnsafe;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.quad;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.math.Matrix4fExtended;
|
||||
import me.jellysquid.mods.sodium.client.util.math.MatrixUtil;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.quad;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.writer.QuadVertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.writer.QuadVertexBufferWriterUnsafe;
|
||||
|
||||
+2
-2
@@ -14,9 +14,9 @@ public class QuadVertexBufferWriterNio extends VertexBufferWriterNio implements
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
|
||||
int i = this.writeOffset;
|
||||
final int i = this.writeOffset;
|
||||
|
||||
ByteBuffer buf = this.byteBuffer;
|
||||
final ByteBuffer buf = this.byteBuffer;
|
||||
buf.putFloat(i, x);
|
||||
buf.putFloat(i + 4, y);
|
||||
buf.putFloat(i + 8, z);
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ public class QuadVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe imple
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
|
||||
long i = this.writePointer;
|
||||
final long i = this.writePointer;
|
||||
|
||||
CompatMemoryUtil.memPutFloat(i, x);
|
||||
CompatMemoryUtil.memPutFloat(i + 4, y);
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.math.Matrix4fExtended;
|
||||
import me.jellysquid.mods.sodium.client.util.math.MatrixUtil;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad.writer.BasicScreenQuadVertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad.writer.BasicScreenQuadVertexBufferWriterUnsafe;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.type;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.BufferVertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
|
||||
|
||||
+36
-37
@@ -3,6 +3,7 @@ package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayFIFOQueue;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import lombok.Setter;
|
||||
import me.jellysquid.mods.sodium.client.gl.arena.GlBufferArena;
|
||||
import me.jellysquid.mods.sodium.client.gl.arena.GlBufferSegment;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexAttribute;
|
||||
@@ -123,20 +124,20 @@ public class MultidrawChunkRenderBackend extends ChunkRenderShaderBackend<Multid
|
||||
commandList.bindBuffer(GlBufferTarget.ARRAY_BUFFER, this.uploadBuffer);
|
||||
|
||||
while (!this.pendingUploads.isEmpty()) {
|
||||
ChunkRegion<MultidrawGraphicsState> region = this.pendingUploads.dequeue();
|
||||
final ChunkRegion<MultidrawGraphicsState> region = this.pendingUploads.dequeue();
|
||||
|
||||
GlBufferArena arena = region.getBufferArena();
|
||||
GlBuffer buffer = arena.getBuffer();
|
||||
final GlBufferArena arena = region.getBufferArena();
|
||||
final GlBuffer buffer = arena.getBuffer();
|
||||
|
||||
ObjectArrayList<ChunkBuildResult<MultidrawGraphicsState>> uploadQueue = region.getUploadQueue();
|
||||
final ObjectArrayList<ChunkBuildResult<MultidrawGraphicsState>> uploadQueue = region.getUploadQueue();
|
||||
arena.prepareBuffer(commandList, getUploadQueuePayloadSize(uploadQueue));
|
||||
|
||||
for (ChunkBuildResult<MultidrawGraphicsState> result : uploadQueue) {
|
||||
ChunkRenderContainer<MultidrawGraphicsState> render = result.render;
|
||||
ChunkRenderData data = result.data;
|
||||
final ChunkRenderContainer<MultidrawGraphicsState> render = result.render;
|
||||
final ChunkRenderData data = result.data;
|
||||
|
||||
for (BlockRenderPass pass : result.passesToUpload) {
|
||||
MultidrawGraphicsState graphics = render.getGraphicsState(pass);
|
||||
final MultidrawGraphicsState graphics = render.getGraphicsState(pass);
|
||||
|
||||
// De-allocate the existing buffer arena for this render
|
||||
// This will allow it to be cheaply re-allocated just below
|
||||
@@ -144,16 +145,16 @@ public class MultidrawChunkRenderBackend extends ChunkRenderShaderBackend<Multid
|
||||
graphics.delete(commandList);
|
||||
}
|
||||
|
||||
ChunkMeshData meshData = data.getMesh(pass);
|
||||
final ChunkMeshData meshData = data.getMesh(pass);
|
||||
|
||||
if (meshData.hasVertexData()) {
|
||||
VertexData upload = meshData.takeVertexData();
|
||||
final VertexData upload = meshData.takeVertexData();
|
||||
|
||||
commandList.uploadData(this.uploadBuffer, upload.buffer);
|
||||
|
||||
GlBufferSegment segment = arena.uploadBuffer(commandList, this.uploadBuffer, 0, upload.buffer.capacity());
|
||||
final GlBufferSegment segment = arena.uploadBuffer(commandList, this.uploadBuffer, 0, upload.buffer.capacity());
|
||||
|
||||
MultidrawGraphicsState graphicsState = new MultidrawGraphicsState(render, region, segment, meshData, this.vertexFormat);
|
||||
final MultidrawGraphicsState graphicsState = new MultidrawGraphicsState(render, region, segment, meshData, this.vertexFormat);
|
||||
if(pass.isTranslucent()) {
|
||||
upload.buffer.limit(upload.buffer.capacity());
|
||||
upload.buffer.position(0);
|
||||
@@ -217,16 +218,14 @@ public class MultidrawChunkRenderBackend extends ChunkRenderShaderBackend<Multid
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* -- SETTER --
|
||||
* Sets whether to reverse the order in which regions are drawn
|
||||
*/
|
||||
@Setter
|
||||
private boolean reverseRegions = false;
|
||||
private ChunkCameraContext regionCamera;
|
||||
|
||||
/**
|
||||
* Sets whether to reverse the order in which regions are drawn (fixes
|
||||
*/
|
||||
public void setReverseRegions(boolean flag) {
|
||||
this.reverseRegions = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(CommandList commandList, ChunkRenderListIterator<MultidrawGraphicsState> renders, ChunkCameraContext camera) {
|
||||
this.bufferManager.cleanup();
|
||||
@@ -242,7 +241,7 @@ public class MultidrawChunkRenderBackend extends ChunkRenderShaderBackend<Multid
|
||||
long pointer = this.commandBuffer == null ? this.commandClientBufferBuilder.getBufferAddress() : 0L;
|
||||
|
||||
for (ChunkRegion<?> region : this.pendingBatches) {
|
||||
ChunkDrawCallBatcher batch = region.getDrawBatcher();
|
||||
final ChunkDrawCallBatcher batch = region.getDrawBatcher();
|
||||
|
||||
if (!batch.isEmpty()) {
|
||||
try (DrawCommandList drawCommandList = commandList.beginTessellating(region.getTessellation())) {
|
||||
@@ -262,11 +261,11 @@ public class MultidrawChunkRenderBackend extends ChunkRenderShaderBackend<Multid
|
||||
this.commandClientBufferBuilder.begin();
|
||||
|
||||
if(this.reverseRegions) {
|
||||
ChunkCameraContext camera = this.regionCamera;
|
||||
final ChunkCameraContext camera = this.regionCamera;
|
||||
for (ChunkRegion<?> region : this.pendingBatches) {
|
||||
float x = camera.getChunkModelOffset(region.getCenterBlockX(), camera.blockOriginX, camera.originX);
|
||||
float y = camera.getChunkModelOffset(region.getCenterBlockY(), camera.blockOriginY, camera.originY);
|
||||
float z = camera.getChunkModelOffset(region.getCenterBlockZ(), camera.blockOriginZ, camera.originZ);
|
||||
final float x = camera.getChunkModelOffset(region.getCenterBlockX(), camera.blockOriginX, camera.originX);
|
||||
final float y = camera.getChunkModelOffset(region.getCenterBlockY(), camera.blockOriginY, camera.originY);
|
||||
final float z = camera.getChunkModelOffset(region.getCenterBlockZ(), camera.blockOriginZ, camera.originZ);
|
||||
region.camDistance = x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
@@ -274,7 +273,7 @@ public class MultidrawChunkRenderBackend extends ChunkRenderShaderBackend<Multid
|
||||
}
|
||||
|
||||
for (ChunkRegion<?> region : this.pendingBatches) {
|
||||
ChunkDrawCallBatcher batcher = region.getDrawBatcher();
|
||||
final ChunkDrawCallBatcher batcher = region.getDrawBatcher();
|
||||
batcher.end();
|
||||
|
||||
this.commandClientBufferBuilder.pushCommandBuffer(batcher);
|
||||
@@ -285,13 +284,13 @@ public class MultidrawChunkRenderBackend extends ChunkRenderShaderBackend<Multid
|
||||
|
||||
private void setupUploadBatches(Iterator<ChunkBuildResult<MultidrawGraphicsState>> renders) {
|
||||
while (renders.hasNext()) {
|
||||
ChunkBuildResult<MultidrawGraphicsState> result = renders.next();
|
||||
final ChunkBuildResult<MultidrawGraphicsState> result = renders.next();
|
||||
|
||||
if(result == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ChunkRenderContainer<MultidrawGraphicsState> render = result.render;
|
||||
final ChunkRenderContainer<MultidrawGraphicsState> render = result.render;
|
||||
|
||||
ChunkRegion<MultidrawGraphicsState> region = this.bufferManager.getRegion(render.getChunkX(), render.getChunkY(), render.getChunkZ());
|
||||
|
||||
@@ -304,7 +303,7 @@ public class MultidrawChunkRenderBackend extends ChunkRenderShaderBackend<Multid
|
||||
region = this.bufferManager.getOrCreateRegion(render.getChunkX(), render.getChunkY(), render.getChunkZ());
|
||||
}
|
||||
|
||||
ObjectArrayList<ChunkBuildResult<MultidrawGraphicsState>> uploadQueue = region.getUploadQueue();
|
||||
final ObjectArrayList<ChunkBuildResult<MultidrawGraphicsState>> uploadQueue = region.getUploadQueue();
|
||||
|
||||
if (uploadQueue.isEmpty()) {
|
||||
this.pendingUploads.enqueue(region);
|
||||
@@ -321,18 +320,18 @@ public class MultidrawChunkRenderBackend extends ChunkRenderShaderBackend<Multid
|
||||
int drawCount = 0;
|
||||
|
||||
while (it.hasNext()) {
|
||||
MultidrawGraphicsState state = it.getGraphicsState();
|
||||
int visible = it.getVisibleFaces();
|
||||
final MultidrawGraphicsState state = it.getGraphicsState();
|
||||
final int visible = it.getVisibleFaces();
|
||||
|
||||
int index = drawCount++;
|
||||
float x = camera.getChunkModelOffset(state.getX(), camera.blockOriginX, camera.originX);
|
||||
float y = camera.getChunkModelOffset(state.getY(), camera.blockOriginY, camera.originY);
|
||||
float z = camera.getChunkModelOffset(state.getZ(), camera.blockOriginZ, camera.originZ);
|
||||
final int index = drawCount++;
|
||||
final float x = camera.getChunkModelOffset(state.getX(), camera.blockOriginX, camera.originX);
|
||||
final float y = camera.getChunkModelOffset(state.getY(), camera.blockOriginY, camera.originY);
|
||||
final float z = camera.getChunkModelOffset(state.getZ(), camera.blockOriginZ, camera.originZ);
|
||||
|
||||
this.uniformBufferBuilder.pushChunkDrawParams(x, y, z);
|
||||
|
||||
ChunkRegion<MultidrawGraphicsState> region = state.getRegion();
|
||||
ChunkDrawCallBatcher batch = region.getDrawBatcher();
|
||||
final ChunkRegion<MultidrawGraphicsState> region = state.getRegion();
|
||||
final ChunkDrawCallBatcher batch = region.getDrawBatcher();
|
||||
|
||||
if (!batch.isBuilding()) {
|
||||
batch.begin();
|
||||
@@ -440,7 +439,7 @@ public class MultidrawChunkRenderBackend extends ChunkRenderShaderBackend<Multid
|
||||
return false;
|
||||
}
|
||||
|
||||
Matcher matcher = INTEL_BUILD_MATCHER.matcher(version);
|
||||
final Matcher matcher = INTEL_BUILD_MATCHER.matcher(version);
|
||||
|
||||
// If the version pattern doesn't match, assume we're dealing with something special
|
||||
if (!matcher.matches()) {
|
||||
@@ -459,7 +458,7 @@ public class MultidrawChunkRenderBackend extends ChunkRenderShaderBackend<Multid
|
||||
|
||||
@Override
|
||||
public List<String> getDebugStrings() {
|
||||
List<String> list = new ArrayList<>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
list.add(String.format("Active Buffers: %s", this.bufferManager.getAllocatedRegionCount()));
|
||||
list.add(String.format("Submission Mode: %s", this.commandBuffer != null ? EnumChatFormatting.AQUA + "Buffer" : EnumChatFormatting.LIGHT_PURPLE + "Client Memory"));
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ public class ModelVertexUtil {
|
||||
* @return The resulting de-normalized unsigned short
|
||||
*/
|
||||
public static short denormalizeVertexTextureFloatAsShort(float value) {
|
||||
return (short) (Math.min(0.99999997F, value) * 32768.0f);
|
||||
return (short) (Math.round(value * 32768.0F) & 0xFFFF);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -27,9 +27,9 @@ public class HFPModelVertexBufferWriterNio extends VertexBufferWriterNio impleme
|
||||
}
|
||||
|
||||
private void writeQuadInternal(short x, short y, short z, int color, short u, short v, int light) {
|
||||
int i = this.writeOffset;
|
||||
final int i = this.writeOffset;
|
||||
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
final ByteBuffer buffer = this.byteBuffer;
|
||||
buffer.putShort(i, x);
|
||||
buffer.putShort(i + 2, y);
|
||||
buffer.putShort(i + 4, z);
|
||||
|
||||
+2
-9
@@ -8,27 +8,20 @@ import me.jellysquid.mods.sodium.client.model.vertex.type.BlittableVertexType;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.ChunkVertexType;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ChunkMeshAttribute;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
import net.coderbot.iris.sodium.vertex_format.IrisGlVertexAttributeFormat;
|
||||
|
||||
/**
|
||||
* Uses half-precision floating point numbers to represent position coordinates and normalized unsigned shorts for
|
||||
* texture coordinates. All texel positions in the block diffuse texture atlas can be exactly mapped (including
|
||||
* their centering offset), as the
|
||||
* their centering offset).
|
||||
*/
|
||||
public class HFPModelVertexType implements ChunkVertexType {
|
||||
// TODO Iris?
|
||||
public static final int STRIDE = 44; // 20
|
||||
public static final int STRIDE = 20;
|
||||
public static final GlVertexFormat<ChunkMeshAttribute> VERTEX_FORMAT =
|
||||
GlVertexFormat.builder(ChunkMeshAttribute.class, STRIDE)
|
||||
.addElement(ChunkMeshAttribute.POSITION, 0, GlVertexAttributeFormat.UNSIGNED_SHORT, 3, false)
|
||||
.addElement(ChunkMeshAttribute.COLOR, 8, GlVertexAttributeFormat.UNSIGNED_BYTE, 4, true)
|
||||
.addElement(ChunkMeshAttribute.TEXTURE, 12, GlVertexAttributeFormat.UNSIGNED_SHORT, 2, false)
|
||||
.addElement(ChunkMeshAttribute.LIGHT, 16, GlVertexAttributeFormat.UNSIGNED_SHORT, 2, true)
|
||||
.addElement(ChunkMeshAttribute.MID_TEX_COORD, 20, GlVertexAttributeFormat.FLOAT, 2, false)
|
||||
.addElement(ChunkMeshAttribute.TANGENT, 28, IrisGlVertexAttributeFormat.BYTE, 4, true)
|
||||
.addElement(ChunkMeshAttribute.NORMAL, 32, IrisGlVertexAttributeFormat.BYTE, 3, true)
|
||||
.addElement(ChunkMeshAttribute.BLOCK_ID, 36, IrisGlVertexAttributeFormat.SHORT, 2, false)
|
||||
.addElement(ChunkMeshAttribute.MID_BLOCK, 40, IrisGlVertexAttributeFormat.BYTE, 3, false)
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
+26
-30
@@ -3,7 +3,6 @@ package me.jellysquid.mods.sodium.client.render.chunk.tasks;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPos;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkOcclusionDataBuilder;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.glsm.TessellatorManager;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
@@ -20,12 +19,10 @@ import me.jellysquid.mods.sodium.client.util.MathUtil;
|
||||
import me.jellysquid.mods.sodium.client.util.task.CancellationSource;
|
||||
import me.jellysquid.mods.sodium.client.world.WorldSlice;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ChunkRenderContext;
|
||||
import me.jellysquid.mods.sodium.common.config.SodiumConfig;
|
||||
import net.coderbot.iris.vertices.ExtendedDataHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -88,16 +85,16 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
}
|
||||
|
||||
private boolean rendersOffThread(Block block) {
|
||||
int type = block.getRenderType();
|
||||
final int type = block.getRenderType();
|
||||
return type < 42 && type != 22 && AngelicaBlockSafetyRegistry.canBlockRenderOffThread(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkBuildResult<T> performBuild(ChunkRenderCacheLocal cache, ChunkBuildBuffers buffers, CancellationSource cancellationSource) {
|
||||
// COMPATIBLITY NOTE: Oculus relies on the LVT of this method being unchanged, at least in 16.5
|
||||
ChunkRenderData.Builder renderData = new ChunkRenderData.Builder();
|
||||
ChunkOcclusionDataBuilder occluder = new ChunkOcclusionDataBuilder();
|
||||
ChunkRenderBounds.Builder bounds = new ChunkRenderBounds.Builder();
|
||||
final ChunkRenderData.Builder renderData = new ChunkRenderData.Builder();
|
||||
final ChunkOcclusionDataBuilder occluder = new ChunkOcclusionDataBuilder();
|
||||
final ChunkRenderBounds.Builder bounds = new ChunkRenderBounds.Builder();
|
||||
|
||||
buffers.init(renderData);
|
||||
|
||||
@@ -106,13 +103,12 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
final WorldSlice slice = cache.getWorldSlice();
|
||||
final RenderBlocks renderBlocks = new RenderBlocks(slice);
|
||||
|
||||
int baseX = this.render.getOriginX();
|
||||
int baseY = this.render.getOriginY();
|
||||
int baseZ = this.render.getOriginZ();
|
||||
final int baseX = this.render.getOriginX();
|
||||
final int baseY = this.render.getOriginY();
|
||||
final int baseZ = this.render.getOriginZ();
|
||||
|
||||
BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||
BlockPos renderOffset = this.offset;
|
||||
final Tessellator tessellator = TessellatorManager.get();
|
||||
final BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||
final BlockPos renderOffset = this.offset;
|
||||
|
||||
boolean hasMainThreadBlocks = false;
|
||||
|
||||
@@ -123,7 +119,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
|
||||
for (int relZ = 0; relZ < 16; relZ++) {
|
||||
for (int relX = 0; relX < 16; relX++) {
|
||||
Block block = slice.getBlockRelative(relX + 16, relY + 16, relZ + 16);
|
||||
final Block block = slice.getBlockRelative(relX + 16, relY + 16, relZ + 16);
|
||||
|
||||
// If the block is vanilla air, assume it renders nothing. Don't use isAir because mods
|
||||
// can abuse it for all sorts of things
|
||||
@@ -131,7 +127,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
continue;
|
||||
}
|
||||
|
||||
int meta = slice.getBlockMetadataRelative(relX + 16, relY + 16, relZ + 16);
|
||||
final int meta = slice.getBlockMetadataRelative(relX + 16, relY + 16, relZ + 16);
|
||||
|
||||
pos.set(baseX + relX, baseY + relY, baseZ + relZ);
|
||||
buffers.setRenderOffset(pos.x - renderOffset.getX(), pos.y - renderOffset.getY(), pos.z - renderOffset.getZ());
|
||||
@@ -142,10 +138,10 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
// Do regular block rendering
|
||||
for (BlockRenderPass pass : BlockRenderPass.VALUES) {
|
||||
if (block.canRenderInPass(pass.ordinal()) && (!AngelicaConfig.enableSodiumFluidRendering || !(block instanceof IFluidBlock))) {
|
||||
long seed = MathUtil.hashPos(pos.x, pos.y, pos.z);
|
||||
final long seed = MathUtil.hashPos(pos.x, pos.y, pos.z);
|
||||
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(block, ExtendedDataHelper.BLOCK_RENDER_TYPE);
|
||||
|
||||
if (cache.getBlockRenderer().renderModel(cache.getWorldSlice(), tessellator, renderBlocks, block, meta, pos, buffers.get(pass), true, seed)) {
|
||||
if (cache.getBlockRenderer().renderModel(cache.getWorldSlice(), renderBlocks, block, meta, pos, buffers.get(pass), true, seed)) {
|
||||
bounds.addBlock(relX, relY, relZ);
|
||||
}
|
||||
}
|
||||
@@ -170,7 +166,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
if(AngelicaConfig.enableIris) buffers.iris$resetBlockContext();
|
||||
|
||||
if (block.hasTileEntity(meta)) {
|
||||
TileEntity entity = slice.getTileEntity(pos.x, pos.y, pos.z);
|
||||
final TileEntity entity = slice.getTileEntity(pos.x, pos.y, pos.z);
|
||||
|
||||
final TileEntitySpecialRenderer renderer = TileEntityRendererDispatcher.instance.getSpecialRenderer(entity);
|
||||
if (entity != null && renderer != null) {
|
||||
@@ -202,7 +198,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
|
||||
render.setRebuildForTranslucents(false);
|
||||
for (BlockRenderPass pass : BlockRenderPass.VALUES) {
|
||||
ChunkMeshData mesh = buffers.createMesh(pass, (float)camera.x - offset.getX(), (float)camera.y - offset.getY(), (float)camera.z - offset.getZ(), this.translucencySorting);
|
||||
final ChunkMeshData mesh = buffers.createMesh(pass, (float)camera.x - offset.getX(), (float)camera.y - offset.getY(), (float)camera.z - offset.getZ(), this.translucencySorting);
|
||||
|
||||
if (mesh != null) {
|
||||
renderData.setMesh(pass, mesh);
|
||||
@@ -223,20 +219,20 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
* TODO: Deduplicate this with the main method above.
|
||||
*/
|
||||
private void performMainBuild(ChunkRenderCacheLocal cache, ChunkBuildBuffers buffers, CancellationSource cancellationSource, ChunkRenderBounds.Builder bounds) {
|
||||
WorldSlice slice = cache.getWorldSlice();
|
||||
BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||
int baseX = this.render.getOriginX();
|
||||
int baseY = this.render.getOriginY();
|
||||
int baseZ = this.render.getOriginZ();
|
||||
BlockPos renderOffset = this.offset;
|
||||
RenderBlocks rb = new RenderBlocks(slice.getWorld());
|
||||
final WorldSlice slice = cache.getWorldSlice();
|
||||
final BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||
final int baseX = this.render.getOriginX();
|
||||
final int baseY = this.render.getOriginY();
|
||||
final int baseZ = this.render.getOriginZ();
|
||||
final BlockPos renderOffset = this.offset;
|
||||
final RenderBlocks rb = new RenderBlocks(slice.getWorld());
|
||||
for (int relY = 0; relY < 16; relY++) {
|
||||
if (cancellationSource.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
for (int relZ = 0; relZ < 16; relZ++) {
|
||||
for (int relX = 0; relX < 16; relX++) {
|
||||
Block block = slice.getBlockRelative(relX + 16, relY + 16, relZ + 16);
|
||||
final Block block = slice.getBlockRelative(relX + 16, relY + 16, relZ + 16);
|
||||
|
||||
// Only render blocks that need main thread assistance
|
||||
if (block.getMaterial() == Material.air || rendersOffThread(block)) {
|
||||
@@ -246,7 +242,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
// TODO: Collect data on which render types are hitting this code path most often
|
||||
// so mods can be updated slowly
|
||||
|
||||
int meta = slice.getBlockMetadataRelative(relX + 16, relY + 16, relZ + 16);
|
||||
final int meta = slice.getBlockMetadataRelative(relX + 16, relY + 16, relZ + 16);
|
||||
|
||||
pos.set(baseX + relX, baseY + relY, baseZ + relZ);
|
||||
buffers.setRenderOffset(pos.x - renderOffset.getX(), pos.y - renderOffset.getY(), pos.z - renderOffset.getZ());
|
||||
@@ -255,10 +251,10 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
// Do regular block rendering
|
||||
for (BlockRenderPass pass : BlockRenderPass.VALUES) {
|
||||
if (block.canRenderInPass(pass.ordinal()) && (!AngelicaConfig.enableSodiumFluidRendering || !(block instanceof IFluidBlock))) {
|
||||
long seed = MathUtil.hashPos(pos.x, pos.y, pos.z);
|
||||
final long seed = MathUtil.hashPos(pos.x, pos.y, pos.z);
|
||||
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(block, ExtendedDataHelper.BLOCK_RENDER_TYPE);
|
||||
|
||||
if (cache.getBlockRenderer().renderModel(slice.getWorld(), Tessellator.instance, rb, block, meta, pos, buffers.get(pass), true, seed)) {
|
||||
if (cache.getBlockRenderer().renderModel(slice.getWorld(), rb, block, meta, pos, buffers.get(pass), true, seed)) {
|
||||
bounds.addBlock(relX, relY, relZ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package me.jellysquid.mods.sodium.client.render.pipeline;
|
||||
|
||||
import com.gtnewhorizons.angelica.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPos;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
import com.gtnewhorizons.angelica.compat.nd.RecyclingList;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITessellatorInstance;
|
||||
import com.gtnewhorizons.angelica.glsm.TessellatorManager;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightMode;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipelineProvider;
|
||||
@@ -21,12 +21,9 @@ import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.joml.Vector3d;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -52,7 +49,7 @@ public class BlockRenderer {
|
||||
this.useAmbientOcclusion = Minecraft.getMinecraft().gameSettings.ambientOcclusion > 0;
|
||||
}
|
||||
|
||||
public boolean renderModel(IBlockAccess world, Tessellator tessellator, RenderBlocks renderBlocks, Block block, int meta, BlockPos pos, ChunkModelBuffers buffers, boolean cull, long seed) {
|
||||
public boolean renderModel(IBlockAccess world, RenderBlocks renderBlocks, Block block, int meta, BlockPos pos, ChunkModelBuffers buffers, boolean cull, long seed) {
|
||||
final LightMode mode = this.getLightingMode(block);
|
||||
final LightPipeline lighter = this.lighters.getLighter(mode);
|
||||
|
||||
@@ -61,85 +58,29 @@ public class BlockRenderer {
|
||||
boolean rendered = false;
|
||||
|
||||
try {
|
||||
tessellator.startDrawingQuads();
|
||||
TessellatorManager.startCapturing();
|
||||
final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
tess.startDrawingQuads();
|
||||
// RenderBlocks adds the subchunk-relative coordinates as the offset, cancel it out here
|
||||
tess.setOffset(pos);
|
||||
|
||||
renderBlocks.renderBlockByRenderType(block, pos.x, pos.y, pos.z);
|
||||
|
||||
|
||||
final List<Quad> all = tessellatorToQuadList(tessellator, pos);
|
||||
final List<Quad> quads = TessellatorManager.stopCapturing();
|
||||
|
||||
for (ModelQuadFacing facing : ModelQuadFacing.VALUES) {
|
||||
this.random.setSeed(seed);
|
||||
this.renderQuadList(pos, lighter, buffers, all, facing);
|
||||
this.renderQuadList(pos, lighter, buffers, quads, facing);
|
||||
}
|
||||
|
||||
if (!all.isEmpty()) rendered = true;
|
||||
if (!quads.isEmpty()) rendered = true;
|
||||
} finally {
|
||||
((ITessellatorInstance) tessellator).discard();
|
||||
TessellatorManager.cleanup();
|
||||
}
|
||||
|
||||
|
||||
return rendered;
|
||||
}
|
||||
|
||||
private int tesselatorDataCount;
|
||||
private List<Quad> tessellatorToQuadList(Tessellator t, BlockPos pos) {
|
||||
// Adapted from Neodymium
|
||||
tesselatorDataCount++;
|
||||
|
||||
// List<String> errors = new ArrayList<>();
|
||||
// List<String> warnings = new ArrayList<>();
|
||||
// if(t.drawMode != GL11.GL_QUADS && t.drawMode != GL11.GL_TRIANGLES) {
|
||||
// errors.add("Unsupported draw mode: " + t.drawMode);
|
||||
// }
|
||||
// if(!t.hasTexture) {
|
||||
// errors.add("Texture data is missing.");
|
||||
// }
|
||||
// if(!t.hasBrightness) {
|
||||
// warnings.add("Brightness data is missing");
|
||||
// }
|
||||
// if(!t.hasColor) {
|
||||
// warnings.add("Color data is missing");
|
||||
// }
|
||||
// if(t.hasNormals && GL11.glIsEnabled(GL11.GL_LIGHTING)) {
|
||||
// errors.add("Chunk uses GL lighting, this is not implemented.");
|
||||
// }
|
||||
FLAGS.hasBrightness = t.hasBrightness;
|
||||
FLAGS.hasColor = t.hasColor;
|
||||
|
||||
int verticesPerPrimitive = t.drawMode == GL11.GL_QUADS ? 4 : 3;
|
||||
|
||||
for(int quadI = 0; quadI < t.vertexCount / verticesPerPrimitive; quadI++) {
|
||||
final Quad quad = quadBuf.next();
|
||||
// RenderBlocks adds the subchunk-relative coordinates as the offset, cancel it out here
|
||||
quad.setState(t.rawBuffer, quadI * (verticesPerPrimitive * 8), FLAGS, t.drawMode, -pos.x, -pos.y, -pos.z);
|
||||
|
||||
if(quad.deleted) {
|
||||
quadBuf.remove();
|
||||
}
|
||||
}
|
||||
// final boolean silenceErrors = false;
|
||||
//
|
||||
// if(!quadBuf.isEmpty() && (!errors.isEmpty() || !warnings.isEmpty()) && /*!Config.silenceErrors*/!silenceErrors) {
|
||||
// for(String error : errors) {
|
||||
// LOGGER.error("Error: " + error);
|
||||
// }
|
||||
// for(String warning : warnings) {
|
||||
// LOGGER.error("Warning: " + warning);
|
||||
// }
|
||||
// LOGGER.error("(Tessellator pos: ({}, {}, {}), Tessellation count: {}", t.xOffset, t.yOffset, t.zOffset, tesselatorDataCount);
|
||||
// LOGGER.error("Stack trace:");
|
||||
// try {
|
||||
// // Generate a stack trace
|
||||
// throw new IllegalArgumentException();
|
||||
// } catch(IllegalArgumentException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
final List<Quad> quads = quadBuf.getAsList();
|
||||
quadBuf.reset();
|
||||
return quads;
|
||||
}
|
||||
|
||||
private void renderQuadList(BlockPos pos, LightPipeline lighter, ChunkModelBuffers buffers, List<Quad> quads, ModelQuadFacing facing) {
|
||||
|
||||
final ModelVertexSink sink = buffers.getSink(facing);
|
||||
@@ -191,7 +132,7 @@ public class BlockRenderer {
|
||||
final float u = quad.getTexU(srcIndex);
|
||||
final float v = quad.getTexV(srcIndex);
|
||||
|
||||
int quadLight = quad.getLight(srcIndex);
|
||||
final int quadLight = quad.getLight(srcIndex);
|
||||
final int lm = useSeparateAo ? ModelQuadUtil.mergeBakedLight(quadLight, light.lm[srcIndex]) : quadLight;
|
||||
|
||||
sink.writeQuad(x, y, z, color, u, v, lm);
|
||||
@@ -214,7 +155,7 @@ public class BlockRenderer {
|
||||
boolean hasTexture;
|
||||
public boolean hasBrightness;
|
||||
public boolean hasColor;
|
||||
boolean hasNormals;
|
||||
public boolean hasNormals;
|
||||
|
||||
public Flags(byte flags) {
|
||||
hasTexture = (flags & 1) != 0;
|
||||
|
||||
@@ -15,6 +15,7 @@ import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelB
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.Norm3b;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorARGB;
|
||||
import me.jellysquid.mods.sodium.client.world.WorldSlice;
|
||||
import me.jellysquid.mods.sodium.common.util.DirectionUtil;
|
||||
import me.jellysquid.mods.sodium.common.util.WorldUtil;
|
||||
@@ -29,6 +30,8 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.joml.Math.lerp;
|
||||
|
||||
public class FluidRenderer {
|
||||
@@ -193,7 +196,7 @@ public class FluidRenderer {
|
||||
this.setVertex(quad, 2, 1.0F, h3, 1.0F, u3, v3);
|
||||
this.setVertex(quad, 3, 1.0F, h4, 0.0f, u4, v4);
|
||||
|
||||
this.calculateQuadColors(quad, pos, lighter, ForgeDirection.UP, 1.0F, hc);
|
||||
this.calculateQuadColors(quad, pos, lighter, ForgeDirection.UP, 1.0F, hc, slice);
|
||||
this.flushQuad(buffers, quad, facing, false);
|
||||
|
||||
if (WorldUtil.method_15756(slice, this.scratchPos.set(posX, posY + 1, posZ), fluid)) {
|
||||
@@ -222,7 +225,7 @@ public class FluidRenderer {
|
||||
this.setVertex(quad, 2, 1.0F, yOffset, 0.0f, maxU, minV);
|
||||
this.setVertex(quad, 3, 1.0F, yOffset, 1.0F, maxU, maxV);
|
||||
|
||||
this.calculateQuadColors(quad, pos, lighter, ForgeDirection.DOWN, 1.0F, hc);
|
||||
this.calculateQuadColors(quad, pos, lighter, ForgeDirection.DOWN, 1.0F, hc, slice);
|
||||
this.flushQuad(buffers, quad, ModelQuadFacing.DOWN, false);
|
||||
|
||||
rendered = true;
|
||||
@@ -326,7 +329,7 @@ public class FluidRenderer {
|
||||
|
||||
ModelQuadFacing facing = ModelQuadFacing.fromDirection(dir);
|
||||
|
||||
this.calculateQuadColors(quad, pos, lighter, dir, br, hc);
|
||||
this.calculateQuadColors(quad, pos, lighter, dir, br, hc, slice);
|
||||
this.flushQuad(buffers, quad, facing, false);
|
||||
|
||||
if (sprite != oSprite) {
|
||||
@@ -345,14 +348,16 @@ public class FluidRenderer {
|
||||
return rendered;
|
||||
}
|
||||
|
||||
private void calculateQuadColors(ModelQuadView quad, BlockPos pos, LightPipeline lighter, ForgeDirection dir, float brightness, boolean colorized) {
|
||||
private void calculateQuadColors(ModelQuadView quad, BlockPos pos, LightPipeline lighter, ForgeDirection dir, float brightness, boolean colorized, WorldSlice slice) {
|
||||
QuadLightData light = this.quadLightData;
|
||||
lighter.calculate(quad, pos, light, null, dir, false);
|
||||
|
||||
int[] biomeColors = null;
|
||||
|
||||
if (colorized) {
|
||||
// TODO: Sodium - Colorizer
|
||||
biomeColors = new int[4];
|
||||
int color = slice.getBlock(pos.x,pos.y,pos.z).colorMultiplier(slice,pos.x,pos.y,pos.z);
|
||||
Arrays.fill(biomeColors,ColorARGB.toABGR(color));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
+10
-2
@@ -1,6 +1,8 @@
|
||||
package me.jellysquid.mods.sodium.client.world.cloned;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import com.gtnewhorizons.angelica.compat.ExtendedBlockStorageExt;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPos;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
|
||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectMap;
|
||||
@@ -56,9 +58,15 @@ public class ClonedChunkSection {
|
||||
}
|
||||
|
||||
this.pos = pos;
|
||||
this.data = new ExtendedBlockStorageExt(section);
|
||||
this.data = new ExtendedBlockStorageExt(chunk, section);
|
||||
|
||||
this.biomeData = new BiomeGenBase[chunk.getBiomeArray().length];
|
||||
int bArrLength;
|
||||
if (ModStatus.isEIDBiomeLoaded) {
|
||||
bArrLength = ((ChunkBiomeHook)chunk).getBiomeShortArray().length;
|
||||
} else {
|
||||
bArrLength = chunk.getBiomeArray().length;
|
||||
}
|
||||
this.biomeData = new BiomeGenBase[bArrLength];
|
||||
|
||||
StructureBoundingBox box = new StructureBoundingBox(pos.getMinX(), pos.getMinY(), pos.getMinZ(), pos.getMaxX(), pos.getMaxY(), pos.getMaxZ());
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package net.coderbot.iris.pipeline;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexBuffer;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITessellatorInstance;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
/**
|
||||
@@ -59,33 +57,13 @@ public class HorizonRenderer {
|
||||
// Build the horizon quads into a buffer
|
||||
tessellator.startDrawingQuads(); //(GL11.GL_QUADS, DefaultVertexFormat.POSITION);
|
||||
buildHorizon(currentRenderDistance * 16, tessellator);
|
||||
final ByteBuffer buf = tessellatorToBuffer(tessellator);
|
||||
((ITessellatorInstance) tessellator).discard();
|
||||
|
||||
this.vertexBuffer = new VertexBuffer();
|
||||
this.vertexBuffer.bind();
|
||||
this.vertexBuffer.upload(buf, tessellator.vertexCount);
|
||||
this.vertexBuffer.upload(tessellator, DefaultVertexFormat.POSITION);
|
||||
this.vertexBuffer.unbind();
|
||||
}
|
||||
|
||||
/* Convert the tessellator's data into a buffer that can be uploaded to the GPU. */
|
||||
private ByteBuffer tessellatorToBuffer(Tessellator tessellator) {
|
||||
final int[] rawBuffer = tessellator.rawBuffer;
|
||||
final int byteSize = (tessellator.vertexCount * 3) << 2;
|
||||
ByteBuffer byteBuffer = BufferUtils.createByteBuffer(byteSize);
|
||||
|
||||
for(int quadI = 0 ; quadI < tessellator.vertexCount / 4 ; quadI++) {
|
||||
for(int vertexI = 0 ; vertexI < 4 ; vertexI++) {
|
||||
int i = (quadI * 4 * 8 ) + (vertexI * 8);
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 0]));
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 1]));
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 2]));
|
||||
}
|
||||
}
|
||||
|
||||
return (ByteBuffer) byteBuffer.rewind();
|
||||
}
|
||||
|
||||
private void buildQuad(Tessellator consumer, double x1, double z1, double x2, double z2) {
|
||||
consumer.addVertex(x1, BOTTOM, z1);
|
||||
consumer.addVertex(x1, TOP, z1);
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.coderbot.iris.postprocess;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import net.coderbot.iris.gl.IrisRenderSystem;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
@@ -10,16 +10,17 @@ import net.coderbot.iris.rendertarget.RenderTarget;
|
||||
import net.coderbot.iris.rendertarget.RenderTargets;
|
||||
import net.coderbot.iris.shaderpack.PackRenderTargetDirectives;
|
||||
import net.coderbot.iris.shadows.ShadowRenderTargets;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class IrisSamplers {
|
||||
public static final int ALBEDO_TEXTURE_UNIT = 0;
|
||||
public static final int ALBEDO_TEXTURE_UNIT = OpenGlHelper.defaultTexUnit;
|
||||
// TODO: Find equivalent in 1.7.10
|
||||
public static final int OVERLAY_TEXTURE_UNIT = 1;
|
||||
public static final int LIGHTMAP_TEXTURE_UNIT = 1;
|
||||
public static final int LIGHTMAP_TEXTURE_UNIT = OpenGlHelper.lightmapTexUnit;
|
||||
|
||||
public static final ImmutableSet<Integer> WORLD_RESERVED_TEXTURE_UNITS = ImmutableSet.of(0, 1, 2);
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.writer.GlyphVertexWriterFallback;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.writer.QuadVertexWriterFallback;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.coderbot.iris.vertices;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
|
||||
public interface ExtendingBufferBuilder {
|
||||
void iris$beginWithoutExtending(int drawMode, VertexFormat vertexFormat);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package net.coderbot.iris.vertices;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormatElement;
|
||||
|
||||
public class IrisVertexFormats {
|
||||
@@ -25,7 +25,7 @@ public class IrisVertexFormats {
|
||||
|
||||
terrainElements.add(DefaultVertexFormat.POSITION_ELEMENT); // 12
|
||||
terrainElements.add(DefaultVertexFormat.COLOR_ELEMENT); // 16
|
||||
terrainElements.add(DefaultVertexFormat.TEXTURE_0_ELEMENT); // 24
|
||||
terrainElements.add(DefaultVertexFormat.TEXTURE_ELEMENT); // 24
|
||||
terrainElements.add(DefaultVertexFormat.LIGHT_ELEMENT); // 28
|
||||
terrainElements.add(DefaultVertexFormat.NORMAL_ELEMENT); // 31
|
||||
terrainElements.add(DefaultVertexFormat.PADDING_ELEMENT); // 32
|
||||
@@ -37,7 +37,7 @@ public class IrisVertexFormats {
|
||||
|
||||
entityElements.add(DefaultVertexFormat.POSITION_ELEMENT); // 12
|
||||
entityElements.add(DefaultVertexFormat.COLOR_ELEMENT); // 16
|
||||
entityElements.add(DefaultVertexFormat.TEXTURE_0_ELEMENT); // 24
|
||||
entityElements.add(DefaultVertexFormat.TEXTURE_ELEMENT); // 24
|
||||
entityElements.add(DefaultVertexFormat.OVERLAY_ELEMENT); // 28
|
||||
entityElements.add(DefaultVertexFormat.LIGHT_ELEMENT); // 32
|
||||
entityElements.add(DefaultVertexFormat.NORMAL_ELEMENT); // 35
|
||||
|
||||
Reference in new issue
Block a user