From 78030b2f40bd9291ba1acc40034db6fcefd3f399 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 27 Dec 2021 13:37:09 -0800 Subject: [PATCH] Fix contraption lighting - Actually just one line. --- changelog.txt | 10 +++++- .../backend/model/ArrayModelRenderer.java | 2 -- .../core/vertex/BlockWriterUnsafe.java | 2 +- .../core/vertex/VertexWriterUnsafe.java | 1 + .../core/virtual/VirtualRenderWorld.java | 32 +++++++++---------- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/changelog.txt b/changelog.txt index e2e1695aa..1a62e6f1a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,12 @@ -0.4.1a: +0.5.0: +New + - Added parallel batching backend, effectively a CPU instancer. + - Now partially compatible with starlight. +Technical/API + - Much more flexible vertex formats. + - Do instance updates/ticking entirely async. + +0.4.2-rc: Fixes - Partially fix crash on intel and mesa drivers (needs Create to update) - Fix garbage rendering on AMD GPUs diff --git a/src/main/java/com/jozufozu/flywheel/backend/model/ArrayModelRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/model/ArrayModelRenderer.java index 0a5185bd9..457226ead 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/model/ArrayModelRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/model/ArrayModelRenderer.java @@ -4,7 +4,6 @@ import java.util.function.Supplier; import com.jozufozu.flywheel.backend.gl.GlVertexArray; import com.jozufozu.flywheel.core.model.Model; -import com.jozufozu.flywheel.util.AttribUtil; public class ArrayModelRenderer extends ModelRenderer { @@ -36,7 +35,6 @@ public class ArrayModelRenderer extends ModelRenderer { vao = new GlVertexArray(); vao.bind(); - vao.enableArrays(this.model.getAttributeCount()); // bind the model's vbo to our vao this.model.setupState(); diff --git a/src/main/java/com/jozufozu/flywheel/core/vertex/BlockWriterUnsafe.java b/src/main/java/com/jozufozu/flywheel/core/vertex/BlockWriterUnsafe.java index 84d49dee9..044160349 100644 --- a/src/main/java/com/jozufozu/flywheel/core/vertex/BlockWriterUnsafe.java +++ b/src/main/java/com/jozufozu/flywheel/core/vertex/BlockWriterUnsafe.java @@ -46,7 +46,7 @@ public class BlockWriterUnsafe extends VertexWriterUnsafe { MemoryUtil.memPutByte(ptr + 15, a); MemoryUtil.memPutFloat(ptr + 16, u); MemoryUtil.memPutFloat(ptr + 20, v); - MemoryUtil.memPutInt(ptr + 24, light); + MemoryUtil.memPutInt(ptr + 24, light << 8); // light is packed in the low byte of each short MemoryUtil.memPutByte(ptr + 28, RenderMath.nb(nX)); MemoryUtil.memPutByte(ptr + 29, RenderMath.nb(nY)); MemoryUtil.memPutByte(ptr + 30, RenderMath.nb(nZ)); diff --git a/src/main/java/com/jozufozu/flywheel/core/vertex/VertexWriterUnsafe.java b/src/main/java/com/jozufozu/flywheel/core/vertex/VertexWriterUnsafe.java index 5ad8bd70c..c524fc804 100644 --- a/src/main/java/com/jozufozu/flywheel/core/vertex/VertexWriterUnsafe.java +++ b/src/main/java/com/jozufozu/flywheel/core/vertex/VertexWriterUnsafe.java @@ -24,6 +24,7 @@ public abstract class VertexWriterUnsafe implements Vertex protected void advance() { writeVertex++; + // account for seeking if (writeVertex > totalVertices) totalVertices = writeVertex; } diff --git a/src/main/java/com/jozufozu/flywheel/core/virtual/VirtualRenderWorld.java b/src/main/java/com/jozufozu/flywheel/core/virtual/VirtualRenderWorld.java index fb50c9469..bfd246988 100644 --- a/src/main/java/com/jozufozu/flywheel/core/virtual/VirtualRenderWorld.java +++ b/src/main/java/com/jozufozu/flywheel/core/virtual/VirtualRenderWorld.java @@ -96,6 +96,22 @@ public class VirtualRenderWorld extends Level implements FlywheelWorld { // MEANINGFUL OVERRIDES + @Override + public boolean setBlock(BlockPos pos, BlockState newState, int flags) { + blocksAdded.put(pos, newState); + + SectionPos sectionPos = SectionPos.of(pos); + if (spannedSections.add(sectionPos)) { + lighter.updateSectionStatus(sectionPos, false); + } + + if ((flags & Block.UPDATE_SUPPRESS_LIGHT) == 0) { + lighter.checkBlock(pos); + } + + return true; + } + @Override public int getHeight() { return height; @@ -134,22 +150,6 @@ public class VirtualRenderWorld extends Level implements FlywheelWorld { return setBlock(pos, state, 0); } - @Override - public boolean setBlock(BlockPos pos, BlockState newState, int flags) { - blocksAdded.put(pos, newState); - - SectionPos sectionPos = SectionPos.of(pos); - if (spannedSections.add(sectionPos)) { - lighter.updateSectionStatus(sectionPos, false); - } - - if ((flags & Block.UPDATE_SUPPRESS_LIGHT) == 0) { - lighter.checkBlock(pos); - } - - return true; - } - @Override @Nullable public BlockEntity getBlockEntity(BlockPos pos) {