[vintage] Increase blend radius to 14 and fix compile of 1.12.2 #24
No files matched your search
@@ -0,0 +1,39 @@
|
|||||||
|
package org.taumc.celeritas.impl.debug;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.Pair;
|
||||||
|
import org.embeddedt.embeddium.impl.common.util.MathUtil;
|
||||||
|
import org.embeddedt.embeddium.impl.common.util.NativeBuffer;
|
||||||
|
import org.taumc.celeritas.impl.Celeritas;
|
||||||
|
import org.taumc.celeritas.impl.render.terrain.CeleritasWorldRenderer;
|
||||||
|
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CeleritasDebugStrings {
|
||||||
|
public static List<Pair<String, Integer>> getStringsToRender() {
|
||||||
|
List<Pair<String, Integer>> stringsToRender = new ArrayList<>();
|
||||||
|
|
||||||
|
stringsToRender.add(Pair.of(getNativeMemoryString(), -1));
|
||||||
|
stringsToRender.add(Pair.of("", -1));
|
||||||
|
|
||||||
|
stringsToRender.add(Pair.of("%s Renderer (%s)".formatted("Celeritas", Celeritas.VERSION), 0xFF55FF55));
|
||||||
|
stringsToRender.add(Pair.of("", -1));
|
||||||
|
|
||||||
|
var renderer = CeleritasWorldRenderer.instanceNullable();
|
||||||
|
|
||||||
|
if (renderer != null) {
|
||||||
|
renderer.getDebugStrings().forEach(str -> stringsToRender.add(Pair.of(str, -1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringsToRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getNativeMemoryString() {
|
||||||
|
return "Off-Heap: +" + MathUtil.toMib(getNativeMemoryUsage()) + "MB";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long getNativeMemoryUsage() {
|
||||||
|
return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getUsed() + NativeBuffer.getTotalAllocated();
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
-3
@@ -19,7 +19,7 @@ import java.util.*;
|
|||||||
/**
|
/**
|
||||||
* Provides an extension to vanilla's world renderer.
|
* Provides an extension to vanilla's world renderer.
|
||||||
*/
|
*/
|
||||||
public class CeleritasWorldRenderer extends SimpleWorldRenderer<World, PrimitiveRenderSectionManager, Integer, BlockEntity, Float> {
|
public class CeleritasWorldRenderer extends SimpleWorldRenderer<World, PrimitiveRenderSectionManager, Object, BlockEntity, Float> {
|
||||||
@Getter
|
@Getter
|
||||||
private SpriteTransparencyTracker transparencyTracker;
|
private SpriteTransparencyTracker transparencyTracker;
|
||||||
|
|
||||||
@@ -57,7 +57,12 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<World, Primitive
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CameraState captureCameraState(float ticks) {
|
protected CameraState captureCameraState(float ticks) {
|
||||||
Entity viewEntity = Objects.requireNonNull(MinecraftAccessor.celeritas$getInstance().camera, "Client must have view entity");
|
//? if <1.8 {
|
||||||
|
Entity viewEntity = MinecraftAccessor.celeritas$getInstance().camera;
|
||||||
|
//?} else
|
||||||
|
/*Entity viewEntity = MinecraftAccessor.celeritas$getInstance().getCamera();*/
|
||||||
|
|
||||||
|
Objects.requireNonNull(viewEntity, "Client must have view entity");
|
||||||
|
|
||||||
double x = viewEntity.prevTickX + (viewEntity.x - viewEntity.prevTickX) * ticks;
|
double x = viewEntity.prevTickX + (viewEntity.x - viewEntity.prevTickX) * ticks;
|
||||||
double y = viewEntity.prevTickY + (viewEntity.y - viewEntity.prevTickY) * ticks + (double) viewEntity.getEyeHeight();
|
double y = viewEntity.prevTickY + (viewEntity.y - viewEntity.prevTickY) * ticks + (double) viewEntity.getEyeHeight();
|
||||||
@@ -98,7 +103,7 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<World, Primitive
|
|||||||
float partialTicks = partialTicksBoxed;
|
float partialTicks = partialTicksBoxed;
|
||||||
for (var blockEntity : list) {
|
for (var blockEntity : list) {
|
||||||
try {
|
try {
|
||||||
BlockEntityRenderDispatcher.INSTANCE.render(blockEntity, partialTicks);
|
BlockEntityRenderDispatcher.INSTANCE.render(blockEntity, partialTicks /*? if >=1.8 {*//*, -1 *//*?}*/);
|
||||||
} catch(RuntimeException e) {
|
} catch(RuntimeException e) {
|
||||||
if(blockEntity.isRemoved()) {
|
if(blockEntity.isRemoved()) {
|
||||||
System.err.println("Suppressing crash from invalid tile entity");
|
System.err.println("Suppressing crash from invalid tile entity");
|
||||||
|
|||||||
+17
-2
@@ -3,6 +3,8 @@ package org.taumc.celeritas.impl.render.terrain;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
|
||||||
|
//? if >=1.8
|
||||||
|
/*import net.minecraft.client.render.block.BlockLayer;*/
|
||||||
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
||||||
import org.embeddedt.embeddium.impl.render.chunk.compile.sorting.QuadPrimitiveType;
|
import org.embeddedt.embeddium.impl.render.chunk.compile.sorting.QuadPrimitiveType;
|
||||||
import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass;
|
import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass;
|
||||||
@@ -18,7 +20,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class PrimitiveRenderPassConfigurationBuilder {
|
public class PrimitiveRenderPassConfigurationBuilder {
|
||||||
public static final TerrainRenderPass SOLID_PASS, CUTOUT_MIPPED_PASS, TRANSLUCENT_PASS;
|
public static final TerrainRenderPass SOLID_PASS, CUTOUT_MIPPED_PASS, TRANSLUCENT_PASS;
|
||||||
public static final Material SOLID_MATERIAL, CUTOUT_MIPPED_MATERIAL, TRANSLUCENT_MATERIAL;
|
public static final Material SOLID_MATERIAL, CUTOUT_MATERIAL, CUTOUT_MIPPED_MATERIAL, TRANSLUCENT_MATERIAL;
|
||||||
|
|
||||||
private record PrimitivePipelineState(int pass, boolean disableBlend) implements TerrainRenderPass.PipelineState {
|
private record PrimitivePipelineState(int pass, boolean disableBlend) implements TerrainRenderPass.PipelineState {
|
||||||
@Override
|
@Override
|
||||||
@@ -77,9 +79,11 @@ public class PrimitiveRenderPassConfigurationBuilder {
|
|||||||
TRANSLUCENT_MATERIAL = new Material(TRANSLUCENT_PASS, AlphaCutoffParameter.ZERO, true);
|
TRANSLUCENT_MATERIAL = new Material(TRANSLUCENT_PASS, AlphaCutoffParameter.ZERO, true);
|
||||||
SOLID_MATERIAL = new Material(SOLID_PASS, AlphaCutoffParameter.ZERO, true);
|
SOLID_MATERIAL = new Material(SOLID_PASS, AlphaCutoffParameter.ZERO, true);
|
||||||
CUTOUT_MIPPED_MATERIAL = new Material(CUTOUT_MIPPED_PASS, AlphaCutoffParameter.ONE_TENTH, true);
|
CUTOUT_MIPPED_MATERIAL = new Material(CUTOUT_MIPPED_PASS, AlphaCutoffParameter.ONE_TENTH, true);
|
||||||
|
CUTOUT_MATERIAL = new Material(CUTOUT_MIPPED_PASS, AlphaCutoffParameter.ONE_TENTH, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RenderPassConfiguration<Integer> build(ChunkVertexType vertexType) {
|
public static RenderPassConfiguration<?> build(ChunkVertexType vertexType) {
|
||||||
|
//? if <1.8 {
|
||||||
Int2ObjectMap<Collection<TerrainRenderPass>> vanillaRenderStages = new Int2ObjectOpenHashMap<>();
|
Int2ObjectMap<Collection<TerrainRenderPass>> vanillaRenderStages = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
vanillaRenderStages.put(1, List.of(TRANSLUCENT_PASS));
|
vanillaRenderStages.put(1, List.of(TRANSLUCENT_PASS));
|
||||||
@@ -91,6 +95,17 @@ public class PrimitiveRenderPassConfigurationBuilder {
|
|||||||
|
|
||||||
renderTypeToMaterialMap.put(0, CUTOUT_MIPPED_MATERIAL);
|
renderTypeToMaterialMap.put(0, CUTOUT_MIPPED_MATERIAL);
|
||||||
renderTypeToMaterialMap.put(1, TRANSLUCENT_MATERIAL);
|
renderTypeToMaterialMap.put(1, TRANSLUCENT_MATERIAL);
|
||||||
|
//?} else {
|
||||||
|
/*Map<BlockLayer, Collection<TerrainRenderPass>> vanillaRenderStages = new Reference2ReferenceOpenHashMap<>();
|
||||||
|
vanillaRenderStages.put(BlockLayer.SOLID, List.of(SOLID_PASS, CUTOUT_MIPPED_PASS));
|
||||||
|
vanillaRenderStages.put(BlockLayer.TRANSLUCENT, List.of(TRANSLUCENT_PASS));
|
||||||
|
|
||||||
|
Map<BlockLayer, Material> renderTypeToMaterialMap = new Reference2ReferenceOpenHashMap<>();
|
||||||
|
renderTypeToMaterialMap.put(BlockLayer.SOLID, SOLID_MATERIAL);
|
||||||
|
renderTypeToMaterialMap.put(BlockLayer.CUTOUT, CUTOUT_MATERIAL);
|
||||||
|
renderTypeToMaterialMap.put(BlockLayer.CUTOUT_MIPPED, CUTOUT_MIPPED_MATERIAL);
|
||||||
|
renderTypeToMaterialMap.put(BlockLayer.TRANSLUCENT, TRANSLUCENT_MATERIAL);
|
||||||
|
*///?}
|
||||||
|
|
||||||
return new RenderPassConfiguration<>(renderTypeToMaterialMap,
|
return new RenderPassConfiguration<>(renderTypeToMaterialMap,
|
||||||
vanillaRenderStages,
|
vanillaRenderStages,
|
||||||
|
|||||||
+9
-1
@@ -6,6 +6,7 @@ import org.embeddedt.embeddium.impl.gl.device.CommandList;
|
|||||||
import org.embeddedt.embeddium.impl.gl.device.RenderDevice;
|
import org.embeddedt.embeddium.impl.gl.device.RenderDevice;
|
||||||
import org.embeddedt.embeddium.impl.render.chunk.*;
|
import org.embeddedt.embeddium.impl.render.chunk.*;
|
||||||
import org.embeddedt.embeddium.impl.render.chunk.compile.ChunkBuildOutput;
|
import org.embeddedt.embeddium.impl.render.chunk.compile.ChunkBuildOutput;
|
||||||
|
import org.embeddedt.embeddium.impl.render.chunk.compile.executor.ChunkBuilder;
|
||||||
import org.embeddedt.embeddium.impl.render.chunk.compile.tasks.ChunkBuilderTask;
|
import org.embeddedt.embeddium.impl.render.chunk.compile.tasks.ChunkBuilderTask;
|
||||||
import org.embeddedt.embeddium.impl.render.chunk.occlusion.AsyncOcclusionMode;
|
import org.embeddedt.embeddium.impl.render.chunk.occlusion.AsyncOcclusionMode;
|
||||||
import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkShaderInterface;
|
import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkShaderInterface;
|
||||||
@@ -28,7 +29,11 @@ public class PrimitiveRenderSectionManager extends RenderSectionManager {
|
|||||||
|
|
||||||
public static PrimitiveRenderSectionManager create(ChunkVertexType vertexType, World world, int renderDistance, CommandList commandList) {
|
public static PrimitiveRenderSectionManager create(ChunkVertexType vertexType, World world, int renderDistance, CommandList commandList) {
|
||||||
// TODO support thread option
|
// TODO support thread option
|
||||||
return new PrimitiveRenderSectionManager(PrimitiveRenderPassConfigurationBuilder.build(vertexType), world, renderDistance, commandList, 0, 8, -1);
|
//? if <1.8 {
|
||||||
|
int idealThreadCount = -1;
|
||||||
|
//?} else
|
||||||
|
/*int idealThreadCount = 0;*/
|
||||||
|
return new PrimitiveRenderSectionManager(PrimitiveRenderPassConfigurationBuilder.build(vertexType), world, renderDistance, commandList, 0, 8, idealThreadCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -51,7 +56,10 @@ public class PrimitiveRenderSectionManager extends RenderSectionManager {
|
|||||||
final boolean useOcclusionCulling;
|
final boolean useOcclusionCulling;
|
||||||
var camBlockPos = positionedViewport.getBlockCoord();
|
var camBlockPos = positionedViewport.getBlockCoord();
|
||||||
|
|
||||||
|
//? if <1.8 {
|
||||||
var block = this.world.getBlock(camBlockPos.x(), camBlockPos.y(), camBlockPos.z());
|
var block = this.world.getBlock(camBlockPos.x(), camBlockPos.y(), camBlockPos.z());
|
||||||
|
//?} else
|
||||||
|
/*var block = this.world.getBlockState(new net.minecraft.util.math.BlockPos(camBlockPos.x(), camBlockPos.y(), camBlockPos.z())).getBlock();*/
|
||||||
|
|
||||||
//? if >=1.7 {
|
//? if >=1.7 {
|
||||||
/*boolean opaque = block.isOpaqueCube();
|
/*boolean opaque = block.isOpaqueCube();
|
||||||
|
|||||||
+26
-10
@@ -1,5 +1,6 @@
|
|||||||
package org.taumc.celeritas.impl.render.terrain.compile;
|
package org.taumc.celeritas.impl.render.terrain.compile;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.embeddedt.embeddium.impl.common.util.MathUtil;
|
import org.embeddedt.embeddium.impl.common.util.MathUtil;
|
||||||
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFacing;
|
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFacing;
|
||||||
@@ -14,16 +15,24 @@ import org.taumc.celeritas.impl.render.terrain.CeleritasWorldRenderer;
|
|||||||
import org.taumc.celeritas.impl.render.terrain.PrimitiveRenderPassConfigurationBuilder;
|
import org.taumc.celeritas.impl.render.terrain.PrimitiveRenderPassConfigurationBuilder;
|
||||||
import org.taumc.celeritas.impl.render.terrain.SpriteTransparencyTracker;
|
import org.taumc.celeritas.impl.render.terrain.SpriteTransparencyTracker;
|
||||||
|
|
||||||
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
public class PrimitiveChunkBuildContext extends ChunkBuildContext {
|
public class PrimitiveChunkBuildContext extends ChunkBuildContext {
|
||||||
public static final int NUM_PASSES = 2;
|
public static final int NUM_PASSES = 2;
|
||||||
|
|
||||||
public final World world;
|
public final World world;
|
||||||
private final SpriteTransparencyTracker transparencyTracker;
|
private final SpriteTransparencyTracker transparencyTracker;
|
||||||
|
|
||||||
|
public final BufferBuilder tesselator;
|
||||||
|
|
||||||
public PrimitiveChunkBuildContext(World world, RenderPassConfiguration renderPassConfiguration) {
|
public PrimitiveChunkBuildContext(World world, RenderPassConfiguration renderPassConfiguration) {
|
||||||
super(renderPassConfiguration);
|
super(renderPassConfiguration);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.transparencyTracker = CeleritasWorldRenderer.instance().getTransparencyTracker();
|
this.transparencyTracker = CeleritasWorldRenderer.instance().getTransparencyTracker();
|
||||||
|
//? if >=1.8 {
|
||||||
|
/*this.tesselator = new BufferBuilder(8192);
|
||||||
|
*///?} else
|
||||||
|
this.tesselator = BufferBuilder.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ChunkVertexEncoder.Vertex[] vertices = ChunkVertexEncoder.Vertex.uninitializedQuad();
|
private final ChunkVertexEncoder.Vertex[] vertices = ChunkVertexEncoder.Vertex.uninitializedQuad();
|
||||||
@@ -42,7 +51,7 @@ public class PrimitiveChunkBuildContext extends ChunkBuildContext {
|
|||||||
private static final int[] NORMAL_WINDING = new int[] {0, 1, 2, 3};
|
private static final int[] NORMAL_WINDING = new int[] {0, 1, 2, 3};
|
||||||
private static final int[] BACKFACE_WINDING = new int[] {3, 2, 1, 0};
|
private static final int[] BACKFACE_WINDING = new int[] {3, 2, 1, 0};
|
||||||
|
|
||||||
public void copyRawBuffer(int[] rawBuffer, int vertexCount, ChunkBuildBuffers buffers, Material material) {
|
public void copyRawBuffer(IntBuffer rawBuffer, int vertexCount, ChunkBuildBuffers buffers, Material material) {
|
||||||
if (vertexCount == 0) {
|
if (vertexCount == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -65,25 +74,32 @@ public class PrimitiveChunkBuildContext extends ChunkBuildContext {
|
|||||||
//?}
|
//?}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void outputQuads(int[] rawBuffer, ChunkVertexEncoder.Vertex[] celeritasVertices, int numQuads, ChunkBuildBuffers buffers, Material material, int[] winding) {
|
private void outputQuads(IntBuffer rawBuffer, ChunkVertexEncoder.Vertex[] celeritasVertices, int numQuads, ChunkBuildBuffers buffers, Material material, int[] winding) {
|
||||||
int ptr = 0;
|
int ptr = 0;
|
||||||
var tracker = this.transparencyTracker;
|
var tracker = this.transparencyTracker;
|
||||||
for (int quadIdx = 0; quadIdx < numQuads; quadIdx++) {
|
for (int quadIdx = 0; quadIdx < numQuads; quadIdx++) {
|
||||||
float uSum = 0, vSum = 0;
|
float uSum = 0, vSum = 0;
|
||||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||||
var vertex = celeritasVertices[winding[vIdx]];
|
var vertex = celeritasVertices[winding[vIdx]];
|
||||||
vertex.x = Float.intBitsToFloat(rawBuffer[ptr++]);
|
vertex.x = Float.intBitsToFloat(rawBuffer.get(ptr++));
|
||||||
vertex.y = Float.intBitsToFloat(rawBuffer[ptr++]);
|
vertex.y = Float.intBitsToFloat(rawBuffer.get(ptr++));
|
||||||
vertex.z = Float.intBitsToFloat(rawBuffer[ptr++]);
|
vertex.z = Float.intBitsToFloat(rawBuffer.get(ptr++));
|
||||||
float u = Float.intBitsToFloat(rawBuffer[ptr++]);
|
|
||||||
float v = Float.intBitsToFloat(rawBuffer[ptr++]);
|
// In 1.8+, color comes before all UVs. In 1.7-, texture UV comes before color.
|
||||||
|
//? if >=1.8
|
||||||
|
/*vertex.color = rawBuffer.get(ptr++);*/
|
||||||
|
|
||||||
|
float u = Float.intBitsToFloat(rawBuffer.get(ptr++));
|
||||||
|
float v = Float.intBitsToFloat(rawBuffer.get(ptr++));
|
||||||
vertex.u = u;
|
vertex.u = u;
|
||||||
uSum += u;
|
uSum += u;
|
||||||
vertex.v = v;
|
vertex.v = v;
|
||||||
vSum += v;
|
vSum += v;
|
||||||
vertex.color = rawBuffer[ptr++];
|
//? if <1.8 {
|
||||||
vertex.vanillaNormal = rawBuffer[ptr++];
|
vertex.color = rawBuffer.get(ptr++);
|
||||||
vertex.light = rawBuffer[ptr++];
|
vertex.vanillaNormal = rawBuffer.get(ptr++);
|
||||||
|
//?}
|
||||||
|
vertex.light = rawBuffer.get(ptr++);
|
||||||
}
|
}
|
||||||
int trueNormal = QuadUtil.calculateNormal(celeritasVertices);
|
int trueNormal = QuadUtil.calculateNormal(celeritasVertices);
|
||||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||||
|
|||||||
+43
-12
@@ -1,10 +1,8 @@
|
|||||||
package org.taumc.celeritas.impl.render.terrain.compile.task;
|
package org.taumc.celeritas.impl.render.terrain.compile.task;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap;
|
import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.client.render.BlockRenderer;
|
|
||||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||||
import net.minecraft.world.WorldRegion;
|
import net.minecraft.world.WorldRegion;
|
||||||
import net.minecraft.world.chunk.WorldChunk;
|
import net.minecraft.world.chunk.WorldChunk;
|
||||||
@@ -21,6 +19,7 @@ import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass;
|
|||||||
import org.embeddedt.embeddium.impl.util.task.CancellationToken;
|
import org.embeddedt.embeddium.impl.util.task.CancellationToken;
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3i;
|
import org.joml.Vector3i;
|
||||||
|
import org.lwjgl.opengl.GL11C;
|
||||||
import org.taumc.celeritas.impl.extensions.TessellatorExtension;
|
import org.taumc.celeritas.impl.extensions.TessellatorExtension;
|
||||||
import org.taumc.celeritas.impl.render.terrain.compile.PrimitiveBuiltRenderSectionData;
|
import org.taumc.celeritas.impl.render.terrain.compile.PrimitiveBuiltRenderSectionData;
|
||||||
import org.taumc.celeritas.impl.render.terrain.compile.PrimitiveChunkBuildContext;
|
import org.taumc.celeritas.impl.render.terrain.compile.PrimitiveChunkBuildContext;
|
||||||
@@ -29,6 +28,8 @@ import org.taumc.celeritas.impl.render.util.Direction;
|
|||||||
import org.taumc.celeritas.impl.world.cloned.ChunkRenderContext;
|
import org.taumc.celeritas.impl.world.cloned.ChunkRenderContext;
|
||||||
import org.taumc.celeritas.mixin.core.TessellatorAccessor;
|
import org.taumc.celeritas.mixin.core.TessellatorAccessor;
|
||||||
|
|
||||||
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput> {
|
public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput> {
|
||||||
private final RenderSection render;
|
private final RenderSection render;
|
||||||
private final int buildTime;
|
private final int buildTime;
|
||||||
@@ -60,19 +61,27 @@ public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput>
|
|||||||
int maxZ = minZ + 16;
|
int maxZ = minZ + 16;
|
||||||
|
|
||||||
// Initialise with minX/minY/minZ so initial getBlockState crash context is correct
|
// Initialise with minX/minY/minZ so initial getBlockState crash context is correct
|
||||||
Vector3i blockPos = new Vector3i(minX, minY, minZ);
|
|
||||||
|
|
||||||
var world = buildContext.world;
|
var world = buildContext.world;
|
||||||
var chunk = world.getChunkAt(this.render.getChunkX(), this.render.getChunkZ());
|
var chunk = world.getChunkAt(this.render.getChunkX(), this.render.getChunkZ());
|
||||||
var region = new WorldRegion(world, minX - 1, minY - 1, minZ - 1, maxX + 1, maxY + 1, maxZ + 1 /*? if >=1.7.10 {*//*, 1*//*?}*/);
|
var tesselator = buildContext.tesselator;
|
||||||
var renderBlocks = new BlockRenderer(region);
|
|
||||||
var tesselator = BufferBuilder.INSTANCE;
|
|
||||||
var extTesselator = (TessellatorExtension)tesselator;
|
|
||||||
|
|
||||||
|
//? if <1.8 {
|
||||||
|
Vector3i blockPos = new Vector3i(minX, minY, minZ);
|
||||||
|
var region = new WorldRegion(world, minX - 1, minY - 1, minZ - 1, maxX + 1, maxY + 1, maxZ + 1 /*? if >=1.7.10 {*//*, 1*//*?}*/);
|
||||||
|
var renderBlocks = new net.minecraft.client.render.BlockRenderer(region);
|
||||||
|
var extTesselator = (TessellatorExtension)tesselator;
|
||||||
//? if <1.7
|
//? if <1.7
|
||||||
TessellatorAccessor.celeritas$setTriangleMode(false);
|
TessellatorAccessor.celeritas$setTriangleMode(false);
|
||||||
tesselator.offset(-this.render.getOriginX(), -this.render.getOriginY(), -this.render.getOriginZ());
|
|
||||||
WorldChunk.hasSkyLight = false;
|
WorldChunk.hasSkyLight = false;
|
||||||
|
//?} else {
|
||||||
|
/*var blockPos = new net.minecraft.util.math.BlockPos.Mutable(minX, minY, minZ);
|
||||||
|
var region = new WorldRegion(world, new net.minecraft.util.math.BlockPos(minX, minY, minZ), new net.minecraft.util.math.BlockPos(maxX, maxY, maxZ), 1);
|
||||||
|
var renderBlocks = Minecraft.getInstance().getBlockRenderDispatcher();
|
||||||
|
*///?}
|
||||||
|
|
||||||
|
tesselator.offset(-this.render.getOriginX(), -this.render.getOriginY(), -this.render.getOriginZ());
|
||||||
|
|
||||||
|
|
||||||
// Beta is insane and updates the matrix inside the tessellation logic
|
// Beta is insane and updates the matrix inside the tessellation logic
|
||||||
try {
|
try {
|
||||||
@@ -93,9 +102,16 @@ public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Block block = Block.BY_ID[blockId];
|
Block block = Block.BY_ID[blockId];
|
||||||
//?} else {
|
//?} else if <1.8 {
|
||||||
/*Block block = chunk.getBlockAt(x & 15, y, z & 15);
|
/*Block block = chunk.getBlockAt(x & 15, y, z & 15);
|
||||||
|
|
||||||
|
if (block == net.minecraft.block.Blocks.AIR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*///?} else {
|
||||||
|
/*var blockState = chunk.getBlockState(blockPos);
|
||||||
|
var block = blockState.getBlock();
|
||||||
|
|
||||||
if (block == net.minecraft.block.Blocks.AIR) {
|
if (block == net.minecraft.block.Blocks.AIR) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -107,18 +123,29 @@ public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput>
|
|||||||
boolean hasBlockEntity = block.hasBlockEntity();
|
boolean hasBlockEntity = block.hasBlockEntity();
|
||||||
|
|
||||||
if (hasBlockEntity) {
|
if (hasBlockEntity) {
|
||||||
|
//? if <1.8 {
|
||||||
BlockEntity tileEntity = chunk.getBlockEntityAt(x & 15, y, z & 15);
|
BlockEntity tileEntity = chunk.getBlockEntityAt(x & 15, y, z & 15);
|
||||||
if (BlockEntityRenderDispatcher.INSTANCE.hasRenderer(tileEntity)) {
|
//?} else
|
||||||
|
/*BlockEntity tileEntity = chunk.getBlockEntity(blockPos, WorldChunk.BlockEntityCreationType.CHECK);*/
|
||||||
|
if (BlockEntityRenderDispatcher.INSTANCE.getRenderer(tileEntity) != null) {
|
||||||
renderData.globalBlockEntities.add(tileEntity);
|
renderData.globalBlockEntities.add(tileEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int pass = block.getRenderLayer();
|
var pass = block.getRenderLayer();
|
||||||
|
|
||||||
|
//? if <1.8 {
|
||||||
tesselator.start();
|
tesselator.start();
|
||||||
renderBlocks.tessellateBlock(block, x, y, z);
|
renderBlocks.tessellateBlock(block, x, y, z);
|
||||||
buildContext.copyRawBuffer(extTesselator.celeritas$getRawBuffer(), extTesselator.celeritas$getVertexCount(), buffers, buffers.getRenderPassConfiguration().getMaterialForRenderType(pass));
|
buildContext.copyRawBuffer(IntBuffer.wrap(extTesselator.celeritas$getRawBuffer()), extTesselator.celeritas$getVertexCount(), buffers, buffers.getRenderPassConfiguration().getMaterialForRenderType(pass));
|
||||||
extTesselator.celeritas$reset();
|
extTesselator.celeritas$reset();
|
||||||
|
//?} else {
|
||||||
|
/*tesselator.begin(GL11C.GL_QUADS, com.mojang.blaze3d.vertex.DefaultVertexFormat.BLOCK);
|
||||||
|
renderBlocks.tessellate(blockState, blockPos, region, tesselator);
|
||||||
|
tesselator.end();
|
||||||
|
buildContext.copyRawBuffer(tesselator.getBuffer().asIntBuffer(), tesselator.getVertexCount(), buffers, buffers.getRenderPassConfiguration().getMaterialForRenderType(pass));
|
||||||
|
tesselator.clear();
|
||||||
|
*///?}
|
||||||
|
|
||||||
//? if <1.7 {
|
//? if <1.7 {
|
||||||
boolean opaque = Block.IS_OPAQUE[blockId];
|
boolean opaque = Block.IS_OPAQUE[blockId];
|
||||||
@@ -126,6 +153,9 @@ public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput>
|
|||||||
/*boolean opaque = block.isOpaqueCube();*/
|
/*boolean opaque = block.isOpaqueCube();*/
|
||||||
|
|
||||||
if (opaque) {
|
if (opaque) {
|
||||||
|
//? if >=1.8 {
|
||||||
|
/*occluder.markClosed(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||||
|
*///?} else
|
||||||
occluder.markClosed(blockPos);
|
occluder.markClosed(blockPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,6 +174,7 @@ public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput>
|
|||||||
renderData.hasBlockGeometry = true;
|
renderData.hasBlockGeometry = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//? if <1.8
|
||||||
renderData.hasSkyLight = WorldChunk.hasSkyLight;
|
renderData.hasSkyLight = WorldChunk.hasSkyLight;
|
||||||
|
|
||||||
encodeVisibilityData(occluder, renderData);
|
encodeVisibilityData(occluder, renderData);
|
||||||
|
|||||||
+5
@@ -43,6 +43,11 @@ public class ChunkOcclusionDataBuilder {
|
|||||||
--this.openCount;
|
--this.openCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void markClosed(int x, int y, int z) {
|
||||||
|
this.closed.set(pack(x, y, z), true);
|
||||||
|
--this.openCount;
|
||||||
|
}
|
||||||
|
|
||||||
private static int pack(Vector3i pos) {
|
private static int pack(Vector3i pos) {
|
||||||
return pack(pos.x() & 15, pos.y() & 15, pos.z() & 15);
|
return pack(pos.x() & 15, pos.y() & 15, pos.z() & 15);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.taumc.celeritas.mixin.core;
|
package org.taumc.celeritas.mixin.core;
|
||||||
|
|
||||||
|
//? if <1.8 {
|
||||||
import net.minecraft.client.render.BlockRenderer;
|
import net.minecraft.client.render.BlockRenderer;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -12,3 +13,4 @@ public class BlockRendererMixin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//?}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package org.taumc.celeritas.mixin.core;
|
||||||
|
|
||||||
|
//? if >=1.8 {
|
||||||
|
/*import net.minecraft.client.gui.overlay.DebugOverlay;
|
||||||
|
import net.minecraft.text.Formatting;
|
||||||
|
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.CallbackInfoReturnable;
|
||||||
|
import org.taumc.celeritas.impl.debug.CeleritasDebugStrings;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mixin(DebugOverlay.class)
|
||||||
|
public class DebugOverlayMixin {
|
||||||
|
@Inject(method = "getSystemInfo", at = @At("RETURN"))
|
||||||
|
private void appendCeleritasSystemInfo(CallbackInfoReturnable<List<String>> cir) {
|
||||||
|
var strings = cir.getReturnValue();
|
||||||
|
strings.add("");
|
||||||
|
strings.addAll(CeleritasDebugStrings.getStringsToRender().stream().map(pair -> {
|
||||||
|
// TODO
|
||||||
|
if (pair.right() == 0xFF55FF55) {
|
||||||
|
return Formatting.GREEN + pair.left();
|
||||||
|
} else {
|
||||||
|
return pair.left();
|
||||||
|
}
|
||||||
|
}).toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*///?}
|
||||||
@@ -33,6 +33,7 @@ public class GameRendererMixin {
|
|||||||
GLStateManagerFogService.fogColorBlue = this.fogBlue;
|
GLStateManagerFogService.fogColorBlue = this.fogBlue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//? if <1.8 {
|
||||||
private boolean lastVsyncStatus;
|
private boolean lastVsyncStatus;
|
||||||
|
|
||||||
@Inject(method = "render", at = @At("HEAD"))
|
@Inject(method = "render", at = @At("HEAD"))
|
||||||
@@ -48,4 +49,5 @@ public class GameRendererMixin {
|
|||||||
private boolean celeritas$forceNormalTranslucentTerrainRendering(GameOptions instance) {
|
private boolean celeritas$forceNormalTranslucentTerrainRendering(GameOptions instance) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//?}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,18 @@
|
|||||||
package org.taumc.celeritas.mixin.core;
|
package org.taumc.celeritas.mixin.core;
|
||||||
|
|
||||||
|
//? if <1.8 {
|
||||||
import com.llamalad7.mixinextras.sugar.Local;
|
import com.llamalad7.mixinextras.sugar.Local;
|
||||||
import it.unimi.dsi.fastutil.Pair;
|
import it.unimi.dsi.fastutil.Pair;
|
||||||
import net.minecraft.client.gui.GameGui;
|
import net.minecraft.client.gui.GameGui;
|
||||||
import net.minecraft.client.render.TextRenderer;
|
import net.minecraft.client.render.TextRenderer;
|
||||||
import net.minecraft.client.render.Window;
|
import net.minecraft.client.render.Window;
|
||||||
import org.embeddedt.embeddium.impl.common.util.MathUtil;
|
|
||||||
import org.embeddedt.embeddium.impl.common.util.NativeBuffer;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.Slice;
|
import org.spongepowered.asm.mixin.injection.Slice;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.taumc.celeritas.impl.Celeritas;
|
import org.taumc.celeritas.impl.debug.CeleritasDebugStrings;
|
||||||
import org.taumc.celeritas.impl.render.terrain.CeleritasWorldRenderer;
|
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mixin(GameGui.class)
|
@Mixin(GameGui.class)
|
||||||
@@ -26,25 +22,13 @@ public class InGameHudMixin {
|
|||||||
//? if <1.4
|
//? if <1.4
|
||||||
+ "Profiler"
|
+ "Profiler"
|
||||||
+ "Enabled:Z")), at = @At(value = "INVOKE", target ="Lorg/lwjgl/opengl/GL11;glPopMatrix()V", ordinal = 0))
|
+ "Enabled:Z")), at = @At(value = "INVOKE", target ="Lorg/lwjgl/opengl/GL11;glPopMatrix()V", ordinal = 0))
|
||||||
private void celeritas$renderDebug(float screenOpen, boolean mouseX, int mouseY, int par4, CallbackInfo ci, @Local(ordinal = 0) Window scaler, @Local(ordinal = 0) TextRenderer font) {
|
private void celeritas$renderDebug(CallbackInfo ci, @Local(ordinal = 0) Window scaler, @Local(ordinal = 0) TextRenderer font) {
|
||||||
int currentY = 22;
|
int currentY = 22;
|
||||||
int yDiff = 10;
|
int yDiff = 10;
|
||||||
|
|
||||||
int screenWidth = scaler.getWidth();
|
int screenWidth = scaler.getWidth();
|
||||||
|
|
||||||
List<Pair<String, Integer>> stringsToRender = new ArrayList<>();
|
List<Pair<String, Integer>> stringsToRender = CeleritasDebugStrings.getStringsToRender();
|
||||||
|
|
||||||
stringsToRender.add(Pair.of(getNativeMemoryString(), -1));
|
|
||||||
stringsToRender.add(Pair.of("", -1));
|
|
||||||
|
|
||||||
stringsToRender.add(Pair.of("%s Renderer (%s)".formatted("Celeritas", Celeritas.VERSION), 0xFF55FF55));
|
|
||||||
stringsToRender.add(Pair.of("", -1));
|
|
||||||
|
|
||||||
var renderer = CeleritasWorldRenderer.instanceNullable();
|
|
||||||
|
|
||||||
if (renderer != null) {
|
|
||||||
renderer.getDebugStrings().forEach(str -> stringsToRender.add(Pair.of(str, -1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var render : stringsToRender) {
|
for (var render : stringsToRender) {
|
||||||
if (!render.left().isBlank()) {
|
if (!render.left().isBlank()) {
|
||||||
@@ -55,12 +39,5 @@ public class InGameHudMixin {
|
|||||||
currentY += yDiff;
|
currentY += yDiff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getNativeMemoryString() {
|
|
||||||
return "Off-Heap: +" + MathUtil.toMib(getNativeMemoryUsage()) + "MB";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long getNativeMemoryUsage() {
|
|
||||||
return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getUsed() + NativeBuffer.getTotalAllocated();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//?}
|
||||||
@@ -13,11 +13,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
|
|
||||||
@Mixin(Minecraft.class)
|
@Mixin(Minecraft.class)
|
||||||
public class MinecraftMixin {
|
public class MinecraftMixin {
|
||||||
|
private static final String INIT_DISPLAY_METHOD =
|
||||||
|
//? if <1.8 {
|
||||||
|
"init"
|
||||||
|
//?} else
|
||||||
|
/*"initDisplay"*/
|
||||||
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author embeddedt
|
* @author embeddedt
|
||||||
* @reason apparently b7.3 uses the default depth buffer precision (8-bit), which looks very bad
|
* @reason apparently b7.3 uses the default depth buffer precision (8-bit), which looks very bad
|
||||||
*/
|
*/
|
||||||
@Redirect(method = "init", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;create()V"))
|
@Redirect(method = INIT_DISPLAY_METHOD, at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;create()V"))
|
||||||
private void createWithHighPrecisionDepthBuffer() throws LWJGLException {
|
private void createWithHighPrecisionDepthBuffer() throws LWJGLException {
|
||||||
Display.create(new PixelFormat().withDepthBits(24));
|
Display.create(new PixelFormat().withDepthBits(24));
|
||||||
}
|
}
|
||||||
@@ -26,12 +33,12 @@ public class MinecraftMixin {
|
|||||||
* @author embeddedt
|
* @author embeddedt
|
||||||
* @reason by default b7.3 does not mark the window as resizeable
|
* @reason by default b7.3 does not mark the window as resizeable
|
||||||
*/
|
*/
|
||||||
@Inject(method = "init", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V"))
|
@Inject(method = INIT_DISPLAY_METHOD, at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V"))
|
||||||
private void makeResizeable(CallbackInfo ci) {
|
private void makeResizeable(CallbackInfo ci) {
|
||||||
Display.setResizable(true);
|
Display.setResizable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyArg(method = "init", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V"), index = 0)
|
@ModifyArg(method = INIT_DISPLAY_METHOD, at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V"), index = 0)
|
||||||
private String removeDuplicateMinecraftInTitle(String newTitle) {
|
private String removeDuplicateMinecraftInTitle(String newTitle) {
|
||||||
if (newTitle.startsWith("Minecraft Minecraft")) {
|
if (newTitle.startsWith("Minecraft Minecraft")) {
|
||||||
return newTitle.replaceFirst("^Minecraft ", "");
|
return newTitle.replaceFirst("^Minecraft ", "");
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.taumc.celeritas.mixin.core;
|
package org.taumc.celeritas.mixin.core;
|
||||||
|
|
||||||
|
//? if <1.8 {
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -35,4 +36,4 @@ public abstract class TessellatorMixin implements TessellatorExtension {
|
|||||||
this.clear();
|
this.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//?}
|
||||||
@@ -4,7 +4,10 @@ import com.llamalad7.mixinextras.sugar.Local;
|
|||||||
import com.mojang.blaze3d.platform.Lighting;
|
import com.mojang.blaze3d.platform.Lighting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.render.Culler;
|
import net.minecraft.client.render.Culler;
|
||||||
|
//? if >=1.8
|
||||||
|
/*import net.minecraft.client.render.block.BlockLayer;*/
|
||||||
import net.minecraft.client.render.world.WorldRenderer;
|
import net.minecraft.client.render.world.WorldRenderer;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.living.LivingEntity;
|
import net.minecraft.entity.living.LivingEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.embeddedt.embeddium.impl.gl.device.RenderDevice;
|
import org.embeddedt.embeddium.impl.gl.device.RenderDevice;
|
||||||
@@ -26,8 +29,18 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
|||||||
@Shadow
|
@Shadow
|
||||||
private Minecraft minecraft;
|
private Minecraft minecraft;
|
||||||
|
|
||||||
|
//? if <1.8 {
|
||||||
@Shadow
|
@Shadow
|
||||||
private int chunkGridSizeX, chunkGridSizeY, chunkGridSizeZ;
|
private int chunkGridSizeX, chunkGridSizeY, chunkGridSizeZ;
|
||||||
|
//?}
|
||||||
|
|
||||||
|
//? if >=1.8 {
|
||||||
|
/*@Shadow
|
||||||
|
private int viewDistance;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public abstract void reload();
|
||||||
|
*///?}
|
||||||
|
|
||||||
private CeleritasWorldRenderer renderer;
|
private CeleritasWorldRenderer renderer;
|
||||||
|
|
||||||
@@ -52,19 +65,25 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//? if <1.8 {
|
||||||
@Inject(method = { "reload", "m_6748042" }, at = @At(opcode = Opcodes.PUTFIELD, value = "FIELD", target = "Lnet/minecraft/client/render/world/WorldRenderer;chunkGridSizeZ:I", shift = At.Shift.AFTER))
|
@Inject(method = { "reload", "m_6748042" }, at = @At(opcode = Opcodes.PUTFIELD, value = "FIELD", target = "Lnet/minecraft/client/render/world/WorldRenderer;chunkGridSizeZ:I", shift = At.Shift.AFTER))
|
||||||
private void nullifyBuiltChunkStorage(CallbackInfo ci) {
|
private void nullifyBuiltChunkStorage(CallbackInfo ci) {
|
||||||
this.chunkGridSizeX = 0;
|
this.chunkGridSizeX = 0;
|
||||||
this.chunkGridSizeY = 0;
|
this.chunkGridSizeY = 0;
|
||||||
this.chunkGridSizeZ = 0;
|
this.chunkGridSizeZ = 0;
|
||||||
}
|
}
|
||||||
|
//?}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @reason Redirect the chunk layer render passes to our renderer
|
* @reason Redirect the chunk layer render passes to our renderer
|
||||||
* @author JellySquid
|
* @author JellySquid
|
||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public int render(LivingEntity viewEntity, int pass, double ticks) {
|
//? if <1.8 {
|
||||||
|
public int render(LivingEntity viewEntity, int layer, double ticks) {
|
||||||
|
//?} else
|
||||||
|
/*public int render(BlockLayer layer, double ticks, int anaglyphRenderPass, Entity viewEntity) {*/
|
||||||
// Allow FalseTweaks mixin to replace constant
|
// Allow FalseTweaks mixin to replace constant
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
double magicSortingConstantValue = 1.0D;
|
double magicSortingConstantValue = 1.0D;
|
||||||
@@ -78,16 +97,16 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
|||||||
double d5 = viewEntity.prevTickZ + (viewEntity.z - viewEntity.prevTickZ) * ticks;
|
double d5 = viewEntity.prevTickZ + (viewEntity.z - viewEntity.prevTickZ) * ticks;
|
||||||
|
|
||||||
//? if >=1.0.0-beta.8
|
//? if >=1.0.0-beta.8
|
||||||
this.minecraft.gameRenderer.enableLightMap(ticks);
|
this.minecraft.gameRenderer.enableLightMap(/*? if <1.8 {*/ticks/*?}*/);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.renderer.drawChunkLayer(pass, d3, d4, d5);
|
this.renderer.drawChunkLayer(layer, d3, d4, d5);
|
||||||
} finally {
|
} finally {
|
||||||
RenderDevice.exitManagedCode();
|
RenderDevice.exitManagedCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
//? if >=1.0.0-beta.8
|
//? if >=1.0.0-beta.8
|
||||||
this.minecraft.gameRenderer.disableLightMap(ticks);
|
this.minecraft.gameRenderer.disableLightMap(/*? if <1.8 {*/ticks/*?}*/);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -100,6 +119,15 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
|||||||
* @author JellySquid
|
* @author JellySquid
|
||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
|
//? if >=1.8 {
|
||||||
|
/*public void setupRender(Entity camera, double tickDelta, Culler culler, int frame, boolean loadChunks) {
|
||||||
|
if (this.minecraft.options.viewDistance != this.viewDistance) {
|
||||||
|
this.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateFrustums(culler, (float)tickDelta);
|
||||||
|
}
|
||||||
|
*///?}
|
||||||
public void updateFrustums(Culler camera, float tick) {
|
public void updateFrustums(Culler camera, float tick) {
|
||||||
RenderDevice.enterManagedCode();
|
RenderDevice.enterManagedCode();
|
||||||
|
|
||||||
@@ -122,7 +150,7 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
|||||||
//? if <1.3 {
|
//? if <1.3 {
|
||||||
private static final String ON_RELOAD = "m_6748042";
|
private static final String ON_RELOAD = "m_6748042";
|
||||||
//?} else
|
//?} else
|
||||||
/*private static final String ON_RELOAD = "reload";*/
|
/*private static final String ON_RELOAD = "reload()V";*/
|
||||||
|
|
||||||
@Inject(method = ON_RELOAD, at = @At("RETURN"))
|
@Inject(method = ON_RELOAD, at = @At("RETURN"))
|
||||||
private void onReload(CallbackInfo ci) {
|
private void onReload(CallbackInfo ci) {
|
||||||
@@ -136,11 +164,22 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Overwrite
|
@Overwrite
|
||||||
|
//? if <1.8 {
|
||||||
public boolean compileChunks(LivingEntity camera, boolean force) {
|
public boolean compileChunks(LivingEntity camera, boolean force) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
//?} else {
|
||||||
|
/*public void compileChunksUntil(long time) {
|
||||||
|
|
||||||
@Inject(method = "renderEntities", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/world/WorldRenderer;globalBlockEntities:Ljava/util/List;", ordinal = 0))
|
}
|
||||||
|
*///?}
|
||||||
|
|
||||||
|
@Inject(method = "renderEntities", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/world/WorldRenderer;globalBlockEntities:"
|
||||||
|
//? if >=1.8 {
|
||||||
|
/*+ "Ljava/util/Set;"
|
||||||
|
*///?} else
|
||||||
|
+ "Ljava/util/List;"
|
||||||
|
, ordinal = 0))
|
||||||
public void sodium$renderTileEntities(CallbackInfo ci, @Local(ordinal = 0, argsOnly = true) float partialTicks) {
|
public void sodium$renderTileEntities(CallbackInfo ci, @Local(ordinal = 0, argsOnly = true) float partialTicks) {
|
||||||
this.renderer.renderBlockEntities(partialTicks);
|
this.renderer.renderBlockEntities(partialTicks);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The render state object for a chunk section. This contains all the graphics state for each render pass along with
|
* The render state object for a chunk section. This contains all the graphics state for each render pass along with
|
||||||
@@ -33,7 +34,6 @@ public class RenderSection extends AbstractSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rendering State
|
// Rendering State
|
||||||
private boolean built = false; // merge with the flags?
|
|
||||||
private BuiltRenderSectionData contextData;
|
private BuiltRenderSectionData contextData;
|
||||||
private boolean hasAnythingToRender;
|
private boolean hasAnythingToRender;
|
||||||
@Getter
|
@Getter
|
||||||
@@ -91,28 +91,17 @@ public class RenderSection extends AbstractSection {
|
|||||||
this.buildCancellationToken = null;
|
this.buildCancellationToken = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clearRenderState();
|
this.setInfo(null);
|
||||||
this.disposed = true;
|
this.disposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInfo(@Nullable BuiltRenderSectionData info) {
|
public boolean setInfo(@Nullable BuiltRenderSectionData info) {
|
||||||
if (info != null) {
|
boolean changed = !Objects.equals(info, this.contextData);
|
||||||
this.setRenderState(info);
|
if (changed) {
|
||||||
} else {
|
|
||||||
this.clearRenderState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setRenderState(@NotNull BuiltRenderSectionData info) {
|
|
||||||
this.built = true;
|
|
||||||
this.contextData = info;
|
this.contextData = info;
|
||||||
this.updateCachedContextDataFlags();
|
this.updateCachedContextDataFlags();
|
||||||
}
|
}
|
||||||
|
return changed;
|
||||||
private void clearRenderState() {
|
|
||||||
this.built = false;
|
|
||||||
this.contextData = null;
|
|
||||||
this.updateCachedContextDataFlags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDisposed() {
|
public boolean isDisposed() {
|
||||||
@@ -120,7 +109,7 @@ public class RenderSection extends AbstractSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBuilt() {
|
public boolean isBuilt() {
|
||||||
return this.built;
|
return this.contextData != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderRegion getRegion() {
|
public RenderRegion getRegion() {
|
||||||
|
|||||||
+49
-11
@@ -83,6 +83,8 @@ public abstract class RenderSectionManager {
|
|||||||
|
|
||||||
private final Object2ObjectOpenHashMap<TerrainRenderPass, TimerQueryManager> renderPassDrawTimers = new Object2ObjectOpenHashMap<>();
|
private final Object2ObjectOpenHashMap<TerrainRenderPass, TimerQueryManager> renderPassDrawTimers = new Object2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
|
protected final ReferenceSet<RenderSection> sectionsRequestingUpdate = new ReferenceOpenHashSet<>();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public RenderSectionManager(RenderPassConfiguration<?> configuration, Supplier<ChunkBuildContext> contextSupplier,
|
public RenderSectionManager(RenderPassConfiguration<?> configuration, Supplier<ChunkBuildContext> contextSupplier,
|
||||||
BiFunction<RenderDevice, RenderPassConfiguration<?>, ChunkRenderer> chunkRenderer,
|
BiFunction<RenderDevice, RenderPassConfiguration<?>, ChunkRenderer> chunkRenderer,
|
||||||
@@ -368,9 +370,27 @@ public abstract class RenderSectionManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inject sections that requested a rebuild between graph updates into the appropriate rebuild lists.
|
||||||
|
*/
|
||||||
|
private void promoteInterimRebuildList() {
|
||||||
|
var rebuildLists = this.getCurrentRenderListManager().getRebuildLists().byUpdateType();
|
||||||
|
for (var section : this.sectionsRequestingUpdate) {
|
||||||
|
rebuildLists.get(section.getPendingUpdate()).add(section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateChunks(boolean updateImmediately) {
|
public void updateChunks(boolean updateImmediately) {
|
||||||
this.regions.update();
|
this.regions.update();
|
||||||
|
|
||||||
|
// Promotion of the interim rebuild list is not required if a graph update is requested, as the graph
|
||||||
|
// generates a new rebuild list anyway
|
||||||
|
if (!this.renderListManager.isNeedsUpdate() && !sectionsRequestingUpdate.isEmpty()) {
|
||||||
|
this.promoteInterimRebuildList();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sectionsRequestingUpdate.clear();
|
||||||
|
|
||||||
if (!rebuildListHasUpdates()) {
|
if (!rebuildListHasUpdates()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -408,6 +428,12 @@ public abstract class RenderSectionManager {
|
|||||||
for (var result : results) {
|
for (var result : results) {
|
||||||
result.delete();
|
result.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forcefully mark the graph as needing updates if the previous render list detected an overflow of the
|
||||||
|
// update queue. This is necessary to queue those additional chunks.
|
||||||
|
if (this.getCurrentRenderListManager().getRebuildLists().hasAdditionalUpdates()) {
|
||||||
|
this.markGraphDirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void tickVisibleRenders() {
|
public final void tickVisibleRenders() {
|
||||||
@@ -421,11 +447,15 @@ public abstract class RenderSectionManager {
|
|||||||
|
|
||||||
for (var result : filtered) {
|
for (var result : filtered) {
|
||||||
if(result.info != null) {
|
if(result.info != null) {
|
||||||
// The chunk graph must be rebuilt whenever a section is remeshed, in order to consider changes in
|
boolean changed = this.updateSectionInfo(result.render, result.info);
|
||||||
// geometry, visibility data, etc.
|
|
||||||
|
if (changed) {
|
||||||
|
// The chunk graph must be rebuilt if the render section reports the info has changed. This
|
||||||
|
// could indicate an occlusion data update, block entity addition/removal, animated texture
|
||||||
|
// change, etc.
|
||||||
this.markGraphDirty();
|
this.markGraphDirty();
|
||||||
|
}
|
||||||
|
|
||||||
this.updateSectionInfo(result.render, result.info);
|
|
||||||
// We only change the translucency info on full rebuilds, as sorts can keep using the same data
|
// We only change the translucency info on full rebuilds, as sorts can keep using the same data
|
||||||
this.updateTranslucencyInfo(result.render, result.meshes);
|
this.updateTranslucencyInfo(result.render, result.meshes);
|
||||||
}
|
}
|
||||||
@@ -451,8 +481,10 @@ public abstract class RenderSectionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@MustBeInvokedByOverriders
|
@MustBeInvokedByOverriders
|
||||||
protected void updateSectionInfo(RenderSection render, @Nullable BuiltRenderSectionData info) {
|
protected boolean updateSectionInfo(RenderSection render, @Nullable BuiltRenderSectionData info) {
|
||||||
render.setInfo(info);
|
boolean changed = render.setInfo(info);
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
long visibilityData = info != null ? info.visibilityData : VisibilityEncoding.NULL;
|
long visibilityData = info != null ? info.visibilityData : VisibilityEncoding.NULL;
|
||||||
this.renderListManager.updateVisibilityData(render.getChunkX(), render.getChunkY(), render.getChunkZ(), visibilityData);
|
this.renderListManager.updateVisibilityData(render.getChunkX(), render.getChunkY(), render.getChunkZ(), visibilityData);
|
||||||
if (this.shadowRenderListManager != null) {
|
if (this.shadowRenderListManager != null) {
|
||||||
@@ -466,6 +498,9 @@ public abstract class RenderSectionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
private static List<ChunkBuildOutput> filterChunkBuildResults(ArrayList<ChunkBuildOutput> outputs) {
|
private static List<ChunkBuildOutput> filterChunkBuildResults(ArrayList<ChunkBuildOutput> outputs) {
|
||||||
var map = new Reference2ReferenceLinkedOpenHashMap<RenderSection, ChunkBuildOutput>();
|
var map = new Reference2ReferenceLinkedOpenHashMap<RenderSection, ChunkBuildOutput>();
|
||||||
|
|
||||||
@@ -648,10 +683,14 @@ public abstract class RenderSectionManager {
|
|||||||
if (pendingUpdate != null) {
|
if (pendingUpdate != null) {
|
||||||
section.setPendingUpdate(pendingUpdate);
|
section.setPendingUpdate(pendingUpdate);
|
||||||
|
|
||||||
|
if (!this.getCurrentRenderListManager().isNeedsUpdate() && this.sectionsRequestingUpdate.size() < this.builder.getSchedulingBudget()) {
|
||||||
|
this.sectionsRequestingUpdate.add(section);
|
||||||
|
} else {
|
||||||
this.markGraphDirty();
|
this.markGraphDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final float NEARBY_REBUILD_DISTANCE = MathUtil.square(16.0f);
|
private static final float NEARBY_REBUILD_DISTANCE = MathUtil.square(16.0f);
|
||||||
|
|
||||||
@@ -770,14 +809,13 @@ public abstract class RenderSectionManager {
|
|||||||
list.add(String.format("G: %d/%d, I: %d/%d MiB (%d buffers)", MathUtil.toMib(deviceUsed), MathUtil.toMib(deviceAllocated), MathUtil.toMib(indexUsed), MathUtil.toMib(indexAllocated), count));
|
list.add(String.format("G: %d/%d, I: %d/%d MiB (%d buffers)", MathUtil.toMib(deviceUsed), MathUtil.toMib(deviceAllocated), MathUtil.toMib(indexUsed), MathUtil.toMib(indexAllocated), count));
|
||||||
list.add(String.format("Transfer Queue: %s", this.regions.getStagingBuffer().toString()));
|
list.add(String.format("Transfer Queue: %s", this.regions.getStagingBuffer().toString()));
|
||||||
|
|
||||||
var rebuildLists = this.getCurrentRenderListManager().getRebuildLists().byUpdateType();
|
var rebuildLists = this.getCurrentRenderListManager().getRebuildLists();
|
||||||
|
|
||||||
list.add(String.format("Chunk Queues: U=%02d (P0=%03d | P1=%03d | P2=%03d)%s",
|
list.add(String.format("Chunk Queues: U=%02d (P0=%03d | P1=%03d | P2=%03d)",
|
||||||
this.buildResults.size(),
|
this.buildResults.size(),
|
||||||
rebuildLists.get(ChunkUpdateType.IMPORTANT_REBUILD).size(),
|
rebuildLists.getUpdateCount(ChunkUpdateType.IMPORTANT_REBUILD),
|
||||||
rebuildLists.get(ChunkUpdateType.REBUILD).size(),
|
rebuildLists.getUpdateCount(ChunkUpdateType.REBUILD),
|
||||||
rebuildLists.get(ChunkUpdateType.INITIAL_BUILD).size(),
|
rebuildLists.getUpdateCount(ChunkUpdateType.INITIAL_BUILD)
|
||||||
this.getCurrentRenderListManager().getRebuildLists().hasAdditionalUpdates() ? "(++)" : ""
|
|
||||||
));
|
));
|
||||||
|
|
||||||
var debugStats = renderListManager.getDebugStatistics();
|
var debugStats = renderListManager.getDebugStatistics();
|
||||||
|
|||||||
+6
-2
@@ -12,9 +12,13 @@ import java.util.Map;
|
|||||||
* @param byUpdateType a map from update type to the appropriate list of sections
|
* @param byUpdateType a map from update type to the appropriate list of sections
|
||||||
* @param hasAdditionalUpdates whether there were additional updates not queued for efficiency reasons
|
* @param hasAdditionalUpdates whether there were additional updates not queued for efficiency reasons
|
||||||
*/
|
*/
|
||||||
public record ChunkRebuildLists(Map<ChunkUpdateType, ArrayDeque<RenderSection>> byUpdateType, boolean hasAdditionalUpdates) {
|
public record ChunkRebuildLists(Map<ChunkUpdateType, ArrayDeque<RenderSection>> byUpdateType, boolean hasAdditionalUpdates, Map<ChunkUpdateType, Integer> queueOverflowCounts) {
|
||||||
public static final ChunkRebuildLists EMPTY;
|
public static final ChunkRebuildLists EMPTY;
|
||||||
|
|
||||||
|
public int getUpdateCount(ChunkUpdateType type) {
|
||||||
|
return byUpdateType.get(type).size() + queueOverflowCounts.getOrDefault(type, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Map<ChunkUpdateType, ArrayDeque<RenderSection>> rebuildLists = new EnumMap<>(ChunkUpdateType.class);
|
Map<ChunkUpdateType, ArrayDeque<RenderSection>> rebuildLists = new EnumMap<>(ChunkUpdateType.class);
|
||||||
|
|
||||||
@@ -22,6 +26,6 @@ public record ChunkRebuildLists(Map<ChunkUpdateType, ArrayDeque<RenderSection>>
|
|||||||
rebuildLists.put(type, new ArrayDeque<>());
|
rebuildLists.put(type, new ArrayDeque<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
EMPTY = new ChunkRebuildLists(rebuildLists, false);
|
EMPTY = new ChunkRebuildLists(rebuildLists, false, new EnumMap<>(ChunkUpdateType.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+14
-1
@@ -1,6 +1,7 @@
|
|||||||
package org.embeddedt.embeddium.impl.render.chunk.lists;
|
package org.embeddedt.embeddium.impl.render.chunk.lists;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Reference2IntArrayMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -17,6 +18,7 @@ public class VisibleChunkCollector implements OcclusionCuller.Visitor {
|
|||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private final ObjectArrayList<ChunkRenderList> sortedRenderLists;
|
private final ObjectArrayList<ChunkRenderList> sortedRenderLists;
|
||||||
private final EnumMap<ChunkUpdateType, ArrayDeque<RenderSection>> sortedRebuildLists;
|
private final EnumMap<ChunkUpdateType, ArrayDeque<RenderSection>> sortedRebuildLists;
|
||||||
|
private final int[] rebuildQueueOverflowCounts;
|
||||||
private final Reference2ReferenceOpenHashMap<RenderRegion, ChunkRenderList> renderListsByRegion;
|
private final Reference2ReferenceOpenHashMap<RenderRegion, ChunkRenderList> renderListsByRegion;
|
||||||
|
|
||||||
private final int frame;
|
private final int frame;
|
||||||
@@ -30,6 +32,7 @@ public class VisibleChunkCollector implements OcclusionCuller.Visitor {
|
|||||||
|
|
||||||
this.sortedRenderLists = new ObjectArrayList<>();
|
this.sortedRenderLists = new ObjectArrayList<>();
|
||||||
this.sortedRebuildLists = new EnumMap<>(ChunkUpdateType.class);
|
this.sortedRebuildLists = new EnumMap<>(ChunkUpdateType.class);
|
||||||
|
this.rebuildQueueOverflowCounts = new int[ChunkUpdateType.values().length];
|
||||||
this.ignoreQueueSizeLimit = ignoreQueueSizeLimit;
|
this.ignoreQueueSizeLimit = ignoreQueueSizeLimit;
|
||||||
this.renderListsByRegion = new Reference2ReferenceOpenHashMap<>();
|
this.renderListsByRegion = new Reference2ReferenceOpenHashMap<>();
|
||||||
|
|
||||||
@@ -74,6 +77,7 @@ public class VisibleChunkCollector implements OcclusionCuller.Visitor {
|
|||||||
if (this.ignoreQueueSizeLimit || queue.size() < type.getMaximumQueueSize()) {
|
if (this.ignoreQueueSizeLimit || queue.size() < type.getMaximumQueueSize()) {
|
||||||
queue.add(section);
|
queue.add(section);
|
||||||
} else {
|
} else {
|
||||||
|
this.rebuildQueueOverflowCounts[type.ordinal()]++;
|
||||||
this.hasAdditionalUpdates = true;
|
this.hasAdditionalUpdates = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,6 +88,15 @@ public class VisibleChunkCollector implements OcclusionCuller.Visitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChunkRebuildLists getRebuildLists() {
|
public ChunkRebuildLists getRebuildLists() {
|
||||||
return new ChunkRebuildLists(this.sortedRebuildLists, this.hasAdditionalUpdates);
|
EnumMap<ChunkUpdateType, Integer> overflowCounts = new EnumMap<>(ChunkUpdateType.class);
|
||||||
|
if (this.hasAdditionalUpdates) {
|
||||||
|
var values = ChunkUpdateType.values();
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
if (this.rebuildQueueOverflowCounts[i] != 0) {
|
||||||
|
overflowCounts.put(values[i], this.rebuildQueueOverflowCounts[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ChunkRebuildLists(this.sortedRebuildLists, this.hasAdditionalUpdates, overflowCounts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,11 +8,16 @@ plugins {
|
|||||||
id("celeritas-unimined-plugin")
|
id("celeritas-unimined-plugin")
|
||||||
id("xyz.wagyourtail.unimined") version "1.3.15-SNAPSHOT"
|
id("xyz.wagyourtail.unimined") version "1.3.15-SNAPSHOT"
|
||||||
id("xyz.wagyourtail.jvmdowngrader") version "1.1.3"
|
id("xyz.wagyourtail.jvmdowngrader") version "1.1.3"
|
||||||
|
id("maven-publish")
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "org.embeddedt"
|
group = "org.embeddedt"
|
||||||
version = rootProject.version
|
version = rootProject.version
|
||||||
|
|
||||||
|
java {
|
||||||
|
withSourcesJar()
|
||||||
|
}
|
||||||
|
|
||||||
data class VersionData(val mcpVersion: String, val forgeVersion: String)
|
data class VersionData(val mcpVersion: String, val forgeVersion: String)
|
||||||
|
|
||||||
val versionDataMap = mapOf(
|
val versionDataMap = mapOf(
|
||||||
@@ -24,7 +29,7 @@ val minecraftVersion = project.name
|
|||||||
|
|
||||||
val versionData = versionDataMap.getValue(project.name)
|
val versionData = versionDataMap.getValue(project.name)
|
||||||
|
|
||||||
base.archivesName = "celeritas-forge-${project.name}"
|
base.archivesName = "celeritas-forge-mc${project.name.replace("^1\\.".toRegex(), "")}"
|
||||||
|
|
||||||
val modCompileOnly by configurations.creating
|
val modCompileOnly by configurations.creating
|
||||||
configurations.compileOnly.get().extendsFrom(modCompileOnly)
|
configurations.compileOnly.get().extendsFrom(modCompileOnly)
|
||||||
@@ -102,3 +107,15 @@ tasks.register("packageJar", Copy::class) {
|
|||||||
from(tasks.named<ShadowJar>("shadowRemapJar").get().archiveFile)
|
from(tasks.named<ShadowJar>("shadowRemapJar").get().archiveFile)
|
||||||
into("${rootProject.layout.buildDirectory.get()}/libs/${project.version}")
|
into("${rootProject.layout.buildDirectory.get()}/libs/${project.version}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("default") {
|
||||||
|
artifactId = base.archivesName.get()
|
||||||
|
artifact(tasks.named<ShadowJar>("shadowRemapJar").map { it.archiveFile })
|
||||||
|
artifact(tasks.named("sourcesJar")) {
|
||||||
|
classifier = "sources"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -3,6 +3,7 @@ org.gradle.jvmargs=-Xmx2G
|
|||||||
# Gradle stuff
|
# Gradle stuff
|
||||||
stonecutter_version=0.7-beta.2
|
stonecutter_version=0.7-beta.2
|
||||||
taugradle_version=0.3.36
|
taugradle_version=0.3.36
|
||||||
|
junit_version=5.13.4
|
||||||
|
|
||||||
project_base_version=2.3
|
project_base_version=2.3
|
||||||
|
|
||||||
@@ -78,7 +79,7 @@ ffapi_1_21_1=0.104.0+2.0.18+1.21.1
|
|||||||
|
|
||||||
# NeoForge stuff
|
# NeoForge stuff
|
||||||
neoforge_1_20_4=20.4.237
|
neoforge_1_20_4=20.4.237
|
||||||
neoforge_1_21_1=21.1.73
|
neoforge_1_21_1=21.1.200
|
||||||
neoforge_1_21_8=21.8.15
|
neoforge_1_21_8=21.8.15
|
||||||
|
|
||||||
# Forge Stuff
|
# Forge Stuff
|
||||||
|
|||||||
@@ -80,6 +80,17 @@ dependencies {
|
|||||||
ModDependencyCollector.obtainDeps(project) { cfg, dep ->
|
ModDependencyCollector.obtainDeps(project) { cfg, dep ->
|
||||||
dependencies.add(cfg, dep)
|
dependencies.add(cfg, dep)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testImplementation("net.fabricmc:fabric-loader-junit:${rootProject.property("fabricloader")}")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named<Test>("test") {
|
||||||
|
useJUnitPlatform()
|
||||||
|
val junitDir = project.layout.buildDirectory.file("fabric-junit").get().asFile
|
||||||
|
doFirst {
|
||||||
|
junitDir.mkdirs()
|
||||||
|
}
|
||||||
|
workingDir = junitDir
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stonecutter.constants.getOrDefault("shaders", false)) {
|
if (stonecutter.constants.getOrDefault("shaders", false)) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ plugins {
|
|||||||
id("celeritas.platform-conventions")
|
id("celeritas.platform-conventions")
|
||||||
id("celeritas.shader-conventions") apply false
|
id("celeritas.shader-conventions") apply false
|
||||||
id("embeddium-fabric-module-finder")
|
id("embeddium-fabric-module-finder")
|
||||||
|
id("maven-publish")
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "org.embeddedt"
|
group = "org.embeddedt"
|
||||||
@@ -44,10 +45,15 @@ tasks.named<Jar>("jar") {
|
|||||||
archiveClassifier.set("deobf")
|
archiveClassifier.set("deobf")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
withSourcesJar()
|
||||||
|
}
|
||||||
|
|
||||||
val config: MDGConfig = if (modLoader == ModLoader.NEOFORGE) {
|
val config: MDGConfig = if (modLoader == ModLoader.NEOFORGE) {
|
||||||
apply(plugin = "net.neoforged.moddev")
|
apply(plugin = "net.neoforged.moddev")
|
||||||
val neoForge = project.extensions.getByName("neoForge") as NeoForgeExtension
|
val neoForge = project.extensions.getByName("neoForge") as NeoForgeExtension
|
||||||
neoForge.version = versionedProperty("neoforge")
|
neoForge.version = versionedProperty("neoforge")
|
||||||
|
neoForge.unitTest.enable()
|
||||||
MDGConfig(neoForge, "jar")
|
MDGConfig(neoForge, "jar")
|
||||||
} else {
|
} else {
|
||||||
apply(plugin = "net.neoforged.moddev.legacyforge")
|
apply(plugin = "net.neoforged.moddev.legacyforge")
|
||||||
@@ -88,11 +94,26 @@ if (parchmentVersion != null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modDevExtension.mods {
|
val mainMod = modDevExtension.mods.create("embeddium") {
|
||||||
create("embeddium") {
|
|
||||||
sourceSet(sourceSets.main.get())
|
sourceSet(sourceSets.main.get())
|
||||||
sourceSet(project(":common").sourceSets.main.get())
|
sourceSet(project(":common").sourceSets.main.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (modLoader == ModLoader.NEOFORGE) {
|
||||||
|
(modDevExtension as NeoForgeExtension).unitTest.testedMod = mainMod
|
||||||
|
|
||||||
|
tasks.named<Test>("test") {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Disable unit tests
|
||||||
|
sourceSets.named("test") {
|
||||||
|
java.setSrcDirs(emptyList<String>())
|
||||||
|
resources.setSrcDirs(emptyList<String>())
|
||||||
|
}
|
||||||
|
tasks.named("test") {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named("createMinecraftArtifacts") {
|
tasks.named("createMinecraftArtifacts") {
|
||||||
@@ -148,12 +169,20 @@ dependencies {
|
|||||||
ModDependencyCollector.obtainDeps(project) { cfg, dep ->
|
ModDependencyCollector.obtainDeps(project) { cfg, dep ->
|
||||||
dependencies.add(cfg, dep)
|
dependencies.add(cfg, dep)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testImplementation(platform("org.junit:junit-bom:${rootProject.property("junit_version")}"))
|
||||||
|
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||||
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named<Jar>("jar") {
|
tasks.named<Jar>("jar") {
|
||||||
manifest {
|
manifest {
|
||||||
|
if (modLoader == ModLoader.NEOFORGE) {
|
||||||
attributes.put("MixinConfigs", modMixinConfigs.joinToString(","))
|
attributes.put("MixinConfigs", modMixinConfigs.joinToString(","))
|
||||||
}
|
}
|
||||||
|
attributes.put("Fabric-Loom-Mixin-Remap-Type", "static")
|
||||||
|
attributes.put("Fabric-Mapping-Namespace", "intermediary")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named<ProcessResources>("processResources") {
|
tasks.named<ProcessResources>("processResources") {
|
||||||
@@ -185,3 +214,15 @@ val packageJar = tasks.register("packageJar", Copy::class) {
|
|||||||
tasks.named("assemble") {
|
tasks.named("assemble") {
|
||||||
dependsOn(packageJar)
|
dependsOn(packageJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("default") {
|
||||||
|
artifactId = defaultArchiveBaseName
|
||||||
|
artifact(shadowJar.map { it.archiveFile })
|
||||||
|
artifact(tasks.named("sourcesJar")) {
|
||||||
|
classifier = "sources"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package org.embeddedt.embeddium.impl.junit;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@ExtendWith({ BootstrapExtension.class })
|
||||||
|
public @interface Bootstrap {
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package org.embeddedt.embeddium.impl.junit;
|
||||||
|
|
||||||
|
import net.minecraft.SharedConstants;
|
||||||
|
import net.minecraft.server.Bootstrap;
|
||||||
|
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||||
|
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||||
|
|
||||||
|
public class BootstrapExtension implements BeforeAllCallback {
|
||||||
|
@Override
|
||||||
|
public void beforeAll(ExtensionContext context) throws Exception {
|
||||||
|
SharedConstants.tryDetectVersion();
|
||||||
|
Bootstrap.bootStrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package org.embeddedt.embeddium.impl.modern.render.chunk.compile.pipeline;
|
||||||
|
|
||||||
|
import net.minecraft.world.phys.shapes.Shapes;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
public class FluidOcclusionCacheTest {
|
||||||
|
private final FluidOcclusionCache cache = new FluidOcclusionCache();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testFullBlockHidesFluidFace() {
|
||||||
|
assertFalse(cache.isTopFluidFacePotentiallyVisible(Shapes.block()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSlabHidesFluidFace() {
|
||||||
|
assertFalse(cache.isTopFluidFacePotentiallyVisible(FluidOcclusionCache.UPPER_HALF_SLAB));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testThinSlabDoesNotHideFluidFace() {
|
||||||
|
assertTrue(cache.isTopFluidFacePotentiallyVisible(Shapes.box(0.0, 0.7, 0.0, 1.0, 1.0, 1.0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testInsetBlockDoesNotHideFluidFace() {
|
||||||
|
double inset = 0.1;
|
||||||
|
assertTrue(cache.isTopFluidFacePotentiallyVisible(Shapes.box(inset, 0.5, inset, 1.0 - inset, 1.0, 1.0 - inset)));
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -122,7 +122,7 @@ createStonecutterProject("forge122", listOf("1.12.2", "1.10.2")) { versions ->
|
|||||||
versions(versions)
|
versions(versions)
|
||||||
}
|
}
|
||||||
|
|
||||||
createStonecutterProject("babric", listOf("1.2.5", "1.0.0-beta.7.3", "1.0.0-beta.8.1", "1.7.10")) { versions ->
|
createStonecutterProject("babric", listOf("1.2.5", "1.0.0-beta.7.3", "1.0.0-beta.8.1", "1.7.10", "1.8.9")) { versions ->
|
||||||
centralScript = "build.gradle.kts"
|
centralScript = "build.gradle.kts"
|
||||||
versions(versions)
|
versions(versions)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user