From 3e01d3f4419feafe75b88ecb05a80daafafab8c0 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Wed, 15 Dec 2021 00:35:49 -0800 Subject: [PATCH 1/7] Batching Engine - Implement alternate backend using SBBs --- .../contraptions/base/flwdata/BeltType.java | 32 +++++++- .../base/flwdata/RotatingType.java | 22 +++++- .../base/flwdata/UnsafeBeltWriter.java | 19 +---- .../base/flwdata/UnsafeKineticWriter.java | 24 ++++++ .../base/flwdata/UnsafeRotatingWriter.java | 19 +---- .../components/actors/flwdata/ActorType.java | 7 +- .../actors/flwdata/UnsafeActorWriter.java | 3 +- .../structureMovement/glue/GlueInstance.java | 78 ++++++++++++++++++- .../logistics/block/flap/FlapData.java | 10 ++- .../logistics/block/flap/FlapType.java | 29 ++++++- .../block/flap/UnsafeFlapWriter.java | 8 +- .../foundation/render/SuperByteBuffer.java | 13 ++-- .../assets/create/flywheel/shaders/flap.vert | 4 +- 13 files changed, 207 insertions(+), 61 deletions(-) create mode 100644 src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeKineticWriter.java diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java index 1c72568d5..8e3a62a6b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java @@ -6,10 +6,14 @@ import com.jozufozu.flywheel.api.struct.Instanced; import com.jozufozu.flywheel.api.struct.StructWriter; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.util.RenderMath; +import com.mojang.math.Quaternion; +import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.foundation.render.AllInstanceFormats; import com.simibubi.create.foundation.render.AllProgramSpecs; +import com.simibubi.create.foundation.utility.AnimationTickHolder; +import net.minecraft.client.renderer.LightTexture; import net.minecraft.resources.ResourceLocation; public class BeltType implements Instanced, Batched { @@ -34,7 +38,29 @@ public class BeltType implements Instanced, Batched { } @Override - public BatchingTransformer getTransformer(Model model) { - return null; + public BatchingTransformer getTransformer() { + return (d, sbb) -> { + + float spriteHeight = d.maxV - d.minV; + double scroll = d.rotationalSpeed * AnimationTickHolder.getRenderTime() / (31.5 * 16) + d.rotationOffset; + scroll = scroll - Math.floor(scroll); + scroll = scroll * spriteHeight * RenderMath.f(d.scrollMult); + + float finalScroll = (float) scroll; + sbb.shiftUV((builder, u, v) -> { + float targetU = u - d.sourceU + d.minU; + float targetV = v - d.sourceV + d.minV + + finalScroll; + builder.uv(targetU, targetV); + }); + + sbb.translate(d.x + 0.5, d.y + 0.5, d.z + 0.5) + .multiply(new Quaternion(d.qX, d.qY, d.qZ, d.qW)) + .unCentre() + .light(d.getPackedLight()); + if (KineticDebugger.isActive()) { + sbb.color(d.r, d.g, d.b, d.a); + } + }; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java index 94e05590f..400afd94f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java @@ -6,10 +6,14 @@ import com.jozufozu.flywheel.api.struct.Instanced; import com.jozufozu.flywheel.api.struct.StructWriter; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.util.RenderMath; +import com.mojang.math.Vector3f; +import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.foundation.render.AllInstanceFormats; import com.simibubi.create.foundation.render.AllProgramSpecs; +import com.simibubi.create.foundation.utility.AnimationTickHolder; +import net.minecraft.client.renderer.LightTexture; import net.minecraft.resources.ResourceLocation; public class RotatingType implements Instanced, Batched { @@ -34,7 +38,19 @@ public class RotatingType implements Instanced, Batched getTransformer(Model model) { - return null; + public BatchingTransformer getTransformer() { + return (d, b) -> { + float angle = ((AnimationTickHolder.getRenderTime() * d.rotationalSpeed * 3f / 10 + d.rotationOffset) % 360); + + Vector3f axis = new Vector3f(RenderMath.f(d.rotationAxisX), RenderMath.f(d.rotationAxisY), RenderMath.f(d.rotationAxisZ)); + b.light(d.getPackedLight()) + .translate(d.x + 0.5, d.y + 0.5, d.z + 0.5) + .multiply(axis.rotationDegrees(angle)) + .unCentre(); + + if (KineticDebugger.isActive()) { + b.color(d.r, d.g, d.b, d.a); + } + }; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeBeltWriter.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeBeltWriter.java index 1bd4e3ac5..59ba5203f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeBeltWriter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeBeltWriter.java @@ -4,27 +4,16 @@ import org.lwjgl.system.MemoryUtil; import com.jozufozu.flywheel.api.struct.StructType; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; -public class UnsafeBeltWriter extends UnsafeBufferWriter { +public class UnsafeBeltWriter extends UnsafeKineticWriter { public UnsafeBeltWriter(VecBuffer backingBuffer, StructType vertexType) { super(backingBuffer, vertexType); } @Override - public void write(BeltData d) { + protected void writeInternal(BeltData d) { + super.writeInternal(d); long addr = writePointer; - MemoryUtil.memPutByte(addr, d.blockLight); - MemoryUtil.memPutByte(addr + 1, d.skyLight); - MemoryUtil.memPutByte(addr + 2, d.r); - MemoryUtil.memPutByte(addr + 3, d.g); - MemoryUtil.memPutByte(addr + 4, d.b); - MemoryUtil.memPutByte(addr + 5, d.a); - MemoryUtil.memPutFloat(addr + 6, d.x); - MemoryUtil.memPutFloat(addr + 10, d.y); - MemoryUtil.memPutFloat(addr + 14, d.z); - MemoryUtil.memPutFloat(addr + 18, d.rotationalSpeed); - MemoryUtil.memPutFloat(addr + 22, d.rotationOffset); MemoryUtil.memPutFloat(addr + 26, d.qX); MemoryUtil.memPutFloat(addr + 30, d.qY); MemoryUtil.memPutFloat(addr + 34, d.qZ); @@ -36,7 +25,5 @@ public class UnsafeBeltWriter extends UnsafeBufferWriter { MemoryUtil.memPutFloat(addr + 58, d.maxU); MemoryUtil.memPutFloat(addr + 62, d.maxV); MemoryUtil.memPutByte(addr + 66, d.scrollMult); - - advance(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeKineticWriter.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeKineticWriter.java new file mode 100644 index 000000000..f6fbeebfc --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeKineticWriter.java @@ -0,0 +1,24 @@ +package com.simibubi.create.content.contraptions.base.flwdata; + +import org.lwjgl.system.MemoryUtil; + +import com.jozufozu.flywheel.api.struct.StructType; +import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; +import com.jozufozu.flywheel.core.materials.UnsafeBasicWriter; + +public abstract class UnsafeKineticWriter extends UnsafeBasicWriter { + public UnsafeKineticWriter(VecBuffer backingBuffer, StructType vertexType) { + super(backingBuffer, vertexType); + } + + @Override + protected void writeInternal(D d) { + super.writeInternal(d); + long addr = writePointer; + MemoryUtil.memPutFloat(addr + 6, d.x); + MemoryUtil.memPutFloat(addr + 10, d.y); + MemoryUtil.memPutFloat(addr + 14, d.z); + MemoryUtil.memPutFloat(addr + 18, d.rotationalSpeed); + MemoryUtil.memPutFloat(addr + 22, d.rotationOffset); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeRotatingWriter.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeRotatingWriter.java index 8b0f13835..b477c8e20 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeRotatingWriter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeRotatingWriter.java @@ -4,31 +4,18 @@ import org.lwjgl.system.MemoryUtil; import com.jozufozu.flywheel.api.struct.StructType; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; -public class UnsafeRotatingWriter extends UnsafeBufferWriter { +public class UnsafeRotatingWriter extends UnsafeKineticWriter { public UnsafeRotatingWriter(VecBuffer backingBuffer, StructType vertexType) { super(backingBuffer, vertexType); } @Override - public void write(RotatingData d) { + protected void writeInternal(RotatingData d) { + super.writeInternal(d); long addr = writePointer; - MemoryUtil.memPutByte(addr, d.blockLight); - MemoryUtil.memPutByte(addr + 1, d.skyLight); - MemoryUtil.memPutByte(addr + 2, d.r); - MemoryUtil.memPutByte(addr + 3, d.g); - MemoryUtil.memPutByte(addr + 4, d.b); - MemoryUtil.memPutByte(addr + 5, d.a); - MemoryUtil.memPutFloat(addr + 6, d.x); - MemoryUtil.memPutFloat(addr + 10, d.y); - MemoryUtil.memPutFloat(addr + 14, d.z); - MemoryUtil.memPutFloat(addr + 18, d.rotationalSpeed); - MemoryUtil.memPutFloat(addr + 22, d.rotationOffset); MemoryUtil.memPutByte(addr + 26, d.rotationAxisX); MemoryUtil.memPutByte(addr + 27, d.rotationAxisY); MemoryUtil.memPutByte(addr + 28, d.rotationAxisZ); - - advance(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java index f664a6698..5ff165d7c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java @@ -6,7 +6,6 @@ import com.jozufozu.flywheel.api.struct.Instanced; import com.jozufozu.flywheel.api.struct.StructWriter; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.core.model.Model; import com.simibubi.create.foundation.render.AllInstanceFormats; import com.simibubi.create.foundation.render.AllProgramSpecs; @@ -34,7 +33,9 @@ public class ActorType implements Instanced, Batched { } @Override - public BatchingTransformer getTransformer(Model model) { - return null; + public BatchingTransformer getTransformer() { + return (d, sbb) -> { + + }; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/UnsafeActorWriter.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/UnsafeActorWriter.java index 0a7184910..4479e800d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/UnsafeActorWriter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/UnsafeActorWriter.java @@ -12,7 +12,7 @@ public class UnsafeActorWriter extends UnsafeBufferWriter { } @Override - public void write(ActorData d) { + protected void writeInternal(ActorData d) { long addr = writePointer; MemoryUtil.memPutFloat(addr, d.x); MemoryUtil.memPutFloat(addr + 4, d.y); @@ -31,6 +31,5 @@ public class UnsafeActorWriter extends UnsafeBufferWriter { MemoryUtil.memPutByte(addr + 38, d.rotationCenterY); MemoryUtil.memPutByte(addr + 39, d.rotationCenterZ); MemoryUtil.memPutFloat(addr + 40, d.speed); - advance(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java index bd464c94c..46a053521 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java @@ -11,6 +11,7 @@ import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.instancing.ConditionalInstance; import com.jozufozu.flywheel.core.materials.oriented.OrientedData; import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.util.ModelReader; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Quaternion; import com.simibubi.create.AllItems; @@ -95,7 +96,7 @@ public class GlueInstance extends EntityInstance implements ITi || AllItems.SUPER_GLUE.isIn(player.getOffhandItem()); } - public static class GlueModel implements Model { + public static class GlueModel implements Model, ModelReader { @Override public String name() { @@ -165,5 +166,80 @@ public class GlueInstance extends EntityInstance implements ITi public VertexFormat format() { return Formats.UNLIT_MODEL; } + + @Override + public ModelReader getReader() { + return this; + } + + @Override + public int getVertexCount() { + return 8; + } + + @Override + public float getX(int index) { + return 0; + } + + @Override + public float getY(int index) { + return 0; + } + + @Override + public float getZ(int index) { + return 0; + } + + @Override + public byte getR(int index) { + return (byte) 0xFF; + } + + @Override + public byte getG(int index) { + return (byte) 0xFF; + } + + @Override + public byte getB(int index) { + return (byte) 0xFF; + } + + @Override + public byte getA(int index) { + return (byte) 0xFF; + } + + @Override + public float getU(int index) { + return 0; + } + + @Override + public float getV(int index) { + return 0; + } + + @Override + public int getLight(int index) { + return 0; + } + + @Override + public float getNX(int index) { + return 0; + } + + @Override + public float getNY(int index) { + return 0; + } + + @Override + public float getNZ(int index) { + return index > 4 ? -1 : 1; + } } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapData.java b/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapData.java index 2e2ebb44b..591f0160c 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapData.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapData.java @@ -4,6 +4,7 @@ import com.jozufozu.flywheel.api.InstanceData; import com.jozufozu.flywheel.core.materials.FlatLit; import com.mojang.math.Vector3f; +import net.minecraft.client.renderer.LightTexture; import net.minecraft.core.BlockPos; public class FlapData extends InstanceData implements FlatLit { @@ -42,18 +43,23 @@ public class FlapData extends InstanceData implements FlatLit { @Override public FlapData setBlockLight(int blockLight) { - this.blockLight = (byte) ((blockLight & 0xF) << 4); + this.blockLight = (byte) (blockLight & 0xF); markDirty(); return this; } @Override public FlapData setSkyLight(int skyLight) { - this.skyLight = (byte) ((skyLight & 0xF) << 4); + this.skyLight = (byte) (skyLight & 0xF); markDirty(); return this; } + @Override + public int getPackedLight() { + return LightTexture.pack(this.blockLight, this.skyLight); + } + public FlapData setSegmentOffset(float x, float y, float z) { this.segmentOffsetX = x; this.segmentOffsetY = y; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java b/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java index 9838d5708..4d3a67b04 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java @@ -6,10 +6,11 @@ import com.jozufozu.flywheel.api.struct.Instanced; import com.jozufozu.flywheel.api.struct.StructWriter; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.core.model.Model; +import com.mojang.math.Vector3f; import com.simibubi.create.foundation.render.AllInstanceFormats; import com.simibubi.create.foundation.render.AllProgramSpecs; +import net.minecraft.client.renderer.LightTexture; import net.minecraft.resources.ResourceLocation; public class FlapType implements Instanced, Batched { @@ -34,7 +35,29 @@ public class FlapType implements Instanced, Batched { } @Override - public BatchingTransformer getTransformer(Model model) { - return null; + public BatchingTransformer getTransformer() { + return (d, sbb) -> { + sbb.translate(d.x, d.y, d.z) + .centre() + .rotateY(-d.horizontalAngle) + .unCentre() + .translate(d.pivotX, d.pivotY, d.pivotZ) + .rotateX(getFlapAngle(d.flapness, d.intensity, d.flapScale)) + .translateBack(d.pivotX, d.pivotY, d.pivotZ) + .translate(d.segmentOffsetX, d.segmentOffsetY, d.segmentOffsetZ) + .light(d.getPackedLight()); + }; + } + + private static float getFlapAngle(float flapness, float intensity, float scale) { + float absFlap = Math.abs(flapness); + + float angle = (float) (Math.sin((1. - absFlap) * Math.PI * intensity) * 30. * flapness * scale); + + if (flapness > 0) { + return angle * 0.5f; + } else { + return angle; + } } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/flap/UnsafeFlapWriter.java b/src/main/java/com/simibubi/create/content/logistics/block/flap/UnsafeFlapWriter.java index f0ace42cc..345fde063 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/flap/UnsafeFlapWriter.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/flap/UnsafeFlapWriter.java @@ -12,13 +12,13 @@ public class UnsafeFlapWriter extends UnsafeBufferWriter { } @Override - public void write(FlapData d) { + protected void writeInternal(FlapData d) { long addr = writePointer; MemoryUtil.memPutFloat(addr, d.x); MemoryUtil.memPutFloat(addr + 4, d.y); MemoryUtil.memPutFloat(addr + 8, d.z); - MemoryUtil.memPutByte(addr + 12, d.blockLight); - MemoryUtil.memPutByte(addr + 13, d.skyLight); + MemoryUtil.memPutByte(addr + 12, (byte) (d.blockLight << 4)); + MemoryUtil.memPutByte(addr + 13, (byte) (d.skyLight << 4)); MemoryUtil.memPutFloat(addr + 14, d.segmentOffsetX); MemoryUtil.memPutFloat(addr + 18, d.segmentOffsetY); MemoryUtil.memPutFloat(addr + 22, d.segmentOffsetZ); @@ -29,7 +29,5 @@ public class UnsafeFlapWriter extends UnsafeBufferWriter { MemoryUtil.memPutFloat(addr + 42, d.intensity); MemoryUtil.memPutFloat(addr + 46, d.flapScale); MemoryUtil.memPutFloat(addr + 50, d.flapness); - - advance(); } } diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java index dec20e4b0..7cb2197cd 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java @@ -1,6 +1,8 @@ package com.simibubi.create.foundation.render; import com.jozufozu.flywheel.util.BufferBuilderReader; +import com.jozufozu.flywheel.util.ModelReader; +import com.jozufozu.flywheel.util.RenderMath; import com.jozufozu.flywheel.util.transform.Rotate; import com.jozufozu.flywheel.util.transform.Scale; import com.jozufozu.flywheel.util.transform.TStack; @@ -31,10 +33,10 @@ import net.minecraftforge.client.model.pipeline.LightUtil; public class SuperByteBuffer implements Scale, Translate, Rotate, TStack { - private final BufferBuilderReader template; + private final ModelReader template; // Vertex Position - private PoseStack transforms; + private final PoseStack transforms; // Vertex Coloring private boolean shouldColor; @@ -115,9 +117,9 @@ public class SuperByteBuffer implements Scale, Translate, Translate Date: Fri, 17 Dec 2021 02:17:39 -0800 Subject: [PATCH 2/7] Use task engine/sync to update instances --- .../structureMovement/render/ContraptionInstanceManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java index 94bfa5183..96e9b6f00 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java @@ -8,6 +8,7 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.api.MaterialManager; +import com.jozufozu.flywheel.backend.instancing.ImmediateExecutor; import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; @@ -24,7 +25,7 @@ public class ContraptionInstanceManager extends TileInstanceManager { private final WeakReference contraption; ContraptionInstanceManager(RenderedContraption contraption, MaterialManager materialManager) { - super(materialManager); + super(ImmediateExecutor.INSTANCE, materialManager); this.contraption = new WeakReference<>(contraption); } From 5f46560fb2b00ab59b960557302d96a7368195ae Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 20 Dec 2021 22:38:34 -0800 Subject: [PATCH 3/7] StructType doesn't need #asBatched and #asInstanced - More organized this way - BatchingTransformer function moved into Batched --- .../contraptions/base/flwdata/BeltType.java | 44 +++++++++---------- .../base/flwdata/RotatingType.java | 25 +++++------ .../components/actors/flwdata/ActorType.java | 6 +-- .../logistics/block/flap/FlapType.java | 26 +++++------ .../simibubi/create/events/ClientEvents.java | 4 +- 5 files changed, 46 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java index 8e3a62a6b..5356f0306 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.contraptions.base.flwdata; import com.jozufozu.flywheel.api.struct.Batched; -import com.jozufozu.flywheel.api.struct.BatchingTransformer; import com.jozufozu.flywheel.api.struct.Instanced; import com.jozufozu.flywheel.api.struct.StructWriter; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; +import com.jozufozu.flywheel.core.model.ModelTransformer; import com.jozufozu.flywheel.util.RenderMath; import com.mojang.math.Quaternion; import com.simibubi.create.content.contraptions.KineticDebugger; @@ -13,7 +13,6 @@ import com.simibubi.create.foundation.render.AllInstanceFormats; import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.client.renderer.LightTexture; import net.minecraft.resources.ResourceLocation; public class BeltType implements Instanced, Batched { @@ -38,29 +37,26 @@ public class BeltType implements Instanced, Batched { } @Override - public BatchingTransformer getTransformer() { - return (d, sbb) -> { + public void transform(BeltData d, ModelTransformer.Params b) { + float spriteHeight = d.maxV - d.minV; + double scroll = d.rotationalSpeed * AnimationTickHolder.getRenderTime() / (31.5 * 16) + d.rotationOffset; + scroll = scroll - Math.floor(scroll); + scroll = scroll * spriteHeight * RenderMath.f(d.scrollMult); - float spriteHeight = d.maxV - d.minV; - double scroll = d.rotationalSpeed * AnimationTickHolder.getRenderTime() / (31.5 * 16) + d.rotationOffset; - scroll = scroll - Math.floor(scroll); - scroll = scroll * spriteHeight * RenderMath.f(d.scrollMult); + float finalScroll = (float) scroll; + b.shiftUV((builder, u, v) -> { + float targetU = u - d.sourceU + d.minU; + float targetV = v - d.sourceV + d.minV + + finalScroll; + builder.uv(targetU, targetV); + }); - float finalScroll = (float) scroll; - sbb.shiftUV((builder, u, v) -> { - float targetU = u - d.sourceU + d.minU; - float targetV = v - d.sourceV + d.minV - + finalScroll; - builder.uv(targetU, targetV); - }); - - sbb.translate(d.x + 0.5, d.y + 0.5, d.z + 0.5) - .multiply(new Quaternion(d.qX, d.qY, d.qZ, d.qW)) - .unCentre() - .light(d.getPackedLight()); - if (KineticDebugger.isActive()) { - sbb.color(d.r, d.g, d.b, d.a); - } - }; + b.translate(d.x + 0.5, d.y + 0.5, d.z + 0.5) + .multiply(new Quaternion(d.qX, d.qY, d.qZ, d.qW)) + .unCentre() + .light(d.getPackedLight()); + if (KineticDebugger.isActive()) { + b.color(d.r, d.g, d.b, d.a); + } } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java index 400afd94f..fd1f444b5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.contraptions.base.flwdata; import com.jozufozu.flywheel.api.struct.Batched; -import com.jozufozu.flywheel.api.struct.BatchingTransformer; import com.jozufozu.flywheel.api.struct.Instanced; import com.jozufozu.flywheel.api.struct.StructWriter; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; +import com.jozufozu.flywheel.core.model.ModelTransformer; import com.jozufozu.flywheel.util.RenderMath; import com.mojang.math.Vector3f; import com.simibubi.create.content.contraptions.KineticDebugger; @@ -13,7 +13,6 @@ import com.simibubi.create.foundation.render.AllInstanceFormats; import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.client.renderer.LightTexture; import net.minecraft.resources.ResourceLocation; public class RotatingType implements Instanced, Batched { @@ -38,19 +37,17 @@ public class RotatingType implements Instanced, Batched getTransformer() { - return (d, b) -> { - float angle = ((AnimationTickHolder.getRenderTime() * d.rotationalSpeed * 3f / 10 + d.rotationOffset) % 360); + public void transform(RotatingData d, ModelTransformer.Params b) { + float angle = ((AnimationTickHolder.getRenderTime() * d.rotationalSpeed * 3f / 10 + d.rotationOffset) % 360); - Vector3f axis = new Vector3f(RenderMath.f(d.rotationAxisX), RenderMath.f(d.rotationAxisY), RenderMath.f(d.rotationAxisZ)); - b.light(d.getPackedLight()) - .translate(d.x + 0.5, d.y + 0.5, d.z + 0.5) - .multiply(axis.rotationDegrees(angle)) - .unCentre(); + Vector3f axis = new Vector3f(RenderMath.f(d.rotationAxisX), RenderMath.f(d.rotationAxisY), RenderMath.f(d.rotationAxisZ)); + b.light(d.getPackedLight()) + .translate(d.x + 0.5, d.y + 0.5, d.z + 0.5) + .multiply(axis.rotationDegrees(angle)) + .unCentre(); - if (KineticDebugger.isActive()) { - b.color(d.r, d.g, d.b, d.a); - } - }; + if (KineticDebugger.isActive()) { + b.color(d.r, d.g, d.b, d.a); + } } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java index 5ff165d7c..8978472ae 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.contraptions.components.actors.flwdata; import com.jozufozu.flywheel.api.struct.Batched; -import com.jozufozu.flywheel.api.struct.BatchingTransformer; import com.jozufozu.flywheel.api.struct.Instanced; import com.jozufozu.flywheel.api.struct.StructWriter; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; +import com.jozufozu.flywheel.core.model.ModelTransformer; import com.simibubi.create.foundation.render.AllInstanceFormats; import com.simibubi.create.foundation.render.AllProgramSpecs; @@ -33,9 +33,7 @@ public class ActorType implements Instanced, Batched { } @Override - public BatchingTransformer getTransformer() { - return (d, sbb) -> { + public void transform(ActorData d, ModelTransformer.Params b) { - }; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java b/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java index 4d3a67b04..8eecc5662 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java @@ -1,16 +1,14 @@ package com.simibubi.create.content.logistics.block.flap; import com.jozufozu.flywheel.api.struct.Batched; -import com.jozufozu.flywheel.api.struct.BatchingTransformer; import com.jozufozu.flywheel.api.struct.Instanced; import com.jozufozu.flywheel.api.struct.StructWriter; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.mojang.math.Vector3f; +import com.jozufozu.flywheel.core.model.ModelTransformer; import com.simibubi.create.foundation.render.AllInstanceFormats; import com.simibubi.create.foundation.render.AllProgramSpecs; -import net.minecraft.client.renderer.LightTexture; import net.minecraft.resources.ResourceLocation; public class FlapType implements Instanced, Batched { @@ -35,18 +33,16 @@ public class FlapType implements Instanced, Batched { } @Override - public BatchingTransformer getTransformer() { - return (d, sbb) -> { - sbb.translate(d.x, d.y, d.z) - .centre() - .rotateY(-d.horizontalAngle) - .unCentre() - .translate(d.pivotX, d.pivotY, d.pivotZ) - .rotateX(getFlapAngle(d.flapness, d.intensity, d.flapScale)) - .translateBack(d.pivotX, d.pivotY, d.pivotZ) - .translate(d.segmentOffsetX, d.segmentOffsetY, d.segmentOffsetZ) - .light(d.getPackedLight()); - }; + public void transform(FlapData d, ModelTransformer.Params b) { + b.translate(d.x, d.y, d.z) + .centre() + .rotateY(-d.horizontalAngle) + .unCentre() + .translate(d.pivotX, d.pivotY, d.pivotZ) + .rotateX(getFlapAngle(d.flapness, d.intensity, d.flapScale)) + .translateBack(d.pivotX, d.pivotY, d.pivotZ) + .translate(d.segmentOffsetX, d.segmentOffsetY, d.segmentOffsetZ) + .light(d.getPackedLight()); } private static float getFlapAngle(float flapness, float intensity, float scale) { diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index ed817e63b..bbb796f35 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -283,9 +283,9 @@ public class ClientEvents { Level level = Minecraft.getInstance().level; BlockPos blockPos = info.getBlockPosition(); FluidState fluidstate = level.getFluidState(blockPos); - if (info.getPosition().y > blockPos.getY() + fluidstate.getHeight(level, blockPos)) + if (info.getPosition().y > blockPos.getY() + fluidstate.getHeight(level, blockPos)) return; - + Fluid fluid = fluidstate.getType(); if (fluid.isSame(AllFluids.CHOCOLATE.get())) { From aa96a28f0bc5c669736b8a32e25f9bc15b93eab3 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Tue, 21 Dec 2021 22:47:30 -0800 Subject: [PATCH 4/7] Make the BatchingEngine not jittery - Stop having threads compete for a single BufferBuilder - ...by skirting around minecraft's BufferSource - Begin work on making vertex writing sane --- .../structureMovement/glue/GlueInstance.java | 8 -------- .../render/FlwContraptionManager.java | 2 +- .../create/foundation/render/SuperByteBuffer.java | 12 ++++++------ 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java index 46a053521..cb4cf3e2f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java @@ -4,9 +4,7 @@ import com.jozufozu.flywheel.api.Instancer; import com.jozufozu.flywheel.api.MaterialGroup; import com.jozufozu.flywheel.api.MaterialManager; import com.jozufozu.flywheel.api.instance.ITickableInstance; -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance; -import com.jozufozu.flywheel.core.Formats; import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.instancing.ConditionalInstance; import com.jozufozu.flywheel.core.materials.oriented.OrientedData; @@ -103,7 +101,6 @@ public class GlueInstance extends EntityInstance implements ITi return "glue"; } - @Override public void buffer(VertexConsumer buffer) { Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal()); Vec3 extension = diff.normalize() @@ -162,11 +159,6 @@ public class GlueInstance extends EntityInstance implements ITi return 8; } - @Override - public VertexFormat format() { - return Formats.UNLIT_MODEL; - } - @Override public ModelReader getReader() { return this; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java index f4794fa75..a3b438224 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java @@ -62,7 +62,7 @@ public class FlwContraptionManager extends ContraptionRenderManager, Translate, Translate Date: Wed, 22 Dec 2021 00:22:43 -0800 Subject: [PATCH 5/7] util and core cleanup - Consolidate/audit utility classes - Move more towards sane vertex types --- .../structureMovement/Contraption.java | 10 +- .../structureMovement/ContraptionLighter.java | 4 +- .../NonStationaryLighter.java | 4 +- .../bearing/AnchoredLighter.java | 2 +- .../structureMovement/glue/GlueInstance.java | 152 +----------------- .../structureMovement/glue/GlueModel.java | 99 ++++++++++++ .../piston/PistonLighter.java | 2 +- .../pulley/AbstractPulleyInstance.java | 4 +- .../pulley/PulleyLighter.java | 2 +- .../render/EmptyLighter.java | 2 +- .../render/FlwContraptionManager.java | 4 +- .../relays/belt/BeltTileEntity.java | 4 +- .../foundation/render/AllInstanceFormats.java | 4 +- .../foundation/render/SuperByteBuffer.java | 8 +- 14 files changed, 126 insertions(+), 175 deletions(-) create mode 100644 src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueModel.java diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java index 66ad205e5..312afd33c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java @@ -25,8 +25,8 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; -import com.jozufozu.flywheel.light.GridAlignedBB; -import com.jozufozu.flywheel.light.ImmutableBox; +import com.jozufozu.flywheel.util.box.GridAlignedBB; +import com.jozufozu.flywheel.util.box.ImmutableBox; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllInteractionBehaviours; import com.simibubi.create.AllMovementBehaviours; @@ -874,9 +874,9 @@ public abstract class Contraption { } ListTag paletteNBT = new ListTag(); - for(int i = 0; i < palette.getSize(); ++i) + for(int i = 0; i < palette.getSize(); ++i) paletteNBT.add(NbtUtils.writeBlockState(palette.values.byId(i))); - + compound.put("Palette", paletteNBT); compound.put("BlockList", blockList); @@ -891,7 +891,7 @@ public abstract class Contraption { palette = new HashMapPalette<>(GameData.getBlockStateIDMap(), 16, (i, s) -> { throw new IllegalStateException("Palette Map index exceeded maximum"); }); - + ListTag list = c.getList("Palette", 10); palette.values.clear(); for (int i = 0; i < list.size(); ++i) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionLighter.java index 95ea67501..76ac67287 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionLighter.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement; import com.jozufozu.flywheel.light.GPULightVolume; -import com.jozufozu.flywheel.light.GridAlignedBB; -import com.jozufozu.flywheel.light.ImmutableBox; +import com.jozufozu.flywheel.util.box.GridAlignedBB; +import com.jozufozu.flywheel.util.box.ImmutableBox; import com.jozufozu.flywheel.light.LightListener; import com.jozufozu.flywheel.light.LightProvider; import com.jozufozu.flywheel.light.LightUpdater; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java index 363cd4afa..1e0cd0d8a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement; -import com.jozufozu.flywheel.light.GridAlignedBB; -import com.jozufozu.flywheel.light.ImmutableBox; +import com.jozufozu.flywheel.util.box.GridAlignedBB; +import com.jozufozu.flywheel.util.box.ImmutableBox; import com.jozufozu.flywheel.light.LightProvider; import com.jozufozu.flywheel.light.MovingListener; import com.simibubi.create.foundation.config.AllConfigs; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/AnchoredLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/AnchoredLighter.java index 16bd4e82a..1f2a06669 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/AnchoredLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/AnchoredLighter.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.bearing; -import com.jozufozu.flywheel.light.GridAlignedBB; +import com.jozufozu.flywheel.util.box.GridAlignedBB; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java index cb4cf3e2f..dd7c8c3d1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java @@ -8,29 +8,21 @@ import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance; import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.instancing.ConditionalInstance; import com.jozufozu.flywheel.core.materials.oriented.OrientedData; -import com.jozufozu.flywheel.core.model.Model; -import com.jozufozu.flywheel.util.ModelReader; -import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Quaternion; import com.simibubi.create.AllItems; -import com.simibubi.create.AllStitchedTextures; import com.simibubi.create.Create; import com.simibubi.create.foundation.utility.AngleHelper; -import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.LightLayer; -import net.minecraft.world.phys.Vec3; public class GlueInstance extends EntityInstance implements ITickableInstance { - private static final boolean USE_ATLAS = false; private static final ResourceLocation TEXTURE = Create.asResource("textures/entity/super_glue/slime.png"); private final Quaternion rotation; @@ -51,9 +43,9 @@ public class GlueInstance extends EntityInstance implements ITi } private Instancer getInstancer(MaterialManager materialManager, SuperGlueEntity entity) { - MaterialGroup group = USE_ATLAS ? materialManager.defaultCutout() : materialManager.cutout(RenderType.entityCutout(TEXTURE)); + MaterialGroup group = GlueModel.USE_ATLAS ? materialManager.defaultCutout() : materialManager.cutout(RenderType.entityCutout(TEXTURE)); - return group.material(Materials.ORIENTED).model(entity.getType(), GlueModel::new); + return group.material(Materials.ORIENTED).model(entity.getType(), GlueModel::get); } @Override @@ -94,144 +86,4 @@ public class GlueInstance extends EntityInstance implements ITi || AllItems.SUPER_GLUE.isIn(player.getOffhandItem()); } - public static class GlueModel implements Model, ModelReader { - - @Override - public String name() { - return "glue"; - } - - public void buffer(VertexConsumer buffer) { - Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal()); - Vec3 extension = diff.normalize() - .scale(1 / 32f - 1 / 128f); - - Vec3 plane = VecHelper.axisAlingedPlaneOf(diff); - Direction.Axis axis = Direction.getNearest(diff.x, diff.y, diff.z) - .getAxis(); - - Vec3 start = Vec3.ZERO.subtract(extension); - Vec3 end = Vec3.ZERO.add(extension); - - plane = plane.scale(1 / 2f); - Vec3 a1 = plane.add(start); - Vec3 b1 = plane.add(end); - plane = VecHelper.rotate(plane, -90, axis); - Vec3 a2 = plane.add(start); - Vec3 b2 = plane.add(end); - plane = VecHelper.rotate(plane, -90, axis); - Vec3 a3 = plane.add(start); - Vec3 b3 = plane.add(end); - plane = VecHelper.rotate(plane, -90, axis); - Vec3 a4 = plane.add(start); - Vec3 b4 = plane.add(end); - - float minU; - float maxU; - float minV; - float maxV; - - if (USE_ATLAS) { - TextureAtlasSprite sprite = AllStitchedTextures.SUPER_GLUE.get(); - minU = sprite.getU0(); - maxU = sprite.getU1(); - minV = sprite.getV0(); - maxV = sprite.getV1(); - } else { - minU = minV = 0; - maxU = maxV = 1; - } - - // inside quad - buffer.vertex(a1.x, a1.y, a1.z).normal(0, 0, -1f).uv(maxU, minV).endVertex(); - buffer.vertex(a2.x, a2.y, a2.z).normal(0, 0, -1f).uv(maxU, maxV).endVertex(); - buffer.vertex(a3.x, a3.y, a3.z).normal(0, 0, -1f).uv(minU, maxV).endVertex(); - buffer.vertex(a4.x, a4.y, a4.z).normal(0, 0, -1f).uv(minU, minV).endVertex(); - // outside quad - buffer.vertex(b4.x, b4.y, b4.z).normal(0, 0, 1f).uv(minU, minV).endVertex(); - buffer.vertex(b3.x, b3.y, b3.z).normal(0, 0, 1f).uv(minU, maxV).endVertex(); - buffer.vertex(b2.x, b2.y, b2.z).normal(0, 0, 1f).uv(maxU, maxV).endVertex(); - buffer.vertex(b1.x, b1.y, b1.z).normal(0, 0, 1f).uv(maxU, minV).endVertex(); - } - - @Override - public int vertexCount() { - return 8; - } - - @Override - public ModelReader getReader() { - return this; - } - - @Override - public int getVertexCount() { - return 8; - } - - @Override - public float getX(int index) { - return 0; - } - - @Override - public float getY(int index) { - return 0; - } - - @Override - public float getZ(int index) { - return 0; - } - - @Override - public byte getR(int index) { - return (byte) 0xFF; - } - - @Override - public byte getG(int index) { - return (byte) 0xFF; - } - - @Override - public byte getB(int index) { - return (byte) 0xFF; - } - - @Override - public byte getA(int index) { - return (byte) 0xFF; - } - - @Override - public float getU(int index) { - return 0; - } - - @Override - public float getV(int index) { - return 0; - } - - @Override - public int getLight(int index) { - return 0; - } - - @Override - public float getNX(int index) { - return 0; - } - - @Override - public float getNY(int index) { - return 0; - } - - @Override - public float getNZ(int index) { - return index > 4 ? -1 : 1; - } - } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueModel.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueModel.java new file mode 100644 index 000000000..c5530c8b1 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueModel.java @@ -0,0 +1,99 @@ +package com.simibubi.create.content.contraptions.components.structureMovement.glue; + +import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.core.vertex.PosTexNormalVertexListUnsafe; +import com.jozufozu.flywheel.core.vertex.PosTexNormalWriter; +import com.jozufozu.flywheel.core.vertex.VertexList; +import com.mojang.blaze3d.platform.MemoryTracker; +import com.simibubi.create.AllStitchedTextures; +import com.simibubi.create.foundation.utility.VecHelper; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.Vec3; + +public class GlueModel implements Model { + + public static final GlueModel INSTANCE = new GlueModel(); + static final boolean USE_ATLAS = false; + + public static GlueModel get() { + return INSTANCE; + } + + private final PosTexNormalVertexListUnsafe reader; + + private GlueModel() { + PosTexNormalWriter writer = new PosTexNormalWriter(MemoryTracker.create(size())); + createGlueModel(writer); + reader = writer.intoReader(); + } + + @Override + public String name() { + return "glue"; + } + + @Override + public int vertexCount() { + return 8; + } + + @Override + public VertexList getReader() { + return reader; + } + + public static void createGlueModel(PosTexNormalWriter buffer) { + Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal()); + Vec3 extension = diff.normalize() + .scale(1 / 32f - 1 / 128f); + + Vec3 plane = VecHelper.axisAlingedPlaneOf(diff); + Direction.Axis axis = Direction.getNearest(diff.x, diff.y, diff.z) + .getAxis(); + + Vec3 start = Vec3.ZERO.subtract(extension); + Vec3 end = Vec3.ZERO.add(extension); + + plane = plane.scale(1 / 2f); + Vec3 a1 = plane.add(start); + Vec3 b1 = plane.add(end); + plane = VecHelper.rotate(plane, -90, axis); + Vec3 a2 = plane.add(start); + Vec3 b2 = plane.add(end); + plane = VecHelper.rotate(plane, -90, axis); + Vec3 a3 = plane.add(start); + Vec3 b3 = plane.add(end); + plane = VecHelper.rotate(plane, -90, axis); + Vec3 a4 = plane.add(start); + Vec3 b4 = plane.add(end); + + float minU; + float maxU; + float minV; + float maxV; + + if (USE_ATLAS) { + TextureAtlasSprite sprite = AllStitchedTextures.SUPER_GLUE.get(); + minU = sprite.getU0(); + maxU = sprite.getU1(); + minV = sprite.getV0(); + maxV = sprite.getV1(); + } else { + minU = minV = 0; + maxU = maxV = 1; + } + + // inside quad + buffer.putVertex((float) a1.x, (float) a1.y, (float) a1.z, 0, 0, -1, maxU, minV); + buffer.putVertex((float) a2.x, (float) a2.y, (float) a2.z, 0, 0, -1, maxU, maxV); + buffer.putVertex((float) a3.x, (float) a3.y, (float) a3.z, 0, 0, -1, minU, maxV); + buffer.putVertex((float) a4.x, (float) a4.y, (float) a4.z, 0, 0, -1, minU, minV); + // outside quad + buffer.putVertex((float) b4.x, (float) b4.y, (float) b4.z, 0, 0, 1f, minU, minV); + buffer.putVertex((float) b3.x, (float) b3.y, (float) b3.z, 0, 0, 1f, minU, maxV); + buffer.putVertex((float) b2.x, (float) b2.y, (float) b2.z, 0, 0, 1f, maxU, maxV); + buffer.putVertex((float) b1.x, (float) b1.y, (float) b1.z, 0, 0, 1f, maxU, minV); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonLighter.java index 2072a657f..5d834de18 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonLighter.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.piston; -import com.jozufozu.flywheel.light.GridAlignedBB; +import com.jozufozu.flywheel.util.box.GridAlignedBB; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; import net.minecraft.core.Vec3i; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java index 8906a5ab0..f4c600ebf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java @@ -7,8 +7,8 @@ import com.jozufozu.flywheel.core.instancing.ConditionalInstance; import com.jozufozu.flywheel.core.instancing.GroupInstance; import com.jozufozu.flywheel.core.instancing.SelectInstance; import com.jozufozu.flywheel.core.materials.oriented.OrientedData; -import com.jozufozu.flywheel.light.GridAlignedBB; -import com.jozufozu.flywheel.light.ImmutableBox; +import com.jozufozu.flywheel.util.box.GridAlignedBB; +import com.jozufozu.flywheel.util.box.ImmutableBox; import com.jozufozu.flywheel.light.LightPacking; import com.jozufozu.flywheel.light.LightProvider; import com.jozufozu.flywheel.light.LightUpdater; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java index b959b2ca4..2a1faf43c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pulley; -import com.jozufozu.flywheel.light.GridAlignedBB; +import com.jozufozu.flywheel.util.box.GridAlignedBB; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/EmptyLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/EmptyLighter.java index da4a5384b..c922a2ccd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/EmptyLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/EmptyLighter.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; -import com.jozufozu.flywheel.light.GridAlignedBB; +import com.jozufozu.flywheel.util.box.GridAlignedBB; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java index a3b438224..e6376222b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java @@ -8,7 +8,7 @@ import com.jozufozu.flywheel.backend.RenderLayer; import com.jozufozu.flywheel.backend.gl.GlTextureUnit; import com.jozufozu.flywheel.backend.gl.GlVertexArray; import com.jozufozu.flywheel.event.RenderLayerEvent; -import com.jozufozu.flywheel.util.TextureBinder; +import com.jozufozu.flywheel.util.Textures; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.render.CreateContexts; @@ -44,7 +44,7 @@ public class FlwContraptionManager extends ContraptionRenderManager, Translate, Rotate, TStack { - private final ModelReader template; + private final VertexList template; // Vertex Position private final PoseStack transforms; @@ -64,7 +64,7 @@ public class SuperByteBuffer implements Scale, Translate Date: Wed, 22 Dec 2021 02:45:46 -0800 Subject: [PATCH 6/7] Finally safe vertex formats - true to false for Pepper - IBufferedModel -> BufferedModel - VertexFormat -> BufferLayout - Use ImmutableList in BufferLayout - LayoutItem naming consistency - Try to reduce usage of raw BufferLayouts - Move vertex interfaces to api package - #createWriter and #createReader in VertexType - Some documentation --- .../contraptions/base/flwdata/BeltType.java | 6 ++-- ...eBeltWriter.java => BeltWriterUnsafe.java} | 4 +-- ...icWriter.java => KineticWriterUnsafe.java} | 6 ++-- .../base/flwdata/RotatingType.java | 6 ++-- ...gWriter.java => RotatingWriterUnsafe.java} | 4 +-- .../components/actors/flwdata/ActorType.java | 4 +-- .../structureMovement/glue/GlueModel.java | 12 +++---- .../logistics/block/flap/FlapType.java | 4 +-- .../foundation/render/AllInstanceFormats.java | 36 +++++++++---------- .../foundation/render/SuperByteBuffer.java | 2 +- .../shaders/contraption_structure.vert | 4 +-- 11 files changed, 44 insertions(+), 44 deletions(-) rename src/main/java/com/simibubi/create/content/contraptions/base/flwdata/{UnsafeBeltWriter.java => BeltWriterUnsafe.java} (87%) rename src/main/java/com/simibubi/create/content/contraptions/base/flwdata/{UnsafeKineticWriter.java => KineticWriterUnsafe.java} (73%) rename src/main/java/com/simibubi/create/content/contraptions/base/flwdata/{UnsafeRotatingWriter.java => RotatingWriterUnsafe.java} (81%) diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java index 5356f0306..2a1e7ae85 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.base.flwdata; import com.jozufozu.flywheel.api.struct.Batched; import com.jozufozu.flywheel.api.struct.Instanced; import com.jozufozu.flywheel.api.struct.StructWriter; -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.core.layout.BufferLayout; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.core.model.ModelTransformer; import com.jozufozu.flywheel.util.RenderMath; @@ -22,13 +22,13 @@ public class BeltType implements Instanced, Batched { } @Override - public VertexFormat format() { + public BufferLayout getLayout() { return AllInstanceFormats.BELT; } @Override public StructWriter getWriter(VecBuffer backing) { - return new UnsafeBeltWriter(backing, this); + return new BeltWriterUnsafe(backing, this); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeBeltWriter.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltWriterUnsafe.java similarity index 87% rename from src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeBeltWriter.java rename to src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltWriterUnsafe.java index 59ba5203f..1cf570be5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeBeltWriter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltWriterUnsafe.java @@ -5,8 +5,8 @@ import org.lwjgl.system.MemoryUtil; import com.jozufozu.flywheel.api.struct.StructType; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -public class UnsafeBeltWriter extends UnsafeKineticWriter { - public UnsafeBeltWriter(VecBuffer backingBuffer, StructType vertexType) { +public class BeltWriterUnsafe extends KineticWriterUnsafe { + public BeltWriterUnsafe(VecBuffer backingBuffer, StructType vertexType) { super(backingBuffer, vertexType); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeKineticWriter.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/KineticWriterUnsafe.java similarity index 73% rename from src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeKineticWriter.java rename to src/main/java/com/simibubi/create/content/contraptions/base/flwdata/KineticWriterUnsafe.java index f6fbeebfc..d450b1d6a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeKineticWriter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/KineticWriterUnsafe.java @@ -4,10 +4,10 @@ import org.lwjgl.system.MemoryUtil; import com.jozufozu.flywheel.api.struct.StructType; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -import com.jozufozu.flywheel.core.materials.UnsafeBasicWriter; +import com.jozufozu.flywheel.core.materials.BasicWriterUnsafe; -public abstract class UnsafeKineticWriter extends UnsafeBasicWriter { - public UnsafeKineticWriter(VecBuffer backingBuffer, StructType vertexType) { +public abstract class KineticWriterUnsafe extends BasicWriterUnsafe { + public KineticWriterUnsafe(VecBuffer backingBuffer, StructType vertexType) { super(backingBuffer, vertexType); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java index fd1f444b5..84e8f5d9a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.base.flwdata; import com.jozufozu.flywheel.api.struct.Batched; import com.jozufozu.flywheel.api.struct.Instanced; import com.jozufozu.flywheel.api.struct.StructWriter; -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.core.layout.BufferLayout; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.core.model.ModelTransformer; import com.jozufozu.flywheel.util.RenderMath; @@ -22,13 +22,13 @@ public class RotatingType implements Instanced, Batched getWriter(VecBuffer backing) { - return new UnsafeRotatingWriter(backing, this); + return new RotatingWriterUnsafe(backing, this); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeRotatingWriter.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingWriterUnsafe.java similarity index 81% rename from src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeRotatingWriter.java rename to src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingWriterUnsafe.java index b477c8e20..b57e21d2a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeRotatingWriter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingWriterUnsafe.java @@ -5,8 +5,8 @@ import org.lwjgl.system.MemoryUtil; import com.jozufozu.flywheel.api.struct.StructType; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; -public class UnsafeRotatingWriter extends UnsafeKineticWriter { - public UnsafeRotatingWriter(VecBuffer backingBuffer, StructType vertexType) { +public class RotatingWriterUnsafe extends KineticWriterUnsafe { + public RotatingWriterUnsafe(VecBuffer backingBuffer, StructType vertexType) { super(backingBuffer, vertexType); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java index 8978472ae..ad55be8cc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.actors.flwdata; import com.jozufozu.flywheel.api.struct.Batched; import com.jozufozu.flywheel.api.struct.Instanced; import com.jozufozu.flywheel.api.struct.StructWriter; -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.core.layout.BufferLayout; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.core.model.ModelTransformer; import com.simibubi.create.foundation.render.AllInstanceFormats; @@ -18,7 +18,7 @@ public class ActorType implements Instanced, Batched { } @Override - public VertexFormat format() { + public BufferLayout getLayout() { return AllInstanceFormats.ACTOR; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueModel.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueModel.java index c5530c8b1..0c8cd46df 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueModel.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.contraptions.components.structureMovement.glue; +import com.jozufozu.flywheel.core.Formats; import com.jozufozu.flywheel.core.model.Model; -import com.jozufozu.flywheel.core.vertex.PosTexNormalVertexListUnsafe; -import com.jozufozu.flywheel.core.vertex.PosTexNormalWriter; -import com.jozufozu.flywheel.core.vertex.VertexList; +import com.jozufozu.flywheel.core.vertex.PosTexNormalWriterUnsafe; +import com.jozufozu.flywheel.api.vertex.VertexList; import com.mojang.blaze3d.platform.MemoryTracker; import com.simibubi.create.AllStitchedTextures; import com.simibubi.create.foundation.utility.VecHelper; @@ -21,10 +21,10 @@ public class GlueModel implements Model { return INSTANCE; } - private final PosTexNormalVertexListUnsafe reader; + private final VertexList reader; private GlueModel() { - PosTexNormalWriter writer = new PosTexNormalWriter(MemoryTracker.create(size())); + PosTexNormalWriterUnsafe writer = Formats.POS_TEX_NORMAL.createWriter(MemoryTracker.create(size())); createGlueModel(writer); reader = writer.intoReader(); } @@ -44,7 +44,7 @@ public class GlueModel implements Model { return reader; } - public static void createGlueModel(PosTexNormalWriter buffer) { + public static void createGlueModel(PosTexNormalWriterUnsafe buffer) { Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal()); Vec3 extension = diff.normalize() .scale(1 / 32f - 1 / 128f); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java b/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java index 8eecc5662..5e1696ad9 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.logistics.block.flap; import com.jozufozu.flywheel.api.struct.Batched; import com.jozufozu.flywheel.api.struct.Instanced; import com.jozufozu.flywheel.api.struct.StructWriter; -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.core.layout.BufferLayout; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.core.model.ModelTransformer; import com.simibubi.create.foundation.render.AllInstanceFormats; @@ -18,7 +18,7 @@ public class FlapType implements Instanced, Batched { } @Override - public VertexFormat format() { + public BufferLayout getLayout() { return AllInstanceFormats.FLAP; } diff --git a/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java b/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java index e0ecfaefa..95a76206c 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java @@ -1,33 +1,33 @@ package com.simibubi.create.foundation.render; -import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.core.layout.CommonItems; +import com.jozufozu.flywheel.core.layout.BufferLayout; public class AllInstanceFormats { - public static VertexFormat ROTATING = kineticInstance() - .addAttributes(CommonAttributes.NORMAL) + public static BufferLayout ROTATING = kineticInstance() + .addItems(CommonItems.NORMAL) .build(); - public static VertexFormat BELT = kineticInstance() - .addAttributes(CommonAttributes.QUATERNION, CommonAttributes.UV, CommonAttributes.VEC4, - CommonAttributes.NORMALIZED_BYTE) + public static BufferLayout BELT = kineticInstance() + .addItems(CommonItems.QUATERNION, CommonItems.UV, CommonItems.VEC4, + CommonItems.NORMALIZED_BYTE) .build(); - public static VertexFormat ACTOR = VertexFormat.builder() - .addAttributes(CommonAttributes.VEC3, CommonAttributes.LIGHT, CommonAttributes.FLOAT, - CommonAttributes.NORMAL, CommonAttributes.QUATERNION, CommonAttributes.NORMAL, - CommonAttributes.FLOAT) + public static BufferLayout ACTOR = BufferLayout.builder() + .addItems(CommonItems.VEC3, CommonItems.LIGHT, CommonItems.FLOAT, + CommonItems.NORMAL, CommonItems.QUATERNION, CommonItems.NORMAL, + CommonItems.FLOAT) .build(); - public static VertexFormat FLAP = VertexFormat.builder() - .addAttributes(CommonAttributes.VEC3, CommonAttributes.LIGHT, CommonAttributes.VEC3, CommonAttributes.VEC3, - CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT) + public static BufferLayout FLAP = BufferLayout.builder() + .addItems(CommonItems.VEC3, CommonItems.LIGHT, CommonItems.VEC3, CommonItems.VEC3, + CommonItems.FLOAT, CommonItems.FLOAT, CommonItems.FLOAT, CommonItems.FLOAT) .build(); - private static VertexFormat.Builder kineticInstance() { - return VertexFormat.builder() - .addAttributes(CommonAttributes.LIGHT, CommonAttributes.RGBA) - .addAttributes(CommonAttributes.VEC3, CommonAttributes.FLOAT, CommonAttributes.FLOAT); + private static BufferLayout.Builder kineticInstance() { + return BufferLayout.builder() + .addItems(CommonItems.LIGHT, CommonItems.RGBA) + .addItems(CommonItems.VEC3, CommonItems.FLOAT, CommonItems.FLOAT); } } diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java index b06ee41ae..a8628aa59 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.render; import com.jozufozu.flywheel.core.vertex.BlockVertexList; -import com.jozufozu.flywheel.core.vertex.VertexList; +import com.jozufozu.flywheel.api.vertex.VertexList; import com.jozufozu.flywheel.util.transform.Rotate; import com.jozufozu.flywheel.util.transform.Scale; import com.jozufozu.flywheel.util.transform.TStack; diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert index 66db67682..2460a76fc 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert @@ -5,10 +5,10 @@ struct Vertex { vec3 pos; - vec3 normal; - vec2 texCoords; vec4 color; + vec2 texCoords; vec2 modelLight; + vec3 normal; }; #use "flywheel:block.frag" From 748c25b3eccbb204d4059aebc6283e1d9b825b8f Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Wed, 22 Dec 2021 21:35:49 -0800 Subject: [PATCH 7/7] Better config/backend to account for multiple engines - Rename probably too many things - Needs to be tested with Optifine --- .../contraptions/base/KineticTileEntityRenderer.java | 4 ++-- .../components/actors/DrillMovementBehaviour.java | 2 +- .../components/actors/HarvesterMovementBehaviour.java | 3 +-- .../components/crafter/MechanicalCrafterRenderer.java | 3 +-- .../components/crank/HandCrankRenderer.java | 2 +- .../deployer/DeployerMovementBehaviour.java | 2 +- .../components/deployer/DeployerRenderer.java | 8 ++++---- .../components/fan/EncasedFanRenderer.java | 2 +- .../components/flywheel/FlywheelRenderer.java | 2 +- .../components/flywheel/engine/EngineRenderer.java | 2 +- .../components/mixer/MechanicalMixerRenderer.java | 2 +- .../components/press/MechanicalPressRenderer.java | 2 +- .../contraptions/components/saw/SawRenderer.java | 3 +-- .../structureMovement/bearing/BearingRenderer.java | 2 +- .../bearing/StabilizedBearingMovementBehaviour.java | 2 +- .../structureMovement/chassis/StickerRenderer.java | 2 +- .../gantry/GantryCarriageRenderer.java | 2 +- .../pulley/AbstractPulleyRenderer.java | 3 +-- .../render/ContraptionRenderDispatcher.java | 2 +- .../render/FlwContraptionManager.java | 2 +- .../structureMovement/render/RenderedContraption.java | 2 +- .../contraptions/fluids/pipes/FluidValveRenderer.java | 2 +- .../relays/advanced/SpeedControllerRenderer.java | 2 +- .../contraptions/relays/belt/BeltRenderer.java | 2 +- .../elementary/BracketedKineticTileInstance.java | 11 ++++++----- .../elementary/BracketedKineticTileRenderer.java | 3 +-- .../relays/encased/EncasedCogRenderer.java | 3 +-- .../relays/encased/SplitShaftRenderer.java | 2 +- .../contraptions/relays/gauge/GaugeRenderer.java | 2 +- .../contraptions/relays/gearbox/GearboxRenderer.java | 2 +- .../block/belts/tunnel/BeltTunnelRenderer.java | 2 +- .../logistics/block/depot/EjectorRenderer.java | 2 +- .../logistics/block/funnel/FunnelRenderer.java | 2 +- .../logistics/block/mechanicalArm/ArmRenderer.java | 2 +- .../logistics/block/redstone/AnalogLeverRenderer.java | 2 +- .../schematics/block/SchematicannonRenderer.java | 3 +-- .../foundation/render/TileEntityRenderHelper.java | 2 +- .../renderer/ColoredOverlayTileEntityRenderer.java | 2 +- 38 files changed, 47 insertions(+), 53 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java index fdae33fc3..eb287ad25 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java @@ -38,7 +38,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer renderItem(te, partialTicks, ms, buffer, light, overlay); FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay); - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; renderComponents(te, partialTicks, ms, buffer, light, overlay); } @@ -113,7 +113,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer protected void renderComponents(DeployerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { VertexConsumer vb = buffer.getBuffer(RenderType.solid()); - if (!Backend.getInstance().canUseInstancing(te.getLevel())) { + if (!Backend.canUseInstancing(te.getLevel())) { KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb, light); } @@ -193,10 +193,10 @@ public class DeployerRenderer extends SafeTileEntityRenderer IRotate def = (IRotate) context.state.getBlock(); axis = def.getRotationAxis(context.state); } - + float time = AnimationTickHolder.getRenderTime(context.world) / 20; float angle = (time * speed) % 360; - + new MatrixTransformStack(m) .centre() .rotateY(axis == Axis.Z ? 90 : 0) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java index 274f95237..73b918fa7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java @@ -28,7 +28,7 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer { @Override protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; Direction direction = te.getBlockState() .getValue(FACING); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java index c816de46d..0b11588ba 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java @@ -36,7 +36,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; BlockState blockState = te.getBlockState(); FlywheelTileEntity wte = (FlywheelTileEntity) te; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java index 1c9c904bd..64984443a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java @@ -22,7 +22,7 @@ public class EngineRenderer extends SafeTileEntityRe protected void renderSafe(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; Block block = te.getBlockState() .getBlock(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java index 83d05442f..ec59b2037 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java @@ -31,7 +31,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer { protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; BlockState blockState = te.getBlockState(); MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java index 5523a7b2e..43e315100 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java @@ -31,7 +31,7 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; BlockState blockState = te.getBlockState(); float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index 149be2e09..5896963ab 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -46,8 +46,7 @@ public class SawRenderer extends SafeTileEntityRenderer { renderItems(te, partialTicks, ms, buffer, light, overlay); FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay); - if (Backend.getInstance() - .canUseInstancing(te.getLevel())) + if (Backend.canUseInstancing(te.getLevel())) return; renderShaft(te, ms, buffer, light, overlay); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java index b3961f558..ed76b3d05 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java @@ -26,7 +26,7 @@ public class BearingRenderer extends KineticTileEntityRenderer { protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; super.renderSafe(te, partialTicks, ms, buffer, light, overlay); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java index f00e600f3..91735760f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java @@ -34,7 +34,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { @OnlyIn(Dist.CLIENT) public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffer) { - if (Backend.getInstance().canUseInstancing()) return; + if (Backend.isOn()) return; Direction facing = context.state.getValue(BlockStateProperties.FACING); PartialModel top = AllBlockPartials.BEARING_TOP; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java index f4c3c8c27..cfb6a1d0e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java @@ -25,7 +25,7 @@ public class StickerRenderer extends SafeTileEntityRenderer { protected void renderSafe(StickerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; BlockState state = te.getBlockState(); SuperByteBuffer head = CachedBufferer.partial(AllBlockPartials.STICKER_HEAD, state); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java index 9e52ea3ea..6e3e6fd44 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java @@ -31,7 +31,7 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; BlockState state = te.getBlockState(); Direction facing = state.getValue(GantryCarriageBlock.FACING); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java index f60c903ab..dfa6dcd0c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java @@ -44,8 +44,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.getInstance() - .canUseInstancing(te.getLevel())) + if (Backend.canUseInstancing(te.getLevel())) return; super.renderSafe(te, partialTicks, ms, buffer, light, overlay); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 59ef2e7eb..c6ae0310d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -178,7 +178,7 @@ public class ContraptionRenderDispatcher { public static void reset() { WORLDS.empty(ContraptionRenderManager::delete); - if (Backend.getInstance().available()) { + if (Backend.isOn()) { WORLDS = new WorldAttached<>(FlwContraptionManager::new); } else { WORLDS = new WorldAttached<>(SBBContraptionManager::new); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java index e6376222b..f2c9c8ee1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java @@ -58,7 +58,7 @@ public class FlwContraptionManager extends ContraptionRenderManager { protected void renderSafe(BeltTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (!Backend.getInstance().canUseInstancing(te.getLevel())) { + if (!Backend.canUseInstancing(te.getLevel())) { BlockState blockState = te.getBlockState(); if (!AllBlocks.BELT.has(blockState)) return; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileInstance.java index 7733d54e7..127addf7f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileInstance.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.relays.elementary; import com.jozufozu.flywheel.api.Instancer; import com.jozufozu.flywheel.api.MaterialManager; -import com.jozufozu.flywheel.util.transform.MatrixTransformStack; +import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Vector3f; import com.simibubi.create.AllBlockPartials; @@ -59,10 +59,11 @@ public class BracketedKineticTileInstance extends SingleRotatingInstance { private PoseStack rotateToAxis(Axis axis) { Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE); PoseStack poseStack = new PoseStack(); - new MatrixTransformStack(poseStack).centre() - .rotateToFace(facing) - .multiply(Vector3f.XN.rotationDegrees(-90)) - .unCentre(); + TransformStack.cast(poseStack) + .centre() + .rotateToFace(facing) + .multiply(Vector3f.XN.rotationDegrees(-90)) + .unCentre(); return poseStack; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileRenderer.java index f8f5754a1..8e0e86660 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileRenderer.java @@ -28,8 +28,7 @@ public class BracketedKineticTileRenderer extends KineticTileEntityRenderer { protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.getInstance() - .canUseInstancing(te.getLevel())) + if (Backend.canUseInstancing(te.getLevel())) return; if (!AllBlocks.LARGE_COGWHEEL.has(te.getBlockState())) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCogRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCogRenderer.java index b7f423b22..12f83e86e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCogRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCogRenderer.java @@ -39,8 +39,7 @@ public class EncasedCogRenderer extends KineticTileEntityRenderer { protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (Backend.getInstance() - .canUseInstancing(te.getLevel())) + if (Backend.canUseInstancing(te.getLevel())) return; BlockState blockState = te.getBlockState(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java index dd7dce660..ba38d1481 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java @@ -28,7 +28,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer { @Override protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; Block block = te.getBlockState().getBlock(); final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java index ce495f0bd..a5872e8b3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java @@ -39,7 +39,7 @@ public class GaugeRenderer extends KineticTileEntityRenderer { @Override protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; super.renderSafe(te, partialTicks, ms, buffer, light, overlay); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java index 56194ec81..04671bcad 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java @@ -27,7 +27,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer { @Override protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; final Axis boxAxis = te.getBlockState().getValue(BlockStateProperties.AXIS); final BlockPos pos = te.getBlockPos(); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java index 708853df2..f5f137b2b 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java @@ -31,7 +31,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (!te.hasFlap() || Backend.getInstance().canUseInstancing(te.getLevel())) + if (!te.hasFlap() || Backend.canUseInstancing(te.getLevel())) return; BlockState blockState = te.getBlockState(); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java index aa513be83..42fb0e55f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java @@ -44,7 +44,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { ArmTileEntity arm = (ArmTileEntity) te; ItemStack item = arm.heldItem; boolean hasItem = !item.isEmpty(); - boolean usingFlywheel = Backend.getInstance().canUseInstancing(te.getLevel()); + boolean usingFlywheel = Backend.canUseInstancing(te.getLevel()); if (usingFlywheel && !hasItem) return; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java index 481e3dda7..2d6026c16 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java @@ -26,7 +26,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer iterator = customRenderTEs.iterator(); while (iterator.hasNext()) { BlockEntity tileEntity = iterator.next(); - if (Backend.getInstance().canUseInstancing(renderWorld) && InstancedRenderRegistry.getInstance() + if (Backend.canUseInstancing(renderWorld) && InstancedRenderRegistry.getInstance() .shouldSkipRender(tileEntity)) continue; BlockEntityRenderer renderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(tileEntity); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java index 310bbeb6e..8ba1894ac 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java @@ -18,7 +18,7 @@ public abstract class ColoredOverlayTileEntityRenderer ex protected void renderSafe(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { - if (Backend.getInstance().canUseInstancing(te.getLevel())) return; + if (Backend.canUseInstancing(te.getLevel())) return; SuperByteBuffer render = render(getOverlayBuffer(te), getColor(te, partialTicks), light); render.renderInto(ms, buffer.getBuffer(RenderType.solid()));