From dbf83b1d361aa62d4eb4478e9f269df2474d2bd3 Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Fri, 14 Jul 2023 07:04:24 -0400 Subject: [PATCH] MASSIVE FPS BOOST! --- .../java/com/mojang/minecraft/Minecraft.java | 20 ++- .../com/mojang/minecraft/level/BlockMap.java | 16 +-- .../minecraft/render/ClippingHelper.java | 41 +++++++ .../render/ClippingHelperImplementation.java | 114 ++++++++++++++++++ .../com/mojang/minecraft/render/Frustrum.java | 36 +++--- .../mojang/minecraft/render/FrustrumImpl.java | 87 ------------- 6 files changed, 202 insertions(+), 112 deletions(-) create mode 100644 src/teavm/java/com/mojang/minecraft/render/ClippingHelper.java create mode 100644 src/teavm/java/com/mojang/minecraft/render/ClippingHelperImplementation.java delete mode 100644 src/teavm/java/com/mojang/minecraft/render/FrustrumImpl.java diff --git a/src/teavm/java/com/mojang/minecraft/Minecraft.java b/src/teavm/java/com/mojang/minecraft/Minecraft.java index aa289bb..2a101c3 100644 --- a/src/teavm/java/com/mojang/minecraft/Minecraft.java +++ b/src/teavm/java/com/mojang/minecraft/Minecraft.java @@ -75,6 +75,7 @@ public final class Minecraft implements Runnable { private int lastClick; public boolean raining; private static Tessellator tessellator = Tessellator.instance; + public Entity field_22009_h; public Minecraft() { @@ -419,13 +420,26 @@ public final class Minecraft implements Runnable { var74 = var116.yo + (var116.y - var116.yo) * var80; var33 = var116.zo + (var116.z - var116.zo) * var80; GL11.glTranslatef(-var69, -var74, -var33); - Frustrum var76 = FrustrumImpl.update(); - Frustrum var100 = var76; + //Frustrum var76 = FrustrumImpl.update(); + //Frustrum var100 = var76; + Frustrum var76 = new Frustrum(); + if(field_22009_h != this.player) { + field_22009_h = player; + float f = this.timer.elapsedTicks; + double d = field_22009_h.x + (field_22009_h.x - field_22009_h.x) * (double) f; + double d1 = field_22009_h.y + (field_22009_h.y - field_22009_h.y) * (double) f; + double d2 = field_22009_h.z + (field_22009_h.z - field_22009_h.z) * (double) f; + ClippingHelperImplementation.getInstance(); + Frustrum frustrum = new Frustrum(); + frustrum.setPosition(d, d1, d2); + var76 = frustrum; + System.out.println("yee"); + } LevelRenderer var101 = var82.minecraft.levelRenderer; int var98; for(var98 = 0; var98 < var101.chunkCache.length; ++var98) { - var101.chunkCache[var98].clip(var100); + var101.chunkCache[var98].clip(var76); } var101 = var82.minecraft.levelRenderer; diff --git a/src/teavm/java/com/mojang/minecraft/level/BlockMap.java b/src/teavm/java/com/mojang/minecraft/level/BlockMap.java index d3035fc..0e7138c 100644 --- a/src/teavm/java/com/mojang/minecraft/level/BlockMap.java +++ b/src/teavm/java/com/mojang/minecraft/level/BlockMap.java @@ -196,42 +196,42 @@ public class BlockMap implements Serializable { break; } - if(var19.frustrum[var20][0] * var18 + var19.frustrum[var20][1] * var13 + var19.frustrum[var20][2] * var14 + var19.frustrum[var20][3] <= 0.0F) { + if(var19.clippingHelper.frustum[var20][0] * var18 + var19.clippingHelper.frustum[var20][1] * var13 + var19.clippingHelper.frustum[var20][2] * var14 + var19.clippingHelper.frustum[var20][3] <= 0.0F) { var10000 = false; break; } - if(var19.frustrum[var20][0] * var15 + var19.frustrum[var20][1] * var13 + var19.frustrum[var20][2] * var14 + var19.frustrum[var20][3] <= 0.0F) { + if(var19.clippingHelper.frustum[var20][0] * var15 + var19.clippingHelper.frustum[var20][1] * var13 + var19.clippingHelper.frustum[var20][2] * var14 + var19.clippingHelper.frustum[var20][3] <= 0.0F) { var10000 = false; break; } - if(var19.frustrum[var20][0] * var18 + var19.frustrum[var20][1] * var17 + var19.frustrum[var20][2] * var14 + var19.frustrum[var20][3] <= 0.0F) { + if(var19.clippingHelper.frustum[var20][0] * var18 + var19.clippingHelper.frustum[var20][1] * var17 + var19.clippingHelper.frustum[var20][2] * var14 + var19.clippingHelper.frustum[var20][3] <= 0.0F) { var10000 = false; break; } - if(var19.frustrum[var20][0] * var15 + var19.frustrum[var20][1] * var17 + var19.frustrum[var20][2] * var14 + var19.frustrum[var20][3] <= 0.0F) { + if(var19.clippingHelper.frustum[var20][0] * var15 + var19.clippingHelper.frustum[var20][1] * var17 + var19.clippingHelper.frustum[var20][2] * var14 + var19.clippingHelper.frustum[var20][3] <= 0.0F) { var10000 = false; break; } - if(var19.frustrum[var20][0] * var18 + var19.frustrum[var20][1] * var13 + var19.frustrum[var20][2] * var16 + var19.frustrum[var20][3] <= 0.0F) { + if(var19.clippingHelper.frustum[var20][0] * var18 + var19.clippingHelper.frustum[var20][1] * var13 + var19.clippingHelper.frustum[var20][2] * var16 + var19.clippingHelper.frustum[var20][3] <= 0.0F) { var10000 = false; break; } - if(var19.frustrum[var20][0] * var15 + var19.frustrum[var20][1] * var13 + var19.frustrum[var20][2] * var16 + var19.frustrum[var20][3] <= 0.0F) { + if(var19.clippingHelper.frustum[var20][0] * var15 + var19.clippingHelper.frustum[var20][1] * var13 + var19.clippingHelper.frustum[var20][2] * var16 + var19.clippingHelper.frustum[var20][3] <= 0.0F) { var10000 = false; break; } - if(var19.frustrum[var20][0] * var18 + var19.frustrum[var20][1] * var17 + var19.frustrum[var20][2] * var16 + var19.frustrum[var20][3] <= 0.0F) { + if(var19.clippingHelper.frustum[var20][0] * var18 + var19.clippingHelper.frustum[var20][1] * var17 + var19.clippingHelper.frustum[var20][2] * var16 + var19.clippingHelper.frustum[var20][3] <= 0.0F) { var10000 = false; break; } - if(var19.frustrum[var20][0] * var15 + var19.frustrum[var20][1] * var17 + var19.frustrum[var20][2] * var16 + var19.frustrum[var20][3] <= 0.0F) { + if(var19.clippingHelper.frustum[var20][0] * var15 + var19.clippingHelper.frustum[var20][1] * var17 + var19.clippingHelper.frustum[var20][2] * var16 + var19.clippingHelper.frustum[var20][3] <= 0.0F) { var10000 = false; break; } diff --git a/src/teavm/java/com/mojang/minecraft/render/ClippingHelper.java b/src/teavm/java/com/mojang/minecraft/render/ClippingHelper.java new file mode 100644 index 0000000..f12e00d --- /dev/null +++ b/src/teavm/java/com/mojang/minecraft/render/ClippingHelper.java @@ -0,0 +1,41 @@ +package com.mojang.minecraft.render; + +public class ClippingHelper { + + public ClippingHelper() { + frustum = new float[16][16]; + projectionMatrix = new float[16]; + modelviewMatrix = new float[16]; + clippingMatrix = new float[16]; + } + + public boolean isBoxInFrustum(double d, double d1, double d2, double d3, double d4, double d5) { + for (int i = 0; i < 6; i++) { + if ((double) frustum[i][0] * d + (double) frustum[i][1] * d1 + (double) frustum[i][2] * d2 + + (double) frustum[i][3] <= 0.0D + && (double) frustum[i][0] * d3 + (double) frustum[i][1] * d1 + (double) frustum[i][2] * d2 + + (double) frustum[i][3] <= 0.0D + && (double) frustum[i][0] * d + (double) frustum[i][1] * d4 + (double) frustum[i][2] * d2 + + (double) frustum[i][3] <= 0.0D + && (double) frustum[i][0] * d3 + (double) frustum[i][1] * d4 + (double) frustum[i][2] * d2 + + (double) frustum[i][3] <= 0.0D + && (double) frustum[i][0] * d + (double) frustum[i][1] * d1 + (double) frustum[i][2] * d5 + + (double) frustum[i][3] <= 0.0D + && (double) frustum[i][0] * d3 + (double) frustum[i][1] * d1 + (double) frustum[i][2] * d5 + + (double) frustum[i][3] <= 0.0D + && (double) frustum[i][0] * d + (double) frustum[i][1] * d4 + (double) frustum[i][2] * d5 + + (double) frustum[i][3] <= 0.0D + && (double) frustum[i][0] * d3 + (double) frustum[i][1] * d4 + (double) frustum[i][2] * d5 + + (double) frustum[i][3] <= 0.0D) { + return false; + } + } + + return true; + } + + public float frustum[][]; + public float projectionMatrix[]; + public float modelviewMatrix[]; + public float clippingMatrix[]; +} \ No newline at end of file diff --git a/src/teavm/java/com/mojang/minecraft/render/ClippingHelperImplementation.java b/src/teavm/java/com/mojang/minecraft/render/ClippingHelperImplementation.java new file mode 100644 index 0000000..8dc6e06 --- /dev/null +++ b/src/teavm/java/com/mojang/minecraft/render/ClippingHelperImplementation.java @@ -0,0 +1,114 @@ +package com.mojang.minecraft.render; +// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. + +// Jad home page: http://www.kpdus.com/jad.html +// Decompiler options: packimports(3) braces deadcode + +import java.nio.FloatBuffer; + +import org.lwjgl.opengl.GL11; + +import net.PeytonPlayz585.math.MathHelper; +import net.lax1dude.eaglercraft.GLAllocation; + +public class ClippingHelperImplementation extends ClippingHelper { + + public ClippingHelperImplementation() { + projectionMatrixBuffer = GLAllocation.createDirectFloatBuffer(16); + modelviewMatrixBuffer = GLAllocation.createDirectFloatBuffer(16); + field_1691_h = GLAllocation.createDirectFloatBuffer(16); + } + + public static ClippingHelper getInstance() { + instance.init(); + return instance; + } + + private void normalize(float af[][], int i) { + float f = MathHelper.sqrt(af[i][0] * af[i][0] + af[i][1] * af[i][1] + af[i][2] * af[i][2]); + af[i][0] /= f; + af[i][1] /= f; + af[i][2] /= f; + af[i][3] /= f; + } + + private void init() { + projectionMatrixBuffer.clear(); + modelviewMatrixBuffer.clear(); + field_1691_h.clear(); + GL11.glGetFloat(2983 /* GL_PROJECTION_MATRIX */, projectionMatrixBuffer); + GL11.glGetFloat(2982 /* GL_MODELVIEW_MATRIX */, modelviewMatrixBuffer); + projectionMatrixBuffer.flip().limit(16); + projectionMatrixBuffer.get(projectionMatrix); + modelviewMatrixBuffer.flip().limit(16); + modelviewMatrixBuffer.get(modelviewMatrix); + clippingMatrix[0] = modelviewMatrix[0] * projectionMatrix[0] + modelviewMatrix[1] * projectionMatrix[4] + + modelviewMatrix[2] * projectionMatrix[8] + modelviewMatrix[3] * projectionMatrix[12]; + clippingMatrix[1] = modelviewMatrix[0] * projectionMatrix[1] + modelviewMatrix[1] * projectionMatrix[5] + + modelviewMatrix[2] * projectionMatrix[9] + modelviewMatrix[3] * projectionMatrix[13]; + clippingMatrix[2] = modelviewMatrix[0] * projectionMatrix[2] + modelviewMatrix[1] * projectionMatrix[6] + + modelviewMatrix[2] * projectionMatrix[10] + modelviewMatrix[3] * projectionMatrix[14]; + clippingMatrix[3] = modelviewMatrix[0] * projectionMatrix[3] + modelviewMatrix[1] * projectionMatrix[7] + + modelviewMatrix[2] * projectionMatrix[11] + modelviewMatrix[3] * projectionMatrix[15]; + clippingMatrix[4] = modelviewMatrix[4] * projectionMatrix[0] + modelviewMatrix[5] * projectionMatrix[4] + + modelviewMatrix[6] * projectionMatrix[8] + modelviewMatrix[7] * projectionMatrix[12]; + clippingMatrix[5] = modelviewMatrix[4] * projectionMatrix[1] + modelviewMatrix[5] * projectionMatrix[5] + + modelviewMatrix[6] * projectionMatrix[9] + modelviewMatrix[7] * projectionMatrix[13]; + clippingMatrix[6] = modelviewMatrix[4] * projectionMatrix[2] + modelviewMatrix[5] * projectionMatrix[6] + + modelviewMatrix[6] * projectionMatrix[10] + modelviewMatrix[7] * projectionMatrix[14]; + clippingMatrix[7] = modelviewMatrix[4] * projectionMatrix[3] + modelviewMatrix[5] * projectionMatrix[7] + + modelviewMatrix[6] * projectionMatrix[11] + modelviewMatrix[7] * projectionMatrix[15]; + clippingMatrix[8] = modelviewMatrix[8] * projectionMatrix[0] + modelviewMatrix[9] * projectionMatrix[4] + + modelviewMatrix[10] * projectionMatrix[8] + modelviewMatrix[11] * projectionMatrix[12]; + clippingMatrix[9] = modelviewMatrix[8] * projectionMatrix[1] + modelviewMatrix[9] * projectionMatrix[5] + + modelviewMatrix[10] * projectionMatrix[9] + modelviewMatrix[11] * projectionMatrix[13]; + clippingMatrix[10] = modelviewMatrix[8] * projectionMatrix[2] + modelviewMatrix[9] * projectionMatrix[6] + + modelviewMatrix[10] * projectionMatrix[10] + modelviewMatrix[11] * projectionMatrix[14]; + clippingMatrix[11] = modelviewMatrix[8] * projectionMatrix[3] + modelviewMatrix[9] * projectionMatrix[7] + + modelviewMatrix[10] * projectionMatrix[11] + modelviewMatrix[11] * projectionMatrix[15]; + clippingMatrix[12] = modelviewMatrix[12] * projectionMatrix[0] + modelviewMatrix[13] * projectionMatrix[4] + + modelviewMatrix[14] * projectionMatrix[8] + modelviewMatrix[15] * projectionMatrix[12]; + clippingMatrix[13] = modelviewMatrix[12] * projectionMatrix[1] + modelviewMatrix[13] * projectionMatrix[5] + + modelviewMatrix[14] * projectionMatrix[9] + modelviewMatrix[15] * projectionMatrix[13]; + clippingMatrix[14] = modelviewMatrix[12] * projectionMatrix[2] + modelviewMatrix[13] * projectionMatrix[6] + + modelviewMatrix[14] * projectionMatrix[10] + modelviewMatrix[15] * projectionMatrix[14]; + clippingMatrix[15] = modelviewMatrix[12] * projectionMatrix[3] + modelviewMatrix[13] * projectionMatrix[7] + + modelviewMatrix[14] * projectionMatrix[11] + modelviewMatrix[15] * projectionMatrix[15]; + frustum[0][0] = clippingMatrix[3] - clippingMatrix[0]; + frustum[0][1] = clippingMatrix[7] - clippingMatrix[4]; + frustum[0][2] = clippingMatrix[11] - clippingMatrix[8]; + frustum[0][3] = clippingMatrix[15] - clippingMatrix[12]; + normalize(frustum, 0); + frustum[1][0] = clippingMatrix[3] + clippingMatrix[0]; + frustum[1][1] = clippingMatrix[7] + clippingMatrix[4]; + frustum[1][2] = clippingMatrix[11] + clippingMatrix[8]; + frustum[1][3] = clippingMatrix[15] + clippingMatrix[12]; + normalize(frustum, 1); + frustum[2][0] = clippingMatrix[3] + clippingMatrix[1]; + frustum[2][1] = clippingMatrix[7] + clippingMatrix[5]; + frustum[2][2] = clippingMatrix[11] + clippingMatrix[9]; + frustum[2][3] = clippingMatrix[15] + clippingMatrix[13]; + normalize(frustum, 2); + frustum[3][0] = clippingMatrix[3] - clippingMatrix[1]; + frustum[3][1] = clippingMatrix[7] - clippingMatrix[5]; + frustum[3][2] = clippingMatrix[11] - clippingMatrix[9]; + frustum[3][3] = clippingMatrix[15] - clippingMatrix[13]; + normalize(frustum, 3); + frustum[4][0] = clippingMatrix[3] - clippingMatrix[2]; + frustum[4][1] = clippingMatrix[7] - clippingMatrix[6]; + frustum[4][2] = clippingMatrix[11] - clippingMatrix[10]; + frustum[4][3] = clippingMatrix[15] - clippingMatrix[14]; + normalize(frustum, 4); + frustum[5][0] = clippingMatrix[3] + clippingMatrix[2]; + frustum[5][1] = clippingMatrix[7] + clippingMatrix[6]; + frustum[5][2] = clippingMatrix[11] + clippingMatrix[10]; + frustum[5][3] = clippingMatrix[15] + clippingMatrix[14]; + normalize(frustum, 5); + } + + private static ClippingHelperImplementation instance = new ClippingHelperImplementation(); + private FloatBuffer projectionMatrixBuffer; + private FloatBuffer modelviewMatrixBuffer; + private FloatBuffer field_1691_h; + +} \ No newline at end of file diff --git a/src/teavm/java/com/mojang/minecraft/render/Frustrum.java b/src/teavm/java/com/mojang/minecraft/render/Frustrum.java index a3823d4..8365c6a 100644 --- a/src/teavm/java/com/mojang/minecraft/render/Frustrum.java +++ b/src/teavm/java/com/mojang/minecraft/render/Frustrum.java @@ -1,21 +1,29 @@ package com.mojang.minecraft.render; - public class Frustrum { - public float[][] frustrum = new float[16][16]; - public float[] projection = new float[16]; - public float[] modelview = new float[16]; - public float[] clipping = new float[16]; + public Frustrum() { + clippingHelper = ClippingHelperImplementation.getInstance(); + } + public void setPosition(double d, double d1, double d2) { + xPosition = d; + yPosition = d1; + zPosition = d2; + } - public final boolean isBoxInFrustrum(float var1, float var2, float var3, float var4, float var5, float var6) { - for(int var7 = 0; var7 < 6; ++var7) { - if(this.frustrum[var7][0] * var1 + this.frustrum[var7][1] * var2 + this.frustrum[var7][2] * var3 + this.frustrum[var7][3] <= 0.0F && this.frustrum[var7][0] * var4 + this.frustrum[var7][1] * var2 + this.frustrum[var7][2] * var3 + this.frustrum[var7][3] <= 0.0F && this.frustrum[var7][0] * var1 + this.frustrum[var7][1] * var5 + this.frustrum[var7][2] * var3 + this.frustrum[var7][3] <= 0.0F && this.frustrum[var7][0] * var4 + this.frustrum[var7][1] * var5 + this.frustrum[var7][2] * var3 + this.frustrum[var7][3] <= 0.0F && this.frustrum[var7][0] * var1 + this.frustrum[var7][1] * var2 + this.frustrum[var7][2] * var6 + this.frustrum[var7][3] <= 0.0F && this.frustrum[var7][0] * var4 + this.frustrum[var7][1] * var2 + this.frustrum[var7][2] * var6 + this.frustrum[var7][3] <= 0.0F && this.frustrum[var7][0] * var1 + this.frustrum[var7][1] * var5 + this.frustrum[var7][2] * var6 + this.frustrum[var7][3] <= 0.0F && this.frustrum[var7][0] * var4 + this.frustrum[var7][1] * var5 + this.frustrum[var7][2] * var6 + this.frustrum[var7][3] <= 0.0F) { - return false; - } - } + public boolean isBoxInFrustrum(double d, double d1, double d2, double d3, double d4, double d5) { + return clippingHelper.isBoxInFrustum(d - xPosition, d1 - yPosition, d2 - zPosition, d3 - xPosition, + d4 - yPosition, d5 - zPosition); + } - return true; - } -} +// public boolean isBoundingBoxInFrustum(AxisAlignedBB axisalignedbb) { +// return isBoxInFrustum(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ, axisalignedbb.maxX, +// axisalignedbb.maxY, axisalignedbb.maxZ); +// } + + public ClippingHelper clippingHelper; + private double xPosition; + private double yPosition; + private double zPosition; +} \ No newline at end of file diff --git a/src/teavm/java/com/mojang/minecraft/render/FrustrumImpl.java b/src/teavm/java/com/mojang/minecraft/render/FrustrumImpl.java deleted file mode 100644 index 946efb7..0000000 --- a/src/teavm/java/com/mojang/minecraft/render/FrustrumImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.mojang.minecraft.render; - -import com.mojang.minecraft.render.Frustrum; -import net.PeytonPlayz585.math.MathHelper; - -import net.lax1dude.eaglercraft.GLAllocation; - -import java.nio.FloatBuffer; -import org.lwjgl.opengl.GL11; - -public final class FrustrumImpl extends Frustrum { - - private static FrustrumImpl instance = new FrustrumImpl(); - private FloatBuffer projectionBuff = GLAllocation.createDirectFloatBuffer(16); - private FloatBuffer modelviewBuff = GLAllocation.createDirectFloatBuffer(16); - private FloatBuffer unused = GLAllocation.createDirectFloatBuffer(16); - - - public static Frustrum update() { - FrustrumImpl var0 = instance; - instance.projectionBuff.clear(); - var0.modelviewBuff.clear(); - var0.unused.clear(); - GL11.glGetFloat(2983, var0.projectionBuff); - GL11.glGetFloat(2982, var0.modelviewBuff); - var0.projectionBuff.flip().limit(16); - var0.projectionBuff.get(var0.projection); - var0.modelviewBuff.flip().limit(16); - var0.modelviewBuff.get(var0.modelview); - var0.clipping[0] = var0.modelview[0] * var0.projection[0] + var0.modelview[1] * var0.projection[4] + var0.modelview[2] * var0.projection[8] + var0.modelview[3] * var0.projection[12]; - var0.clipping[1] = var0.modelview[0] * var0.projection[1] + var0.modelview[1] * var0.projection[5] + var0.modelview[2] * var0.projection[9] + var0.modelview[3] * var0.projection[13]; - var0.clipping[2] = var0.modelview[0] * var0.projection[2] + var0.modelview[1] * var0.projection[6] + var0.modelview[2] * var0.projection[10] + var0.modelview[3] * var0.projection[14]; - var0.clipping[3] = var0.modelview[0] * var0.projection[3] + var0.modelview[1] * var0.projection[7] + var0.modelview[2] * var0.projection[11] + var0.modelview[3] * var0.projection[15]; - var0.clipping[4] = var0.modelview[4] * var0.projection[0] + var0.modelview[5] * var0.projection[4] + var0.modelview[6] * var0.projection[8] + var0.modelview[7] * var0.projection[12]; - var0.clipping[5] = var0.modelview[4] * var0.projection[1] + var0.modelview[5] * var0.projection[5] + var0.modelview[6] * var0.projection[9] + var0.modelview[7] * var0.projection[13]; - var0.clipping[6] = var0.modelview[4] * var0.projection[2] + var0.modelview[5] * var0.projection[6] + var0.modelview[6] * var0.projection[10] + var0.modelview[7] * var0.projection[14]; - var0.clipping[7] = var0.modelview[4] * var0.projection[3] + var0.modelview[5] * var0.projection[7] + var0.modelview[6] * var0.projection[11] + var0.modelview[7] * var0.projection[15]; - var0.clipping[8] = var0.modelview[8] * var0.projection[0] + var0.modelview[9] * var0.projection[4] + var0.modelview[10] * var0.projection[8] + var0.modelview[11] * var0.projection[12]; - var0.clipping[9] = var0.modelview[8] * var0.projection[1] + var0.modelview[9] * var0.projection[5] + var0.modelview[10] * var0.projection[9] + var0.modelview[11] * var0.projection[13]; - var0.clipping[10] = var0.modelview[8] * var0.projection[2] + var0.modelview[9] * var0.projection[6] + var0.modelview[10] * var0.projection[10] + var0.modelview[11] * var0.projection[14]; - var0.clipping[11] = var0.modelview[8] * var0.projection[3] + var0.modelview[9] * var0.projection[7] + var0.modelview[10] * var0.projection[11] + var0.modelview[11] * var0.projection[15]; - var0.clipping[12] = var0.modelview[12] * var0.projection[0] + var0.modelview[13] * var0.projection[4] + var0.modelview[14] * var0.projection[8] + var0.modelview[15] * var0.projection[12]; - var0.clipping[13] = var0.modelview[12] * var0.projection[1] + var0.modelview[13] * var0.projection[5] + var0.modelview[14] * var0.projection[9] + var0.modelview[15] * var0.projection[13]; - var0.clipping[14] = var0.modelview[12] * var0.projection[2] + var0.modelview[13] * var0.projection[6] + var0.modelview[14] * var0.projection[10] + var0.modelview[15] * var0.projection[14]; - var0.clipping[15] = var0.modelview[12] * var0.projection[3] + var0.modelview[13] * var0.projection[7] + var0.modelview[14] * var0.projection[11] + var0.modelview[15] * var0.projection[15]; - var0.frustrum[0][0] = var0.clipping[3] - var0.clipping[0]; - var0.frustrum[0][1] = var0.clipping[7] - var0.clipping[4]; - var0.frustrum[0][2] = var0.clipping[11] - var0.clipping[8]; - var0.frustrum[0][3] = var0.clipping[15] - var0.clipping[12]; - normalize(var0.frustrum, 0); - var0.frustrum[1][0] = var0.clipping[3] + var0.clipping[0]; - var0.frustrum[1][1] = var0.clipping[7] + var0.clipping[4]; - var0.frustrum[1][2] = var0.clipping[11] + var0.clipping[8]; - var0.frustrum[1][3] = var0.clipping[15] + var0.clipping[12]; - normalize(var0.frustrum, 1); - var0.frustrum[2][0] = var0.clipping[3] + var0.clipping[1]; - var0.frustrum[2][1] = var0.clipping[7] + var0.clipping[5]; - var0.frustrum[2][2] = var0.clipping[11] + var0.clipping[9]; - var0.frustrum[2][3] = var0.clipping[15] + var0.clipping[13]; - normalize(var0.frustrum, 2); - var0.frustrum[3][0] = var0.clipping[3] - var0.clipping[1]; - var0.frustrum[3][1] = var0.clipping[7] - var0.clipping[5]; - var0.frustrum[3][2] = var0.clipping[11] - var0.clipping[9]; - var0.frustrum[3][3] = var0.clipping[15] - var0.clipping[13]; - normalize(var0.frustrum, 3); - var0.frustrum[4][0] = var0.clipping[3] - var0.clipping[2]; - var0.frustrum[4][1] = var0.clipping[7] - var0.clipping[6]; - var0.frustrum[4][2] = var0.clipping[11] - var0.clipping[10]; - var0.frustrum[4][3] = var0.clipping[15] - var0.clipping[14]; - normalize(var0.frustrum, 4); - var0.frustrum[5][0] = var0.clipping[3] + var0.clipping[2]; - var0.frustrum[5][1] = var0.clipping[7] + var0.clipping[6]; - var0.frustrum[5][2] = var0.clipping[11] + var0.clipping[10]; - var0.frustrum[5][3] = var0.clipping[15] + var0.clipping[14]; - normalize(var0.frustrum, 5); - return instance; - } - - private static void normalize(float[][] var0, int var1) { - float var2 = MathHelper.sqrt(var0[var1][0] * var0[var1][0] + var0[var1][1] * var0[var1][1] + var0[var1][2] * var0[var1][2]); - var0[var1][0] /= var2; - var0[var1][1] /= var2; - var0[var1][2] /= var2; - var0[var1][3] /= var2; - } - -}