mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 23:47:09 +01:00
Minecraft already stores the projection matrix
mixins--
This commit is contained in:
parent
a930bc97cc
commit
40034daa64
5 changed files with 4 additions and 54 deletions
|
@ -21,7 +21,6 @@ import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
|||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
|
@ -39,7 +38,6 @@ public class Backend {
|
|||
public GLCapabilities capabilities;
|
||||
public GlCompat compat;
|
||||
|
||||
private Matrix4f projectionMatrix = new Matrix4f();
|
||||
private boolean instancedArrays;
|
||||
private boolean enabled;
|
||||
public boolean chunkCachingEnabled;
|
||||
|
@ -160,14 +158,6 @@ public class Backend {
|
|||
return contexts;
|
||||
}
|
||||
|
||||
public Matrix4f getProjectionMatrix() {
|
||||
return projectionMatrix;
|
||||
}
|
||||
|
||||
public void setProjectionMatrix(Matrix4f projectionMatrix) {
|
||||
this.projectionMatrix = projectionMatrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to avoid calling Flywheel functions on (fake) worlds that don't specifically support it.
|
||||
*/
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.jozufozu.flywheel.event;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.state.RenderLayer;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -31,8 +31,7 @@ public class RenderLayerEvent extends Event {
|
|||
viewProjection = stack.last()
|
||||
.pose()
|
||||
.copy();
|
||||
viewProjection.multiplyBackward(Backend.getInstance()
|
||||
.getProjectionMatrix());
|
||||
viewProjection.multiplyBackward(RenderSystem.getProjectionMatrix());
|
||||
|
||||
this.buffers = buffers;
|
||||
this.camX = camX;
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.jozufozu.flywheel.core.crumbling.CrumblingRenderer;
|
|||
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
||||
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
||||
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
@ -84,8 +85,7 @@ public class RenderHooksMixin {
|
|||
Matrix4f view = stack.last()
|
||||
.pose();
|
||||
Matrix4f viewProjection = view.copy();
|
||||
viewProjection.multiplyBackward(Backend.getInstance()
|
||||
.getProjectionMatrix());
|
||||
viewProjection.multiplyBackward(RenderSystem.getProjectionMatrix());
|
||||
|
||||
Vec3 cameraPos = info.getPosition();
|
||||
CrumblingRenderer.renderBreaking(level, viewProjection, cameraPos.x, cameraPos.y, cameraPos.z);
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
package com.jozufozu.flywheel.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public abstract class StoreProjectionMatrixMixin {
|
||||
|
||||
@Unique
|
||||
private boolean shouldCopy = false;
|
||||
|
||||
/**
|
||||
* We only want to copy the projection matrix if it is going to be used to render the world.
|
||||
* We don't care about the mat for your hand.
|
||||
*/
|
||||
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;resetProjectionMatrix(Lcom/mojang/math/Matrix4f;)V"))
|
||||
private void projectionMatrixReady(float p_228378_1_, long p_228378_2_, PoseStack p_228378_4_, CallbackInfo ci) {
|
||||
shouldCopy = true;
|
||||
}
|
||||
|
||||
@Inject(method = "resetProjectionMatrix", at = @At("TAIL"))
|
||||
private void onProjectionMatrixLoad(Matrix4f projection, CallbackInfo ci) {
|
||||
if (shouldCopy) {
|
||||
Backend.getInstance()
|
||||
.setProjectionMatrix(projection.copy());
|
||||
shouldCopy = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@
|
|||
"FixFabulousDepthMixin",
|
||||
"RenderHooksMixin",
|
||||
"ShaderCloseMixin",
|
||||
"StoreProjectionMatrixMixin",
|
||||
"TileRemoveMixin",
|
||||
"TileWorldHookMixin",
|
||||
"atlas.AtlasDataMixin",
|
||||
|
|
Loading…
Reference in a new issue