From c2000b3edc2d06e7d0ca6419d0cd33c52c536af6 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sun, 13 Aug 2017 12:03:06 +0200 Subject: [PATCH] Fix only front-facing chunks visible for ODS rendering (fixes #67) --- .../replaymod/render/mixin/MixinFrustum.java | 23 +++++++++++++++++++ .../resources/mixins.render.replaymod.json | 1 + 2 files changed, 24 insertions(+) create mode 100644 src/main/java/com/replaymod/render/mixin/MixinFrustum.java diff --git a/src/main/java/com/replaymod/render/mixin/MixinFrustum.java b/src/main/java/com/replaymod/render/mixin/MixinFrustum.java new file mode 100644 index 00000000..ed22976e --- /dev/null +++ b/src/main/java/com/replaymod/render/mixin/MixinFrustum.java @@ -0,0 +1,23 @@ +package com.replaymod.render.mixin; + +import com.replaymod.render.hooks.EntityRendererHandler; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.culling.Frustum; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Frustum.class) +public abstract class MixinFrustum { + @Inject(method = "isBoxInFrustum", at = @At("HEAD"), cancellable = true) + public void isBoxInFrustum(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, CallbackInfoReturnable ci) { + EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler(); + if (handler != null && handler.omnidirectional && handler.data == null) { + // Normally the camera is always facing the direction of the omnidirectional image face that is currently + // getting rendered. With ODS however, the camera is always facing forwards and the turning happens in the + // vertex shader (non-trivial due to stereo). As such, all chunks need to be rendered all the time for ODS. + ci.setReturnValue(true); + } + } +} diff --git a/src/main/resources/mixins.render.replaymod.json b/src/main/resources/mixins.render.replaymod.json index de808884..a2e940c8 100644 --- a/src/main/resources/mixins.render.replaymod.json +++ b/src/main/resources/mixins.render.replaymod.json @@ -4,6 +4,7 @@ "mixins": [ "MixinEffectRenderer", "MixinEntityRenderer", + "MixinFrustum", "MixinRender", "MixinRendererLivingEntity", "MixinRenderGlobal",