Add in TESR culling, and a new TileEntity method to allow for differential sizing of the

TESR view culling vs the TE collision bounding box (the former defaults to the latter)
Checked into a branch because it's likely to break expanded TileEntities.
This commit is contained in:
Christian 2013-01-26 11:11:20 -05:00
parent 695b080197
commit 70ca0eeb74
2 changed files with 56 additions and 15 deletions

View file

@ -9,7 +9,20 @@
@SideOnly(Side.CLIENT)
public class RenderGlobal implements IWorldAccess
{
@@ -929,6 +931,12 @@
@@ -494,7 +496,11 @@
for (var6 = 0; var6 < this.tileEntities.size(); ++var6)
{
- TileEntityRenderer.instance.renderTileEntity((TileEntity)this.tileEntities.get(var6), par3);
+ TileEntity te = (TileEntity)this.tileEntities.get(var6);
+ if (par2ICamera.isBoundingBoxInFrustum(te.getRenderBoundingBox()))
+ {
+ TileEntityRenderer.instance.renderTileEntity(te, par3);
+ }
}
this.mc.entityRenderer.disableLightmap((double)par3);
@@ -929,6 +935,12 @@
*/
public void renderSky(float par1)
{
@ -22,7 +35,7 @@
if (this.mc.theWorld.provider.dimensionId == 1)
{
GL11.glDisable(GL11.GL_FOG);
@@ -1167,6 +1175,13 @@
@@ -1167,6 +1179,13 @@
public void renderClouds(float par1)
{
@ -36,7 +49,7 @@
if (this.mc.theWorld.provider.isSurfaceWorld())
{
if (this.mc.gameSettings.fancyGraphics)
@@ -1596,6 +1611,11 @@
@@ -1596,6 +1615,11 @@
}
public void drawBlockDamageTexture(Tessellator par1Tessellator, EntityPlayer par2EntityPlayer, float par3)
@ -48,7 +61,7 @@
{
double var4 = par2EntityPlayer.lastTickPosX + (par2EntityPlayer.posX - par2EntityPlayer.lastTickPosX) * (double)par3;
double var6 = par2EntityPlayer.lastTickPosY + (par2EntityPlayer.posY - par2EntityPlayer.lastTickPosY) * (double)par3;
@@ -1873,6 +1893,7 @@
@@ -1873,6 +1897,7 @@
double var17 = this.mc.renderViewEntity.posY - par4;
double var19 = this.mc.renderViewEntity.posZ - par6;
EntityFX var21 = null;
@ -56,7 +69,7 @@
if (par1Str.equals("hugeexplosion"))
{
@@ -2009,6 +2030,7 @@
@@ -2009,6 +2034,7 @@
else if (par1Str.equals("snowballpoof"))
{
var21 = new EntityBreakingFX(this.theWorld, par2, par4, par6, Item.snowball);
@ -64,7 +77,7 @@
}
else if (par1Str.equals("dripWater"))
{
@@ -2025,6 +2047,7 @@
@@ -2025,6 +2051,7 @@
else if (par1Str.equals("slime"))
{
var21 = new EntityBreakingFX(this.theWorld, par2, par4, par6, Item.slimeBall);
@ -72,7 +85,7 @@
}
else if (par1Str.equals("heart"))
{
@@ -2046,6 +2069,7 @@
@@ -2046,6 +2073,7 @@
{
int var27 = Integer.parseInt(par1Str.substring(par1Str.indexOf("_") + 1));
var21 = new EntityBreakingFX(this.theWorld, par2, par4, par6, par8, par10, par12, Item.itemsList[var27]);
@ -80,7 +93,7 @@
}
else if (par1Str.startsWith("tilecrack_"))
{
@@ -2053,11 +2077,12 @@
@@ -2053,11 +2081,12 @@
int var25 = Integer.parseInt(var28[1]);
int var26 = Integer.parseInt(var28[2]);
var21 = (new EntityDiggingFX(this.theWorld, par2, par4, par6, par8, par10, par12, Block.blocksList[var25], 0, var26)).applyRenderColor(var26);

View file

@ -1,16 +1,21 @@
--- ../src_base/minecraft/net/minecraft/tileentity/TileEntity.java
+++ ../src_work/minecraft/net/minecraft/tileentity/TileEntity.java
@@ -11,7 +11,9 @@
@@ -9,9 +9,14 @@
import net.minecraft.block.Block;
import net.minecraft.block.TileEntityRecordPlayer;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet132TileEntityData;
+import net.minecraft.util.AABBPool;
+import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class TileEntity
@@ -296,4 +298,52 @@
@@ -296,4 +301,75 @@
addMapping(TileEntityBeacon.class, "Beacon");
addMapping(TileEntitySkull.class, "Skull");
}
@ -27,10 +32,10 @@
+ /**
+ * Called when you receive a TileEntityData packet for the location this
+ * TileEntity is currently in. On the client, the NetworkManager will always
+ * be the remote server. On the server, it will be whomever is responsible for
+ * be the remote server. On the server, it will be whomever is responsible for
+ * sending the packet.
+ *
+ * @param net The NetworkManager the packet originated from
+ *
+ * @param net The NetworkManager the packet originated from
+ * @param pkt The data packet
+ */
+ public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt)
@ -47,12 +52,12 @@
+ /**
+ * Called from Chunk.setBlockIDWithMetadata, determines if this tile entity should be re-created when the ID, or Metadata changes.
+ * Use with caution as this will leave straggler TileEntities, or create conflicts with other TileEntities if not used properly.
+ *
+ *
+ * @param oldID The old ID of the block
+ * @param newID The new ID of the block (May be the same)
+ * @param oldMeta The old metadata of the block
+ * @param newMeta The new metadata of the block (May be the same)
+ * @param world Current world
+ * @param world Current world
+ * @param x X Postion
+ * @param y Y Position
+ * @param z Z Position
@ -61,5 +66,28 @@
+ public boolean shouldRefresh(int oldID, int newID, int oldMeta, int newMeta, World world, int x, int y, int z)
+ {
+ return true;
+ }
+
+ /**
+ * Default render bounding box: infinite in scope. Used to control rendering on {@link TileEntitySpecialRenderer}.
+ */
+ @SideOnly(Side.CLIENT)
+ public static final AxisAlignedBB INFINITE_EXTENT_AABB = AxisAlignedBB.getBoundingBox(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
+
+ /**
+ * Return an {@link AxisAlignedBB} that controls the visible scope of a {@link TileEntitySpecialRenderer} associated with this {@link TileEntity}
+ * Defaults to the collision bounding box {@link Block#getCollisionBoundingBoxFromPool(World, int, int, int)} associated with the block
+ * at this location.
+ *
+ * @return an appropriately size {@link AxisAlignedBB} for the {@link TileEntity}
+ */
+ @SideOnly(Side.CLIENT)
+ public AxisAlignedBB getRenderBoundingBox()
+ {
+ if (getBlockType()!=null)
+ {
+ return getBlockType().getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord, zCoord);
+ }
+ return INFINITE_EXTENT_AABB;
+ }
}