Rendering Fixes / Performance.
This commit is contained in:
parent
36b266d5b6
commit
1f3cddb2eb
|
@ -8,6 +8,8 @@ import net.minecraft.client.renderer.Tessellator;
|
|||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.block.AEBaseBlock;
|
||||
|
||||
|
@ -32,6 +34,94 @@ public class BusRenderHelper implements IPartRenderHelper
|
|||
|
||||
int color = 0xffffff;
|
||||
|
||||
class BoundBoxCalculator implements IPartCollsionHelper
|
||||
{
|
||||
|
||||
public boolean started = false;
|
||||
|
||||
float minX;
|
||||
float minY;
|
||||
float minZ;
|
||||
|
||||
float maxX;
|
||||
float maxY;
|
||||
float maxZ;
|
||||
|
||||
@Override
|
||||
public void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
|
||||
{
|
||||
if ( started )
|
||||
{
|
||||
this.minX = Math.min( this.minX, (float) minX );
|
||||
this.minY = Math.min( this.minY, (float) minY );
|
||||
this.minZ = Math.min( this.minZ, (float) minZ );
|
||||
this.maxX = Math.max( this.maxX, (float) maxX );
|
||||
this.maxY = Math.max( this.maxY, (float) maxY );
|
||||
this.maxZ = Math.max( this.maxZ, (float) maxZ );
|
||||
}
|
||||
else
|
||||
{
|
||||
started = true;
|
||||
this.minX = (float) minX;
|
||||
this.minY = (float) minY;
|
||||
this.minZ = (float) minZ;
|
||||
this.maxX = (float) maxX;
|
||||
this.maxY = (float) maxY;
|
||||
this.maxZ = (float) maxZ;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getWorldX()
|
||||
{
|
||||
return ax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getWorldY()
|
||||
{
|
||||
return ay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getWorldZ()
|
||||
{
|
||||
return az;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BoundBoxCalculator bbc = new BoundBoxCalculator();
|
||||
|
||||
@Override
|
||||
public void normalRendering()
|
||||
{
|
||||
RenderBlocksWorkaround rbw = BusRenderer.instance.renderer;
|
||||
rbw.calculations = true;
|
||||
rbw.useTextures = true;
|
||||
rbw.enableAO = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSimpliedRendering(int x, int y, int z, IPart p)
|
||||
{
|
||||
RenderBlocksWorkaround rbw = BusRenderer.instance.renderer;
|
||||
rbw.calculations = true;
|
||||
rbw.faces.clear();
|
||||
|
||||
bbc.started = false;
|
||||
p.getBoxes( bbc );
|
||||
|
||||
setBounds( bbc.minX, bbc.minY, bbc.minZ, bbc.maxX, bbc.maxY, bbc.maxZ );
|
||||
|
||||
bbr.renderBlockBounds( rbw, minX, minY, minZ, maxX, maxY, maxZ, ax, ay, az );
|
||||
rbw.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
rbw.faces = EnumSet.allOf( ForgeDirection.class );
|
||||
rbw.calculations = false;
|
||||
rbw.useTextures = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBounds(float minx, float miny, float minz, float maxx, float maxy, float maxz)
|
||||
{
|
||||
|
@ -251,4 +341,5 @@ public class BusRenderHelper implements IPartRenderHelper
|
|||
{
|
||||
return az;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ public class RenderBlocksWorkaround extends RenderBlocks
|
|||
private float foZNeg[] = new float[12];
|
||||
|
||||
public boolean isFacade = false;
|
||||
public boolean useTextures = true;
|
||||
|
||||
Field fBrightness;
|
||||
|
||||
|
@ -75,27 +76,27 @@ public class RenderBlocksWorkaround extends RenderBlocks
|
|||
{
|
||||
Tessellator.instance.setBrightness( bXPos );
|
||||
restoreAO( aoXPos, foXPos );
|
||||
renderFaceXPos( b, x, y, z, rXPos );
|
||||
renderFaceXPos( b, x, y, z, useTextures ? rXPos : getBlockIcon( b, this.blockAccess, x, y, z, ForgeDirection.EAST.ordinal() ) );
|
||||
|
||||
Tessellator.instance.setBrightness( bXNeg );
|
||||
restoreAO( aoXNeg, foXNeg );
|
||||
renderFaceXNeg( b, x, y, z, rXNeg );
|
||||
renderFaceXNeg( b, x, y, z, useTextures ? rXNeg : getBlockIcon( b, this.blockAccess, x, y, z, ForgeDirection.WEST.ordinal() ) );
|
||||
|
||||
Tessellator.instance.setBrightness( bYPos );
|
||||
restoreAO( aoYPos, foYPos );
|
||||
renderFaceYPos( b, x, y, z, rYPos );
|
||||
renderFaceYPos( b, x, y, z, useTextures ? rYPos : getBlockIcon( b, this.blockAccess, x, y, z, ForgeDirection.UP.ordinal() ) );
|
||||
|
||||
Tessellator.instance.setBrightness( bYNeg );
|
||||
restoreAO( aoYNeg, foYNeg );
|
||||
renderFaceYNeg( b, x, y, z, rYNeg );
|
||||
renderFaceYNeg( b, x, y, z, useTextures ? rYNeg : getBlockIcon( b, this.blockAccess, x, y, z, ForgeDirection.DOWN.ordinal() ) );
|
||||
|
||||
Tessellator.instance.setBrightness( bZPos );
|
||||
restoreAO( aoZPos, foZPos );
|
||||
renderFaceZPos( b, x, y, z, rZPos );
|
||||
renderFaceZPos( b, x, y, z, useTextures ? rZPos : getBlockIcon( b, this.blockAccess, x, y, z, ForgeDirection.SOUTH.ordinal() ) );
|
||||
|
||||
Tessellator.instance.setBrightness( bZNeg );
|
||||
restoreAO( aoZNeg, foZNeg );
|
||||
renderFaceZNeg( b, x, y, z, rZNeg );
|
||||
renderFaceZNeg( b, x, y, z, useTextures ? rZNeg : getBlockIcon( b, this.blockAccess, x, y, z, ForgeDirection.NORTH.ordinal() ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ public class PartAnnihilationPlane extends PartBasicState
|
|||
|
||||
boolean isActive = (clientFlags & (POWERED_FLAG | CHANNEL_FLAG)) == (POWERED_FLAG | CHANNEL_FLAG);
|
||||
|
||||
rh.useSimpliedRendering( x, y, z, this );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : is.getIconIndex(),
|
||||
CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
|
|
@ -58,6 +58,7 @@ public class PartFormationPlane extends PartBasicState
|
|||
|
||||
boolean isActive = (clientFlags & (POWERED_FLAG | CHANNEL_FLAG)) == (POWERED_FLAG | CHANNEL_FLAG);
|
||||
|
||||
rh.useSimpliedRendering( x, y, z, this );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : is.getIconIndex(),
|
||||
CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
|
|
@ -41,6 +41,7 @@ public class PartP2PTunnel extends PartBasicState
|
|||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.useSimpliedRendering( x, y, z, this );
|
||||
rh.setTexture( AEApi.instance().blocks().blockQuartz.block().getIcon( 0, 0 ) );
|
||||
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
|
|
|
@ -150,6 +150,7 @@ public class PartStorageBus extends PartBasicState implements IGridTickable, ICe
|
|||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.useSimpliedRendering( x, y, z, this );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
||||
|
|
|
@ -141,6 +141,7 @@ public class PartToggleBus extends PartBasicState
|
|||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.useSimpliedRendering( x, y, z, this );
|
||||
rh.setTexture( is.getIconIndex() );
|
||||
|
||||
rh.setBounds( 6, 6, 14, 10, 10, 16 );
|
||||
|
|
|
@ -740,14 +740,10 @@ public class PartCable extends AEBasePart implements IPartCable
|
|||
if ( useCovered )
|
||||
{
|
||||
rh.setTexture( getCoveredTexture( getCableColor() ) );
|
||||
rh.setBounds( 5, 5, 5, 11, 11, 11 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
else
|
||||
{
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
rh.setBounds( 6, 6, 6, 10, 10, 10 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
|
||||
IPartHost ph = getHost();
|
||||
|
@ -787,9 +783,54 @@ public class PartCable extends AEBasePart implements IPartCable
|
|||
}
|
||||
}
|
||||
|
||||
for (ForgeDirection of : connections)
|
||||
if ( connections.size() != 2 || !nonLinear( connections ) || useCovered )
|
||||
{
|
||||
rendereGlassConection( x, y, z, rh, renderer, of );
|
||||
if ( useCovered )
|
||||
{
|
||||
rh.setBounds( 5, 5, 5, 11, 11, 11 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
else
|
||||
{
|
||||
rh.setBounds( 6, 6, 6, 10, 10, 10 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
|
||||
for (ForgeDirection of : connections)
|
||||
{
|
||||
rendereGlassConection( x, y, z, rh, renderer, of );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Icon def = getTexture( getCableColor() );
|
||||
rh.setTexture( def );
|
||||
|
||||
for (ForgeDirection of : connections)
|
||||
{
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
renderer.setRenderBounds( 6 / 16.0, 0, 6 / 16.0, 10 / 16.0, 16 / 16.0, 10 / 16.0 );
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
renderer.uvRotateEast = renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateBottom = renderer.uvRotateTop = 1;
|
||||
renderer.setRenderBounds( 0, 6 / 16.0, 6 / 16.0, 16 / 16.0, 10 / 16.0, 10 / 16.0 );
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
renderer.uvRotateNorth = renderer.uvRotateSouth = 1;
|
||||
renderer.setRenderBounds( 6 / 16.0, 6 / 16.0, 0, 10 / 16.0, 10 / 16.0, 16 / 16.0 );
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
renderer.renderStandardBlock( rh.getBlock(), x, y, z );
|
||||
}
|
||||
|
||||
rh.setTexture( null );
|
||||
|
|
|
@ -36,6 +36,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
|
|||
private ForgeDirection up = ForgeDirection.UNKNOWN;
|
||||
|
||||
public boolean dropItems = true;
|
||||
public int renderFragment = 0;
|
||||
|
||||
/**
|
||||
* isRedstonePowerd has already changed.
|
||||
|
@ -158,9 +159,14 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
|
|||
output = !forward.equals( old_Forward ) || !up.equals( old_Up );
|
||||
}
|
||||
|
||||
renderFragment = 100;
|
||||
for (AETileEventHandler h : getHandlerListFor( TileEventType.NETWORK ))
|
||||
if ( h.readFromStream( data ) )
|
||||
output = true;
|
||||
|
||||
if ( (renderFragment & 1) == 1 )
|
||||
output = true;
|
||||
renderFragment = 0;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
@ -246,8 +252,13 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
|
|||
|
||||
public void markForUpdate()
|
||||
{
|
||||
if ( worldObj != null )
|
||||
worldObj.markBlockForUpdate( xCoord, yCoord, zCoord );
|
||||
if ( renderFragment > 0 )
|
||||
renderFragment = renderFragment | 1;
|
||||
else
|
||||
{
|
||||
if ( worldObj != null )
|
||||
worldObj.markBlockForUpdate( xCoord, yCoord, zCoord );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue