ForgePatch/patches/minecraft/net/minecraft/client/renderer/Tessellator.java.patch

146 lines
5.1 KiB
Diff

--- ../src-base/minecraft/net/minecraft/client/renderer/Tessellator.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/Tessellator.java
@@ -7,6 +7,7 @@
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
+import java.util.Arrays;
import java.util.PriorityQueue;
import net.minecraft.client.shader.TesselatorVertexState;
import net.minecraft.client.util.QuadComparator;
@@ -15,10 +16,17 @@
@SideOnly(Side.CLIENT)
public class Tessellator
{
- private ByteBuffer field_78394_d;
- private IntBuffer field_147568_c;
- private FloatBuffer field_147566_d;
- private ShortBuffer field_147567_e;
+ private static int nativeBufferSize = 0x200000;
+ private static int trivertsInBuffer = (nativeBufferSize / 48) * 6;
+ public static boolean renderingWorldRenderer = false;
+ public boolean defaultTexture = false;
+ private int rawBufferSize = 0;
+ public int textureID = 0;
+
+ private static ByteBuffer field_78394_d = GLAllocation.func_74524_c(nativeBufferSize * 4);
+ private static IntBuffer field_147568_c = field_78394_d.asIntBuffer();
+ private static FloatBuffer field_147566_d = field_78394_d.asFloatBuffer();
+ private static ShortBuffer field_147567_e = field_78394_d.asShortBuffer();
private int[] field_78405_h;
private int field_78406_i;
private double field_78403_j;
@@ -44,14 +52,17 @@
private Tessellator(int p_i1250_1_)
{
- this.field_78388_E = p_i1250_1_;
- this.field_78394_d = GLAllocation.func_74524_c(p_i1250_1_ * 4);
- this.field_147568_c = this.field_78394_d.asIntBuffer();
- this.field_147566_d = this.field_78394_d.asFloatBuffer();
- this.field_147567_e = this.field_78394_d.asShortBuffer();
- this.field_78405_h = new int[p_i1250_1_];
}
+ public Tessellator()
+ {
+ }
+
+ static
+ {
+ field_78398_a.defaultTexture = true;
+ }
+
public int func_78381_a()
{
if (!this.field_78415_z)
@@ -62,12 +73,15 @@
{
this.field_78415_z = false;
- if (this.field_78406_i > 0)
+ int offs = 0;
+ while (offs < field_78406_i)
{
+ int vtc = Math.min(field_78406_i - offs, nativeBufferSize >> 5);
this.field_147568_c.clear();
- this.field_147568_c.put(this.field_78405_h, 0, this.field_147569_p);
+ this.field_147568_c.put(this.field_78405_h, offs * 8, vtc * 8);
this.field_78394_d.position(0);
- this.field_78394_d.limit(this.field_147569_p * 4);
+ this.field_78394_d.limit(vtc * 32);
+ offs += vtc;
if (this.field_78400_o)
{
@@ -102,7 +116,7 @@
this.field_147566_d.position(0);
GL11.glVertexPointer(3, 32, this.field_147566_d);
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
- GL11.glDrawArrays(this.field_78409_u, 0, this.field_78406_i);
+ GL11.glDrawArrays(this.field_78409_u, 0, vtc);
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
if (this.field_78400_o)
@@ -128,6 +142,12 @@
}
}
+ if (rawBufferSize > 0x20000 && field_147569_p < (rawBufferSize << 3))
+ {
+ rawBufferSize = 0x10000;
+ field_78405_h = new int[rawBufferSize];
+ }
+
int i = this.field_147569_p * 4;
this.func_78379_d();
return i;
@@ -162,6 +182,14 @@
public void func_147565_a(TesselatorVertexState p_147565_1_)
{
+ while (p_147565_1_.func_147572_a().length > rawBufferSize && rawBufferSize > 0)
+ {
+ rawBufferSize <<= 1;
+ }
+ if (rawBufferSize > field_78405_h.length)
+ {
+ field_78405_h = new int[rawBufferSize];
+ }
System.arraycopy(p_147565_1_.func_147572_a(), 0, this.field_78405_h, 0, p_147565_1_.func_147572_a().length);
this.field_147569_p = p_147565_1_.func_147576_b();
this.field_78406_i = p_147565_1_.func_147575_c();
@@ -301,6 +329,19 @@
public void func_78377_a(double p_78377_1_, double p_78377_3_, double p_78377_5_)
{
+ if (field_147569_p >= rawBufferSize - 32)
+ {
+ if (rawBufferSize == 0)
+ {
+ rawBufferSize = 0x10000;
+ field_78405_h = new int[rawBufferSize];
+ }
+ else
+ {
+ rawBufferSize *= 2;
+ field_78405_h = Arrays.copyOf(field_78405_h, rawBufferSize);
+ }
+ }
++this.field_78411_s;
if (this.field_78400_o)
@@ -329,12 +370,6 @@
this.field_78405_h[this.field_147569_p + 2] = Float.floatToRawIntBits((float)(p_78377_5_ + this.field_78417_x));
this.field_147569_p += 8;
++this.field_78406_i;
-
- if (this.field_78406_i % 4 == 0 && this.field_147569_p >= this.field_78388_E - 32)
- {
- this.func_78381_a();
- this.field_78415_z = true;
- }
}
public void func_78378_d(int p_78378_1_)