Performance Change for Facade Lighting Calculations.

This commit is contained in:
AlgorithmX2 2014-08-17 03:58:06 -05:00
parent 497b9c2e51
commit 339709bed9

View file

@ -19,11 +19,13 @@ import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.parts.IBoxProvider;
import appeng.api.parts.IFacadeContainer; import appeng.api.parts.IFacadeContainer;
import appeng.api.parts.IFacadePart; import appeng.api.parts.IFacadePart;
import appeng.api.parts.IPartCollsionHelper; import appeng.api.parts.IPartCollsionHelper;
import appeng.api.parts.IPartHost; import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartRenderHelper; import appeng.api.parts.IPartRenderHelper;
import appeng.api.parts.ISimplifiedBundle;
import appeng.client.render.BusRenderHelper; import appeng.client.render.BusRenderHelper;
import appeng.client.render.RenderBlocksWorkaround; import appeng.client.render.RenderBlocksWorkaround;
import appeng.core.AELog; import appeng.core.AELog;
@ -34,13 +36,16 @@ import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class FacadePart implements IFacadePart public class FacadePart implements IFacadePart, IBoxProvider
{ {
public final ItemStack facade; public final ItemStack facade;
public final ForgeDirection side; public final ForgeDirection side;
public int thickness = 2; public int thickness = 2;
@SideOnly(Side.CLIENT)
ISimplifiedBundle prevLight;
public FacadePart(ItemStack facade, ForgeDirection side) { public FacadePart(ItemStack facade, ForgeDirection side) {
if ( facade == null ) if ( facade == null )
throw new RuntimeException( "Facade Part constructed on null item." ); throw new RuntimeException( "Facade Part constructed on null item." );
@ -70,6 +75,13 @@ public class FacadePart implements IFacadePart
} }
} }
@Override
public void getBoxes(IPartCollsionHelper bch)
{
getBoxes( bch, null );
}
public static boolean isFacade(ItemStack is) public static boolean isFacade(ItemStack is)
{ {
if ( is.getItem() instanceof IFacadeItem ) if ( is.getItem() instanceof IFacadeItem )
@ -183,9 +195,15 @@ public class FacadePart implements IFacadePart
rbw.calculations = true; rbw.calculations = true;
rbw.faces = EnumSet.noneOf( ForgeDirection.class ); rbw.faces = EnumSet.noneOf( ForgeDirection.class );
instance.setRenderColor( color ); if ( prevLight != null && rbw.similarLighting( blk, rbw.blockAccess, x, y, z, prevLight ) )
rbw.renderStandardBlock( instance.getBlock(), x, y, z ); rbw.populate( prevLight );
instance.setRenderColor( 0xffffff ); else
{
instance.setRenderColor( color );
rbw.renderStandardBlock( instance.getBlock(), x, y, z );
instance.setRenderColor( 0xffffff );
prevLight = rbw.getLightingCache();
}
rbw.calculations = false; rbw.calculations = false;
rbw.faces = calculateFaceOpenFaces( rbw.blockAccess, fc, x, y, z, side ); rbw.faces = calculateFaceOpenFaces( rbw.blockAccess, fc, x, y, z, side );
@ -516,4 +534,5 @@ public class FacadePart implements IFacadePart
return false; return false;
} }
} }