mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 05:02:18 +00:00
147 lines
5.0 KiB
Diff
147 lines
5.0 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,11 +16,18 @@
|
|
@SideOnly(Side.CLIENT)
|
|
public class Tessellator
|
|
{
|
|
+ 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;
|
|
+
|
|
// JAVADOC FIELD $$ field_78394_d
|
|
- private ByteBuffer byteBuffer;
|
|
- private IntBuffer field_147568_c;
|
|
- private FloatBuffer field_147566_d;
|
|
- private ShortBuffer field_147567_e;
|
|
+ private static ByteBuffer byteBuffer = GLAllocation.createDirectByteBuffer(nativeBufferSize * 4);
|
|
+ private static IntBuffer field_147568_c = byteBuffer.asIntBuffer();
|
|
+ private static FloatBuffer field_147566_d = byteBuffer.asFloatBuffer();
|
|
+ private static ShortBuffer field_147567_e = byteBuffer.asShortBuffer();
|
|
// JAVADOC FIELD $$ field_78405_h
|
|
private int[] rawBuffer;
|
|
// JAVADOC FIELD $$ field_78406_i
|
|
@@ -63,14 +71,17 @@
|
|
|
|
private Tessellator(int par1)
|
|
{
|
|
- this.bufferSize = par1;
|
|
- this.byteBuffer = GLAllocation.createDirectByteBuffer(par1 * 4);
|
|
- this.field_147568_c = this.byteBuffer.asIntBuffer();
|
|
- this.field_147566_d = this.byteBuffer.asFloatBuffer();
|
|
- this.field_147567_e = this.byteBuffer.asShortBuffer();
|
|
- this.rawBuffer = new int[par1];
|
|
}
|
|
|
|
+ public Tessellator()
|
|
+ {
|
|
+ }
|
|
+
|
|
+ static
|
|
+ {
|
|
+ instance.defaultTexture = true;
|
|
+ }
|
|
+
|
|
// JAVADOC METHOD $$ func_78381_a
|
|
public int draw()
|
|
{
|
|
@@ -82,12 +93,15 @@
|
|
{
|
|
this.isDrawing = false;
|
|
|
|
- if (this.vertexCount > 0)
|
|
+ int offs = 0;
|
|
+ while (offs < vertexCount)
|
|
{
|
|
+ int vtc = Math.min(vertexCount - offs, nativeBufferSize >> 5);
|
|
this.field_147568_c.clear();
|
|
- this.field_147568_c.put(this.rawBuffer, 0, this.field_147569_p);
|
|
+ this.field_147568_c.put(this.rawBuffer, offs * 8, vtc * 8);
|
|
this.byteBuffer.position(0);
|
|
- this.byteBuffer.limit(this.field_147569_p * 4);
|
|
+ this.byteBuffer.limit(vtc * 32);
|
|
+ offs += vtc;
|
|
|
|
if (this.hasTexture)
|
|
{
|
|
@@ -122,7 +136,7 @@
|
|
this.field_147566_d.position(0);
|
|
GL11.glVertexPointer(3, 32, this.field_147566_d);
|
|
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
|
|
- GL11.glDrawArrays(this.drawMode, 0, this.vertexCount);
|
|
+ GL11.glDrawArrays(this.drawMode, 0, vtc);
|
|
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
|
|
|
|
if (this.hasTexture)
|
|
@@ -148,6 +162,12 @@
|
|
}
|
|
}
|
|
|
|
+ if (rawBufferSize > 0x20000 && field_147569_p < (rawBufferSize << 3))
|
|
+ {
|
|
+ rawBufferSize = 0x10000;
|
|
+ rawBuffer = new int[rawBufferSize];
|
|
+ }
|
|
+
|
|
int i = this.field_147569_p * 4;
|
|
this.reset();
|
|
return i;
|
|
@@ -182,6 +202,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 > rawBuffer.length)
|
|
+ {
|
|
+ rawBuffer = new int[rawBufferSize];
|
|
+ }
|
|
System.arraycopy(p_147565_1_.func_147572_a(), 0, this.rawBuffer, 0, p_147565_1_.func_147572_a().length);
|
|
this.field_147569_p = p_147565_1_.func_147576_b();
|
|
this.vertexCount = p_147565_1_.func_147575_c();
|
|
@@ -326,6 +354,19 @@
|
|
// JAVADOC METHOD $$ func_78377_a
|
|
public void addVertex(double par1, double par3, double par5)
|
|
{
|
|
+ if (field_147569_p >= rawBufferSize - 32)
|
|
+ {
|
|
+ if (rawBufferSize == 0)
|
|
+ {
|
|
+ rawBufferSize = 0x10000;
|
|
+ rawBuffer = new int[rawBufferSize];
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ rawBufferSize *= 2;
|
|
+ rawBuffer = Arrays.copyOf(rawBuffer, rawBufferSize);
|
|
+ }
|
|
+ }
|
|
++this.addedVertices;
|
|
|
|
if (this.hasTexture)
|
|
@@ -354,12 +395,6 @@
|
|
this.rawBuffer[this.field_147569_p + 2] = Float.floatToRawIntBits((float)(par5 + this.zOffset));
|
|
this.field_147569_p += 8;
|
|
++this.vertexCount;
|
|
-
|
|
- if (this.vertexCount % 4 == 0 && this.field_147569_p >= this.bufferSize - 32)
|
|
- {
|
|
- this.draw();
|
|
- this.isDrawing = true;
|
|
- }
|
|
}
|
|
|
|
// JAVADOC METHOD $$ func_78378_d
|