mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-28 16:06:28 +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.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import com.mojang.math.Matrix4f;
|
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
|
@ -39,7 +38,6 @@ public class Backend {
|
||||||
public GLCapabilities capabilities;
|
public GLCapabilities capabilities;
|
||||||
public GlCompat compat;
|
public GlCompat compat;
|
||||||
|
|
||||||
private Matrix4f projectionMatrix = new Matrix4f();
|
|
||||||
private boolean instancedArrays;
|
private boolean instancedArrays;
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
public boolean chunkCachingEnabled;
|
public boolean chunkCachingEnabled;
|
||||||
|
@ -160,14 +158,6 @@ public class Backend {
|
||||||
return contexts;
|
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.
|
* 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 javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
|
||||||
import com.jozufozu.flywheel.backend.state.RenderLayer;
|
import com.jozufozu.flywheel.backend.state.RenderLayer;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
@ -31,8 +31,7 @@ public class RenderLayerEvent extends Event {
|
||||||
viewProjection = stack.last()
|
viewProjection = stack.last()
|
||||||
.pose()
|
.pose()
|
||||||
.copy();
|
.copy();
|
||||||
viewProjection.multiplyBackward(Backend.getInstance()
|
viewProjection.multiplyBackward(RenderSystem.getProjectionMatrix());
|
||||||
.getProjectionMatrix());
|
|
||||||
|
|
||||||
this.buffers = buffers;
|
this.buffers = buffers;
|
||||||
this.camX = camX;
|
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.BeginFrameEvent;
|
||||||
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
||||||
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
@ -84,8 +85,7 @@ public class RenderHooksMixin {
|
||||||
Matrix4f view = stack.last()
|
Matrix4f view = stack.last()
|
||||||
.pose();
|
.pose();
|
||||||
Matrix4f viewProjection = view.copy();
|
Matrix4f viewProjection = view.copy();
|
||||||
viewProjection.multiplyBackward(Backend.getInstance()
|
viewProjection.multiplyBackward(RenderSystem.getProjectionMatrix());
|
||||||
.getProjectionMatrix());
|
|
||||||
|
|
||||||
Vec3 cameraPos = info.getPosition();
|
Vec3 cameraPos = info.getPosition();
|
||||||
CrumblingRenderer.renderBreaking(level, viewProjection, cameraPos.x, cameraPos.y, cameraPos.z);
|
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",
|
"FixFabulousDepthMixin",
|
||||||
"RenderHooksMixin",
|
"RenderHooksMixin",
|
||||||
"ShaderCloseMixin",
|
"ShaderCloseMixin",
|
||||||
"StoreProjectionMatrixMixin",
|
|
||||||
"TileRemoveMixin",
|
"TileRemoveMixin",
|
||||||
"TileWorldHookMixin",
|
"TileWorldHookMixin",
|
||||||
"atlas.AtlasDataMixin",
|
"atlas.AtlasDataMixin",
|
||||||
|
|
Loading…
Reference in a new issue