From effc39cefd671cbec6a834cf8d27d6ea2bb61724 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Thu, 6 Jun 2024 18:37:43 -0400 Subject: [PATCH] the wheel is gone --- .../flywheel/lib/model/part/VertexWriter.java | 19 ------------------- .../impl/mixin/LevelRendererMixin.java | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/common/src/lib/java/dev/engine_room/flywheel/lib/model/part/VertexWriter.java b/common/src/lib/java/dev/engine_room/flywheel/lib/model/part/VertexWriter.java index 9c7bafed6..fddde36ad 100644 --- a/common/src/lib/java/dev/engine_room/flywheel/lib/model/part/VertexWriter.java +++ b/common/src/lib/java/dev/engine_room/flywheel/lib/model/part/VertexWriter.java @@ -93,25 +93,6 @@ public VertexConsumer setNormal(float x, float y, float z) { return this; } - public VertexConsumer endVertex() { - if (!filledPosition || !filledTexture || !filledNormal) { - throw new IllegalStateException("Not filled all elements of the vertex"); - } - - filledPosition = false; - filledTexture = false; - filledNormal = false; - vertexCount++; - - long byteSize = (vertexCount + 1) * STRIDE; - long capacity = data.size(); - if (byteSize > capacity) { - data = data.realloc(capacity * 2); - } - - return this; - } - private long vertexPtr() { return data.ptr() + vertexCount * STRIDE; } diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/LevelRendererMixin.java b/common/src/main/java/dev/engine_room/flywheel/impl/mixin/LevelRendererMixin.java index 40d14e3be..5b2df6980 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/LevelRendererMixin.java +++ b/common/src/main/java/dev/engine_room/flywheel/impl/mixin/LevelRendererMixin.java @@ -2,6 +2,10 @@ import java.util.SortedSet; +import com.llamalad7.mixinextras.sugar.Share; + +import com.llamalad7.mixinextras.sugar.ref.LocalRef; + import net.minecraft.client.DeltaTracker; import org.jetbrains.annotations.Nullable; @@ -15,6 +19,7 @@ import org.spongepowered.asm.mixin.injection.At.Shift; import org.spongepowered.asm.mixin.injection.Group; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.mojang.blaze3d.vertex.PoseStack; @@ -52,11 +57,19 @@ abstract class LevelRendererMixin { // @Inject(method = "renderLevel", at = @At("HEAD")) @Inject(method = "renderLevel", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I")) - private void flywheel$beginRender(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, Matrix4f frustrumMatrix, CallbackInfo ci) { + private void flywheel$beginRender(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, Matrix4f frustrumMatrix, CallbackInfo ci, @Share("poseStack") LocalRef sharedPose) { + PoseStack pose = new PoseStack(); // fixme - is the delta stuff correct? no idea! - flywheel$renderContext = RenderContextImpl.create((LevelRenderer) (Object) this, level, renderBuffers, new PoseStack(), projectionMatrix, camera, deltaTracker.getGameTimeDeltaTicks()); + flywheel$renderContext = RenderContextImpl.create((LevelRenderer) (Object) this, level, renderBuffers, pose, projectionMatrix, camera, deltaTracker.getGameTimeDeltaTicks()); FlwImplXplat.INSTANCE.dispatchBeginFrameEvent(flywheel$renderContext); + + sharedPose.set(pose); + } + + @Redirect(method = "renderLevel", at = @At(value = "NEW", target = "com/mojang/blaze3d/vertex/PoseStack")) + private PoseStack flywheel$fixPoseStack(@Share("poseStack") LocalRef sharedPose) { + return sharedPose.get(); } @Inject(method = "renderLevel", at = @At("RETURN"))