Merge pull request #109 from CovertJaguar/patch-3

Some efficiency improvements to the pipe renderer.
This commit is contained in:
Krapht 2012-07-20 00:51:22 -07:00
commit b06adb30c6

View file

@ -46,6 +46,10 @@ public class RenderPipe extends TileEntitySpecialRenderer {
final static private int maxPower = 1000;
final static private int displayLiquidStages = 40;
final static private int renderDistanceSq = 24 * 24;
final static private int numItemsToRender = 10;
private final static EntityItem dummyEntityItem = new EntityItem(null);
@ -214,6 +218,9 @@ public class RenderPipe extends TileEntitySpecialRenderer {
if (BuildCraftCore.render == RenderMode.NoDynamic)
return;
if(tileentity.getDistanceFrom(tileEntityRenderer.playerX, tileEntityRenderer.playerY, tileEntityRenderer.playerZ) >= renderDistanceSq)
return;
initializeDisplayPowerList(tileentity.worldObj);
@ -222,14 +229,15 @@ public class RenderPipe extends TileEntitySpecialRenderer {
if (pipe.pipe == null)
return;
if (pipe.pipe.transport instanceof PipeTransportLiquids)
renderLiquids(pipe.pipe, x, y, z);
if (pipe.pipe.transport instanceof PipeTransportItems)
if (pipe.pipe.transport instanceof PipeTransportItems)
renderSolids(pipe.pipe, x, y, z);
if (pipe.pipe.transport instanceof PipeTransportPower)
else if (pipe.pipe.transport instanceof PipeTransportLiquids)
renderLiquids(pipe.pipe, x, y, z);
else if (pipe.pipe.transport instanceof PipeTransportPower)
renderPower(pipe.pipe, x, y, z);
}
private void renderPower(Pipe pipe, double x, double y, double z) {
@ -350,11 +358,10 @@ public class RenderPipe extends TileEntitySpecialRenderer {
o = Block.blocksList[liquidId];
else
o = Item.itemsList[liquidId];
if (o instanceof ITextureProvider)
MinecraftForgeClient.bindTexture(((ITextureProvider) o).getTextureFile());
else
MinecraftForgeClient.bindTexture("/terrain.png");
// should be safe, items and block all implement ITextureProvider now
// and if o is null, something else is wrong somewhere
MinecraftForgeClient.bindTexture(((ITextureProvider) o).getTextureFile());
return getDisplayLiquidLists(liquidId, world);
}
@ -362,10 +369,18 @@ public class RenderPipe extends TileEntitySpecialRenderer {
private void renderSolids(Pipe pipe, double x, double y, double z) {
GL11.glPushMatrix();
GL11.glDisable(2896 /* GL_LIGHTING */);
float light = pipe.worldObj.getLightBrightness(pipe.xCoord, pipe.yCoord, pipe.zCoord);
for (EntityData data : ((PipeTransportItems) pipe.transport).travelingEntities.values())
int count = 0;
for (EntityData data : ((PipeTransportItems) pipe.transport).travelingEntities.values()) {
if(count >= numItemsToRender)
break;
doRenderItem(data.item, x + data.item.posX - pipe.xCoord, y + data.item.posY - pipe.yCoord, z + data.item.posZ
- pipe.zCoord, pipe.worldObj.getLightBrightness(pipe.xCoord, pipe.yCoord, pipe.zCoord));
- pipe.zCoord, light);
count++;
}
GL11.glEnable(2896 /* GL_LIGHTING */);
GL11.glPopMatrix();
@ -386,10 +401,6 @@ public class RenderPipe extends TileEntitySpecialRenderer {
byte quantity = 1;
if (entityitem.item.stackSize > 1)
quantity = 2;
if (entityitem.item.stackSize > 5)
quantity = 3;
if (entityitem.item.stackSize > 20)
quantity = 4;
GL11.glTranslatef((float) d, (float) d1, (float) d2);
GL11.glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);